List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.aptana.ruby.internal.debug.ui.breakpoints.BreakpointDetailPaneFactory.java
License:Open Source License
public String getDefaultDetailPane(IStructuredSelection selection) { if (selection.size() == 1) { IBreakpoint b = (IBreakpoint) selection.getFirstElement(); try {//ww w .j av a 2 s.c om String type = b.getMarker().getType(); if (RubyLineBreakpoint.RUBY_LINE_BREAKPOINT.equals(type)) { return LineBreakpointDetailPane.DETAIL_PANE_LINE_BREAKPOINT; } return StandardBreakpointDetailPane.DETAIL_PANE_STANDARD; } catch (CoreException e) { } } return null; }
From source file:com.aptana.ui.io.compare.FileStoreCompareEditorInput.java
License:Open Source License
@Override public Viewer createDiffViewer(Composite parent) { fDiffViewer = new DiffTreeViewer(parent, getCompareConfiguration()) { @Override// w ww .j a va 2 s .c o m protected void fillContextMenu(IMenuManager manager) { if (fOpenAction == null) { fOpenAction = new Action() { public void run() { handleOpen(null); } }; Utilities.initAction(fOpenAction, getBundle(), "action.CompareContents."); //$NON-NLS-1$ } boolean enable = false; ISelection selection = getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() == 1) { Object element = ss.getFirstElement(); if (element instanceof MyDiffNode) { ITypedElement typedElement = ((MyDiffNode) element).getId(); if (typedElement != null) { enable = !ITypedElement.FOLDER_TYPE.equals(typedElement.getType()); } } else { enable = true; } } } fOpenAction.setEnabled(enable); manager.add(fOpenAction); super.fillContextMenu(manager); } }; return fDiffViewer; }
From source file:com.aptana.ui.widgets.CListTable.java
License:Open Source License
private void updateStates() { IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); boolean hasSelection = !selection.isEmpty(); boolean hasMultiSelections = selection.size() > 1; editButton.setEnabled(hasSelection && !hasMultiSelections); removeButton.setEnabled(hasSelection); addButton.setEnabled(true);//from www.j a va 2 s. c o m }
From source file:com.arc.cdt.debug.seecode.internal.ui.action.AbstractDebugActionDelegate.java
License:Open Source License
/** * Return whether the action should be enabled or not based on the given selection. *//*from ww w. ja v a2 s.c o m*/ @SuppressWarnings("unchecked") protected boolean getEnableStateForSelection(IStructuredSelection selection) { if (selection.size() == 0) { return false; } Iterator<Object> itr = selection.iterator(); while (itr.hasNext()) { Object element = itr.next(); if (!isEnabledFor(element)) { return false; } } return true; }
From source file:com.archimatetool.editor.views.tree.actions.RenameAction.java
License:Open Source License
@Override public void update(IStructuredSelection selection) { setEnabled(selection.size() == 1 && RenameCommandHandler.canRename(selection.getFirstElement())); }
From source file:com.architexa.org.eclipse.gef.ui.actions.CopyTemplateAction.java
License:Open Source License
/** * Sets the selected EditPart and refreshes the enabled state of this action. * /*from www. j a v a 2s . c om*/ * @see ISelectionChangedListener#selectionChanged(SelectionChangedEvent) */ public void selectionChanged(SelectionChangedEvent event) { ISelection s = event.getSelection(); if (!(s instanceof IStructuredSelection)) return; IStructuredSelection selection = (IStructuredSelection) s; template = null; if (selection != null && selection.size() == 1) { Object obj = selection.getFirstElement(); if (obj instanceof EditPart) { Object model = ((EditPart) obj).getModel(); if (model instanceof CombinedTemplateCreationEntry) template = ((CombinedTemplateCreationEntry) model).getTemplate(); else if (model instanceof PaletteTemplateEntry) template = ((PaletteTemplateEntry) model).getTemplate(); } } refresh(); }
From source file:com.arm.cmsis.pack.project.wizards.CmsisCodeTemplateNewWizardPage.java
License:Open Source License
/** * Tests if the current workbench selection is a suitable container to use. *//*from ww w. j a v a 2s . c om*/ private void initialize() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) { return; } Object obj = ssel.getFirstElement(); IContainer container = null; if (obj instanceof IResource) { if (obj instanceof IContainer) { container = (IContainer) obj; } else { container = ((IResource) obj).getParent(); } } else if (obj instanceof IAdaptable) { IAdaptable adaptable = (IAdaptable) obj; IResource res = (IResource) adaptable.getAdapter(IResource.class); if (res == null) { return; } if (res instanceof IContainer) { container = (IContainer) res; } else { container = res.getParent(); } } if (container != null) { projectText.setText(container.getProject().getName()); projectText.setEditable(false); projectBrowse.setEnabled(false); containerText.setText(container.getFullPath().toString()); } } if (getProjectName().isEmpty()) { containerText.setEditable(false); containerBrowse.setEnabled(false); fileText.setEditable(false); } }
From source file:com.arm.cmsis.pack.project.wizards.CmsisCodeTemplateNewWizardPage.java
License:Open Source License
private IRteProject getRteProject() { if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; if (ssel.size() > 1) { return null; }// ww w .j av a2 s.c om Object obj = ssel.getFirstElement(); IResource res = ProjectUtils.getResource(obj); if (res != null) { return CpProjectPlugIn.getRteProjectManager().getRteProject(res.getProject()); } } return null; }
From source file:com.arm.cmsis.pack.ui.widgets.RteDeviceSelectorWidget.java
License:Open Source License
/** * Returns IRteDeviceItem currently selected in the tree *//*from www . j av a 2 s . c om*/ private IRteDeviceItem getSelectedItem() { IStructuredSelection sel = (IStructuredSelection) treeViewer.getSelection(); if (sel.size() == 1) { Object o = sel.getFirstElement(); if (o instanceof IRteDeviceItem) { return (IRteDeviceItem) o; } } return null; }
From source file:com.arm.cmsis.pack.ui.widgets.RteValidateWidget.java
License:Open Source License
private IRteDependencyItem getSelectedDependencyItem() { IStructuredSelection sel = (IStructuredSelection) fViewer.getSelection(); if (sel.size() == 1) { Object o = sel.getFirstElement(); if (o instanceof IRteDependencyItem) { return (IRteDependencyItem) o; }//from w ww .j av a2s. c om } return null; }