List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:eu.geclipse.workflow.ui.listeners.JSDLTransferDropTargetListener.java
License:Open Source License
protected List<JSDLJobDescription> getObjectsBeingDropped() { List<JSDLJobDescription> result = new ArrayList<JSDLJobDescription>(); if (getTransfer() instanceof LocalSelectionTransfer) { LocalSelectionTransfer transfer = (LocalSelectionTransfer) getTransfer(); IStructuredSelection selection = (IStructuredSelection) transfer.getSelection(); List<?> objects = selection.toList(); for (Object o : objects) { if (o instanceof JSDLJobDescription) { result.add((JSDLJobDescription) o); }//w w w.ja va2 s. c o m } } return result; }
From source file:eu.ml82.bpmn_layouter.camunda_modeler.LayoutHandler.java
License:Open Source License
/** * {@inheritDoc}//from w w w. j a v a 2s. c om */ public Object execute(final ExecutionEvent event) throws ExecutionException { ISelection selection = null; // check parameter for layout scope, default is diagram scope String layoutScope = event.getParameter(PARAM_LAYOUT_SCOPE); if (layoutScope != null && layoutScope.equals(VAL_SELECTION)) { selection = HandlerUtil.getCurrentSelection(event); } // fetch general settings from preferences boolean animation = true; boolean zoomToFit = true; boolean progressDialog = false; // get the active editor, which is expected to contain the diagram for applying layout IEditorPart editorPart = HandlerUtil.getActiveEditor(event); if (selection instanceof IStructuredSelection && !selection.isEmpty()) { // perform layout with the given selection (only the first element is considered) IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object diagramPart; if (structuredSelection.size() == 1) { diagramPart = structuredSelection.getFirstElement(); } else { diagramPart = structuredSelection.toList(); } DiagramLayoutEngine.INSTANCE.layout(editorPart, diagramPart, animation, progressDialog, false, zoomToFit); } else { // perform layout on the whole diagram DiagramLayoutEngine.INSTANCE.layout(editorPart, null, animation, progressDialog, false, zoomToFit); } return null; }
From source file:eu.numberfour.n4js.ui.organize.imports.N4JSOrganizeImportsHandler.java
License:Open Source License
private Multimap<IProject, IFile> collectFiles(IStructuredSelection structuredSelection) { Multimap<IProject, IFile> result = HashMultimap.create(); for (Object object : structuredSelection.toList()) { collectRelevantFiles(object, result); }/* w w w .j av a 2 s. c o m*/ return result; }
From source file:eu.numberfour.n4js.ui.workingsets.internal.N4JSNewWizardsActionGroup.java
License:Open Source License
private boolean canEnable(final IStructuredSelection sel) { if (sel.size() == 0) { return true; }/* www. jav a2 s .com*/ final List<?> list = sel.toList(); for (final Iterator<?> iterator = list.iterator(); iterator.hasNext(); /**/) { if (!isNewTarget(iterator.next())) { return false; } } return true; }
From source file:eu.scasefp7.eclipse.core.ui.views.Dashboard.java
License:Apache License
private void updateSelection(ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; if (sel.getFirstElement() instanceof IResource) { @SuppressWarnings("unchecked") IProject project = getProjectOfSelectionList(sel.toList()); if (project != null) { Activator.TRACE.trace("/dashboard/selectedProjectChanged", "Selected project: " + project.getName()); this.currentProject = project; }//from w w w. ja v a2s . com } } }
From source file:ext.org.eclipse.jdt.internal.ui.actions.GenerateConstructorUsingFieldsSelectionDialog.java
License:Open Source License
List<?> getElementList() { IStructuredSelection selection = (IStructuredSelection) getTreeViewer().getSelection(); List<?> elements = selection.toList(); ArrayList<Object> elementList = new ArrayList<Object>(); for (int i = 0; i < elements.size(); i++) { elementList.add(elements.get(i)); }/*ww w . j a v a 2s . co m*/ return elementList; }
From source file:ext.org.eclipse.jdt.internal.ui.actions.NewWizardsActionGroup.java
License:Open Source License
private boolean canEnable(IStructuredSelection sel) { if (sel.size() == 0) return true; List<?> list = sel.toList(); for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) { if (!isNewTarget(iterator.next())) return false; }//w w w .j a v a 2 s . com return true; }
From source file:ext.org.eclipse.jdt.internal.ui.callhierarchy.OpenCallHierarchyAction.java
License:Open Source License
@Override public void run(IStructuredSelection selection) { List<?> elements = selection.toList(); if (!CallHierarchy.arePossibleInputElements(elements)) { elements = Collections.EMPTY_LIST; }/* ww w . j av a 2s . c o m*/ IMember[] members = elements.toArray(new IMember[elements.size()]); if (!ActionUtil.areProcessable(getShell(), members)) return; CallHierarchyUI.openView(members, getSite().getWorkbenchWindow()); }
From source file:ext.org.eclipse.jdt.internal.ui.dialogs.GenerateToStringDialog.java
License:Open Source License
@Override protected CheckboxTreeViewer createTreeViewer(Composite parent) { CheckboxTreeViewer treeViewer = super.createTreeViewer(parent); treeViewer.setLabelProvider(new GenerateToStringLabelProvider()); //expandAll because setSubtreeChecked() used in CheckStateListener below assumes that elements have been expanded treeViewer.expandAll();/*from w w w .ja v a2 s . com*/ //but actually we only need one branch expanded treeViewer.collapseAll(); treeViewer.expandToLevel(GenerateToStringContentProvider.fieldsNode, 1); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) getTreeViewer().getSelection(); Object selected = selection.size() > 0 ? selection.toList().get(0) : null; GenerateToStringContentProvider cp = (GenerateToStringContentProvider) getContentProvider(); fButtonControls[UP_INDEX].setEnabled(cp.canMoveUp(selected)); fButtonControls[DOWN_INDEX].setEnabled(cp.canMoveDown(selected)); } }); treeViewer.addCheckStateListener(new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { getTreeViewer().setSubtreeChecked(event.getElement(), event.getChecked()); getTreeViewer().setGrayed(event.getElement(), false); Object parentElement = ((ITreeContentProvider) (getTreeViewer().getContentProvider())) .getParent(event.getElement()); if (parentElement != null) { Object[] siblings = ((ITreeContentProvider) (getTreeViewer().getContentProvider())) .getChildren(parentElement); int count = 0; for (int i = 0; i < siblings.length; i++) { if (getTreeViewer().getChecked(siblings[i])) count++; } if (count == 0) getTreeViewer().setGrayChecked(parentElement, false); else if (count == siblings.length) { getTreeViewer().setChecked(parentElement, true); getTreeViewer().setGrayed(parentElement, false); } else getTreeViewer().setGrayChecked(parentElement, true); } updateOKStatus(); } }); return treeViewer; }
From source file:ext.org.eclipse.jdt.internal.ui.javaeditor.JavaOutlinePage.java
License:Open Source License
public void select(ISourceReference reference) { if (fOutlineViewer != null) { ISelection s = fOutlineViewer.getSelection(); if (s instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) s; List<?> elements = ss.toList(); if (!elements.contains(reference)) { s = (reference == null ? StructuredSelection.EMPTY : new StructuredSelection(reference)); fOutlineViewer.setSelection(s, true); }/*from w ww . j av a 2s . c o m*/ } } }