List of usage examples for org.eclipse.jface.viewers StructuredSelection iterator
@Override
public Iterator iterator()
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()); }/* ww w .ja va 2 s.c om*/ } } }
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()); }//from ww w . ja va2 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()); }//w ww . j a v a 2 s. c om 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.refactor.refactoring.runtime.ui.ApplicationMenu.java
License:Open Source License
/** * Returns a list of relevant objects from the given selection. * @param selection Origin selection in the workbench. * @return List of relevant objects from the given selection. *///from w w w . j a va2s . c o m @SuppressWarnings("rawtypes") private Object[] getSelection(ISelection selection) { if (null != selection && selection instanceof StructuredSelection) { StructuredSelection ss = (StructuredSelection) selection; if (null == ss.getFirstElement()) { return ss.toArray(); } List<Object> list = new ArrayList<Object>(); final Iterator i = ss.iterator(); while (i.hasNext()) { final Object selectedEObject = i.next(); final Class cl = selectedEObject.getClass(); //Usual EMF-Tree: boolean added = checkEMFTree(list, selectedEObject); if (!added) { added = checkGmf(list, selectedEObject, cl); } } return list.toArray(); } return new Object[0]; }
From source file:org.eclipse.gef4.zest.examples.jface.ConnectionDecorationJFaceSnippet.java
License:Open Source License
/** * @param args// ww w . j av a 2 s. co m */ public static void main(String[] args) { Display d = new Display(); Shell shell = new Shell(d); shell.setText("GraphJFaceSnippet2"); shell.setLayout(new FillLayout(SWT.VERTICAL)); shell.setSize(400, 400); viewer = new GraphViewer(shell, SWT.NONE); viewer.setContentProvider(new MyContentProvider()); viewer.setLabelProvider(new MyConnectionRelationLabelProvider()); // MyEndpointEntityLabelProvider viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm()); viewer.setInput(new Object()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { System.out.println( "Selection Changed: " + selectionToString((StructuredSelection) event.getSelection())); } private String selectionToString(StructuredSelection selection) { StringBuffer stringBuffer = new StringBuffer(); Iterator iterator = selection.iterator(); boolean first = true; while (iterator.hasNext()) { if (first) { first = false; } else { stringBuffer.append(" : "); } stringBuffer.append(iterator.next()); } return stringBuffer.toString(); } }); shell.open(); while (!shell.isDisposed()) { while (!d.readAndDispatch()) { d.sleep(); } } }
From source file:org.eclipse.gef4.zest.examples.jface.GraphJFaceSnippet4.java
License:Open Source License
/** * @param args/*from ww w . j a v a2 s . co m*/ */ public static void main(String[] args) { Display d = new Display(); Shell shell = new Shell(d); shell.setText("GraphJFaceSnippet2"); shell.setLayout(new FillLayout(SWT.VERTICAL)); shell.setSize(400, 400); viewer = new GraphViewer(shell, SWT.NONE); viewer.setContentProvider(new MyContentProvider()); viewer.setLabelProvider(new MyLabelProvider()); viewer.setLayoutAlgorithm(new SpringLayoutAlgorithm()); viewer.setInput(new Object()); viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { System.out.println( "Selection Changed: " + selectionToString((StructuredSelection) event.getSelection())); } private String selectionToString(StructuredSelection selection) { StringBuffer stringBuffer = new StringBuffer(); Iterator iterator = selection.iterator(); boolean first = true; while (iterator.hasNext()) { if (first) { first = false; } else { stringBuffer.append(" : "); } stringBuffer.append(iterator.next()); } return stringBuffer.toString(); } }); shell.open(); while (!shell.isDisposed()) { while (!d.readAndDispatch()) { d.sleep(); } } }
From source file:org.eclipse.gemoc.bcool.transformation.qvto2ccsl.ui.popup.actions.Qvto2CCSLTranslator.java
License:Open Source License
/**path * @see IActionDelegate#selectionChanged(IAction, ISelection) *///from www . jav a 2 s . com // Here models are loaded from the parameters // I should split it into two groups here public void selectionChanged(IAction action, ISelection selection) { qvtoFile = null; modelfiles.removeAll(modelfiles); if (selection instanceof StructuredSelection) { StructuredSelection ts = (StructuredSelection) selection; Iterator it = ts.iterator(); while (it.hasNext()) { Object o = it.next(); if (o instanceof IFile) { IFile f = (IFile) o; if (f.getFileExtension().compareTo("qvto") == 0) { qvtoFile = (IFile) o; } else { modelfiles.add((IFile) o); } } } } }
From source file:org.eclipse.gmf.graphdef.editor.sheet.AbstractCustomSectionParent.java
License:Open Source License
public void setInput(IWorkbenchPart part, ISelection selection) { if (selection.isEmpty() || false == selection instanceof StructuredSelection) { super.setInput(part, selection); return;/*w ww . j a v a2s . co m*/ } final StructuredSelection structuredSelection = ((StructuredSelection) selection); ArrayList transformedSelection = new ArrayList(structuredSelection.size()); for (Iterator it = structuredSelection.iterator(); it.hasNext();) { Object r = transformSelection(it.next()); if (r != null) { transformedSelection.add(r); } } mySavedSelection = transformedSelection; super.setInput(part, new StructuredSelection(transformedSelection)); }
From source file:org.eclipse.gmf.runtime.lite.properties.AdvancedPropertySection.java
License:Open Source License
public void setInput(IWorkbenchPart part, ISelection selection) { if (selection.isEmpty() || false == selection instanceof StructuredSelection) { super.setInput(part, selection); return;/*w w w. ja va2 s. c o m*/ } final StructuredSelection structuredSelection = ((StructuredSelection) selection); ArrayList<Object> transformedSelection = new ArrayList<Object>(structuredSelection.size()); for (Iterator<?> it = structuredSelection.iterator(); it.hasNext();) { Object r = transformSelection(it.next()); if (r != null) { transformedSelection.add(r); } } CommandStack commandStack = getCommandStack(transformedSelection); myPropertySheetEntry.setCommandStack(commandStack); super.setInput(part, new StructuredSelection(transformedSelection)); }
From source file:org.eclipse.gmf.runtime.lite.properties.ColorsAndFontsPropertySection.java
License:Open Source License
@Override public void setInput(IWorkbenchPart part, ISelection selection) { if (selection.isEmpty() || false == selection instanceof StructuredSelection) { super.setInput(part, selection); return;//from w w w. ja v a2s .c o m } final StructuredSelection structuredSelection = ((StructuredSelection) selection); myViews = new ArrayList<View>(structuredSelection.size()); for (Iterator<?> it = structuredSelection.iterator(); it.hasNext();) { Object r = transformSelection(it.next()); if (r instanceof View) { myViews.add((View) r); } } myEditingDomain = getEditingDomain(myViews); myCommandStack = AdvancedPropertySection.getCommandStack(myEditingDomain); super.setInput(part, new StructuredSelection(myViews)); }