| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.lum.common.client.lo; |
| 17 |
|
|
| 18 |
|
import java.util.ArrayList; |
| 19 |
|
import java.util.HashMap; |
| 20 |
|
import java.util.Map; |
| 21 |
|
|
| 22 |
|
import org.kuali.student.common.assembly.data.QueryPath; |
| 23 |
|
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
| 24 |
|
import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection; |
| 25 |
|
import org.kuali.student.common.ui.client.theme.Theme; |
| 26 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo; |
| 27 |
|
|
| 28 |
|
import com.google.gwt.event.dom.client.MouseMoveHandler; |
| 29 |
|
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
| 30 |
|
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
| 31 |
|
import com.google.gwt.event.shared.HandlerRegistration; |
| 32 |
|
import com.google.gwt.user.client.DOM; |
| 33 |
|
import com.google.gwt.user.client.Event; |
| 34 |
|
import com.google.gwt.user.client.ui.HasValue; |
| 35 |
|
import com.google.gwt.user.client.ui.HorizontalPanel; |
| 36 |
|
import com.google.gwt.user.client.ui.Image; |
| 37 |
|
import com.google.gwt.user.client.ui.Label; |
| 38 |
|
import com.google.gwt.user.client.ui.VerticalPanel; |
| 39 |
|
import com.google.gwt.user.client.ui.Widget; |
| 40 |
|
|
| 41 |
|
|
|
|
|
| 0% |
Uncovered Elements: 65 (65) |
Complexity: 16 |
Complexity Density: 0.37 |
|
| 42 |
|
public class OutlineManager extends VerticalSection implements HasValue<OutlineNodeModel> { |
| 43 |
|
OutlineNodeModel<?> outlineModel; |
| 44 |
|
String startOfPath; |
| 45 |
|
String endOfPath; |
| 46 |
|
String middleOfPath; |
| 47 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 48 |
0
|
public OutlineManager(String pathStart, String pathMiddle, String pathEnd) {... |
| 49 |
0
|
startOfPath = pathStart; |
| 50 |
0
|
middleOfPath = pathMiddle; |
| 51 |
0
|
endOfPath = pathEnd; |
| 52 |
|
} |
| 53 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 3 |
Complexity Density: 0.18 |
|
| 54 |
0
|
public void render() {... |
| 55 |
0
|
Map<Integer, Integer> levelIndexes = new HashMap<Integer, Integer>(); |
| 56 |
0
|
int currIndent = 0; |
| 57 |
|
|
| 58 |
0
|
levelIndexes.put(0, -1); |
| 59 |
0
|
OutlineNode[] outlineNodes = outlineModel.toOutlineNodes(); |
| 60 |
0
|
for (final OutlineNode aNode : outlineNodes) { |
| 61 |
0
|
NodePanel nodePanel = new NodePanel(); |
| 62 |
0
|
nodePanel.setStyleName("KS-LONodePanel"); |
| 63 |
0
|
nodePanel.setOutlineNode(aNode); |
| 64 |
0
|
if (aNode.getIndentLevel() > currIndent) { |
| 65 |
0
|
currIndent = aNode.getIndentLevel(); |
| 66 |
0
|
levelIndexes.put(currIndent, 0); |
| 67 |
0
|
} else if (aNode.getIndentLevel() < currIndent) { |
| 68 |
0
|
currIndent = aNode.getIndentLevel(); |
| 69 |
0
|
levelIndexes.put(currIndent, levelIndexes.get(currIndent) + 1); |
| 70 |
|
} else { |
| 71 |
0
|
levelIndexes.put(currIndent, levelIndexes.get(currIndent) + 1); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
0
|
addField(getFieldKey(currIndent, levelIndexes), null, nodePanel, null); |
| 75 |
|
|
| 76 |
0
|
showAllToolbar(); |
| 77 |
|
} |
| 78 |
|
} |
| 79 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 80 |
0
|
private String getFieldKey(int currIndent, Map<Integer, Integer> levelIndexes) {... |
| 81 |
0
|
StringBuilder keyBuilder = new StringBuilder(startOfPath); |
| 82 |
|
|
| 83 |
0
|
keyBuilder.append("/").append(levelIndexes.get(0)).append("/"); |
| 84 |
0
|
for (int idx = 1; idx <= currIndent; idx++) { |
| 85 |
0
|
keyBuilder.append(middleOfPath).append("/").append(levelIndexes.get(idx)).append("/"); |
| 86 |
|
} |
| 87 |
0
|
keyBuilder.append(endOfPath); |
| 88 |
|
|
| 89 |
0
|
return keyBuilder.toString(); |
| 90 |
|
} |
| 91 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 92 |
0
|
private FieldDescriptor addField(String fieldKey, MessageKeyInfo messageKey, Widget widget, String parentPath) {... |
| 93 |
0
|
QueryPath path = QueryPath.concat(parentPath, fieldKey); |
| 94 |
|
|
| 95 |
0
|
FieldDescriptor fd = new FieldDescriptor(path.toString(), messageKey, null); |
| 96 |
0
|
if (widget != null) { |
| 97 |
0
|
fd.setFieldWidget(widget); |
| 98 |
0
|
fd.setHasHadFocus(true); |
| 99 |
|
} |
| 100 |
0
|
this.addField(fd); |
| 101 |
0
|
return fd; |
| 102 |
|
} |
| 103 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 104 |
0
|
public void closeAllToolbar(){... |
| 105 |
0
|
for (FieldDescriptor fd : this.getFields()) { |
| 106 |
0
|
if (fd.getFieldWidget() instanceof NodePanel) { |
| 107 |
0
|
((NodePanel) fd.getFieldWidget()).hideToolbar(); |
| 108 |
|
} |
| 109 |
|
} |
| 110 |
|
} |
| 111 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 112 |
0
|
public void showAllToolbar(){... |
| 113 |
0
|
for (FieldDescriptor fd : this.getFields()) { |
| 114 |
0
|
if (fd.getFieldWidget() instanceof NodePanel) { |
| 115 |
0
|
((NodePanel) fd.getFieldWidget()).showToolbar(); |
| 116 |
|
} |
| 117 |
|
} |
| 118 |
|
} |
| 119 |
|
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 10 |
Complexity Density: 0.3 |
|
| 120 |
|
class NodePanel extends VerticalPanel{ |
| 121 |
|
OutlineManagerToolbar toolbar = new OutlineManagerToolbar(); |
| 122 |
|
HorizontalPanel emptySpacePanel = new HorizontalPanel(); |
| 123 |
|
ArrayList<MouseMoveHandler> mouseMoveHandlerList = new ArrayList<MouseMoveHandler>(); |
| 124 |
|
HorizontalPanel horitonalPanel = new HorizontalPanel(); |
| 125 |
|
OutlineNode currentNode; |
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
| 126 |
0
|
NodePanel() {... |
| 127 |
0
|
toolbar.setModel(outlineModel); |
| 128 |
0
|
horitonalPanel.setStyleName("KS-LOHNodePanel"); |
| 129 |
0
|
super.sinkEvents(Event.ONMOUSEMOVE); |
| 130 |
0
|
super.sinkEvents(Event.ONMOUSEOUT); |
| 131 |
0
|
emptySpacePanel.setStyleName("KS-LOOutlineManagerToolbar"); |
| 132 |
0
|
Image ieHack = Theme.INSTANCE.getCommonImages().getSpacer(); |
| 133 |
0
|
emptySpacePanel.add(ieHack); |
| 134 |
0
|
super.insert(emptySpacePanel,0); |
| 135 |
|
} |
| 136 |
|
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 137 |
0
|
public void setOutlineNode(OutlineNode aNode) {... |
| 138 |
0
|
currentNode = aNode; |
| 139 |
0
|
for (int i = 0; i < aNode.getIndentLevel(); i++) { |
| 140 |
0
|
Label label = new Label(); |
| 141 |
0
|
label.setStyleName("KS-LONodeIndent"); |
| 142 |
0
|
horitonalPanel.add(label); |
| 143 |
|
|
| 144 |
|
|
| 145 |
0
|
label = new Label(); |
| 146 |
0
|
label.setStyleName("KS-LONodeIndentToolbar"); |
| 147 |
0
|
toolbar.insert(label, 0); |
| 148 |
|
} |
| 149 |
0
|
Widget userWidget = (Widget) aNode.getUserObject(); |
| 150 |
0
|
userWidget.setStyleName("KS-LOaNode"); |
| 151 |
0
|
horitonalPanel.add(userWidget); |
| 152 |
|
|
| 153 |
0
|
add(horitonalPanel); |
| 154 |
|
} |
| 155 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 156 |
0
|
public void addMouseMoveHandler(MouseMoveHandler handler) {... |
| 157 |
0
|
mouseMoveHandlerList.add(handler); |
| 158 |
|
} |
| 159 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 160 |
0
|
public void setToolbar(OutlineManagerToolbar t) {... |
| 161 |
0
|
toolbar = t; |
| 162 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 163 |
0
|
public void showToolbar(){... |
| 164 |
0
|
super.remove(emptySpacePanel); |
| 165 |
0
|
super.insert(toolbar, 0); |
| 166 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 167 |
0
|
public void hideToolbar(){... |
| 168 |
0
|
super.remove(toolbar); |
| 169 |
0
|
super.insert(emptySpacePanel,0); |
| 170 |
|
} |
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 171 |
0
|
@Override... |
| 172 |
|
public void onBrowserEvent(Event event) { |
| 173 |
0
|
switch (DOM.eventGetType(event)) { |
| 174 |
0
|
case Event.ONMOUSEMOVE: { |
| 175 |
0
|
outlineModel.setCurrentNode(currentNode); |
| 176 |
0
|
break; |
| 177 |
|
} |
| 178 |
0
|
case Event.ONMOUSEOUT: |
| 179 |
0
|
break; |
| 180 |
|
} |
| 181 |
0
|
super.onBrowserEvent(event); |
| 182 |
|
} |
| 183 |
|
} |
| 184 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 185 |
0
|
@Override... |
| 186 |
|
public OutlineNodeModel getValue() { |
| 187 |
0
|
return outlineModel; |
| 188 |
|
} |
| 189 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 190 |
0
|
@Override... |
| 191 |
|
public void setValue(OutlineNodeModel value) { |
| 192 |
0
|
outlineModel = value; |
| 193 |
|
} |
| 194 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 195 |
0
|
@Override... |
| 196 |
|
public void setValue(OutlineNodeModel value, boolean fireEvents) { |
| 197 |
0
|
setValue(value); |
| 198 |
|
} |
| 199 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 200 |
0
|
@Override... |
| 201 |
|
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<OutlineNodeModel> handler) { |
| 202 |
0
|
return addHandler(handler, ValueChangeEvent.getType()); |
| 203 |
|
} |
| 204 |
|
} |