List of usage examples for org.eclipse.jface.viewers IStructuredSelection size
public int size();
From source file:com.ibm.etools.mft.conversion.esb.extension.render.CompleteToDo.java
License:Open Source License
@Override public void selectionChanged(IAction action, ISelection selection) { IStructuredSelection s = (IStructuredSelection) selection; if (!s.isEmpty() && s.size() == 1 && (s.getFirstElement() instanceof TodoEntry)) { selected = (TodoEntry) s.getFirstElement(); action.setEnabled(!selected.isCompleted()); } else {/*from w ww. j a v a 2s . co m*/ action.setEnabled(false); } }
From source file:com.ibm.etools.mft.conversion.esb.extension.render.ReopenToDo.java
License:Open Source License
@Override public void selectionChanged(IAction action, ISelection selection) { IStructuredSelection s = (IStructuredSelection) selection; if (!s.isEmpty() && s.size() == 1 && (s.getFirstElement() instanceof TodoEntry)) { selected = (TodoEntry) s.getFirstElement(); action.setEnabled(selected.isCompleted()); } else {//from ww w.ja v a 2 s . com action.setEnabled(false); } }
From source file:com.ibm.research.tagging.core.ui.tags.TagTableSelectionChangedListener.java
License:Open Source License
public void selectionChanged(SelectionChangedEvent event) { // Get the selection IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (TagUIPlugin.getDefault().getTagView().isLinkedWithWaypointView()) { List<ITag> tagList = selection.toList(); // Convert to array ITag[] tags = new ITag[0]; tags = tagList.toArray(tags);//w w w.j av a 2s . c o m // Fire the selection event TagUIPlugin.getDefault().getTagUI().tagSelectionChanged(tags); } if (selection.size() == 1) { TagUIPlugin.getDefault().getTagView().getRenameTagAction().setEnabled(true); } else { TagUIPlugin.getDefault().getTagView().getRenameTagAction().setEnabled(false); } }
From source file:com.ibm.research.tagging.core.ui.tags.TagViewListener.java
License:Open Source License
public void renameTag(TagView view) { IStructuredSelection selection = (IStructuredSelection) view.getTagTableViewer().getSelection(); if (selection.size() == 1) { ITag tag = (ITag) selection.toArray()[0]; NoWhitespaceNameValidator validator = new NoWhitespaceNameValidator(); InputDialog dialog = new InputDialog(view.getTagTableViewer().getTable().getShell(), "Rename tag", "Enter the new name for the tag:", tag.getName(), validator); if (dialog.open() == InputDialog.OK) { String newName = dialog.getValue().trim(); TagCorePlugin.getDefault().getTagCore().getTagModel().renameTag(tag, newName); }/*from www .j a va2 s .co m*/ } }
From source file:com.ibm.research.tagging.core.ui.waypoints.WaypointView.java
License:Open Source License
private void createWaypointPropertiesSection(Composite parent) { fPropertiesSection = fFormToolkit.createSection(parent, Section.SHORT_TITLE_BAR | Section.TWISTIE); fPropertiesSection.setText("Properties"); fPropertiesSection.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); fPropertiesComposite = fFormToolkit.createComposite(fPropertiesSection); GridLayout propertiesLayout = new GridLayout(2, false); propertiesLayout.marginWidth = 0;/*from ww w . j ava 2 s .co m*/ propertiesLayout.marginHeight = 0; propertiesLayout.verticalSpacing = 0; propertiesLayout.marginTop = 0; propertiesLayout.marginBottom = 3; propertiesLayout.marginLeft = 0; propertiesLayout.marginRight = 0; propertiesLayout.horizontalSpacing = 0; fPropertiesComposite.setLayout(propertiesLayout); fPropertiesComposite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); fFormTextComposite = fFormToolkit.createComposite(fPropertiesComposite); fFormTextComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fFormTextComposite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); GridLayout textCompositeLayout = new GridLayout(); textCompositeLayout.marginWidth = 0; textCompositeLayout.marginTop = 0; textCompositeLayout.marginBottom = 0; fFormTextComposite.setLayout(textCompositeLayout); fEditPropertiesButton = fFormToolkit.createButton(fPropertiesComposite, "Edit...", SWT.PUSH); fEditPropertiesButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); fEditPropertiesButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) fWaypointViewer.getSelection(); if (selection != null && selection.size() == 1) { final IWaypoint waypoint = (IWaypoint) selection.getFirstElement(); if (TagUIPlugin.getDefault().getTagUI().editProperties(waypoint)) { setSelectedWaypoint(waypoint); Display.getDefault().asyncExec(new Runnable() { public void run() { fWaypointViewer.refresh(); } }); } } } }); fPropertiesSection.setClient(fPropertiesComposite); fPropertiesSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fPropertiesSection.setExpanded(true); clearSelectedWaypoint(); }
From source file:com.ibm.wala.ide.ui.ViewIFDSLocalAction.java
License:Open Source License
@SuppressWarnings("unchecked") protected P getProcedureForSelection() { // we assume the tree viewer's current selection is a P IStructuredSelection selection = viewer.getSelection(); if (selection.size() != 1) { throw new UnsupportedOperationException("did not expect selection of size " + selection.size()); }//from ww w . ja va 2 s .c o m P first = (P) selection.getFirstElement(); return first; }
From source file:com.ibm.wala.ide.ui.ViewIRAction.java
License:Open Source License
/** * @throws IllegalStateException if the viewer is not running *//*from w ww . ja v a 2 s. co m*/ protected IR getIRForSelection() { // we assume the tree viewer's current selection is a CGNode IStructuredSelection selection = viewer.getSelection(); if (selection.size() != 1) { throw new UnsupportedOperationException("did not expect selection of size " + selection.size()); } CGNode first = (CGNode) selection.getFirstElement(); // get the IR for the node return first.getIR(); }
From source file:com.ibm.wala.ide.ui.ViewIRAction.java
License:Open Source License
protected CGNode getNodeForSelection() { // we assume the tree viewer's current selection is a CGNode IStructuredSelection selection = viewer.getSelection(); if (selection.size() != 1) { throw new UnsupportedOperationException("did not expect selection of size " + selection.size()); }/*from w w w . j av a2 s .com*/ CGNode first = (CGNode) selection.getFirstElement(); return first; }
From source file:com.inepex.classtemplater.plugin.popup.actions.Generator.java
License:Eclipse Public License
private void processSelection(IStructuredSelection selection) throws Exception { classModels.clear();/*from w w w . jav a2 s.co m*/ if (ICompilationUnit.class.isInstance(selection.getFirstElement())) { for (Object o : selection.toList()) { ICompilationUnit compunit = ((ICompilationUnit) o); classModels.add(new Class(compunit)); } if (selection.size() == 1) mode = "One class"; else mode = "Multiple class"; } else if (IField.class.isInstance(selection.getFirstElement())) { classModels.add(new Class(selection.toList())); mode = "Attribute list"; } else if (IMethod.class.isInstance(selection.getFirstElement())) { classModels.add(new Class(selection.toList(), true)); mode = "Method list"; } }
From source file:com.iw.plugins.spindle.actions.AbstractTapestryProjectAction.java
License:Mozilla Public License
/** * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) *///from ww w .ja v a 2s. c o m public void selectionChanged(IAction action, ISelection sel) { boolean enable = false; this.selection = null; IStructuredSelection selection = null; if (sel instanceof IStructuredSelection) { selection = (IStructuredSelection) sel; if (selection != null && !selection.isEmpty() && selection.size() == 1) { if (checkProjectIsOpenAndHasJavaNature(selection)) { enable = checkSelection(selection); } } } if (enable) { this.selection = selection; } action.setEnabled(enable); }