View Javadoc

1   package org.kuali.student.lum.common.client.lo;
2   
3   import com.google.gwt.event.dom.client.ClickEvent;
4   import com.google.gwt.event.dom.client.ClickHandler;
5   import com.google.gwt.user.client.Event;
6   import com.google.gwt.user.client.ui.Button;
7   import com.google.gwt.user.client.ui.HorizontalPanel;
8   
9   /**
10   * @author Igor
11   */
12  class OutlineManagerToolbar extends HorizontalPanel {
13  	Button moveUpButton = new Button();
14  
15  	Button moveDownButton = new Button();
16  
17  	Button indentButton = new Button();
18  
19  	Button outdentButton = new Button();
20  
21  	Button deleteButton = new Button();
22  
23  
24  	Button addPeerButton = new Button();
25  
26  	Button addChildButton = new Button();
27  
28  	OutlineNodeModel outlineModel;
29  
30  	OutlineManagerToolbar() {
31  
32  		HorizontalPanel buttonPanel = new HorizontalPanel();
33  
34  		this.setStyleName("KS-LOOutlineManagerToolbar");
35  		super.add(buttonPanel);
36  		buttonPanel.add(moveUpButton);
37  		buttonPanel.add(moveDownButton);
38  		buttonPanel.add(indentButton);
39  		buttonPanel.add(outdentButton);
40  		buttonPanel.add(deleteButton);
41  		buttonPanel.addStyleName("KS-LOButtonPanel");
42  
43  		sinkEvents(Event.ONMOUSEMOVE);
44  		sinkEvents(Event.ONMOUSEOUT);
45  
46  		moveUpButton.sinkEvents(Event.ONMOUSEMOVE);
47  		moveUpButton.sinkEvents(Event.ONMOUSEOUT);
48  		moveUpButton.setTitle("Move learning objective up");
49  		moveUpButton.addStyleName("KS-LOMoveUpButton");
50  		moveDownButton.addStyleName("KS-LOMoveDownButton");
51  		moveDownButton.setTitle("Move learning objective down");
52  		deleteButton.setText("Delete");
53  		deleteButton.setTitle("Delete");
54  		deleteButton.addStyleName("KS-LODeleteButton");
55  		indentButton.addStyleName("KS-LOIndentButton");
56  		indentButton.setTitle("Indent learning objective");
57  		outdentButton.addStyleName("KS-LOOutdentButton");
58  		outdentButton.setTitle("Outdent learning objective");
59  
60  		moveUpButton.addClickHandler(new ClickHandler() {
61  			public void onClick(ClickEvent event) {
62  				outlineModel.moveUpCurrent();
63  
64  			}
65  		});
66  		moveDownButton.addClickHandler(new ClickHandler() {
67  			public void onClick(ClickEvent event) {
68  				outlineModel.moveDownCurrent();
69  			}
70  		});
71  		indentButton.addClickHandler(new ClickHandler() {
72  			public void onClick(ClickEvent event) {
73  				outlineModel.indentCurrent();
74  			}
75  		});
76  		outdentButton.addClickHandler(new ClickHandler() {
77  			public void onClick(ClickEvent event) {
78  				outlineModel.outdentCurrent();
79  			}
80  		});
81  		deleteButton.addClickHandler(new ClickHandler() {
82  			public void onClick(ClickEvent event) {
83  				outlineModel.deleteCurrent();
84  			}
85  		});
86  		addPeerButton.addClickHandler(new ClickHandler() {
87  			public void onClick(ClickEvent event) {
88  				outlineModel.addPeer();
89  			}
90  		});
91  		addChildButton.addClickHandler(new ClickHandler() {
92  			public void onClick(ClickEvent event) {
93  				outlineModel.addChild();
94  			}
95  		});
96  	}
97  
98  	public void setModel(OutlineNodeModel model) {
99  		outlineModel = model;
100 	}
101 
102 	public void updateButtonStates() {
103 		if(  this.outlineModel.isMoveUpable()){
104 			moveUpButton.setEnabled(true);
105 			moveUpButton.removeStyleName("KS-LOMoveUpButtonDisabled");
106 			moveUpButton.addStyleName("KS-LOMoveUpButton");
107 		}else{
108 			moveUpButton.setEnabled(false);
109 			moveUpButton.removeStyleName("KS-LOMoveUpButton");
110 			moveUpButton.addStyleName("KS-LOMoveUpButtonDisabled");
111 		}
112 		if(this.outlineModel.isDeletable()){
113 			deleteButton.setEnabled(true);
114 			deleteButton.removeStyleName("KS-LODeleteButtonDisabled");
115 			deleteButton.addStyleName("KS-LODeleteButton");
116 		} else{
117 			deleteButton.setEnabled(false);
118 			deleteButton.removeStyleName("KS-LODeleteButton");
119 			deleteButton.addStyleName("KS-LODeleteButtonDisabled");
120 		}
121 		if(this.outlineModel.isIndentable()){
122 			indentButton.setEnabled(true);
123 			indentButton.removeStyleName("KS-LOIndentButtonDisabled");
124 			indentButton.addStyleName("KS-LOIndentButton");
125 		}else{
126 			indentButton.setEnabled(false);
127 			indentButton.removeStyleName("KS-LOIndentButton");
128 			indentButton.addStyleName("KS-LOIndentButtonDisabled");
129 		}
130 		if(this.outlineModel.isMoveDownable()){
131 			moveDownButton.setEnabled(true);
132 			moveDownButton.removeStyleName("KS-LOMoveDownButtonDisabled");
133 			moveDownButton.addStyleName("KS-LOMoveDownButton");
134 		}else{
135 			moveDownButton.setEnabled(false);
136 			moveDownButton.removeStyleName("KS-LOMoveDownButton");
137 			moveDownButton.addStyleName("KS-LOMoveDownButtonDisabled");
138 		}
139 		if(this.outlineModel.isOutdentable()){
140 			outdentButton.setEnabled(true);
141 			outdentButton.removeStyleName("KS-LOOutdentButtonDisabled");
142 			outdentButton.addStyleName("KS-LOOutdentButton");
143 		}else{
144 			outdentButton.setEnabled(false);
145 			outdentButton.removeStyleName("KS-LOOutdentButton");
146 			outdentButton.addStyleName("KS-LOOutdentButtonDisabled");
147 		}
148 	}
149 }