List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:eclox.ui.editor.editors.ListEditor.java
License:Open Source License
/** * Removes the selected value compounds. *///from w w w. j ava 2s .c o m private void removeValueCompounds() { // Pre-condition assert listViewer != null; assert valueCompounds != null; // Retrieves the current selection and skip if it is empty. IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection(); if (selection.isEmpty() == true) { return; } // Removes selected items from the value compounds. valueCompounds.removeAll(selection.toList()); fireEditorChanged(); // Commits changes. commit(); listViewer.refresh(); }
From source file:edu.illinois.compositerefactorings.steps.CreateNewSuperclassCommandHandler.java
License:Open Source License
private static List<IType> getSelectedTypes(IStructuredSelection selection) throws JavaModelException, InvalidSelectionException { List<IType> selectedTypes = new ArrayList<IType>(); for (Object selectionElement : selection.toList()) { selectedTypes.add(extractTypeFromSelection(selectionElement)); }// w w w. ja va2 s.c o m return selectedTypes; }
From source file:edu.kit.joana.ui.ifc.sdg.gui.views.DoubleListDialog.java
License:Open Source License
protected void okPressed() { // Build a list of selected children. IStructuredSelection selection1 = (IStructuredSelection) fTableViewer1.getSelection(); IStructuredSelection selection2 = (IStructuredSelection) fTableViewer2.getSelection(); @SuppressWarnings("rawtypes") ArrayList<List> results = new ArrayList<List>(); results.add(selection1.toList()); results.add(selection2.toList());/* w w w. j av a 2s.co m*/ setResult(results); super.okPressed(); }
From source file:edu.washington.cs.cupid.scripting.java.wizards.JavaCapabilityWizardPage.java
License:Open Source License
/** * Construct a wizard page for configuring a new Java capability script. * @param selection currently does nothing *///from ww w . j a va 2 s .com public JavaCapabilityWizardPage(final ISelection selection) { super("wizardPage"); setTitle("New Cupid Capability"); setDescription("Create a new Java Cupid Capability"); if (selection == null || selection.isEmpty()) { // NO OP } else if (selection instanceof IStructuredSelection) { IStructuredSelection values = (IStructuredSelection) selection; if (values.size() == 1) { this.startType = values.getFirstElement().getClass(); } else { List<Class<?>> classes = Lists.newArrayList(); for (Object value : values.toList()) { classes.add(value.getClass()); } List<Class<?>> common = TypeManager.commonSuperClass(classes.toArray(new Class[] {})); this.startType = common.isEmpty() ? null : common.get(0); } } }
From source file:edu.washington.cs.cupid.wizards.popup.actions.CreatePipelineContextAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)/*from w ww .j a va2s . co m*/ */ public void run(IAction action) { CreatePipelineWizard wizard = null; if (selection.isEmpty()) { wizard = new CreatePipelineWizard(); } else if (selection instanceof IStructuredSelection) { IStructuredSelection values = (IStructuredSelection) selection; if (values.size() == 1) { wizard = new CreatePipelineWizard(TypeToken.of(values.getFirstElement().getClass()), values.toArray()); } else { List<Class<?>> classes = Lists.newArrayList(); for (Object value : values.toList()) { classes.add(value.getClass()); } List<Class<?>> common = TypeManager.commonSuperClass(classes.toArray(new Class[] {})); if (common.isEmpty()) { wizard = new CreatePipelineWizard(); } else { wizard = new CreatePipelineWizard(TypeToken.of(common.get(0)), values.toArray()); } } } WizardDialog dialog = new WizardDialog(shell, wizard); dialog.create(); dialog.open(); }
From source file:edu.washington.cs.cupid.wizards.popup.actions.NewExtractCapabilityAction.java
License:Open Source License
/** * @see IActionDelegate#run(IAction)/* w w w . j a v a2s .c om*/ */ public void run(IAction action) { ExtractFieldWizard wizard = null; if (selection.isEmpty()) { wizard = new ExtractFieldWizard(); } else if (selection instanceof IStructuredSelection) { IStructuredSelection values = (IStructuredSelection) selection; if (values.size() == 1) { wizard = new ExtractFieldWizard(values.getFirstElement().getClass()); } else { List<Class<?>> classes = Lists.newArrayList(); for (Object value : values.toList()) { classes.add(value.getClass()); } List<Class<?>> common = TypeManager.commonSuperClass(classes.toArray(new Class[] {})); if (common.isEmpty()) { wizard = new ExtractFieldWizard(); } else { wizard = new ExtractFieldWizard(common.get(0)); } } } WizardDialog dialog = new WizardDialog(shell, wizard); dialog.create(); dialog.open(); }
From source file:edu.ycp.cs.marmoset.uploader.handlers.SubmitProjectHandler.java
License:Apache License
private List<IProject> getSelectedProjects(IStructuredSelection selection) { List<IProject> selectedProjects = new ArrayList<IProject>(); List<?> selectedItems = selection.toList(); for (Object selectedItem : selectedItems) { if (selectedItem instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) selectedItem; IProject project = (IProject) adaptable.getAdapter(IProject.class); if (project != null) { selectedProjects.add(project); }//from w ww.ja v a2s. c o m } } return selectedProjects; }
From source file:es.cv.gvcase.emf.ui.common.dialogs.ChooseDialog.java
License:Open Source License
protected void changeItemHandle(SelectionChangedEvent event) { if (event.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.isEmpty()) { getOkButton().setEnabled(false); return; }//from ww w.j a v a2s. com for (Object o : selection.toList()) { if (!((checkSelectionValid(o)) || (o instanceof EObjectChooserComposite.NullObject))) { getOkButton().setEnabled(false); return; } } getOkButton().setEnabled(true); if (selection instanceof TreeSelection) { TreeSelection ts = (TreeSelection) selection; modifySelectionPath(ts); } return; } getOkButton().setEnabled(false); return; }
From source file:es.cv.gvcase.emf.ui.common.dialogs.ChooseDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#okPressed() *//* ww w . jav a 2s . c o m*/ protected void okPressed() { IStructuredSelection selection = (IStructuredSelection) tree.getTreeViewer().getSelection(); List<Object> filteredSelection = new ArrayList<Object>(); for (Object o : selection.toList()) { filteredSelection.add(o); } setResult(filteredSelection); super.okPressed(); }
From source file:es.cv.gvcase.fefem.common.widgets.ChooseDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#okPressed() *//*from w w w. j a v a2 s.c o m*/ protected void okPressed() { IStructuredSelection selection = (IStructuredSelection) tree.getTreeViewer().getSelection(); setResult(selection.toList()); super.okPressed(); }