org.eclipse.ui.ISelectionListener Java Examples
The following examples show how to use
org.eclipse.ui.ISelectionListener.
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: FindbugsPlugin.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
public static void showMarker(IMarker marker, String viewId, IWorkbenchPart source) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewPart view = page.findView(viewId); if (!page.isPartVisible(view)) { try { view = page.showView(viewId); } catch (PartInitException e) { FindbugsPlugin.getDefault().logException(e, "Could not open view: " + viewId); return; } } if (view instanceof IMarkerSelectionHandler) { IMarkerSelectionHandler handler = (IMarkerSelectionHandler) view; handler.markerSelected(source, marker); } else if (DETAILS_VIEW_ID.equals(viewId) && view instanceof ISelectionListener) { ISelectionListener listener = (ISelectionListener) view; listener.selectionChanged(source, new StructuredSelection(marker)); } }
Example #2
Source File: DeleteItemViewActionDelegate.java From ice with Eclipse Public License 1.0 | 6 votes |
@Override public void init(IViewPart view) { // Set the reference viewPart = view; // Setup the action deleteItemAction = new DeleteItemAction(viewPart.getSite() .getWorkbenchWindow()); // Register the action as a listener viewPart.getSite() .getPage() .addPostSelectionListener((ISelectionListener) deleteItemAction); }
Example #3
Source File: SelectionListenerWithASTManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public PartListenerGroup(ITextEditor editorPart) { fPart= editorPart; fCurrentJob= null; fAstListeners= new ListenerList(ListenerList.IDENTITY); fSelectionListener= new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection selection= event.getSelection(); if (selection instanceof ITextSelection) { fireSelectionChanged((ITextSelection) selection); } } }; fPostSelectionListener= new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (part == fPart && selection instanceof ITextSelection) firePostSelectionChanged((ITextSelection) selection); } }; }
Example #4
Source File: JavaSelectMarkerRulerAction2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void triggerAction(String actionID, Event event) { IAction action= getTextEditor().getAction(actionID); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); // hack to propagate line change if (action instanceof ISelectionListener) { ((ISelectionListener)action).selectionChanged(null, null); } if (action.isEnabled()) { if (event == null) { action.run(); } else { event.type= SWT.MouseDoubleClick; event.count= 2; action.runWithEvent(event); } } } }
Example #5
Source File: BibtexEntryWatcher.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
public BibtexEntryWatcher(ISelectionService selectionService) { this.selectionService = selectionService; this.selectionListener = new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { List<Document> documents = new LinkedList<Document>(); if (selection instanceof IStructuredSelection) for (Object element : ((IStructuredSelection) selection).toList()) if (element instanceof Document) documents.add((Document) element); final Document doc; if (documents.size() == 1) doc = documents.get(0); else doc = null; listeners.stream().forEach(it -> it.accept(doc)); } }; selectionService.addPostSelectionListener(selectionListener); }
Example #6
Source File: IndexView.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * addListeners */ private void addListeners() { // this.listenForScriptChanges(); ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService(); // @formatter:off selectionService.addPostSelectionListener( IPageLayout.ID_PROJECT_EXPLORER, new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (part != IndexView.this && selection instanceof IStructuredSelection) { setInputFromSelection(selection); } } } ); // @formatter:on }
Example #7
Source File: AbstractAlarmsEventsView.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 ) { AbstractAlarmsEventsView.this.setSelection ( selection ); } } ); } }
Example #8
Source File: QueryViewPart.java From neoscada with Eclipse Public License 1.0 | 5 votes |
/** * Add a listener to the global selection service and set the currently selected query */ protected void addListener () { if ( this.selectionListener == null ) { getViewSite ().getWorkbenchWindow ().getSelectionService ().addSelectionListener ( this.selectionListener = new ISelectionListener () { @Override public void selectionChanged ( final IWorkbenchPart part, final ISelection selection ) { QueryViewPart.this.setSelection ( selection ); } } ); } }
Example #9
Source File: AbstractStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
/** * {@inheritDoc} * * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ @Override public void createPartControl(Composite parent) { mMainComposite = parent; // create and register the workspace focus listener mFocusListener = new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { AbstractStatsView.this.focusSelectionChanged(part, selection); } }; getSite().getPage().addSelectionListener(mFocusListener); focusSelectionChanged(getSite().getPage().getActivePart(), getSite().getPage().getSelection()); // create and register the listener for resource changes mResourceListener = new IResourceChangeListener() { @Override public void resourceChanged(IResourceChangeEvent event) { IMarkerDelta[] markerDeltas = event.findMarkerDeltas(CheckstyleMarker.MARKER_ID, true); if (markerDeltas.length > 0) { refresh(); } } }; ResourcesPlugin.getWorkspace().addResourceChangeListener(mResourceListener); makeActions(); initActionBars(getViewSite().getActionBars()); }
Example #10
Source File: SvnPropertiesView.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ public void createPartControl(Composite parent) { GridLayout layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.numColumns = 1; parent.setLayout(layout); statusLabel = new Label(parent,SWT.LEFT); GridData gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.grabExcessHorizontalSpace = true; statusLabel.setLayoutData(gridData); SashForm sashForm = new SashForm(parent, SWT.VERTICAL); sashForm.setLayoutData(new GridData(GridData.FILL_BOTH)); tableViewer = createTable(sashForm); textViewer = createText(sashForm); sashForm.setWeights(new int[] { 70, 30 }); contributeActions(); pageSelectionListener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart part, ISelection selection) { handlePartSelectionChanged(part,selection); } }; getSite().getPage().addPostSelectionListener(pageSelectionListener); resourceStateChangeListener = new ResourceStateChangeListener(); SVNProviderPlugin.addResourceStateChangeListener(resourceStateChangeListener); }
Example #11
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 #12
Source File: AbstractQueryViewPart.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 () { public void selectionChanged ( final IWorkbenchPart part, final ISelection selection ) { AbstractQueryViewPart.this.setSelection ( selection ); } } ); } }
Example #13
Source File: AbstractChartManagePart.java From neoscada with 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 #14
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override protected IVerticalRulerColumn createAnnotationRulerColumn(CompositeRuler ruler) { if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER)) return super.createAnnotationRulerColumn(ruler); AnnotationRulerColumn column= new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess()); column.setHover(new JavaExpandHover(ruler, getAnnotationAccess(), new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { // for now: just invoke ruler double click action triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK); } private void triggerAction(String actionID) { IAction action= getAction(actionID); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); // hack to propagate line change if (action instanceof ISelectionListener) { ((ISelectionListener)action).selectionChanged(null, null); } if (action.isEnabled()) action.run(); } } })); return column; }
Example #15
Source File: AbstractChartView.java From neoscada with Eclipse Public License 1.0 | 5 votes |
protected void createView ( final Chart configuration ) { final Composite extensionSpace = new Composite ( this.wrapper, SWT.NONE ); extensionSpace.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, false ) ); extensionSpace.setLayout ( new RowLayout ( SWT.HORIZONTAL ) ); this.chartArea = new ChartArea ( this.wrapper, SWT.NONE ); this.chartArea.setLayoutData ( new GridData ( SWT.FILL, SWT.FILL, true, true ) ); this.viewer = new ChartViewer ( this.chartArea.getDisplay (), this.chartArea.getChartRenderer (), configuration, new CompositeExtensionSpace ( extensionSpace ), null ); getSite ().setSelectionProvider ( this.viewer ); getSite ().getWorkbenchWindow ().getSelectionService ().addPostSelectionListener ( new ISelectionListener () { @Override public void selectionChanged ( final IWorkbenchPart part, final ISelection selection ) { final ChartInput sel = SelectionHelper.first ( selection, ChartInput.class ); if ( sel == null ) { AbstractChartView.this.viewer.setSelection ( (ChartInput)null ); } else { AbstractChartView.this.viewer.setSelection ( sel ); } // else: don't select anything which we do not care about } } ); }
Example #16
Source File: ConnectionDetailsView.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public void createPartControl ( final Composite parent ) { parent.setBackgroundMode ( SWT.INHERIT_FORCE ); this.view = new DetailsView ( parent ); getViewSite ().getWorkbenchWindow ().getSelectionService ().addSelectionListener ( new ISelectionListener () { @Override public void selectionChanged ( final IWorkbenchPart part, final ISelection selection ) { ConnectionDetailsView.this.view.setSelection ( selection ); } } ); this.view.setSelection ( getViewSite ().getWorkbenchWindow ().getSelectionService ().getSelection () ); }
Example #17
Source File: ERDiagramActionBarContributor.java From ermasterr with Apache License 2.0 | 4 votes |
public void contributeToToolBar(final ERDiagram diagram, final IToolBarManager toolBarManager, final ZoomComboContributionItem zoomComboContributionItem) { toolBarManager.add(getAction(ActionFactory.DELETE.getId())); toolBarManager.add(getAction(ActionFactory.UNDO.getId())); toolBarManager.add(getAction(ActionFactory.REDO.getId())); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_IN)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT)); toolBarManager.add(getActionRegistry().getAction(ZoomAdjustAction.ID)); toolBarManager.add(zoomComboContributionItem); toolBarManager.add(new Separator()); toolBarManager.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY)); toolBarManager.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY)); toolBarManager.add(getAction(TooltipAction.ID)); toolBarManager.add(getAction(LockEditAction.ID)); toolBarManager.add(new Separator()); toolBarManager.add(getAction(ExportToDBAction.ID)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_LEFT)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_CENTER)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_RIGHT)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_TOP)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_MIDDLE)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_BOTTOM)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.MATCH_WIDTH)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.MATCH_HEIGHT)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(HorizontalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(VerticalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(ChangeBackgroundColorAction.ID)); toolBarManager.add(new Separator()); final FontNameContributionItem fontNameContributionItem = new FontNameContributionItem(getPage()); final FontSizeContributionItem fontSizeContributionItem = new FontSizeContributionItem(getPage()); toolBarManager.add(fontNameContributionItem); toolBarManager.add(fontSizeContributionItem); getPage().addSelectionListener(new ISelectionListener() { @Override public void selectionChanged(final IWorkbenchPart part, final ISelection selection) { if (selection instanceof IStructuredSelection) { final List selectedEditParts = ((IStructuredSelection) selection).toList(); if (!selectedEditParts.isEmpty()) { if (selectedEditParts.get(0) instanceof EditPart) { final Object model = ((EditPart) selectedEditParts.get(0)).getModel(); if (model instanceof ViewableModel) { final ViewableModel viewableModel = (ViewableModel) model; final String fontName = viewableModel.getFontName(); final int fontSize = viewableModel.getFontSize(); if (fontName != null) { fontNameContributionItem.setText(fontName); } else { final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0]; fontNameContributionItem.setText(fontData.getName()); viewableModel.setFontName(fontData.getName()); } if (fontSize > 0) { fontSizeContributionItem.setText(String.valueOf(fontSize)); } else { fontSizeContributionItem.setText(String.valueOf(ViewableModel.DEFAULT_FONT_SIZE)); viewableModel.setFontSize(fontSize); } } } } } } }); }
Example #18
Source File: ERDiagramActionBarContributor.java From erflute with Apache License 2.0 | 4 votes |
@Override public void contributeToToolBar(IToolBarManager toolBarManager) { toolBarManager.add(getAction(ActionFactory.DELETE.getId())); toolBarManager.add(getAction(ActionFactory.UNDO.getId())); toolBarManager.add(getAction(ActionFactory.REDO.getId())); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_IN)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT)); toolBarManager.add(getActionRegistry().getAction(ZoomAdjustAction.ID)); toolBarManager.add(zoomComboContributionItem); toolBarManager.add(new Separator()); toolBarManager.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY)); toolBarManager.add(getAction(ToggleMainColumnAction.ID)); toolBarManager.add(getAction(LockEditAction.ID)); toolBarManager.add(new Separator()); toolBarManager.add(getAction(ExportToDDLAction.ID)); toolBarManager.add(getAction(ExportToDBAction.ID)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_LEFT)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_CENTER)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_RIGHT)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_TOP)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_MIDDLE)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.ALIGN_BOTTOM)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.MATCH_WIDTH)); toolBarManager.add(getActionRegistry().getAction(GEFActionConstants.MATCH_HEIGHT)); toolBarManager.add(new Separator()); toolBarManager.add(getActionRegistry().getAction(HorizontalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(VerticalLineAction.ID)); toolBarManager.add(getActionRegistry().getAction(ChangeBackgroundColorAction.ID)); toolBarManager.add(new Separator()); final FontNameContributionItem fontNameContributionItem = new FontNameContributionItem(getPage()); final FontSizeContributionItem fontSizeContributionItem = new FontSizeContributionItem(getPage()); toolBarManager.add(fontNameContributionItem); toolBarManager.add(fontSizeContributionItem); getPage().addSelectionListener(new ISelectionListener() { @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (selection instanceof IStructuredSelection) { final List<?> selectedEditParts = ((IStructuredSelection) selection).toList(); if (!selectedEditParts.isEmpty()) { if (selectedEditParts.get(0) instanceof EditPart) { final Object model = ((EditPart) selectedEditParts.get(0)).getModel(); if (model instanceof ViewableModel) { final ViewableModel viewableModel = (ViewableModel) model; final String fontName = viewableModel.getFontName(); if (fontName != null) { fontNameContributionItem.setText(fontName); } else { final FontData fonData = Display.getCurrent().getSystemFont().getFontData()[0]; fontNameContributionItem.setText(fonData.getName()); viewableModel.setFontName(fonData.getName()); } final int fontSize = viewableModel.getFontSize(); if (fontSize > 0) { fontSizeContributionItem.setText(String.valueOf(fontSize)); } else { fontSizeContributionItem.setText(String.valueOf(ViewableModel.DEFAULT_FONT_SIZE)); viewableModel.setFontSize(fontSize); } } } } } } }); }
Example #19
Source File: GraphicalEditorWithFlyoutPalette.java From birt with Eclipse Public License 1.0 | 2 votes |
/** * Returns the selection listener. * * @return the <code>ISelectionListener</code> */ protected ISelectionListener getSelectionListener( ) { return selectionListener; }