List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:org.eclipse.birt.report.designer.ui.lib.explorer.dnd.LibraryDragListener.java
License:Open Source License
public void dragStart(DragSourceEvent event) { boolean doit = !getViewer().getSelection().isEmpty(); if (doit) {/*from w w w .j a v a 2s. c o m*/ IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection(); List objectList = selection.toList(); selectionList.clear(); for (int i = 0; i < objectList.size(); i++) { if (objectList.get(i) instanceof ReportResourceEntry) selectionList.add(((ReportResourceEntry) objectList.get(i)).getReportElement()); else selectionList.add(objectList.get(i)); } Object[] objects = selectionList.toArray(); if (validateType(objects)) { for (int i = 0; i < objects.length; i++) if (!validateTransfer(objects[i])) { doit = false; break; } } else doit = false; if (doit) TemplateTransfer.getInstance().setTemplate(objects); } event.doit = doit; if (Policy.TRACING_DND_DRAG && doit) { System.out.println("DND >> Drag starts."); //$NON-NLS-1$ } }
From source file:org.eclipse.buildship.ui.generic.NodeSelection.java
License:Open Source License
/** * Creates a new instance reflecting the given {@link IStructuredSelection} instance. * * @param selection the selection from which to create the new instance * @return the new instance//from w w w .j a v a2 s .c o m */ public static NodeSelection from(IStructuredSelection selection) { return selection.isEmpty() ? empty() : new NodeSelection(selection.toList()); }
From source file:org.eclipse.buildship.ui.taskview.TreeViewerSelectionChangeListener.java
License:Open Source License
private void findAndUpdateViewSelections(ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; ImmutableList<ProjectNode> projectNodes = collectProjectNodesToSelect(structuredSelection.toList()); ImmutableList<IProject> projects = collectProjectsToSelect(projectNodes); updateViewSelection(projects);/*w w w .ja v a2s . c o m*/ } }
From source file:org.eclipse.buildship.ui.util.workbench.WorkingSetUtils.java
License:Open Source License
/** * Returns the selected {@link org.eclipse.ui.IWorkingSet} instances or an empty List, if the * selection does not contain any {@link org.eclipse.ui.IWorkingSet}. * * @param selection the selection// w w w .j a v a2s . co m * @return the selected working sets */ public static List<IWorkingSet> getSelectedWorkingSets(IStructuredSelection selection) { if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) { return ImmutableList.of(); } List<?> elements = selection.toList(); @SuppressWarnings("unchecked") List<IWorkingSet> workingSets = (List<IWorkingSet>) FluentIterable.from(elements) .filter(Predicates.instanceOf(IWorkingSet.class)).toList(); return workingSets; }
From source file:org.eclipse.buildship.ui.workspace.ProjectSynchronizer.java
License:Open Source License
private static List<IProject> collectSelectedProjects(ExecutionEvent event) { ISelection currentSelection = HandlerUtil.getCurrentSelection(event); if (currentSelection instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) currentSelection; @SuppressWarnings("unchecked") ImmutableList<IProject> selectedProjects = FluentIterable.from(selection.toList()) .transform(new AdapterFunction<IProject>(IProject.class, Platform.getAdapterManager())) .filter(com.google.common.base.Predicates.notNull()).filter(Predicates.hasGradleNature()) .toList();//from w ww .ja v a2 s .com return selectedProjects; } else { return ImmutableList.of(); } }
From source file:org.eclipse.buildship.ui.workspace.RefreshGradleClasspathContainerHandler.java
License:Open Source License
private List<IProject> collectSelectedProjects(ExecutionEvent event) { ISelection currentSelection = HandlerUtil.getCurrentSelection(event); Builder<IProject> result = ImmutableList.builder(); if (currentSelection instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) currentSelection; IAdapterManager adapterManager = Platform.getAdapterManager(); for (Object selectionItem : selection.toList()) { @SuppressWarnings({ "cast", "RedundantCast" }) IResource resource = (IResource) adapterManager.getAdapter(selectionItem, IResource.class); if (resource != null) { IProject project = resource.getProject(); result.add(project);/* ww w . java 2 s . c om*/ } } } return result.build(); }
From source file:org.eclipse.capra.ui.helpers.TraceCreationHelper.java
License:Open Source License
/** * Extract selected elements from an {@link ISelection}. * // w ww .j a va 2s .c o m * @param selection * @return A list of all the selected elements */ @SuppressWarnings("unchecked") public static List<Object> extractSelectedElements(ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection sselection = (IStructuredSelection) selection; return sselection.toList(); } else { return new ArrayList<Object>(); } }
From source file:org.eclipse.capra.ui.plantuml.util.SelectionUtil.java
License:Open Source License
/** * Extract selected elements from a selection event. * //from ww w .ja v a2s. c om * @param event * This is the click event to create a trace * @return A list of all the selected elements * @throws CapraException */ public static List<Object> extractSelectedElements(ExecutionEvent event) { ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; ArrayList<Object> result = new ArrayList<>(); List<?> list = structuredSelection.toList(); result.addAll(list); return result; } return new ArrayList<>(); }
From source file:org.eclipse.capra.ui.plantuml.util.SelectionUtil.java
License:Open Source License
/** * Extract selected elements from an {@link ISelection}. * /*from w w w . j av a 2 s . c om*/ * @param selection * @return A list of all the selected elements * @throws CapraException */ public static List<Object> extractSelectedElements(ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; ArrayList<Object> result = new ArrayList<>(); List<?> list = structuredSelection.toList(); result.addAll(list); return result; } return new ArrayList<>(); }