org.eclipse.jface.viewers.ISelection Java Examples
The following examples show how to use
org.eclipse.jface.viewers.ISelection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GhidraProjectUtils.java From ghidra with Apache License 2.0 | 6 votes |
/** * Gets the selected project, or null if a project is not selected. If multiple things * are selected, only the first selected item is considered. * * @param selection A selection from which to get a project. * @return The selected project, or null if a project is not selected. */ public static IProject getSelectedProject(ISelection selection) { IProject project = null; if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object firstElement = structuredSelection.getFirstElement(); if (firstElement instanceof IResource) { project = ((IResource) (firstElement)).getProject(); } else if (firstElement instanceof IJavaElement) { project = ((IJavaElement) (firstElement)).getResource().getProject(); } } return project; }
Example #2
Source File: ApiCompareView.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void makeActions() { actionUpdate = new Action() { @Override public void run() { updateComparison(); } }; actionUpdate.setText("Update"); actionUpdate.setToolTipText( "Recompute comparison for all API project and their implementation projects in the workspace."); // action2.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages(). // getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK)); actionOpenInEditor = new Action() { @Override public void run() { ISelection selection = viewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); if (obj instanceof ProjectComparisonEntry) showInEditor((ProjectComparisonEntry) obj, true, true); } }; actionOpenInEditor.setText("Open in Editor"); actionOpenInEditor.setToolTipText( "Open the currently selected API element and its implementations in N4JS editors."); }
Example #3
Source File: RemoveAction.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private void setSelection ( final ISelection selection ) { this.entries = new LinkedList<ListEntry> (); if ( selection instanceof IStructuredSelection ) { final Iterator<?> i = ( (IStructuredSelection)selection ).iterator (); while ( i.hasNext () ) { final Object o = i.next (); if ( o instanceof ListEntry ) { this.entries.add ( (ListEntry)o ); } } } }
Example #4
Source File: CrossflowDiagramEditor.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ private ISelection getNavigatorSelection() { IDiagramDocument document = getDiagramDocument(); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { CrossflowNavigatorItem item = new CrossflowNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
Example #5
Source File: CrossflowDiagramUpdateCommand.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.size() != 1) { return null; } if (structuredSelection.getFirstElement() instanceof EditPart && ((EditPart) structuredSelection.getFirstElement()).getModel() instanceof View) { EObject modelElement = ((View) ((EditPart) structuredSelection.getFirstElement()).getModel()) .getElement(); List editPolicies = CanonicalEditPolicy.getRegisteredEditPolicies(modelElement); for (Iterator it = editPolicies.iterator(); it.hasNext();) { CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it.next(); nextEditPolicy.refresh(); } } } return null; }
Example #6
Source File: SuperListener.java From lapse-plus with GNU General Public License v3.0 | 6 votes |
public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (part != this.view.fEditor && part instanceof ITextEditor && (LapseView.getJavaInput((ITextEditor) part) != null)) { try { if(LapseView.TRACE) { System.out.println("In selectionChanged: setting the input"); } this.view.setInput((ITextEditor) part); if(this.view.fEditor == null) { throw new RuntimeException("Couldn't set the editor properly"); } } catch (CoreException e) { JavaPlugin.logErrorMessage("Caught exception: " + e.toString()); return; } } }
Example #7
Source File: CheckstylePropertyPage.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void selectionChanged(SelectionChangedEvent event) { Object source = event.getSource(); if (source == mFilterList) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { Object selectedElement = ((IStructuredSelection) selection).getFirstElement(); if (selectedElement instanceof IFilter) { IFilter filterDef = (IFilter) selectedElement; mTxtFilterDescription.setText(filterDef.getDescription()); // activate edit button mBtnEditFilter.setEnabled(PluginFilterEditors.hasEditor(filterDef)); } } } }
Example #8
Source File: AbstractChartManagePart.java From neoscada with Eclipse Public License 1.0 | 6 votes |
protected void handleSelectionChanged ( final ISelection sel ) { if ( sel == null || sel.isEmpty () ) { return; } if ( ! ( sel instanceof IStructuredSelection ) ) { return; } final Object o = ( (IStructuredSelection)sel ).getFirstElement (); if ( ! ( o instanceof ChartViewer ) ) { return; } setChartViewer ( (ChartViewer)o ); }
Example #9
Source File: AbstractQueryViewPart.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected synchronized void setSelection ( final ISelection selection ) { final QueryBean query = getQueryFromSelection ( selection ); if ( query != this.query && query != null && isSupported ( query ) ) { clear (); if ( query != null ) { setQuery ( query ); } } }
Example #10
Source File: AbstractEntryViewPart.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected void addSelectionListener () { if ( this.selectionListener == null ) { getViewSite ().getWorkbenchWindow ().getSelectionService ().addSelectionListener ( this.selectionListener = new ISelectionListener () { @Override public void selectionChanged ( final IWorkbenchPart part, final ISelection selection ) { AbstractEntryViewPart.this.setSelection ( selection ); } } ); } }
Example #11
Source File: GenerateXpectReportShortcut.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override public void launch(ISelection selection, String mode) { Object selectObj = ((IStructuredSelection) selection).getFirstElement(); if (selectObj instanceof IFile) { generateBug((IFile) selectObj); } else { showDialogNotImplemented(selection.getClass().getName()); } }
Example #12
Source File: ChartActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, and returns the collection of these actions. <!-- begin-user-doc --> <!-- * end-user-doc --> * * @generated */ protected Collection<IAction> generateCreateChildActions ( final Collection<?> descriptors, final ISelection selection ) { final Collection<IAction> actions = new ArrayList<IAction> (); if ( descriptors != null ) { for ( final Object descriptor : descriptors ) { actions.add ( new CreateChildAction ( this.activeEditorPart, selection, descriptor ) ); } } return actions; }
Example #13
Source File: CheckSelectedFilesAction.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} */ @Override public void selectionChanged(IAction action, ISelection selection) { if (selection instanceof IStructuredSelection) { mSelection = (IStructuredSelection) selection; } }
Example #14
Source File: RecipeEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setStatusLineManager ( ISelection selection ) { IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager : getActionBars ().getStatusLineManager (); if ( statusLineManager != null ) { if ( selection instanceof IStructuredSelection ) { Collection<?> collection = ( (IStructuredSelection)selection ).toList (); switch ( collection.size () ) { case 0: { statusLineManager.setMessage ( getString ( "_UI_NoObjectSelected" ) ); //$NON-NLS-1$ break; } case 1: { String text = new AdapterFactoryItemDelegator ( adapterFactory ).getText ( collection.iterator ().next () ); statusLineManager.setMessage ( getString ( "_UI_SingleObjectSelected", text ) ); //$NON-NLS-1$ break; } default: { statusLineManager.setMessage ( getString ( "_UI_MultiObjectSelected", Integer.toString ( collection.size () ) ) ); //$NON-NLS-1$ break; } } } else { statusLineManager.setMessage ( "" ); //$NON-NLS-1$ } } }
Example #15
Source File: AddDotnetBuilder.java From aCute with Eclipse Public License 2.0 | 5 votes |
public static IProject getProject(final ExecutionEvent event) { final ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { final Object element = ((IStructuredSelection) selection).getFirstElement(); return Platform.getAdapterManager().getAdapter(element, IProject.class); } return null; }
Example #16
Source File: ProtocolEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. * Calling this result will notify the listeners. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setSelection ( ISelection selection ) { editorSelection = selection; for ( ISelectionChangedListener listener : selectionChangedListeners ) { listener.selectionChanged ( new SelectionChangedEvent ( this, selection ) ); } setStatusLineManager ( selection ); }
Example #17
Source File: ComponentEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. * Calling this result will notify the listeners. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void setSelection ( ISelection selection ) { editorSelection = selection; for ( ISelectionChangedListener listener : selectionChangedListeners ) { listener.selectionChanged ( new SelectionChangedEvent ( this, selection ) ); } setStatusLineManager ( selection ); }
Example #18
Source File: ProtocolActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<IAction> generateCreateChildActions ( Collection<?> descriptors, ISelection selection ) { Collection<IAction> actions = new ArrayList<IAction> (); if ( descriptors != null ) { for ( Object descriptor : descriptors ) { actions.add ( new CreateChildAction ( activeEditorPart, selection, descriptor ) ); } } return actions; }
Example #19
Source File: ProtocolActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in <code>descriptors</code>, * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<IAction> generateCreateSiblingActions ( Collection<?> descriptors, ISelection selection ) { Collection<IAction> actions = new ArrayList<IAction> (); if ( descriptors != null ) { for ( Object descriptor : descriptors ) { actions.add ( new CreateSiblingAction ( activeEditorPart, selection, descriptor ) ); } } return actions; }
Example #20
Source File: LinkGhidraCommand.java From ghidra with Apache License 2.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); ISelection selection = window.getSelectionService().getSelection(); WizardDialog dialog = new WizardDialog(window.getShell(), new LinkGhidraWizard(selection)); dialog.open(); return null; }
Example #21
Source File: WorldEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setStatusLineManager ( ISelection selection ) { IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager : getActionBars ().getStatusLineManager (); if ( statusLineManager != null ) { if ( selection instanceof IStructuredSelection ) { Collection<?> collection = ( (IStructuredSelection)selection ).toList (); switch ( collection.size () ) { case 0: { statusLineManager.setMessage ( getString ( "_UI_NoObjectSelected" ) ); //$NON-NLS-1$ break; } case 1: { String text = new AdapterFactoryItemDelegator ( adapterFactory ).getText ( collection.iterator ().next () ); statusLineManager.setMessage ( getString ( "_UI_SingleObjectSelected", text ) ); //$NON-NLS-1$ break; } default: { statusLineManager.setMessage ( getString ( "_UI_MultiObjectSelected", Integer.toString ( collection.size () ) ) ); //$NON-NLS-1$ break; } } } else { statusLineManager.setMessage ( "" ); //$NON-NLS-1$ } } }
Example #22
Source File: AcceleoGenerateGeneratorAction.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} * * @see org.eclipse.ui.actions.ActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, * org.eclipse.jface.viewers.ISelection) * @generated */ @Override @SuppressWarnings ( "unchecked" ) public void selectionChanged ( final IAction action, final ISelection selection ) { if ( selection instanceof IStructuredSelection ) { this.files = ( (IStructuredSelection)selection ).toList (); } }
Example #23
Source File: SetupActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<IAction> generateCreateChildActions ( Collection<?> descriptors, ISelection selection ) { Collection<IAction> actions = new ArrayList<IAction> (); if ( descriptors != null ) { for ( Object descriptor : descriptors ) { actions.add ( new CreateChildAction ( activeEditorPart, selection, descriptor ) ); } } return actions; }
Example #24
Source File: InfrastructureActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<IAction> generateCreateChildActions ( Collection<?> descriptors, ISelection selection ) { Collection<IAction> actions = new ArrayList<IAction> (); if ( descriptors != null ) { for ( Object descriptor : descriptors ) { actions.add ( new CreateChildAction ( activeEditorPart, selection, descriptor ) ); } } return actions; }
Example #25
Source File: AbstractItemAction.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged ( final IAction action, final ISelection selection ) { clearSelection (); this.items.addAll ( ItemSelectionHelper.getSelection ( selection ) ); }
Example #26
Source File: MemoryEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setStatusLineManager ( ISelection selection ) { IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? contentOutlineStatusLineManager : getActionBars ().getStatusLineManager (); if ( statusLineManager != null ) { if ( selection instanceof IStructuredSelection ) { Collection<?> collection = ( (IStructuredSelection)selection ).toList (); switch ( collection.size () ) { case 0: { statusLineManager.setMessage ( getString ( "_UI_NoObjectSelected" ) ); break; } case 1: { String text = new AdapterFactoryItemDelegator ( adapterFactory ).getText ( collection.iterator ().next () ); statusLineManager.setMessage ( getString ( "_UI_SingleObjectSelected", text ) ); break; } default: { statusLineManager.setMessage ( getString ( "_UI_MultiObjectSelected", Integer.toString ( collection.size () ) ) ); break; } } } else { statusLineManager.setMessage ( "" ); } } }
Example #27
Source File: ComponentEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This deals with how we want selection in the outliner to affect the other views. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void handleContentOutlineSelection ( ISelection selection ) { if ( currentViewerPane != null && !selection.isEmpty () && selection instanceof IStructuredSelection ) { Iterator<?> selectedElements = ( (IStructuredSelection)selection ).iterator (); if ( selectedElements.hasNext () ) { // Get the first selected element. // Object selectedElement = selectedElements.next (); // If it's the selection viewer, then we want it to select the same selection as this selection. // if ( currentViewerPane.getViewer () == selectionViewer ) { ArrayList<Object> selectionList = new ArrayList<Object> (); selectionList.add ( selectedElement ); while ( selectedElements.hasNext () ) { selectionList.add ( selectedElements.next () ); } // Set the selection to the widget. // selectionViewer.setSelection ( new StructuredSelection ( selectionList ) ); } else { // Set the input to the widget. // if ( currentViewerPane.getViewer ().getInput () != selectedElement ) { currentViewerPane.getViewer ().setInput ( selectedElement ); currentViewerPane.setTitle ( selectedElement ); } } } } }
Example #28
Source File: RecipeEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. * Calling this result will notify the listeners. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setSelection ( ISelection selection ) { editorSelection = selection; for ( ISelectionChangedListener listener : selectionChangedListeners ) { listener.selectionChanged ( new SelectionChangedEvent ( this, selection ) ); } setStatusLineManager ( selection ); }
Example #29
Source File: RecipeActionBarContributor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in <code>descriptors</code>, * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected Collection<IAction> generateCreateChildActions ( Collection<?> descriptors, ISelection selection ) { Collection<IAction> actions = new ArrayList<IAction> (); if ( descriptors != null ) { for ( Object descriptor : descriptors ) { actions.add ( new CreateChildAction ( activeEditorPart, selection, descriptor ) ); } } return actions; }
Example #30
Source File: ProtocolEditor.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * This deals with how we want selection in the outliner to affect the other views. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void handleContentOutlineSelection ( ISelection selection ) { if ( currentViewerPane != null && !selection.isEmpty () && selection instanceof IStructuredSelection ) { Iterator<?> selectedElements = ( (IStructuredSelection)selection ).iterator (); if ( selectedElements.hasNext () ) { // Get the first selected element. // Object selectedElement = selectedElements.next (); // If it's the selection viewer, then we want it to select the same selection as this selection. // if ( currentViewerPane.getViewer () == selectionViewer ) { ArrayList<Object> selectionList = new ArrayList<Object> (); selectionList.add ( selectedElement ); while ( selectedElements.hasNext () ) { selectionList.add ( selectedElements.next () ); } // Set the selection to the widget. // selectionViewer.setSelection ( new StructuredSelection ( selectionList ) ); } else { // Set the input to the widget. // if ( currentViewerPane.getViewer ().getInput () != selectedElement ) { currentViewerPane.getViewer ().setInput ( selectedElement ); currentViewerPane.setTitle ( selectedElement ); } } } } }