use of org.eclipse.che.ide.ui.smartTree.event.internal.NativeTreeEvent in project che by eclipse.
the class SelectionModel method onKeyUp.
protected void onKeyUp(NativeEvent ke) {
NativeTreeEvent e = ke.cast();
e.preventDefault();
Node prev = prev();
if (prev != null) {
doSingleSelect(prev, false);
tree.scrollIntoView(prev);
}
}
use of org.eclipse.che.ide.ui.smartTree.event.internal.NativeTreeEvent in project che by eclipse.
the class Tree method onClick.
private void onClick(Event event) {
NativeTreeEvent e = event.cast();
NodeDescriptor node = getNodeDescriptor((Element) event.getEventTarget().cast());
if (node != null) {
Element jointEl = view.getJointContainer(node);
if (jointEl != null && e.within(jointEl)) {
toggle(node.getNode());
}
}
focus();
}
use of org.eclipse.che.ide.ui.smartTree.event.internal.NativeTreeEvent in project che by eclipse.
the class SelectionModel method onMouseClick.
protected void onMouseClick(ClickEvent ce) {
NativeTreeEvent e = ce.getNativeEvent().cast();
if (fireSelectionChangeOnClick) {
fireSelectionChange();
fireSelectionChangeOnClick = false;
}
if (selectionMode == Mode.MULTI) {
NodeDescriptor node = tree.getNodeDescriptor((Element) e.getEventTarget().cast());
// on dnd prevent drag the node will be null
if (node != null) {
Node sel = node.getNode();
if (e.getCtrlOrMetaKey() && isSelected(sel)) {
doDeselect(Collections.singletonList(sel), false);
tree.focus();
// reset the starting location of the click when meta is used during a multiselect
lastSelectedNode = sel;
} else if (e.getCtrlOrMetaKey()) {
doSelect(Collections.singletonList(sel), true, false);
tree.focus();
// reset the starting location of the click when meta is used during a multiselect
lastSelectedNode = sel;
} else if (isSelected(sel) && !e.getShiftKey() && !e.getCtrlOrMetaKey() && selectionStorage.size() > 0) {
doSelect(Collections.singletonList(sel), false, false);
tree.focus();
}
}
}
}
use of org.eclipse.che.ide.ui.smartTree.event.internal.NativeTreeEvent in project che by eclipse.
the class SelectionModel method onMouseDown.
protected void onMouseDown(MouseDownEvent mde) {
NativeTreeEvent e = mde.getNativeEvent().cast();
Element target = e.getEventTargetEl();
NodeDescriptor selNode = tree.getNodeDescriptor(target);
if (selNode == null || tree == null) {
return;
}
Node sel = selNode.getNode();
if (!tree.getView().isSelectableTarget(sel, target)) {
return;
}
boolean isSelected = isSelected(sel);
boolean isMeta = e.getCtrlOrMetaKey();
boolean isShift = e.getShiftKey();
if (e.isRightClick() && isSelected) {
return;
} else {
switch(selectionMode) {
case SIMPLE:
tree.focus();
if (isSelected(sel)) {
deselect(sel);
} else {
doSelect(Collections.singletonList(sel), true, false);
}
break;
case SINGLE:
tree.focus();
if (isMeta && isSelected) {
deselect(sel);
} else if (!isSelected) {
select(sel, false);
}
break;
case MULTI:
if (isShift && lastSelectedNode != null) {
List<Node> selectedItems = new ArrayList<>();
// from last selected or firstly selected
NodeDescriptor lastSelTreeNode = tree.getNodeDescriptor(lastSelectedNode);
Element lastSelTreeEl = tree.getView().getRootContainer(lastSelTreeNode);
// to selected or secondly selected
NodeDescriptor selTreeNode = tree.getNodeDescriptor(sel);
Element selTreeNodeEl = tree.getView().getRootContainer(selTreeNode);
// holding shift down, selecting the same item again, selecting itself
if (sel == lastSelectedNode) {
tree.focus();
doSelect(Collections.singletonList(sel), false, false);
} else if (lastSelTreeEl != null && selTreeNodeEl != null) {
// add the last selected, as its not added during the walk
selectedItems.add(lastSelectedNode);
// After walking reset back to previously selected
final Node previouslyLastSelected = lastSelectedNode;
// This deals with flipping directions
if (lastSelTreeEl.getAbsoluteTop() < selTreeNodeEl.getAbsoluteTop()) {
// down selection
Node next = next();
while (next != null) {
selectedItems.add(next);
lastSelectedNode = next;
if (next == sel)
break;
next = next();
}
} else {
// up selection
Node prev = prev();
while (prev != null) {
selectedItems.add(prev);
lastSelectedNode = prev;
if (prev == sel)
break;
prev = prev();
}
}
tree.focus();
doSelect(selectedItems, false, false);
// change back to last selected, the walking causes this need
lastSelectedNode = previouslyLastSelected;
}
} else if (!isSelected(sel)) {
tree.focus();
doSelect(Collections.singletonList(sel), e.getCtrlOrMetaKey(), false);
// reset the starting location of multi select
lastSelectedNode = sel;
} else if (isSelected(sel) && !e.getShiftKey() && !e.getCtrlOrMetaKey() && !selectionStorage.isEmpty()) {
doSelect(Collections.singletonList(sel), false, false);
tree.focus();
} else if (isSelected(sel) && !selectionStorage.isEmpty()) {
doDeselect(Collections.singletonList(sel), false);
}
break;
}
}
mouseDown = false;
}
Aggregations