List of usage examples for org.eclipse.jface.viewers IStructuredSelection iterator
@Override
public Iterator iterator();
From source file:eu.artist.migration.deployment.dialog.DeploymentDialog.java
License:Open Source License
/** * This method renders the widgets for selecting available Cloud target deployment generators. * @param container Composite where placing these widgets *///from w w w. j a v a 2 s .c o m private void createCloudTargetSelector(Composite container) { Label lbtFirstName = new Label(container, SWT.NONE); lbtFirstName.setText("Select deployment target:"); lvDeployer = new ListViewer(container); lvDeployer.setContentProvider(ArrayContentProvider.getInstance()); lvDeployer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof Target) { Target generator = (Target) element; return generator.getLabel(); } return super.getText(element); } }); Target cmTypes[] = Target.values(); lvDeployer.setInput(cmTypes); lvDeployer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); selectedTargets.clear(); Iterator abstractors = selection.iterator(); while (abstractors.hasNext()) { Target abstractor = (Target) abstractors.next(); selectedTargets.add(abstractor); } validate(); } }); }
From source file:eu.artist.migration.mut.cmg.dialog.ComponentModelGeneratorDialog.java
License:Open Source License
/** * This method renders the widgets for selecting available component model generators. * @param container Composite where placing these widgets *//* w w w. j av a 2 s . c om*/ private void createComponentModelSelector(Composite container) { Label lbtFirstName = new Label(container, SWT.NONE); lbtFirstName.setText("Select component model types"); // GridData gridData = new GridData(); // gridData.grabExcessHorizontalSpace = true; // gridData.horizontalAlignment = GridData.FILL; lvCMSelector = new ListViewer(container); lvCMSelector.setContentProvider(ArrayContentProvider.getInstance()); lvCMSelector.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof CMGenerators) { CMGenerators generator = (CMGenerators) element; return generator.getLabel(); } return super.getText(element); } }); CMGenerators cmTypes[] = CMGenerators.values();//{ CMGenerators.Observer_pattern, CMGenerators.RCP }; lvCMSelector.setInput(cmTypes); lvCMSelector.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); selectedCMGenerators.clear(); Iterator selectors = selection.iterator(); RCPCMGeneratorEnabled = false; while (selectors.hasNext()) { CMGenerators selector = (CMGenerators) selectors.next(); selectedCMGenerators.add(selector); if (selector.equals(CMGenerators.RCP)) RCPCMGeneratorEnabled = true; } if (selectedCMGenerators.size() >= 2) mergeModelComposite.setVisible(true); else mergeModelComposite.setVisible(false); if (RCPCMGeneratorEnabled) pluginModelComposite.setVisible(true); else pluginModelComposite.setVisible(false); validate(); } // private Collection<? extends CMGenerators> getGenerators( // int[] selectedItems) { // Collection<CMGenerators> result = new ArrayList<>(); // for (int i = 0; i < selectedItems.length; i++) { // CMGenerators generator = CMGenerators.values()[selectedItems[i]]; // result.add(generator); // } // // return result; // } // // private boolean contains(int[] selectedItems, int ordinal) { // boolean result = false; // for (int i = 0; i < selectedItems.length; i++) { // if (selectedItems[i] == ordinal) { // result = true; // break; // } // } // return result; // } }); }
From source file:eu.artist.migration.mut.pimabstractor.dialog.PIMAbstractorDialog.java
License:Open Source License
/** * This method renders the widgets for selecting available component model generators. * @param container Composite where placing these widgets *///from ww w.j a v a2 s .com private void createAbstractorSelector(Composite container) { Label lbtFirstName = new Label(container, SWT.NONE); lbtFirstName.setText("Select abstractor types"); // GridData gridData = new GridData(); // gridData.grabExcessHorizontalSpace = true; // gridData.horizontalAlignment = GridData.FILL; lvAbstractor = new ListViewer(container); lvAbstractor.setContentProvider(ArrayContentProvider.getInstance()); lvAbstractor.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof Abstractors) { Abstractors generator = (Abstractors) element; return generator.getLabel(); } return super.getText(element); } }); Abstractors cmTypes[] = Abstractors.values(); lvAbstractor.setInput(cmTypes); lvAbstractor.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); selectedAbstractors.clear(); Iterator abstractors = selection.iterator(); RCPAbstractorEnabled = false; while (abstractors.hasNext()) { Abstractors abstractor = (Abstractors) abstractors.next(); selectedAbstractors.add(abstractor); if (abstractor.equals(Abstractors.RCP) || abstractor.equals(Abstractors.GUI)) RCPAbstractorEnabled = true; } if (RCPAbstractorEnabled) pluginModelComposite.setVisible(true); else pluginModelComposite.setVisible(false); validate(); } }); }
From source file:eu.artist.postmigration.nfrvt.eval.run.ui.launch.ModelSelectionTab.java
License:Open Source License
/** * Returns the first {@link GoalModel} from the given selection or null if no * such model can be found. /* w w w .ja v a2s. com*/ * @param selection selection to be searched * @return first goal model in selection */ private GoalModel getGoalModelFromSelection(ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext();) { Object next = iter.next(); if (next instanceof GoalModel) { return (GoalModel) next; } } } return null; }
From source file:eu.artist.postmigration.nfrvt.strategy.fumlsimulation.run.ui.QNModelSelectionTab.java
License:Open Source License
@Override protected EObject loadModelElementFromSelection(ISelection selection) { if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; structuredSelection.size();/*from w w w . j av a 2 s . co m*/ for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext();) { Object next = iter.next(); if (next instanceof Element) { Element element = (Element) next; if (isAnalysisContext(element)) { return element; } } } } return null; }
From source file:eu.cloudwave.wp5.feedback.eclipse.base.core.handlers.HandlerToolkit.java
License:Apache License
/** * Returns all projects that are currently selected. * // w w w. ja va2 s . c o m * @param event * {@link ExecutionEvent} * @return a {@link Set} containing all currently selected {@link IProject}'s */ public static Set<IProject> getSelectedProjects(final ExecutionEvent event) { final Set<IProject> selectedProjects = Sets.newHashSet(); final ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { final IStructuredSelection structuredSelection = (IStructuredSelection) selection; for (final Iterator<?> it = structuredSelection.iterator(); it.hasNext();) { final Object selectedElement = it.next(); if (selectedElement instanceof IProject) { selectedProjects.add((IProject) selectedElement); } else if (selectedElement instanceof IAdaptable) { selectedProjects.add((IProject) ((IAdaptable) selectedElement).getAdapter(IProject.class)); } } } return ImmutableSet.copyOf(selectedProjects); }
From source file:eu.geclipse.batch.ui.actions.ApplyQueueConfigurationAction.java
License:Open Source License
public void selectionChanged(final IAction action, final ISelection selection) { action.setEnabled(true);/* w w w . ja v a 2 s.c om*/ this.queueDescrList = new ArrayList<IGridBatchQueueDescription>(); if (selection instanceof IStructuredSelection) { IStructuredSelection sselection = (IStructuredSelection) selection; Iterator<?> it = sselection.iterator(); while (it.hasNext()) { Object element = it.next(); if (element instanceof BatchQueueDescription) { this.queueDescrList.add((BatchQueueDescription) element); } } } }
From source file:eu.geclipse.batch.ui.internal.adapters.QueueAdapter.java
License:Open Source License
/** * Delete a selected Virtual Organizations (VO) name. * /* w w w. ja v a 2s . com*/ * @param tableViewer The {@link TableViewer} that contains all allowed VO's for the {@link QueueType}. */ public void deleteAllowedVo(final TableViewer tableViewer) { IStructuredSelection structSelection = (IStructuredSelection) tableViewer.getSelection(); if (structSelection != null) { Iterator<?> it = structSelection.iterator(); /* * Iterate over the selections and delete them from the model. */ while (it.hasNext()) { Object feature = it.next(); try { /* Delete only Multi-Valued Elements */ if (!this.adapterRefreshed) { this.allowedVOs.getVOName().remove(feature); if (this.allowedVOs.getVOName().size() == 0) { EcoreUtil.remove(this.allowedVOs); } contentChanged(); } else { tableViewer.remove(feature); } } //end try catch (Exception e) { Activator.logException(e); } /* * Refresh the table viewer and notify the editor that the page content has * changed. */ tableViewer.refresh(); } // end While } // end_if }
From source file:eu.geclipse.callgraph.views.CallGraphView.java
License:Open Source License
@Override public void createPartControl(final Composite parent) { this.graph = new Graph(parent, SWT.NONE); this.graph.addSelectionListener(new SelectionAdapter() { @Override/* w w w.java 2s . c o m*/ public void widgetSelected(final SelectionEvent e) { super.widgetSelected(e); } }); this.graph.addPaintListener(new PaintListener() { @SuppressWarnings("synthetic-access") public void paintControl(final PaintEvent e) { CallGraphView.this.graph.layout(); } }); this.selectionListener = new ISelectionListener() { @SuppressWarnings("synthetic-access") public void selectionChanged(final IWorkbenchPart part, final ISelection selection) { if (graph.isDisposed()) { getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(selectionListener); return; } if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; // OTF based call graph if (structuredSelection.getFirstElement() instanceof IProcess) { Iterator iterator = structuredSelection.iterator(); Object[] objects = CallGraphView.this.graph.getConnections().toArray(); for (int i = 0; i < objects.length; i++) { ((GraphConnection) objects[i]).dispose(); } objects = CallGraphView.this.graph.getNodes().toArray(); for (int i = 0; i < objects.length; i++) { ((GraphNode) objects[i]).dispose(); } while (iterator.hasNext()) { Object next = iterator.next(); if (next instanceof Process) { Process process = (Process) next; OTFReader otfReader = (OTFReader) process.getTrace(); Node root = otfReader.getRootNode(process.getProcessId()); CallGraphView.this.max = 0; getMax(root); drawNode(root, null); CompositeLayoutAlgorithm treeLayoutAlgorithm = new CompositeLayoutAlgorithm( LayoutStyles.NO_LAYOUT_NODE_RESIZING, new LayoutAlgorithm[] { new TreeLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), new HorizontalShift(LayoutStyles.NO_LAYOUT_NODE_RESIZING) }); CallGraphView.this.graph.setLayoutAlgorithm(treeLayoutAlgorithm, true); } } } else // experimental C/C++ file call graph if (structuredSelection.getFirstElement() instanceof ITranslationUnit) { ITranslationUnit translationUnit = (ITranslationUnit) structuredSelection.getFirstElement(); Object[] objects = CallGraphView.this.graph.getConnections().toArray(); for (int i = 0; i < objects.length; i++) { ((GraphConnection) objects[i]).dispose(); } objects = CallGraphView.this.graph.getNodes().toArray(); for (int i = 0; i < objects.length; i++) { ((GraphNode) objects[i]).dispose(); // TODO find fix to dispose selected nodes } try { IASTTranslationUnit astTranslationUnit = translationUnit.getAST(); // IASTDeclaration[] declarations = astTranslationUnit.getDeclarations(); // declarations[ 0 ].getFileLocation(); // Visitor visitor = new Visitor(); // astTranslationUnit.accept( visitor); IASTNode[] nodes = astTranslationUnit.getChildren(); for (IASTNode node : nodes) { if (node instanceof IASTFunctionDefinition) { IASTFunctionDefinition functionDefinition = (IASTFunctionDefinition) node; if ("main".equals(functionDefinition.getDeclarator().getName().toString())) { //$NON-NLS-1$ CallGraphView.this.depth = 0; CallGraphView.this.x = 0; GraphNode main = new GraphNode(CallGraphView.this.graph, SWT.NONE, "main"); //$NON-NLS-1$ CallGraphView.this.stack = new Stack<GraphNode>(); CallGraphView.this.stack.push(main); node(functionDefinition); } } } } catch (CoreException e) { e.printStackTrace(); } } } } }; getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this.selectionListener); }
From source file:eu.geclipse.jsdl.ui.adapters.jsdl.DataStageTypeAdapter.java
License:Open Source License
/** * Delete the selected Element in the TableViewer. The selected element must * be of type: {@link DataStagingType}//from ww w . j av a 2 s . c o m * */ protected void performDelete(final TableViewer viewer) { /* Get the table viewer selection. */ IStructuredSelection structSelection = (IStructuredSelection) viewer.getSelection(); Iterator<?> it = structSelection.iterator(); /* * Iterate over the selections and delete them from the model. */ while (it.hasNext()) { /* Get the First Element of the selection. */ Object feature = it.next(); /* Cast the first element to DataStageingType */ DataStagingType selectedDataStage = (DataStagingType) feature; /* Remove the selected DataStage object from it's container (JobDescription) */ try { EcoreUtil.remove(selectedDataStage); } catch (Exception e) { Activator.logException(e); } // end while /* Refresh the viewer and notify the editor that the page content has * changed. */ viewer.refresh(); contentChanged(); } //end iterator }