List of usage examples for org.eclipse.jface.viewers IStructuredSelection toList
public List toList();
List
. From source file:com.mentor.nucleus.bp.ui.graphics.editor.ModelEditor.java
License:Open Source License
@Override public NonRootModelElement getFirstSelectedElement() { if (getGraphicalEditor() == null) { return null; }/* w ww .j av a 2 s . c o m*/ IStructuredSelection selection = (IStructuredSelection) getGraphicalEditor().getEditorSite() .getSelectionProvider().getSelection(); for (Object selected : selection.toList()) { if (selected instanceof ShapeEditPart) { NonRootModelElement nrme = (NonRootModelElement) ((ShapeEditPart) selected).getGraphicalElement() .getRepresents(); return nrme; } } return null; }
From source file:com.mentor.nucleus.bp.ui.graphics.selection.GraphicalSelectionManager.java
License:Open Source License
private boolean selectionContainsNonEditParts(ISelection newSelection) { IStructuredSelection ss = (IStructuredSelection) newSelection; for (Object object : ss.toList()) { EditPart part = findEditPartFor(object); if (part == null && object instanceof NonRootModelElement) return true; }/* ww w. j a va 2s.co m*/ return false; }
From source file:com.mg.merp.wb.report.deployer.support.MenuController.java
License:Open Source License
@SuppressWarnings("unchecked") public void selectionChanged(IAction action, ISelection selection) { if (!selection.isEmpty() && RptTool.getRptView().getViewController().isSynchronized()) { IStructuredSelection structured = (IStructuredSelection) selection; if (action.getId().equals(MENU_ID_DEL)) { templToDel = structured.toList(); action.setEnabled(isAllSynchronized(templToDel)); } else {// w w w . java2 s.co m template = (IFile) structured.getFirstElement(); RptMainTransfer rmt = RptTool.getReportFromRepository(RptTool.getCode(template)); isDeployEnabled = rmt != null; if (action.getId().equals(MENU_ID_DEPLOY) || action.getId().equals(MENU_ID_EDIT)) action.setEnabled(isDeployEnabled); if (action.getId().equals(MENU_ID_ADD)) action.setEnabled(!isDeployEnabled); } } else action.setEnabled(false); }
From source file:com.microsoft.tfs.client.common.ui.controls.vc.ServerItemTreeControl.java
License:Open Source License
public ServerItemTreeControl(final Composite parent, final int style) { super(parent, style); final FillLayout layout = new FillLayout(); setLayout(layout);/*from w w w . j a va2 s . co m*/ viewer = new TreeViewer(this, TREE_STYLES | (style & OPTIONAL_TREE_STYLES)); AutomationIDHelper.setWidgetID(viewer.getTree(), TREE_VIEWER_ID); viewer.setUseHashlookup(true); viewer.setContentProvider(new ContentProvider()); viewer.setLabelProvider(new ServerItemLabelProvider()); viewer.addFilter(new Filter()); viewer.setSorter(new ViewerSorter() { @Override public int compare(final Viewer viewer, final Object e1, final Object e2) { final TypedServerItem node1 = (TypedServerItem) e1; final TypedServerItem node2 = (TypedServerItem) e2; return node1.getName().compareToIgnoreCase(node2.getName()); } }); contextMenu = createContextMenu(); createActions(); contributeActions(); viewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { final IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() == 0) { selectedItems = null; } else { @SuppressWarnings("unchecked") final List<TypedServerItem> l = selection.toList(); selectedItems = l.toArray(new TypedServerItem[l.size()]); } } }); viewer.addDoubleClickListener(new IDoubleClickListener() { @Override public void doubleClick(final DoubleClickEvent event) { final TypedServerItem doubleClickedElement = (TypedServerItem) ((IStructuredSelection) event .getSelection()).getFirstElement(); if (ServerItemType.isFolder(doubleClickedElement.getType())) { final boolean expandedState = viewer.getExpandedState(doubleClickedElement); viewer.setExpandedState(doubleClickedElement, !expandedState); } } }); }
From source file:com.microsoft.tfs.client.common.ui.framework.diagnostics.ui.DataProviderOutputControl.java
License:Open Source License
private void copyToClipboard() { final IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); final List rows = selection.toList(); final TabularData viewTable = (TabularData) tableViewer.getInput(); final TabularData selectionTable = new TabularData(viewTable, (Row[]) rows.toArray(new Row[rows.size()])); selectionTable.setSorted(true);/*from ww w . j a v a 2s .c o m*/ final String value = (String) Adapters.get(selectionTable, String.class); UIHelpers.copyToClipboard(value); }
From source file:com.minres.scviewer.e4.application.handlers.AddWaveformHandler.java
License:Open Source License
@Execute public void execute(@Named(PARAM_WHERE_ID) String where, @Named(PARAM_ALL_ID) String all, EPartService partService,//from w ww. j ava 2 s. c o m @Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection) { if (designBrowser == null) designBrowser = getListPart(partService); if (designBrowser != null && selection.size() > 0) { List<?> sel = selection.toList(); designBrowser.getActiveWaveformViewerPart().addStreamsToList(sel.toArray(new IWaveform<?>[] {}), "before".equalsIgnoreCase(where)); } }
From source file:com.minres.scviewer.e4.application.parts.DesignBrowser.java
License:Open Source License
/** * Sets the focus./*from w w w . j a v a2 s. c om*/ */ @Focus public void setFocus() { txTableViewer.getTable().setFocus(); IStructuredSelection selection = (IStructuredSelection) txTableViewer.getSelection(); if (selection.size() == 0) { appendItem.setEnabled(false); } selectionService.setSelection(selection); thisSelectionCount = selection.toList().size(); updateButtons(); }
From source file:com.misc.common.moplaf.emf.editor.action.CommandAction.java
License:Open Source License
/** * This invokes createActionCommand to create the command */// w w w. j av a 2s. c om private void makeCommand() { this.command = null; // make the command and setEnabled the action // only handle structured selections if (!(selection instanceof IStructuredSelection)) { disable(); } else { // convert the selection to a collection of the selected objects IStructuredSelection sselection = (IStructuredSelection) selection; List<?> list = sselection.toList(); Collection<Object> collection = new ArrayList<Object>(list); // if the editing domain wasn't given by the workbench part, try to get // it from the selection if (editingDomain == null) { for (Object o : collection) { editingDomain = AdapterFactoryEditingDomain.getEditingDomainFor(o); if (editingDomain != null) { break; } } } // if we found an editing domain, create command if (editingDomain != null) { command = createActionCommand(editingDomain, collection); setEnabled(command.canExecute()); } // give up if we couldn't create the command; otherwise, use a // CommandActionDelegate to set the action's text, tool-tip, icon, // etc. or just use the default icon if (command == null || command == UnexecutableCommand.INSTANCE) { disable(); } } }
From source file:com.mobilesorcery.sdk.ui.internal.actions.ChangeBuildConfigContextAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection selection) { IStructuredSelection ssel = (IStructuredSelection) selection; project = CoreMoSyncPlugin.getDefault().extractProject(ssel.toList()); action.setMenuCreator(this); }
From source file:com.mobilesorcery.sdk.ui.internal.actions.ManageBuildConfigsAction.java
License:Open Source License
public void selectionChanged(IAction action, ISelection selection) { IStructuredSelection ssel = (IStructuredSelection) selection; project = CoreMoSyncPlugin.getDefault().extractProject(ssel.toList()); }