List of usage examples for org.eclipse.jface.viewers IStructuredSelection iterator
@Override
public Iterator iterator();
From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.CustomizationDataSelectionDialog.java
License:Open Source License
private CustomizeData getSelectedCustomizeData() { IStructuredSelection selection = (IStructuredSelection) getTableViewer().getSelection(); if (selection.isEmpty()) { return null; }// w w w .ja va 2s. co m Iterator<?> i = selection.iterator(); return (CustomizeData) i.next(); }
From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java
License:Open Source License
private CustomizeData getCustTableSelection() { IStructuredSelection selection = (IStructuredSelection) custTable.getViewer().getSelection(); if (selection.isEmpty()) { return null; }/*from www . j a v a2 s.com*/ Iterator<?> i = selection.iterator(); return (CustomizeData) i.next(); }
From source file:com.hydra.project.myplugin_nebula.xviewer.customize.dialog.XViewerCustomizeDialog.java
License:Open Source License
private List<XViewerColumn> getTableSelection(TreeViewer xColTableViewer) { List<XViewerColumn> xCols = new ArrayList<XViewerColumn>(); IStructuredSelection selection = (IStructuredSelection) xColTableViewer.getSelection(); if (selection.isEmpty()) { return null; }//from www .j a va 2s . c om Iterator<?> i = selection.iterator(); while (i.hasNext()) { xCols.add((XViewerColumn) i.next()); } return xCols; }
From source file:com.ibm.research.tours.fx.dialogs.SelectViewDialog.java
License:Open Source License
/** * Update the selection object./* w ww .j av a2s . com*/ */ protected void updateSelection(SelectionChangedEvent event) { ArrayList descs = new ArrayList(); IStructuredSelection sel = (IStructuredSelection) event.getSelection(); for (Iterator i = sel.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof IViewDescriptor) { descs.add(o); } } viewDescs = new IViewDescriptor[descs.size()]; descs.toArray(viewDescs); }
From source file:com.ibm.wala.ide.AbstractJavaAnalysisAction.java
License:Open Source License
/** * Compute an analysis scope for the current selection * // w ww.j a va 2 s .c o m * @param scopeType should analysis use the source files in the Eclipse projects rather than the class files. */ public static AnalysisScope computeScope(final IStructuredSelection selection, final EclipseProjectPath.AnalysisScopeType scopeType) throws IOException { if (selection == null) { throw new IllegalArgumentException("null selection"); } final Collection<EclipseProjectPath> projectPaths = new LinkedList<EclipseProjectPath>(); Job job = new Job("Compute project paths") { @SuppressWarnings("unchecked") @Override protected IStatus run(IProgressMonitor monitor) { for (Iterator it = selection.iterator(); it.hasNext();) { Object object = it.next(); if (object instanceof IJavaElement) { IJavaElement e = (IJavaElement) object; IJavaProject jp = e.getJavaProject(); try { projectPaths.add(JavaEclipseProjectPath.make(jp, scopeType)); } catch (CoreException e1) { e1.printStackTrace(); // skip and continue } catch (IOException e2) { e2.printStackTrace(); return new Status(IStatus.ERROR, "", 0, "", e2); } } else { Assertions.UNREACHABLE(object.getClass()); } } return Status.OK_STATUS; } }; // lock the whole workspace job.setRule(ResourcesPlugin.getWorkspace().getRoot()); job.schedule(); try { job.join(); IStatus result = job.getResult(); if (result.getSeverity() == IStatus.ERROR) { Throwable exception = result.getException(); if (exception instanceof IOException) { throw (IOException) exception; } else if (exception instanceof RuntimeException) { throw (RuntimeException) exception; } } } catch (InterruptedException e) { e.printStackTrace(); assert false; } AnalysisScope scope = mergeProjectPaths(projectPaths); return scope; }
From source file:com.ibm.wala.ide.AbstractJavaAnalysisAction.java
License:Open Source License
/** * compute the java projects represented by the current selection *//*from www .j a va2 s. co m*/ @SuppressWarnings("unchecked") protected Collection<IJavaProject> computeJavaProjects() { IStructuredSelection selection = (IStructuredSelection) currentSelection; Collection<IJavaProject> projects = HashSetFactory.make(); for (Iterator it = selection.iterator(); it.hasNext();) { Object object = it.next(); if (object instanceof IJavaElement) { IJavaElement e = (IJavaElement) object; IJavaProject jp = e.getJavaProject(); projects.add(jp); } else { Assertions.UNREACHABLE(object.getClass()); } } return projects; }
From source file:com.ifedorenko.m2e.binaryproject.ui.internal.BinaryProjectImportWizard.java
License:Open Source License
@Override public void init(IWorkbench workbench, IStructuredSelection selection) { final List<Dependency> dependencies = new ArrayList<Dependency>(); for (Iterator<?> it = selection.iterator(); it.hasNext();) { Object element = it.next(); ArtifactKey artifactKey = SelectionUtil.getType(element, ArtifactKey.class); if (artifactKey != null) { Dependency d = new Dependency(); d.setGroupId(artifactKey.getGroupId()); d.setArtifactId(artifactKey.getArtifactId()); d.setVersion(artifactKey.getVersion()); d.setClassifier(artifactKey.getClassifier()); dependencies.add(d);/* ww w. java 2 s .co m*/ } } artifactsPage = new MavenDependenciesWizardPage(new ProjectImportConfiguration(), "Artifacts", "Select artifacts to import") { @Override protected void createAdvancedSettings(Composite composite, GridData gridData) { // TODO profile can theoretically be usedful } }; artifactsPage.setDependencies(dependencies.toArray(new Dependency[dependencies.size()])); artifactsPage.addListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { getContainer().updateButtons(); } }); this.initialDependencies = Collections.unmodifiableList(dependencies); }
From source file:com.iw.plugins.spindle.actions.AbstractTapestryResourceAction.java
License:Mozilla Public License
/** * Method checkMultiSelection.//from w ww . j a v a2 s .co m * * @param selection * @return boolean */ private boolean checkSelection(IStructuredSelection selection) { boolean result = true; if (selection == null || selection.isEmpty()) { result = false; } else { for (Iterator iter = selection.iterator(); iter.hasNext();) { IFile candidateFile = (IFile) iter.next(); IProject project = candidateFile.getProject(); try { if (!project.isOpen() || !project.hasNature(TapestryCore.NATURE_ID)) return false; if (project.findMarkers(ITapestryMarker.TAPESTRY_BUILDBROKEN_MARKER, false, IResource.DEPTH_ZERO).length > 0) return false; } catch (CoreException e) { return false; } if (checkSpecificationExists(candidateFile)) result = false; } } return result; }
From source file:com.iw.plugins.spindle.html.HTMLContentOutlinePage.java
License:Mozilla Public License
private IStructuredSelection filterSelection(IFile file, IStructuredSelection selection) { if (selection == null || selection.isEmpty()) { return selection; }//from w w w .j a va 2s . c om if (file == null) { return StructuredSelection.EMPTY; } TapestryComponentModel model = editor.getComponentModel(file); if (model == null || !model.isLoaded()) { return StructuredSelection.EMPTY; } ILabelProvider provider = (ILabelProvider) getTreeViewer().getLabelProvider(); List collected = new ArrayList(); for (Iterator iter = selection.iterator(); iter.hasNext();) { ITypedRegion element = (ITypedRegion) iter.next(); String jwcId = provider.getText(element); if (jwcId.startsWith("$")) { continue; } if (editor.alreadyHasJWCID(jwcId, model)) { continue; } collected.add(jwcId); } return new StructuredSelection(collected); }
From source file:com.iw.plugins.spindle.wizards.extra.AbstractTapestryResourceAction.java
License:Mozilla Public License
/** * Method checkMultiSelection.// w ww.jav a 2s .co m * @param selection * @return boolean */ private boolean checkSelection(IStructuredSelection selection) { boolean result = true; if (selection == null || selection.isEmpty()) { result = false; } else { try { for (Iterator iter = selection.iterator(); iter.hasNext();) { IFile candidateFile = (IFile) iter.next(); try { ITapestryProject project = TapestryPlugin.getDefault().getTapestryProjectFor(candidateFile); if (checkJWCExists(candidateFile)) { result = false; } } catch (CoreException e) { result = false; } } } catch (ClassCastException e) { result = false; } } return result; }