@Override public void tearDown() throws Exception { super.tearDown(); broker.resetState(); waitForIdleState(); final TreeItem[] treeItems = commonViewer.getTree().getItems(); assertTrue("Expected empty Project Explorer. Input was: " + Arrays.toString(treeItems), Arrays2.isEmpty(treeItems)); assertFalse("Expected projects as top level elements in navigator.", broker.isWorkingSetTopLevel()); assertNull( "Select working set drop down contribution was visible when projects are configured as top level elements.", getWorkingSetDropDownContribution()); IContributionItem showHiddenWorkingSetsItem = from( Arrays.asList(projectExplorer.getViewSite().getActionBars().getToolBarManager().getItems())) .firstMatch(i -> ShowHiddenWorkingSetsDropDownAction.class.getName().equals(i.getId())) .orNull(); assertNull( "Show hidden working set drop down contribution was visible when projects are configured as top level elements.", showHiddenWorkingSetsItem); }
/***/ @Test public void testWorkingSetIsTheSingleRootInNavaigator() { activateWorkingSetManager(ManualAssociationAwareWorkingSetManager.class); final TreeItem[] treeItems = commonViewer.getTree().getItems(); assertTrue("Expected exactly one item in the Project Explorer. Input was: " + Arrays.toString(treeItems), treeItems.length == 1); final Object data = treeItems[0].getData(); assertTrue("Expected " + WorkingSet.class + " input in navigator. Was " + data, data instanceof WorkingSet); final WorkingSet workingSet = (WorkingSet) treeItems[0].getData(); assertTrue("Expected working set with ID: " + OTHERS_WORKING_SET_ID + ". Was " + workingSet.getId(), OTHERS_WORKING_SET_ID.equals(workingSet.getId())); }
@Override protected boolean shouldCreateToolTip(final Event e) { this.lastDescriptor = null; if (e.widget instanceof Tree) { final Tree tree = (Tree) e.widget; final TreeItem item = tree.getItem(new Point(e.x, e.y)); if (null != item && item.getData() instanceof ResultNode) { final ResultNode node = (ResultNode) item.getData(); if (node.getElement() instanceof TestCase) { final URI uri = ((TestCase) node.getElement()).getURI(); if (null != uri) { final StyledTextDescriptor descriptor = getDescriptor(uri); if (null != descriptor) { this.lastDescriptor = descriptor; } } } } } return null != this.lastDescriptor; }
private TreeItem findStepInTree(Object parent, long priority) { TreeItem[] items = null; if (parent == null) { items = tree.getItems(); } else { DatabaseObject databaseObject = (DatabaseObject)((TreeItem)parent).getData(); if (databaseObject instanceof Step) { if ((databaseObject).priority == priority) { return (TreeItem)parent; } } items = ((TreeItem)parent).getItems(); } for (int i=0; i<items.length; i++) { TreeItem tItem = findStepInTree(items[i],priority); if (tItem != null) return tItem; } return null; }
public void displaySelectionXpathWithAnchor(TwsDomTree tree, String anchor, String xpath) { TreeItem[] items; items = findTreeItems(anchor); if (items.length > 0) stepSourceEditorComposite.selectItemsInTree(items); setXpathText(anchor); setAnchor(true); if (!xpath.equals("")) { xpath = xpath.replaceFirst("\\.", anchor); items = findTreeItems(xpath); if (items.length > 0) { stepSourceEditorComposite.selectItemsInTree(items); } setXpathText(xpath); } }
public TreeItem[] findTreeItems(String xpath) { TreeItem[] items = new TreeItem[]{}; try { xpath = xpath.replaceAll(regexpForPredicates, ""); NodeList nl = twsCachedXPathAPI.selectNodeList(currentDom, xpath); if (nl.getLength()>0) { TreeItem tItem = twsDomTree.findTreeItem(nl.item(0)); List<TreeItem> v = new ArrayList<TreeItem>(); while (tItem != null) { v.add(tItem); tItem = tItem.getParentItem(); } items = v.toArray(new TreeItem[]{}); } } catch (TransformerException e) { ConvertigoPlugin.logException(e, "Error while finding items in tree"); } return items; }
private void fillCheckedList(TreeItem parent, List<String> csSourceData) { if (csSourceData != null && !csSourceData.isEmpty()) { TreeItem[] items = null; if (parent == null) { items = checkboxTreeViewer.getTree().getItems(); } else { items = parent.getItems(); TVObject tvo = (TVObject) parent.getData(); String tvoSourceData = tvo.getSourceData(); if (csSourceData.contains(tvoSourceData)) { int index = csSourceData.indexOf(tvoSourceData); if (index == 0) checkedList.add(0,tvo); else checkedList.add(tvo); } } for (int i=0; i<items.length; i++) { fillCheckedList(items[i], csSourceData); } } }
private TVObject findModelItem(TreeItem parent, String modelPath) { if (modelPath != null && !modelPath.isEmpty()) { TreeItem[] items = null; items = parent == null ? modelTreeViewer.getTree().getItems() : parent.getItems(); for (int i=0; i<items.length; i++) { TreeItem treeItem = items[i]; TVObject tvo = (TVObject) treeItem.getData(); if (tvo != null) { String tvoSourcePath = tvo.getSourcePath().replaceAll("\\?\\.", "."); if (modelPath.startsWith(tvoSourcePath.replaceFirst("root", ""))) { if (modelPath.equals(tvoSourcePath.replaceFirst("root", ""))) { return tvo; } return findModelItem(items[i], modelPath); } } } } return null; }
protected void computeAndDisplayStats(AvroSchemaEditor editor) { SchemaViewer masterViewer = editor.getContentPart().getSchemaViewer(AvroContext.Kind.MASTER); TreeViewer treeViewer = masterViewer.getTreeViewer(); AvroNode inputNode = (AvroNode) treeViewer.getInput(); NodeType inputType = inputNode.getType(); String name = AttributeUtil.getNameFromAttribute(inputNode); NodeStats stats = new NodeStats("Compute stats of " + inputType.toString().toLowerCase() + " " + name + " from editor " + editor.getName()); stats.start(); Tree tree = treeViewer.getTree(); TreeItem[] items = tree.getItems(); for (TreeItem item : items) { visitTreeItem(item, stats); } stats.finish(); AvroSchemaLogger.logStats(stats, false); }
private void initialize() { if (parentObject instanceof Project) { Project project = (Project)parentObject; List<String> projectList = new ArrayList<String>(); projectList.add(project.getName()); List<Reference> references = project.getReferenceList(); for (Reference reference: references) { if (reference instanceof ProjectSchemaReference) { projectList.add(((ProjectSchemaReference)reference).getProjectName()); } } String[] projects = Engine.theApp.databaseObjectsManager.getAllProjectNamesArray(); for (String name: projects) { if (!projectList.contains(name)) { TreeItem branch = new TreeItem(tree, SWT.NONE); branch.setText(name); } } tree.setVisible(true); } else tree.setVisible(false); }
private void buildContextMenu(MouseEvent e) { Point point = new Point(e.x, e.y); TreeItem treeItem = getTree().getItem(point); Menu menu = new Menu((Control)e.getSource()); Iterator<MenuMaker> i = menuMakers.iterator(); int cpt = 0; while(i.hasNext()) { i.next().makeMenu(this, treeItem, e, menu); if (i.hasNext() && menu.getItemCount() != cpt) { new MenuItem(menu, SWT.SEPARATOR); cpt = menu.getItemCount(); } } if (menu.getItemCount() > 0) { menu.setVisible(true); } else { menu.dispose(); } }
private void getSelectedItems(TreeItem[] items, List<Node> selectedItems) { if (items == null) { return; } for (TreeItem item : items) { Node parent = new Node(item.getText(), true); TreeItem[] children = item.getItems(); if (children != null) { boolean selected = false; for (TreeItem child : children) { if (child.getChecked()) { parent.addChild(new Node(child.getText(), false)); selected = true; } } if (selected) { nodeListManager.addSelectedNode(parent); } } } }
@Override public void drop(DropTargetEvent event) { IStructuredSelection structuredSelection = (IStructuredSelection) LocalSelectionTransfer .getTransfer().getSelection(); if (structuredSelection.size() == 1) { AvroNode sourceNode = (AvroNode) structuredSelection.getFirstElement(); TreeItem item = (TreeItem) event.item; if (item != null) { AvroNode targetNode = nodeConverter.convertToAvroNode(item.getData()); dropPolicy.drop(sourceNode, targetNode, position); } } }
public String removeItem(TreeItem selItem, String parent, String content) throws JAXBException { Unmarshaller unmarshaller = JAXBContext.newInstance(ServiceDefinition.class).createUnmarshaller(); MarshallerImpl marshaller = (MarshallerImpl) JAXBContext.newInstance(ServiceDefinition.class).createMarshaller(); marshaller.setProperty(MarshallerImpl.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new NamespacePrefixMapper()); ServiceDefinition sDef = (ServiceDefinition) unmarshaller.unmarshal(new StringReader(editorText)); ArrayList<Operation> ops = new ArrayList<Operation>(); ops.addAll(sDef.getOperations().getDataOrEventOrRequestresponse()); int i = 0; for (Object obj : sDef.getOperations().getDataOrEventOrRequestresponse()) { if (obj instanceof Data && parent.equalsIgnoreCase("Data")) { if (((Data) obj).getName().equalsIgnoreCase(selItem.getText())) ops.remove(i); } else if (obj instanceof Event && parent.equalsIgnoreCase("Event")) { if (((Event) obj).getName().equalsIgnoreCase(selItem.getText())) ops.remove(i); } else if (obj instanceof RequestResponse && parent.equalsIgnoreCase("Request Response")) { if (((RequestResponse) obj).getName().equalsIgnoreCase(selItem.getText())) ops.remove(i); } i++; } sDef.getOperations().getDataOrEventOrRequestresponse().clear(); sDef.getOperations().getDataOrEventOrRequestresponse().addAll(ops); StringWriter writer = new StringWriter(); marshaller.marshal(sDef, writer); return ParseUtil.removeEmptyTags(writer.toString(), ServiceDefinition.class); }
/** * Change the current format and refresh the display. */ protected void changeCurrentFormat(int newFormat) { TreeItem selection = directoryTree.getSelection()[0]; Object data = selection.getData(); DirectoryEntry directory = (DirectoryEntry) data; List<FileEntry> fileList = directory.getFiles(); formatChanged = (currentFormat != newFormat); if (formatChanged || !fileList.equals(currentFileList)) { preserveColumnWidths(); // must be done before assigning newFormat currentFormat = newFormat; fillFileTable(fileList); // Ensure that the control buttons are set appropriately. // Primarly required for keyboard interface. standardFormatToolItem.setSelection( currentFormat == FormattedDisk.FILE_DISPLAY_STANDARD); nativeFormatToolItem.setSelection( currentFormat == FormattedDisk.FILE_DISPLAY_NATIVE); detailFormatToolItem.setSelection( currentFormat == FormattedDisk.FILE_DISPLAY_DETAIL); } }
/** * Updates the check state of all created children */ private void updateChildrenItems(TreeItem parent) { boolean state = parent.getChecked(); // do not implicitly check children, only uncheck if(state) { return; } Item[] children = getChildren(parent); for (int i = 0; i < children.length; i++) { TreeItem curr = (TreeItem) children[i]; if (curr.getData() != null && ((curr.getChecked() != state) || curr.getGrayed())) { curr.setChecked(state); curr.setGrayed(false); updateChildrenItems(curr); } } }
/** * Updates the check / gray state of all parent items */ private void updateParentItems(TreeItem item) { if (item != null) { Item[] children = getChildren(item); boolean containsChecked = false; boolean containsUnchecked = false; for (int i = 0; i < children.length; i++) { TreeItem curr = (TreeItem) children[i]; containsChecked |= curr.getChecked(); containsUnchecked |= (!curr.getChecked() || curr.getGrayed()); } item.setChecked(containsChecked); item.setGrayed(containsChecked && containsUnchecked); updateParentItems(item.getParentItem()); } }
/** * Change the current format and refresh the display. */ protected void changeCurrentFormat(int newFormat) { TreeItem selection = directoryTree.getSelection()[0]; Object data = selection.getData(); DirectoryEntry directory = (DirectoryEntry) data; List fileList = directory.getFiles(); formatChanged = (currentFormat != newFormat); if (formatChanged || !fileList.equals(currentFileList)) { preserveColumnWidths(); // must be done before assigning newFormat currentFormat = newFormat; fillFileTable(fileList); // Ensure that the control buttons are set appropriately. // Primarly required for keyboard interface. standardFormatToolItem.setSelection( currentFormat == FormattedDisk.FILE_DISPLAY_STANDARD); nativeFormatToolItem.setSelection( currentFormat == FormattedDisk.FILE_DISPLAY_NATIVE); detailFormatToolItem.setSelection( currentFormat == FormattedDisk.FILE_DISPLAY_DETAIL); } }
/** * Load the root directories of the file system into the directory tree, * priorly removing any entries. */ public void loadRootsIntoDirectoryTree() { this.directoryTree.removeAll(); File[] roots = File.listRoots(); for (int a = 0; a < roots.length; a++) { /* * Skip drive A if it is not explicitly wanted - no one needs it nowadays and it slows * initialization down. */ if (!Options.getInst().hideDrivesAB || (!roots[a].getPath().startsWith("A:") && !roots[a].getPath() .startsWith("B:"))) { String rootEntry = roots[a].toString(); if (rootEntry.endsWith("\\")) rootEntry = rootEntry.substring(0, rootEntry.length() - 1); TreeItem root = new TreeItem(this.directoryTree, 0); root.setText(rootEntry); root.setData(roots[a]); new TreeItem(root, 0); } } }
private void removeSelectedPackage(SelectionEvent e, TreeViewer treeViewer) { Tree tree = getTree(e); if (tree == null) { return; } TreeItem[] selection = tree.getSelection(); if (selection != null && selection.length > 0) { for (TreeItem item : selection) { TreeItem parent = item.getParentItem(); if (parent == null) { removePackage(item); updatePageComplete(tree); } else { alert("请选择要删除的包!"); } } } else { alert("请选择要删除的包!"); } }
void refreshDetails() { configDetails.removeAll(); Map webseeds = wizard.webseeds; Iterator iter = webseeds.entrySet().iterator(); while(iter.hasNext()) { Map.Entry entry = (Map.Entry)iter.next(); TreeItem itemRoot = new TreeItem(configDetails,SWT.NULL); itemRoot.setText((String)entry.getKey()); Iterator iter2 = ((List)entry.getValue()).iterator(); while(iter2.hasNext()) { String url = (String) iter2.next(); new TreeItem(itemRoot,SWT.NULL).setText(url); } itemRoot.setExpanded(true); } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (null == activeWorkbenchWindow) { return null; } IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); if (null == activePage) { return null; } IWorkbenchPart activePart = activePage.getActivePart(); if (!(activePart instanceof CommonNavigator)) { return null; } CommonNavigator navigator = (CommonNavigator) activePart; CommonViewer commonViewer = navigator.getCommonViewer(); Tree navigatorTree = commonViewer.getTree(); List<TreeItem> visibleItems = new ArrayList<>(); collectChildren(navigatorTree.getItems(), visibleItems); List<Object> visibleData = visibleItems.stream().map(i -> i.getData()).collect(Collectors.toList()); commonViewer.setSelection(new StructuredSelection(visibleData), false); return null; }
private void collectChildren(TreeItem[] items, List<TreeItem> visibleItems) { Arrays.asList(items).stream() .filter(i -> i.getData() != null) .forEach(item -> { visibleItems.add(item); if (item.getExpanded()) { collectChildren(item.getItems(), visibleItems); } }); }
private void dispose(TreeItem item) { if (item != null) { if (item.getItems() != null) { for (TreeItem child : item.getItems()) { dispose(child); } } } item.getImage().dispose(); item.dispose(); }
private TreeItem findParentStepInTree() { try { long priority = ((Step)step.getParent()).priority; return findStepInTree(null,priority); } catch (Exception e) { if (lastSelectableItem.getForeground().equals(Display.getCurrent().getSystemColor(SWT.COLOR_RED))) { return null; } return lastSelectableItem; } }
private void disableStepsInTree() { if (stepItem != null) { // disable parents 'XML' steps if needed if (step.isXml()) { TreeItem tItem = stepItem; while (tItem.getParentItem().getData() instanceof Step) { tItem = tItem.getParentItem(); if (((Step) tItem.getData()).isXml()) { tItem.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); } } } } }
public void getInHeritedScreenClass(ScreenClass screenClass, TreeItem branch) { TreeItem leaf = new TreeItem(branch, SWT.NONE); leaf.setText(screenClass.getName()); List<ScreenClass> screenClasses = screenClass.getInheritedScreenClasses(); for (ScreenClass sC : screenClasses) { getInHeritedScreenClass(sC, leaf); } }
/** * highlights the specified TreeItem with a special colour . The node and all * its childs will be highlighted * * @param item the item to be highlighted * @param color the color to be used, null to set as default colour */ private void highLightTreeItem(TreeItem item, Color color) { item.setBackground(color); for (int i =0; i < item.getItemCount(); i++) { highLightTreeItem(item.getItem(i), color); } }
public void selectTreeItem(TreeItem ti) { if (selectedTreeItem != null) { selectedTreeItem.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); } selectedTreeItem = ti; selectedTreeItem.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GREEN)); //deselectAll(); }
public Document getDocument() { TreeItem top = (getItemCount() > 0) ? getItem(0) : null; if (top != null) { Node obj = getTreeItemData(top); if (obj != null) { return obj.getOwnerDocument(); } } return null; }
public void expandAll(TreeItem treeItem) { TreeItem[] treeItems = treeItem.getItems(); treeItem.setExpanded(true); for (TreeItem sub : treeItems) { expandAll(sub); } }
/** * Gets the property descriptor of the selected property for this databaseObjectBeanInfo * @param databaseObjectBeanInfo : BeanInfo of the selected databaseObject in the TreeExplorerView * @return PropertyDescriptor */ public PropertyDescriptor getSelectedPropertyDescriptor(BeanInfo databaseObjectBeanInfo) { PropertyDescriptor propertyDescriptor = null; // gets the properties editor PropertySheet view = ConvertigoPlugin.getDefault().getPropertiesView(); Tree tree = (Tree) view.getCurrentPage().getControl(); // gets the property selected in the property editor if one is selected TreeItem[] items = tree.getSelection(); if (items.length > 0) { TreeItem selectedItem = items[0]; // gets the local name of the selected property String text = selectedItem.getText(); // gets the PropertyDescriptors of this databaseObject PropertyDescriptor[] descriptors = databaseObjectBeanInfo.getPropertyDescriptors(); String displayName = null; int i = 0; // gets the PropertyDescriptor of the selected property while (i < descriptors.length && propertyDescriptor == null) { displayName = descriptors[i].getDisplayName(); if (displayName.equals(text)) propertyDescriptor = descriptors[i]; i++; } } return propertyDescriptor; }
public String removeItem(TreeItem selItem, String parent, String content) throws JAXBException { Unmarshaller unmarshaller = JAXBContext.newInstance(ComponentType.class).createUnmarshaller(); MarshallerImpl marshaller = (MarshallerImpl) JAXBContext.newInstance(ComponentType.class).createMarshaller(); marshaller.setProperty(MarshallerImpl.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new NamespacePrefixMapper()); ComponentType sDef = ((JAXBElement<ComponentType>) unmarshaller.unmarshal(new StringReader(editorText))).getValue(); ArrayList<Object> ops = new ArrayList<Object>(); ops.addAll(sDef.getServiceOrReferenceOrProperty()); int i = 0; for (Object obj : sDef.getServiceOrReferenceOrProperty()) { if (obj instanceof ComponentTypeReference && parent.equalsIgnoreCase("Required Service")) { if (((ComponentTypeReference) obj).getName().equalsIgnoreCase(selItem.getText())) ops.remove(i); } else if (obj instanceof Service && parent.equalsIgnoreCase("Provided Service")) { if (((Service) obj).getName().equalsIgnoreCase(selItem.getText())) ops.remove(i); } else if (obj instanceof Property && parent.equalsIgnoreCase("Properties")) { if (((Property) obj).getName().equalsIgnoreCase(selItem.getText())) ops.remove(i); } i++; } sDef.getServiceOrReferenceOrProperty().clear(); sDef.getServiceOrReferenceOrProperty().addAll(ops); StringWriter writer = new StringWriter(); marshaller.marshal(sDef, writer); return ParseUtil.removeEmptyTags(writer.toString(), ComponentType.class); }
public String removeItem(TreeItem selItem, String parent, String content) throws JAXBException { Unmarshaller unmarshaller = JAXBContext.newInstance(Library.class).createUnmarshaller(); MarshallerImpl marshaller = (MarshallerImpl) JAXBContext.newInstance(Library.class).createMarshaller(); marshaller.setProperty(MarshallerImpl.JAXB_FORMATTED_OUTPUT, true); marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper", new NamespacePrefixMapper()); Library lib = (Library) unmarshaller.unmarshal(new StringReader(editorText)); ArrayList<Object> types = new ArrayList<Object>(); types.addAll(lib.getTypes().getSimpleOrRecordOrConstant()); int i = 0; for (Object obj : lib.getTypes().getSimpleOrRecordOrConstant()) { if (obj instanceof Simple && parent.equalsIgnoreCase("Simple")) { if (((Simple) obj).getName().equalsIgnoreCase(selItem.getText())) types.remove(i); } else if (obj instanceof Constant && parent.equalsIgnoreCase("Constant")) { if (((Constant) obj).getName().equalsIgnoreCase(selItem.getText())) types.remove(i); } else if (obj instanceof tech.ecoa.osets.model.types.Enum && parent.equalsIgnoreCase("Enum")) { if (((tech.ecoa.osets.model.types.Enum) obj).getName().equalsIgnoreCase(selItem.getText())) types.remove(i); } else if (obj instanceof Array && parent.equalsIgnoreCase("Array")) { if (((Array) obj).getName().equalsIgnoreCase(selItem.getText())) types.remove(i); } else if (obj instanceof Record && parent.equalsIgnoreCase("Record")) { if (((Record) obj).getName().equalsIgnoreCase(selItem.getText())) types.remove(i); } else if (obj instanceof FixedArray && parent.equalsIgnoreCase("Fixed Array")) { if (((FixedArray) obj).getName().equalsIgnoreCase(selItem.getText())) types.remove(i); } else if (obj instanceof VariantRecord && parent.equalsIgnoreCase("Variant Record")) { if (((VariantRecord) obj).getName().equalsIgnoreCase(selItem.getText())) types.remove(i); } i++; } lib.getTypes().getSimpleOrRecordOrConstant().clear(); lib.getTypes().getSimpleOrRecordOrConstant().addAll(types); StringWriter writer = new StringWriter(); marshaller.marshal(lib, writer); return ParseUtil.removeEmptyTags(writer.toString(), Library.class); }
/** * Change the "expanded" state of the node. */ protected void setDirectoryExpandedStates(TreeItem treeItem, boolean expand) { treeItem.setExpanded(expand); TreeItem[] treeItems = treeItem.getItems(); for (int i=0; i<treeItems.length; i++) { setDirectoryExpandedStates(treeItems[i], expand); } }
/** * Helper function for building fileTree. */ protected void addDirectoriesToTree(TreeItem directoryItem, DirectoryEntry directoryEntry) { Iterator files = directoryEntry.getFiles().iterator(); while (files.hasNext()) { final FileEntry entry = (FileEntry) files.next(); if (entry.isDirectory()) { TreeItem item = new TreeItem(directoryItem, SWT.BORDER); item.setText(entry.getFilename()); item.setData(entry); addDirectoriesToTree(item, (DirectoryEntry)entry); } } }
/** * Create the keyboard handler for the directory pane. * These are keys that are <em>only</em> active in the directory * viewer. See createToolbarCommandHandler for the general application * keyboard handler. * @see #createToolbarCommandHandler */ private Listener createDirectoryKeyboardHandler() { return new Listener() { public void handleEvent(Event event) { if (event.type == SWT.KeyUp) { TreeItem[] treeItem = null; if ((event.stateMask & SWT.CTRL) != 0) { switch (event.character) { case '-': treeItem = getDirectoryTree().getSelection(); setDirectoryExpandedStates(treeItem[0], false); break; case '+': treeItem = getDirectoryTree().getSelection(); setDirectoryExpandedStates(treeItem[0], true); break; } } else { // assume no control and no alt switch (event.character) { case '-': treeItem = getDirectoryTree().getSelection(); treeItem[0].setExpanded(false); break; case '+': treeItem = getDirectoryTree().getSelection(); treeItem[0].setExpanded(true); break; } } } } }; }