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 Project: ghidra Author: NationalSecurityAgency File: GhidraProjectUtils.java License: 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 Project: lapse-plus Author: OWASP File: SuperListener.java License: 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 #3
Source Project: neoscada Author: eclipse File: AbstractChartManagePart.java License: 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 #4
Source Project: eclipse-cs Author: checkstyle File: CheckstylePropertyPage.java License: 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 #5
Source Project: scava Author: crossminer File: CrossflowDiagramEditor.java License: 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 #6
Source Project: n4js Author: eclipse File: ApiCompareView.java License: 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 #7
Source Project: neoscada Author: eclipse File: RemoveAction.java License: 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 #8
Source Project: scava Author: crossminer File: CrossflowDiagramUpdateCommand.java License: 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 #9
Source Project: ghidra Author: NationalSecurityAgency File: LinkGhidraCommand.java License: 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 #10
Source Project: ghidra Author: NationalSecurityAgency File: AbstractGhidraLaunchShortcut.java License: Apache License 2.0 | 5 votes |
@Override public void launch(ISelection selection, String mode) { IProject project = GhidraProjectUtils.getSelectedProject(selection); if (project != null) { launch(JavaCore.create(project), mode); } }
Example #11
Source Project: neoscada Author: eclipse File: VisualInterfaceActionBarContributor.java License: 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 #12
Source Project: neoscada Author: eclipse File: DeploymentActionBarContributor.java License: 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 #13
Source Project: neoscada Author: eclipse File: AbstractQueryViewPart.java License: Eclipse Public License 1.0 | 5 votes |
protected void addSelectionListener () { if ( this.selectionListener == null ) { getViewSite ().getWorkbenchWindow ().getSelectionService ().addSelectionListener ( this.selectionListener = new ISelectionListener () { public void selectionChanged ( final IWorkbenchPart part, final ISelection selection ) { AbstractQueryViewPart.this.setSelection ( selection ); } } ); } }
Example #14
Source Project: codewind-eclipse Author: eclipse File: CodewindApplicationActionProvider.java License: Eclipse Public License 2.0 | 5 votes |
private void addLogFileSubMenu(IMenuManager menu) { final ICommonViewerSite viewSite = getActionSite().getViewSite(); ISelection selection = viewSite.getSelectionProvider().getSelection(); if (!(selection instanceof IStructuredSelection)) { return; } IStructuredSelection sel = (IStructuredSelection) selection; if (sel.size() == 1) { Object obj = sel.getFirstElement(); if (obj instanceof CodewindEclipseApplication) { final CodewindEclipseApplication app = (CodewindEclipseApplication) obj; if (app.isAvailable() && app.getLogInfos() != null && !app.getLogInfos().isEmpty()) { MenuManager menuMgr = new MenuManager(Messages.ShowLogFilesMenu, "ShowLogFiles"); showAllLogsAction.setApp(app); menuMgr.add(showAllLogsAction); hideAllLogsAction.setApp(app); menuMgr.add(hideAllLogsAction); menuMgr.add(new Separator()); for (ProjectLogInfo logInfo : app.getLogInfos()) { menuMgr.add(new LogFileAction(app, logInfo, viewSite)); } menu.add(menuMgr); } } } }
Example #15
Source Project: scava Author: crossminer File: CrossflowActionBarContributor.java License: Eclipse Public License 2.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 #16
Source Project: neoscada Author: eclipse File: MemoryEditor.java License: 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 #17
Source Project: neoscada Author: eclipse File: WriteOperationAction.java License: Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged ( final IAction action, final ISelection selection ) { if ( selection == null ) { return; } if ( ! ( selection instanceof IStructuredSelection ) ) { return; } this.selection = (IStructuredSelection)selection; }
Example #18
Source Project: neoscada Author: eclipse File: WorldActionBarContributor.java License: 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 Project: dartboard Author: eclipse File: LaunchShortcut.java License: Eclipse Public License 2.0 | 5 votes |
@Override public void launch(ISelection selection, String mode) { IProject selected = null; if (selection instanceof StructuredSelection) { Object firstElement = ((StructuredSelection) selection).getFirstElement(); if (firstElement instanceof IResource) { selected = ((IResource) firstElement).getProject(); } } launchProject(selected, mode); }
Example #20
Source Project: dartboard Author: eclipse File: LaunchFileShortcut.java License: Eclipse Public License 2.0 | 5 votes |
@Override public void launch(ISelection selection, String mode) { if (selection instanceof StructuredSelection) { Object firstElement = ((StructuredSelection) selection).getFirstElement(); if (firstElement instanceof IFile) { IFile file = (IFile) firstElement; launch(file.getLocation(), null); } } }
Example #21
Source Project: neoscada Author: eclipse File: SelectionHelper.java License: Eclipse Public License 1.0 | 5 votes |
public static <T> T first ( final ISelection selection, final Class<T> clazz ) { final Iterator<T> i = iterator ( selection, clazz ); if ( i.hasNext () ) { return i.next (); } return null; }
Example #22
Source Project: CogniCrypt Author: eclipse-cognicrypt File: Utils.java License: Eclipse Public License 2.0 | 5 votes |
/** * This method gets the project that is currently selected. * * @return Currently selected project. */ public static IProject getCurrentlySelectedIProject() { ISelection curSel = getCurrentSelection(); Object resource = null; if ((resource = getIResourceFromSelection(curSel)) != null) { return ((IProject) resource).getProject(); } else { return getJavaProjectFromSelection(curSel); } }
Example #23
Source Project: neoscada Author: eclipse File: DeploymentEditor.java License: 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 #24
Source Project: neoscada Author: eclipse File: SecurityEditor.java License: 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 #25
Source Project: neoscada Author: eclipse File: LaunchShortcut.java License: Eclipse Public License 1.0 | 5 votes |
@Override public void launch ( final ISelection selection, final String mode ) { final IResource resource = SelectionHelper.first ( selection, IResource.class ); if ( resource != null ) { performLanuch ( resource, mode ); } }
Example #26
Source Project: neoscada Author: eclipse File: AbstractChartManagePart.java License: Eclipse Public License 1.0 | 5 votes |
protected void attachSelectionService () { getViewSite ().getWorkbenchWindow ().getSelectionService ().addPostSelectionListener ( new ISelectionListener () { @Override public void selectionChanged ( final IWorkbenchPart part, final ISelection selection ) { handleSelectionChanged ( selection ); } } ); handleSelectionChanged ( getViewSite ().getWorkbenchWindow ().getSelectionService ().getSelection () ); }
Example #27
Source Project: neoscada Author: eclipse File: AbstractEntryViewPart.java License: Eclipse Public License 1.0 | 5 votes |
protected synchronized void setSelection ( final ISelection selection ) { final BrowserEntryBean browserEntry = SelectionHelper.first ( selection, BrowserEntryBean.class ); if ( browserEntry != this.entry && browserEntry != null && isSupported ( browserEntry ) ) { clear (); if ( browserEntry != null ) { setEntry ( browserEntry ); } } }
Example #28
Source Project: neoscada Author: eclipse File: SelectionHelper.java License: Eclipse Public License 1.0 | 5 votes |
public static <T> List<T> list ( final ISelection selection, final Class<T> clazz ) { final List<T> result = new LinkedList<T> (); if ( selection instanceof IStructuredSelection ) { final Iterator<?> i = ( (IStructuredSelection)selection ).iterator (); while ( i.hasNext () ) { final Object o = i.next (); if ( o == null ) { continue; } if ( clazz.isAssignableFrom ( o.getClass () ) ) { result.add ( clazz.cast ( o ) ); } else { final T ro = AdapterHelper.adapt ( o, clazz ); if ( ro != null ) { result.add ( ro ); } } } } return result; }
Example #29
Source Project: neoscada Author: eclipse File: MemoryActionBarContributor.java License: 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 #30
Source Project: neoscada Author: eclipse File: ConfigurationEditor.java License: 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 ); } } } } }