List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:de.opalproject.vespucci.ui.handlers.DeleteSliceHandler.java
License:Open Source License
@Override public Command getCommand(IStructuredSelection selection, final ExecutionEvent event) { @SuppressWarnings("unchecked") final List<Slice> sliceList = selection.toList(); Command deleteCommand = new RecordingCommand(getEditingDomain()) { private IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); @Override/*from w ww. j ava2 s . c o m*/ protected void doExecute() { for (final Slice slice : sliceList) { // Resolve diagram string to diagram object Diagram diagram = (Diagram) slice.eResource().getEObject(slice.getDiagram()); closeEditor(diagram); // Delete Slice and Diagram EcoreUtil.delete(slice, true); EcoreUtil.delete(diagram); } } private void closeEditor(Diagram diagram) { IWorkbenchPage page = window.getActivePage(); DiagramEditorInput editorInput = DiagramEditorInput.createEditorInput(diagram, SliceEditorDiagramTypeProvider.DIAGRAM_TYPE_PROVIDER_ID); IEditorPart openEditor = page.findEditor(editorInput); if (openEditor != null) { page.closeEditor(openEditor, false); } } }; return deleteCommand; }
From source file:de.ovgu.featureide.ui.views.collaboration.action.FilterAction.java
License:Open Source License
public void setEnabled(boolean enabled) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); super.setEnabled(false); for (Object part : selection.toList()) { if (part instanceof RoleEditPart) { classFilter.add(((RoleEditPart) part).getRoleModel().getName()); super.setEnabled(true); } else if (part instanceof ClassEditPart) { classFilter.add(((ClassEditPart) part).getClassModel().getName()); super.setEnabled(true); } else if (part instanceof CollaborationEditPart) { featureFilter.add(((CollaborationEditPart) part).getCollaborationModel().getName()); super.setEnabled(true); }//www. j av a2 s . c o m } if (checked) super.setEnabled(true); }
From source file:de.rowlo.diffeclipse.event.ButtonExtractMissingExtensionsHandler.java
License:Open Source License
protected void extractSelectedElements(IStructuredSelection selection) { final Text text = getTargetLocationText(); if (selection != null && text != null) { final String sourceLocation = DiffEclipseUtil.INSTANCE.getExtendedEclipseLocation(); final String targetLocation = text.getText(); final String dropStructure = File.separator + "additionalExtensions" + File.separator + "eclipse"; final List<?> selectedElements = selection.toList(); final int size = count(selectedElements); final ArrayList<Integer> counterResult = new ArrayList<Integer>(1); Shell shell = text.getShell();// w w w. j a va 2 s.c o m try { ProgressMonitorDialog progressMonitorDialog = new ProgressMonitorDialog(shell); progressMonitorDialog.run(true, true, new IRunnableWithProgress() { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { String taskMsg = MessageFormat.format("Extracting Missing Extensions to: {0}", targetLocation + dropStructure); monitor.beginTask(taskMsg, size); totalCounter = 0; processElements(selectedElements, monitor); counterResult.clear(); counterResult.add(totalCounter); monitor.done(); if (monitor.isCanceled()) { throw new InterruptedException("The long extraction was cancelled"); } } private void processElements(List<?> selectedElements, IProgressMonitor monitor) { if (selectedElements == null || monitor == null) { return; } for (Object selectedElement : selectedElements) { if (selectedElement instanceof TreeModel) { TreeModel treeModel = (TreeModel) selectedElement; String filePath = treeModel.getFilePath(); String sourceFilePath = sourceLocation + filePath; String targetFilePath = targetLocation + dropStructure + filePath; if (treeModel.isFile()) { copyFile(sourceFilePath, targetFilePath); } else { createDirectory(targetFilePath); ArrayList<Object> childElements = new ArrayList<Object>(treeModel.children); processElements(childElements, monitor); } totalCounter++; monitor.worked(1); String taskMsg = MessageFormat.format( "Extracting Missing Extensions to: {0} ({1}/{2})", targetLocation + dropStructure, totalCounter, size); monitor.setTaskName(taskMsg); } } } }); } catch (InvocationTargetException e) { MessageDialog.openError(shell, "Error", e.getMessage()); } catch (InterruptedException e) { MessageDialog.openInformation(shell, "Cancelled", e.getMessage()); } int counter = counterResult.size() > 0 ? counterResult.get(0) : 0; String msg = MessageFormat.format("Extracted {1} extensions to: {0}", targetLocation + dropStructure, counter); MessageDialog.openInformation(shell, "Extract Missing Extensions", msg); } }
From source file:de.tub.tfs.henshin.tggeditor.actions.GenericTGGGraphLayoutAction.java
License:Open Source License
/** * This action is enabled if some graphical edit part is currently selected * from which a viewer can be determined to be layout. */// w w w. jav a 2 s . c o m @Override protected boolean calculateEnabled() { viewer = null; if (getSelection() == null) { return false; } if (getSelection() instanceof IStructuredSelection) { final IStructuredSelection selection = (IStructuredSelection) getSelection(); for (final Object selectedObject : selection.toList()) { if (selectedObject instanceof GraphicalEditPart) { viewer = ((GraphicalEditPart) selectedObject).getViewer(); return viewer != null; } } } return false; }
From source file:de.tub.tfs.muvitor.actions.MuvitorToggleGridAction.java
License:Open Source License
/** * This action is enabled if some graphical edit part is currently selected * from which a viewer can be determined. *//*from w ww.jav a2 s . co m*/ @Override protected boolean calculateEnabled() { if (getSelection() == null) { return false; } if (getSelection() instanceof IStructuredSelection) { final IStructuredSelection selection = (IStructuredSelection) getSelection(); for (final Object selectedObject : selection.toList()) { if (selectedObject instanceof GraphicalEditPart) { final EditPartViewer selectedViewer = ((GraphicalEditPart) selectedObject).getViewer(); if (selectedViewer != null) { setViewer(selectedViewer); return true; } } } } return false; }
From source file:de.tub.tfs.muvitor.actions.TrimViewerAction.java
License:Open Source License
/** * This action is enabled if some graphical edit part is currently selected * from which a viewer can be determined to be trimmed. *///from ww w.j a va 2s. co m @Override protected boolean calculateEnabled() { if (getSelection() == null) { return false; } if (getSelection() instanceof IStructuredSelection) { final IStructuredSelection selection = (IStructuredSelection) getSelection(); for (final Object selectedObject : selection.toList()) { if (selectedObject instanceof GraphicalEditPart) { viewer = ((GraphicalEditPart) selectedObject).getViewer(); return viewer != null; } } } return false; }
From source file:de.tuilmenau.ics.fog.eclipse.ui.views.PacketView.java
License:Open Source License
/** * Called by the workbench if any other view/editor is reporting a selection. * // w w w . j av a 2 s . co m * @param sourcepart Part, which is announcing the selection * @param selection Selected element(s) */ public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) { if (sourcepart != this) { if (selection instanceof IStructuredSelection) { // is the selection not locked? if (!lockSelectedLogger.getSelection()) { PacketLogger newLogger = null; IStructuredSelection strSelection = (IStructuredSelection) selection; // search for first available logger for selected elements for (Object selectedElement : strSelection.toList()) { newLogger = PacketLogger.getLogger(selectedElement); if (newLogger != null) { currentSelectedLoggerKey.setText(selectedElement.toString()); break; } else { // TODO fully create packet logger hierarchy // currently it ends at node // should we get global logger? if (selectedElement instanceof Simulation) { newLogger = PacketLogger.getLogger(null); if (newLogger != null) { currentSelectedLoggerKey.setText(selectedElement.toString()); break; } } } } if (newLogger == null) { currentSelectedLoggerKey.setText(NO_SELECTED_LOGGER); } setLogger(newLogger); } } } // else: it is our stuff; ignore it }
From source file:de.uniluebeck.itm.spyglass.gui.databinding.StringFormatter.java
License:Open Source License
private void delEntryWidgetSelected(final SelectionEvent evt) { final IStructuredSelection selection = (IStructuredSelection) table.getSelection(); for (final Object o : selection.toList()) { tableData.remove(o);/*from w w w . j a va2 s. c om*/ } }
From source file:de.uniluebeck.itm.spyglass.plugin.nodesensorrange.NodeSensorRangePerNodeConfigurationComposite.java
License:Open Source License
private void clickedButtonDelEntry(final SelectionEvent evt) { final IStructuredSelection selection = (IStructuredSelection) table.getSelection(); for (final Object o : selection.toList()) { tableData.remove(o);//from w ww .j a va 2s .com } page.markFormDirty(); }
From source file:de.uniluebeck.itm.spyglass.plugin.simpleglobalinformation.SGIStringFormatter.java
License:Open Source License
/** * Deletes the statistical information evaluator which was selected in the table * //ww w . ja va 2s . co m * @param evt * a selection event (which is not used at all, since the table provides all * information itself) */ private void delEntryWidgetSelected(@SuppressWarnings("unused") final SelectionEvent evt) { final IStructuredSelection selection = (IStructuredSelection) table.getSelection(); for (final Object o : selection.toList()) { tableData.remove(o); } table.refresh(); }