List of usage examples for org.eclipse.jface.viewers StructuredSelection isEmpty
@Override public boolean isEmpty()
From source file:org.eclipse.edt.ide.ui.internal.editor.EGLEditor.java
License:Open Source License
public void doSelectionChanged(SelectionChangedEvent event) { int offset;/* www . j av a 2 s . c o m*/ int nodeLength; StructuredSelection selection = (StructuredSelection) event.getSelection(); if (selection == null || selection.isEmpty()) return; IEGLDocument document = (IEGLDocument) getDocumentProvider().getDocument(getEditorInput()); if (document == null) return; // Use the 1st for selection (know it's not empty because of // test above) Object selectedElement = selection.getFirstElement(); if (selectedElement == null) return; if (selectedElement instanceof ImportGroup) { offset = ((ImportGroup) selectedElement).getOffset(); nodeLength = ((ImportGroup) selectedElement).getLength(); } else if (selectedElement instanceof ImportDeclaration || selectedElement instanceof PackageDeclaration) { offset = ((Node) selectedElement).getOffset(); nodeLength = ((Node) selectedElement).getLength(); } else { offset = ((Node) selectedElement).getOffset(); nodeLength = ((Node) selectedElement).getLength(); } try { editingScriptStarted(); setSelection(offset, nodeLength); TreeViewer tv = (TreeViewer) event.getSource(); ILabelProvider provider = (ILabelProvider) tv.getLabelProvider(); IRegion region = ((OutlineLabelProvider) provider).getHighlightRange(selectedElement); if (region.getLength() != 0) { getSourceViewer().revealRange(region.getOffset(), region.getLength()); getSourceViewer().setSelectedRange(region.getOffset(), region.getLength()); } } finally { editingScriptEnded(); } }
From source file:org.eclipse.emf.ecoretools.legacy.tabbedproperties.sections.AbstractCollectionPropertySection.java
License:Open Source License
private void handleAddButtonSelected() { if (listElements.getSelection() instanceof StructuredSelection) { StructuredSelection selection = (StructuredSelection) listElements.getSelection(); if (!selection.isEmpty()) { Iterator<?> iterator = selection.iterator(); while (iterator.hasNext()) { executeAddCommand(iterator.next()); }/*from w w w.j av a2 s .c o m*/ } } }
From source file:org.eclipse.emf.ecoretools.legacy.tabbedproperties.sections.AbstractCollectionPropertySection.java
License:Open Source License
private void handleRemoveButtonSelected() { if (listMembers.getSelection() instanceof StructuredSelection) { StructuredSelection selection = (StructuredSelection) listMembers.getSelection(); if (!selection.isEmpty()) { Iterator<?> iterator = selection.iterator(); while (iterator.hasNext()) { executeRemoveCommand(iterator.next()); }//w w w.ja v a 2 s . co m } } }
From source file:org.eclipse.emf.ecoretools.legacy.tabbedproperties.sections.AbstractCollectionPropertySection.java
License:Open Source License
private void executeMovement(boolean up) { if (listMembers.getSelection() instanceof StructuredSelection) { StructuredSelection selection = (StructuredSelection) listMembers.getSelection(); if (!selection.isEmpty()) { EList<EObject> membersToMove = new BasicEList<EObject>(); Iterator<?> iterator = selection.iterator(); while (iterator.hasNext()) { membersToMove.add((EObject) iterator.next()); }/*from w ww . j a v a 2 s . c o m*/ int[] indexes = new int[membersToMove.size()]; for (int k = 0; k < indexes.length; k++) { indexes[k] = -1; } EList<EObject> members = getFeatureAsList(); EList<EObject> movedMembers = moveMembers(members, membersToMove, up, indexes); if (!movedMembers.equals(members)) { executeEmptyListCommand(); executeAddAllCommand(movedMembers); listMembers.getTable().setSelection(indexes); } } } return; }
From source file:org.eclipse.emf.eef.runtime.ui.widgets.AdvancedEObjectFlatComboViewer.java
License:Open Source License
public void setSelection(ISelection selection) { if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (!structuredSelection.isEmpty() && !"".equals(structuredSelection.getFirstElement())) { setSelection((EObject) structuredSelection.getFirstElement()); } else {//w w w . ja v a2 s . co m this.valueText.setText(UNDEFINED_VALUE); // this.parent.pack(); } } }
From source file:org.eclipse.emf.eef.runtime.ui.widgets.LinkEObjectFlatComboViewer.java
License:Open Source License
/** (non-Javadoc) * @see org.eclipse.emf.eef.runtime.ui.widgets.AbstractAdvancedEObjectFlatComboViewer#setSelection(org.eclipse.jface.viewers.ISelection) *//*from ww w .j a v a 2s. c o m*/ public void setSelection(ISelection selection) { if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (!structuredSelection.isEmpty() && !"".equals(structuredSelection.getFirstElement())) { setSelection((EObject) structuredSelection.getFirstElement()); } else { this.valueLink.setText(UNDEFINED_VALUE); } } }
From source file:org.eclipse.epf.authoring.ui.wizards.SynchronizationSelectConfigPage.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) *///from ww w. j a v a2 s . c om public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { Object[] config = selection.toArray(); syncChoices.setSelectedConfig((MethodConfiguration) config[0]); } // System.out.println("$$$ config =" + syncChoices.toString()); }
From source file:org.eclipse.epf.export.wizards.ExportConfigSelectConfigPage.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) *///from w w w . j av a2 s.co m public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { Object[] configs = selection.toArray(); setDisplayAttributes((MethodConfiguration) configs[0]); } }
From source file:org.eclipse.epf.export.wizards.ExportConfigSelectSpecsPage.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) *///w w w.j a va 2s. c o m public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { Object[] configs = selection.toArray(); setDisplayAttributes((MethodConfiguration) configs[0]); } }
From source file:org.eclipse.epf.export.wizards.PluginInfoPage.java
License:Open Source License
/** * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */// w ww . j a va2 s . c om public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { Object[] plugin = selection.toArray(); displayRelatedInfo((MethodPlugin) plugin[0]); } }