org.eclipse.jface.viewers.IPostSelectionProvider Java Examples
The following examples show how to use
org.eclipse.jface.viewers.IPostSelectionProvider.
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: DelegatingSelectionProvider.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * Sets a new selection provider to delegate to. Selection listeners registered with the * previous delegate are removed before. * * @param newDelegate * new selection provider */ public void setSelectionProviderDelegate(ISelectionProvider newDelegate){ if (delegate == newDelegate) { return; } if (delegate != null) { delegate.removeSelectionChangedListener(selectionListener); if (delegate instanceof IPostSelectionProvider) { ((IPostSelectionProvider) delegate) .removePostSelectionChangedListener(postSelectionListener); } } delegate = newDelegate; if (newDelegate != null) { newDelegate.addSelectionChangedListener(selectionListener); if (newDelegate instanceof IPostSelectionProvider) { ((IPostSelectionProvider) newDelegate) .addPostSelectionChangedListener(postSelectionListener); } fireSelectionChanged(newDelegate.getSelection()); firePostSelectionChanged(newDelegate.getSelection()); } }
Example #2
Source File: TexlipseAnnotationUpdater.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * Creates a new TexlipseAnnotationUpdater and adds itself to the TexEditor via * <code>addPostSelectionChangedListener</code> * @param editor The TexEditor */ public TexlipseAnnotationUpdater (AbstractTextEditor editor) { //Add this listener to the current editors IPostSelectionListener (lazy update) ((IPostSelectionProvider) editor.getSelectionProvider()).addPostSelectionChangedListener(this); fEditor = editor; fEnabled = TexlipsePlugin.getDefault().getPreferenceStore().getBoolean( TexlipseProperties.TEX_EDITOR_ANNOTATATIONS); //Add a PropertyChangeListener TexlipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (TexlipseProperties.TEX_EDITOR_ANNOTATATIONS.equals(property)) { boolean enabled = TexlipsePlugin.getDefault().getPreferenceStore().getBoolean( TexlipseProperties.TEX_EDITOR_ANNOTATATIONS); fEnabled = enabled; } } }); }
Example #3
Source File: LinkWithEditorTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testTreeToText() throws Exception { IPostSelectionProvider editorSelectionProvider = (IPostSelectionProvider) editor.getSelectionProvider(); editorSelectionProvider.addPostSelectionChangedListener(selectionSyncer); assertSelected(treeViewer); activate(editor); try { selectionSyncer.start(); treeViewer.setSelection(new StructuredSelection(modelNode)); selectionSyncer.awaitSignal(EXPECTED_TIMEOUT); fail("Selection from inactive part should not be linked"); } catch (TimeoutException e) { } activate(outlineView); try { checkTreeSelectionToText(modelNode, modelAsText, selectionSyncer); checkTreeSelectionToText(oneNode, "one", selectionSyncer); checkTreeSelectionToText(twoNode, "two", selectionSyncer); checkTreeSelectionToText(threeNode, "three", selectionSyncer); checkTreeSelectionToText(fourNode, "four", selectionSyncer); } finally { editorSelectionProvider.removePostSelectionChangedListener(selectionSyncer); } }
Example #4
Source File: JavaScriptLightWeightEditor.java From typescript.java with MIT License | 5 votes |
/** * Installs this selection changed listener with the given selection * provider. If the selection provider is a post selection provider, * post selection changed events are the preferred choice, otherwise * normal selection changed events are requested. * * @param selectionProvider */ public void install(ISelectionProvider selectionProvider) { if (selectionProvider == null) return; if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider = (IPostSelectionProvider) selectionProvider; provider.addPostSelectionChangedListener(this); } else { selectionProvider.addSelectionChangedListener(this); } }
Example #5
Source File: ExecuteCommandHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Remove the selection changed listener * * @param selectionProvider */ private void removeListener(ISelectionProvider selectionProvider, ISelectionChangedListener listener) { if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; provider.removePostSelectionChangedListener(listener); } else { selectionProvider.removeSelectionChangedListener(listener); } }
Example #6
Source File: ExecuteCommandHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Add the selection changed listener * * @param selectionProvider */ private void addListener(ISelectionProvider selectionProvider, ISelectionChangedListener listener) { if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; provider.addPostSelectionChangedListener(listener); } else { selectionProvider.addSelectionChangedListener(listener); } }
Example #7
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Removes this selection changed listener from the given selection provider. * * @param selectionProvider the selection provider */ public void uninstall(ISelectionProvider selectionProvider) { if (selectionProvider == null) return; if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; provider.removePostSelectionChangedListener(this); } else { selectionProvider.removeSelectionChangedListener(this); } }
Example #8
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Installs this selection changed listener with the given selection provider. If * the selection provider is a post selection provider, post selection changed * events are the preferred choice, otherwise normal selection changed events * are requested. * * @param selectionProvider the selection provider */ public void install(ISelectionProvider selectionProvider) { if (selectionProvider == null) return; if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider; provider.addPostSelectionChangedListener(this); } else { selectionProvider.addSelectionChangedListener(this); } }
Example #9
Source File: AbstractThemeableEditor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void uninstall(ISelectionProvider selectionProvider) { if (selectionProvider == null) { return; } if (selectionProvider instanceof IPostSelectionProvider) { ((IPostSelectionProvider) selectionProvider).removePostSelectionChangedListener(this); } else { selectionProvider.removeSelectionChangedListener(this); } }
Example #10
Source File: AbstractThemeableEditor.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void install(ISelectionProvider selectionProvider) { if (selectionProvider == null) { return; } if (selectionProvider instanceof IPostSelectionProvider) { ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(this); } else { selectionProvider.addSelectionChangedListener(this); } }
Example #11
Source File: CommonEditorPropertySheetPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void removePostSelectionListener() { if (sourcePart != null) { ((IPostSelectionProvider) sourcePart.getSelectionProvider()) .removePostSelectionChangedListener(selectionChangedListener); sourcePart = null; } }
Example #12
Source File: AnnotateView.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void disconnect() { if(editor != null) { if (editor.getSelectionProvider() instanceof IPostSelectionProvider) { ((IPostSelectionProvider) editor.getSelectionProvider()).removePostSelectionChangedListener(this); } editor.getSite().getPage().removePartListener(partListener); editor = null; document = null; } }
Example #13
Source File: JavaScriptLightWeightEditor.java From typescript.java with MIT License | 5 votes |
/** * Removes this selection changed listener from the given selection * provider. * * @param selectionProvider * the selection provider */ public void uninstall(ISelectionProvider selectionProvider) { if (selectionProvider == null) return; if (selectionProvider instanceof IPostSelectionProvider) { IPostSelectionProvider provider = (IPostSelectionProvider) selectionProvider; provider.removePostSelectionChangedListener(this); } else { selectionProvider.removeSelectionChangedListener(this); } }
Example #14
Source File: TexEditor.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Create the part control. * * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) */ public void createPartControl(Composite parent) { super.createPartControl(parent); // enable projection support (for code folder) ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer(); fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors()); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); fProjectionSupport.install(); if (TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(TexlipseProperties.CODE_FOLDING)) { projectionViewer.doOperation(ProjectionViewer.TOGGLE); } fAnnotationUpdater = new TexlipseAnnotationUpdater(this); ((IPostSelectionProvider) getSelectionProvider()).addPostSelectionChangedListener( new ISelectionChangedListener(){ public void selectionChanged(SelectionChangedEvent event) { //Delete all StatuslineErrors after selection changes documentModel.removeStatusLineErrorMessage(); } }); // register documentModel as documentListener // in initializeEditor this would cause NPE this.getDocumentProvider().getDocument(getEditorInput()).addDocumentListener(this.documentModel); this.documentModel.initializeModel(); this.documentModel.updateNow(); ISourceViewer sourceViewer = getSourceViewer(); if (sourceViewer instanceof ITextViewerExtension) { if (fBracketInserter == null) fBracketInserter = new BracketInserter(getSourceViewer(), this); ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter); } }
Example #15
Source File: XtextEditor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void uninstallSelectionChangedListener() { ISelectionProvider selectionProvider = getSelectionProvider(); if (selectionProvider != null) { if (selectionProvider instanceof IPostSelectionProvider) { final IPostSelectionProvider postSelectionProvider = (IPostSelectionProvider) selectionProvider; postSelectionProvider.removePostSelectionChangedListener(selectionChangedListener); } else { selectionProvider.removeSelectionChangedListener(selectionChangedListener); } } }
Example #16
Source File: XtextEditor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void installSelectionChangedListener() { selectionChangedListener = new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { updateStatusLine(); } }; final ISelectionProvider selectionProvider = getSelectionProvider(); if (selectionProvider instanceof IPostSelectionProvider) { final IPostSelectionProvider postSelectionProvider = (IPostSelectionProvider) selectionProvider; postSelectionProvider.addPostSelectionChangedListener(selectionChangedListener); } else { getSelectionProvider().addSelectionChangedListener(selectionChangedListener); } }
Example #17
Source File: OutlineWithEditorLinker.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void deactivate() { ISelectionProvider textSelectionProvider = textViewer.getSelectionProvider(); if (textSelectionProvider instanceof IPostSelectionProvider) ((IPostSelectionProvider) textSelectionProvider).removePostSelectionChangedListener(textListener); else textSelectionProvider.removeSelectionChangedListener(textListener); textListener = null; textViewer = null; treeViewer.removePostSelectionChangedListener(treeListener); treeViewer.removeDoubleClickListener(treeListener); treeViewer = null; treeListener = null; outlinePage = null; }
Example #18
Source File: OutlineWithEditorLinker.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void activate(OutlinePage outlinePage) { this.outlinePage = outlinePage; treeViewer = outlinePage.getTreeViewer(); treeListener = new TreeListener(); treeViewer.addPostSelectionChangedListener(treeListener); treeViewer.addDoubleClickListener(treeListener); textViewer = outlinePage.getSourceViewer(); textListener = new TextListener(); ISelectionProvider textSelectionProvider = textViewer.getSelectionProvider(); if (textSelectionProvider instanceof IPostSelectionProvider) ((IPostSelectionProvider) textSelectionProvider).addPostSelectionChangedListener(textListener); else textSelectionProvider.addSelectionChangedListener(textListener); }
Example #19
Source File: RailroadSelectionLinker.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void removeTextSelectionListener(XtextEditor editor) { ISelectionProvider selectionProvider = editor.getSelectionProvider(); if (selectionProvider != null) { if (selectionProvider instanceof IPostSelectionProvider) ((IPostSelectionProvider) selectionProvider) .removePostSelectionChangedListener(textSelectionChangeListener); else selectionProvider.removeSelectionChangedListener(textSelectionChangeListener); } }
Example #20
Source File: RailroadSelectionLinker.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public void setXtextEditor(XtextEditor xtextEditor) { if (currentEditor != null) { removeTextSelectionListener(currentEditor); } if (XTEXT_LANGUAGE_NAME.equals(xtextEditor.getLanguageName())) { currentEditor = xtextEditor; ISelectionProvider selectionProvider = xtextEditor.getSelectionProvider(); if (selectionProvider instanceof IPostSelectionProvider) ((IPostSelectionProvider) selectionProvider) .addPostSelectionChangedListener(textSelectionChangeListener); else selectionProvider.addSelectionChangedListener(textSelectionChangeListener); } }
Example #21
Source File: OccurrenceMarker.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void disconnect(XtextEditor editor) { ((IPostSelectionProvider) editor.getSelectionProvider()) .removePostSelectionChangedListener(getSelectionChangedListener()); this.editor = null; }
Example #22
Source File: OccurrenceMarker.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public void connect(XtextEditor editor, boolean isMarkOccurrences) { this.editor = editor; ((IPostSelectionProvider) editor.getSelectionProvider()) .addPostSelectionChangedListener(getSelectionChangedListener()); this.isMarkOccurrences = isMarkOccurrences; }
Example #23
Source File: JavaEditor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void addPostSelectionChangedListener(ISelectionChangedListener listener) { super.addPostSelectionChangedListener(listener); if (getSourceViewer() != null && getSourceViewer().getSelectionProvider() instanceof IPostSelectionProvider) fPostSelectionListeners.add(listener); }