org.eclipse.jface.text.ITextViewerExtension Java Examples

The following examples show how to use org.eclipse.jface.text.ITextViewerExtension. 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: ContentAssistSubjectControlAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#prependVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
 */
public boolean prependVerifyKeyListener(VerifyKeyListener verifyKeyListener)
{
	if (fContentAssistSubjectControl != null)
	{
		return fContentAssistSubjectControl.prependVerifyKeyListener(verifyKeyListener);
	}
	else if (fViewer instanceof ITextViewerExtension)
	{
		ITextViewerExtension e = (ITextViewerExtension) fViewer;
		e.prependVerifyKeyListener(verifyKeyListener);
		return true;
	}
	else
	{

		StyledText textWidget = fViewer.getTextWidget();
		if (Helper.okToUse(textWidget))
		{
			textWidget.addVerifyKeyListener(verifyKeyListener);
			return true;
		}
	}
	return false;
}
 
Example #2
Source File: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Start the definition of a keyboard macro
 * 
 * @param editor
 * @param append - if true, append to the current definition
 */
public void startKbdMacro(ITextEditor editor, boolean append) {
	
	if (!isExecuting()) {
		setEditor(editor);
		isdefining = true;
		ics = (ICommandService) editor.getSite().getService(ICommandService.class);
		// listen for command executions
		ics.addExecutionListener(this);
		addDocumentListener(editor);
		if (!append || kbdMacro == null) {
			kbdMacro = new KbdMacro();
		}
		setViewer(findSourceViewer(editor));
		if (viewer instanceof ITextViewerExtension) {
			((ITextViewerExtension) viewer).prependVerifyKeyListener(whileDefining);
		} else {
			viewer = null;
		}
		// add a listener for ^G
		Beeper.addBeepListener(KbdMacroBeeper.beeper);
		currentCommand = null;
	}
}
 
Example #3
Source File: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {

	super.createPartControl(parent);

	IPreferenceStore preferenceStore= getPreferenceStore();
	boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS);
	boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS);
	boolean closeAngularBrackets= JavaCore.VERSION_1_5.compareTo(preferenceStore.getString(JavaCore.COMPILER_SOURCE)) <= 0;

	fBracketInserter.setCloseBracketsEnabled(closeBrackets);
	fBracketInserter.setCloseStringsEnabled(closeStrings);
	fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);

	ISourceViewer sourceViewer= getSourceViewer();
	if (sourceViewer instanceof ITextViewerExtension)
		((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);

	if (isMarkingOccurrences())
		installOccurrencesFinder(false);
}
 
Example #4
Source File: CompilationUnitEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void dispose() {

	ISourceViewer sourceViewer= getSourceViewer();
	if (sourceViewer instanceof ITextViewerExtension)
		((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);

	if (fJavaEditorErrorTickUpdater != null) {
		fJavaEditorErrorTickUpdater.dispose();
		fJavaEditorErrorTickUpdater= null;
	}

	if (fCorrectionCommands != null) {
		fCorrectionCommands.deregisterCommands();
		fCorrectionCommands= null;
	}

	super.dispose();
}
 
Example #5
Source File: CommonLineNumberRulerColumn.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Layouts the enclosing viewer to adapt the layout to changes of the
 * size of the individual components.
 *
 * @param redraw <code>true</code> if this column can be redrawn
 */
protected void layout(boolean redraw) {
	if (!redraw) {
		fRelayoutRequired= true;
		return;
	}

	fRelayoutRequired= false;
	if (fCachedTextViewer instanceof ITextViewerExtension) {
		ITextViewerExtension extension= (ITextViewerExtension) fCachedTextViewer;
		Control control= extension.getControl();
		if (control instanceof Composite && !control.isDisposed()) {
			Composite composite= (Composite) control;
			composite.layout(true);
		}
	}
}
 
Example #6
Source File: ContentAssistSubjectControlAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#removeVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
 */
public void removeVerifyKeyListener(VerifyKeyListener verifyKeyListener)
{
	if (fContentAssistSubjectControl != null)
	{
		fContentAssistSubjectControl.removeVerifyKeyListener(verifyKeyListener);
	}
	else if (fViewer instanceof ITextViewerExtension)
	{
		ITextViewerExtension extension = (ITextViewerExtension) fViewer;
		extension.removeVerifyKeyListener(verifyKeyListener);
	}
	else
	{
		StyledText textWidget = fViewer.getTextWidget();
		if (Helper.okToUse(textWidget))
		{
			textWidget.removeVerifyKeyListener(verifyKeyListener);
		}
	}
}
 
Example #7
Source File: ContentAssistSubjectControlAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @see org.eclipse.jface.contentassist.IContentAssistSubjectControl#appendVerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener)
 */
public boolean appendVerifyKeyListener(VerifyKeyListener verifyKeyListener)
{
	if (fContentAssistSubjectControl != null)
	{
		return fContentAssistSubjectControl.appendVerifyKeyListener(verifyKeyListener);
	}
	else if (fViewer instanceof ITextViewerExtension)
	{
		ITextViewerExtension extension = (ITextViewerExtension) fViewer;
		extension.appendVerifyKeyListener(verifyKeyListener);
		return true;
	}
	else
	{
		StyledText textWidget = fViewer.getTextWidget();
		if (Helper.okToUse(textWidget))
		{
			textWidget.addVerifyKeyListener(verifyKeyListener);
			return true;
		}
	}
	return false;
}
 
Example #8
Source File: JavaScriptLightWeightEditor.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
public void dispose() {
	if (fProjectionSupport != null) {
		fProjectionSupport.dispose();
		fProjectionSupport = null;
	}

	if (fBracketMatcher != null) {
		fBracketMatcher.dispose();
		fBracketMatcher = null;
	}

	ISourceViewer sourceViewer = getSourceViewer();
	if (sourceViewer instanceof ITextViewerExtension) {
		((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
	}

	super.dispose();
}
 
Example #9
Source File: JavaScriptLightWeightEditor.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
public void createPartControl(Composite parent) {

	super.createPartControl(parent);

	// do not even install projection support until folding is actually
	// enabled
	if (isFoldingEnabled()) {
		installProjectionSupport();
	}

	IPreferenceStore preferenceStore = getPreferenceStore();
	boolean closeBrackets = preferenceStore.getBoolean(CLOSE_BRACKETS);
	boolean closeStrings = preferenceStore.getBoolean(CLOSE_STRINGS);
	boolean closeAngularBrackets = JavaScriptCore.VERSION_1_5
			.compareTo(preferenceStore.getString(JavaScriptCore.COMPILER_SOURCE)) <= 0;

	fBracketInserter.setCloseBracketsEnabled(closeBrackets);
	fBracketInserter.setCloseStringsEnabled(closeStrings);
	fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);

	ISourceViewer sourceViewer = getSourceViewer();
	if (sourceViewer instanceof ITextViewerExtension)
		((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
}
 
Example #10
Source File: BookmarkRulerColumn.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Layouts the enclosing viewer to adapt the layout to changes of the
 * size of the individual components.
 *
 * @param redraw <code>true</code> if this column can be redrawn
 */
protected void layout(boolean redraw) {
    if (!redraw) {
        fRelayoutRequired= true;
        return;
    }

    fRelayoutRequired= false;
    if (fCachedTextViewer instanceof ITextViewerExtension) {
        ITextViewerExtension extension= (ITextViewerExtension) fCachedTextViewer;
        Control control= extension.getControl();
        if (control instanceof Composite && !control.isDisposed()) {
            Composite composite= (Composite) control;
            composite.layout(true);
        }
    }
}
 
Example #11
Source File: MarkRegionTargetWithoutStatusline.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void swapMarkAndCursor() {

	if (!(fViewer instanceof ITextViewerExtension))
		return;

	ITextViewerExtension viewerExtension = ((ITextViewerExtension) fViewer);

	int markPosition = viewerExtension.getMark();
	if (markPosition == -1) {
		return;
	}

	if (!isVisible(fViewer, markPosition)) {
		return;
	}

	Point selection = fViewer.getSelectedRange();
	viewerExtension.setMark(selection.x);

	fViewer.setSelectedRange(markPosition, 0);
	fViewer.revealRange(markPosition, 0);
}
 
Example #12
Source File: RepositionHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * A semi-hack... This uses stuff that may change at any time in Eclipse.  
 * In the java editor, the projection annotation model contains the collapsible regions which correspond to methods (and other areas
 * such as import groups).
 * 
 * This may work in other editor types as well... TBD
 */
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection,
		ExecutionEvent event) throws BadLocationException {

	ITextViewerExtension viewer = MarkUtils.getITextViewer(editor);
	if (viewer instanceof ProjectionViewer) {
		ProjectionAnnotationModel projection = ((ProjectionViewer)viewer).getProjectionAnnotationModel();
		Iterator<Annotation> pit = projection.getAnnotationIterator();
		while (pit.hasNext()) {
			Position p = projection.getPosition(pit.next());
			if (p.includes(currentSelection.getOffset())) {
				if (isUniversalPresent()) {
					// Do this here to prevent subsequent scrolling once range is revealed
					MarkUtils.setSelection(editor, new TextSelection(document, p.offset, 0));
				}
				// the viewer is pretty much guaranteed to be a TextViewer
				if (viewer instanceof TextViewer) {
					((TextViewer)viewer).revealRange(p.offset, p.length);
				}
				break;
			}
		}
	}
	return NO_OFFSET;		
}
 
Example #13
Source File: MarkUtils.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
public static ITextViewerExtension getITextViewer(ITextEditor editor) {
	ITextViewerExtension result = null;
	ISourceViewer viewer = findSourceViewer(editor);
	if ((viewer instanceof ITextViewerExtension)) {
		result = ((ITextViewerExtension) viewer);
	}
	return result;
}
 
Example #14
Source File: WithMinibuffer.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Installs this target. I.e. adds all required listeners.
 */
private boolean install() {
	if (editor instanceof AbstractTextEditor && !isInstalled()) {
		bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
		viewer = findSourceViewer(editor);
		if (viewer != null) {
			widget = viewer.getTextWidget();
			if (widget == null || widget.isDisposed()) {
				viewer = null;
				widget = null;
				return false;
			}
			widget.addMouseListener(this);
			widget.addFocusListener(this);
			viewer.addTextListener(this);

			ISelectionProvider selectionProvider = viewer.getSelectionProvider();
			if (selectionProvider != null)
				selectionProvider.addSelectionChangedListener(this);

			if (viewer instanceof ITextViewerExtension){
				((ITextViewerExtension) viewer).prependVerifyKeyListener(this);
				KbdMacroSupport.getInstance().continueKbdMacro(this,editor);
			} else {
				widget.addVerifyKeyListener(this);
			}
			addOtherListeners(page,viewer, widget);
			installed = true;
		}
	}
	addStatusContribution(editor);		
	return installed;
}
 
Example #15
Source File: WithMinibuffer.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Uninstalls itself. I.e. removes all listeners installed in
 * <code>install</code>.
 */
private void uninstall() {
	try {
		if (isInstalled()) {
			setKeyFilter(true);
			if (viewer != null) {
				removeStatusContribution(editor);
				viewer.removeTextListener(this);

				ISelectionProvider selectionProvider = viewer.getSelectionProvider();
				if (selectionProvider != null)
					selectionProvider.removeSelectionChangedListener(this);

				if (widget != null && !widget.isDisposed()) {
					widget.removeMouseListener(this);
					widget.removeFocusListener(this);
				}

				if (viewer instanceof ITextViewerExtension) {
					((ITextViewerExtension) viewer).removeVerifyKeyListener(this);
					KbdMacroSupport.setKbdMinibuffer(null);
				} else {
					if (widget != null && !widget.isDisposed())
						widget.removeVerifyKeyListener(this);
				}
				removeOtherListeners(page, viewer, widget);
			}
		}
	} finally {
		widget = null;
		page = null;	// TODO: elsewhere?
		installed = false;
	}
}
 
Example #16
Source File: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
public void setExecuting(boolean is, ITextEditor editor, VerifyKeyListener vkf) {
	boolean wasExecuting = isExecuting();
	// keep track of nested macro executions
	if (is) {
		++executeCount;
	} else {
		--executeCount;
	}
	if (!wasExecuting && is) {
		whileExecuting = vkf;
		setViewer(findSourceViewer(editor));
		if (viewer != null) {
			setRedraw(viewer,false);
			if (whileExecuting != null
					&& viewer instanceof ITextViewerExtension) {
				((ITextViewerExtension) viewer)
						.prependVerifyKeyListener(whileExecuting);
			}
		}
		setEditor(editor); 
	} else if (!isExecuting() && viewer != null) {
		setRedraw(viewer,true);
		if (whileExecuting != null && viewer instanceof ITextViewerExtension){
			((ITextViewerExtension) viewer).removeVerifyKeyListener(whileExecuting);
			whileExecuting = null;
		}
		setEditor(null); 
	} 
}
 
Example #17
Source File: TemplateProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void endCompoundChange(ITextViewer viewer) {
	if (viewer instanceof ITextViewerExtension) {
		ITextViewerExtension extension= (ITextViewerExtension) viewer;
		IRewriteTarget target= extension.getRewriteTarget();
		target.endCompoundChange();
	}
}
 
Example #18
Source File: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * End the definition of a keyboard macro
 *  
 * @param abort if true, terminate with extreme prejudice
 * @return true if macro was being defined, else false
 */
private boolean endKbdMacro(boolean abort) {
	boolean result = isDefining();
	if (result) {
		if (ics != null) {
			ics.removeExecutionListener(this);
			ics = null;
		}
		if (viewer != null) {
			if (viewer instanceof ITextViewerExtension) {
				((ITextViewerExtension) viewer)
						.removeVerifyKeyListener(whileDefining);
			}
			viewer = null;
		}
		if (abort) {
			// restore last from ring buffer
			restoreFromHistory();
		} else {
			addToHistory(kbdMacro);
		}
		ITextEditor ed = getEditor();
		if (ed != null) {
			removeDocumentListener(ed);			
			EmacsPlusUtils.showMessage(ed, (abort ? KBD_ABORTED : KBD_DEFINED), abort);
		}
		
		// remove a listener for ^G
		Beeper.removeBeepListener(KbdMacroBeeper.beeper);
		setEditor(null);
		isdefining = false;
		currentCommand = null;
	}
	return result;
}
 
Example #19
Source File: KbdMacroSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
private void prependKeyListener(ITextEditor editor, VerifyKeyListener key) {
	if (key != null && editor != null) {
		if (viewer == findSourceViewer(editor)) {
			((ITextViewerExtension) viewer).prependVerifyKeyListener(key);
		}
	} 
}
 
Example #20
Source File: OfflineActionTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Installs this target. I.e. adds all required listeners.
 */
private void install() {
    if (fInstalled)
        return;

    StyledText text = fTextViewer.getTextWidget();
    if (text == null)
        return;

    text.addMouseListener(this);
    text.addFocusListener(this);
    fTextViewer.addTextListener(this);

    ISelectionProvider selectionProvider = fTextViewer.getSelectionProvider();
    if (selectionProvider != null)
        selectionProvider.addSelectionChangedListener(this);

    if (fTextViewer instanceof ITextViewerExtension)
        ((ITextViewerExtension) fTextViewer).prependVerifyKeyListener(this);
    else
        text.addVerifyKeyListener(this);

    keyAssistDialog = new KeyAssistDialog(this.fEdit);
    fInstalled = true;

    //Wait a bit until showing the key assist dialog
    new UIJob("") {

        @Override
        public IStatus runInUIThread(IProgressMonitor monitor) {
            synchronized (lock) {
                if (fInstalled && keyAssistDialog != null) {
                    keyAssistDialog.open(OfflineActionTarget.this.fEdit.getOfflineActionDescriptions(),
                            OfflineActionTarget.this);
                }
            }
            return Status.OK_STATUS;
        }
    }.schedule(700);
}
 
Example #21
Source File: OfflineActionTarget.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Uninstalls itself. I.e. removes all listeners installed in <code>install</code>.
 */
private void uninstall() {
    synchronized (lock) {
        if (!fInstalled) {
            return;
        }
        fTextViewer.removeTextListener(this);

        ISelectionProvider selectionProvider = fTextViewer.getSelectionProvider();
        if (selectionProvider != null)
            selectionProvider.removeSelectionChangedListener(this);

        StyledText text = fTextViewer.getTextWidget();
        if (text != null) {
            text.removeMouseListener(this);
            text.removeFocusListener(this);
        }

        if (fTextViewer instanceof ITextViewerExtension) {
            ((ITextViewerExtension) fTextViewer).removeVerifyKeyListener(this);

        } else {
            if (text != null)
                text.removeVerifyKeyListener(this);
        }

        if (keyAssistDialog != null) {
            keyAssistDialog.close();
        }
        keyAssistDialog = null;
        fInstalled = false;
    }
}
 
Example #22
Source File: EditorAPI.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
/** Enables/disables the ability to edit the document in given editor. */
public static void setEditable(final IEditorPart editorPart, final boolean isEditable) {

  ITextViewer textViewer = getViewer(editorPart);

  if (textViewer == null) return;

  if (isEditable) {
    updateStatusLine(editorPart, "");

    if (textViewer instanceof ITextViewerExtension)
      ((ITextViewerExtension) textViewer).removeVerifyKeyListener(keyVerifier);

    textViewer.setEditable(true);
    setEditorActionState(editorPart, true);

    // TODO use undoLevel from Preferences (TextEditorPlugin)
    if (textViewer instanceof ITextViewerExtension6)
      ((ITextViewerExtension6) textViewer).getUndoManager().setMaximalUndoLevel(200);

  } else {
    updateStatusLine(editorPart, "Not editable");

    if (textViewer instanceof ITextViewerExtension)
      ((ITextViewerExtension) textViewer).prependVerifyKeyListener(keyVerifier);

    textViewer.setEditable(false);
    setEditorActionState(editorPart, false);

    if (textViewer instanceof ITextViewerExtension6)
      ((ITextViewerExtension6) textViewer).getUndoManager().setMaximalUndoLevel(0);
  }
}
 
Example #23
Source File: VerifyKeyRecorder.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public VerifyKeyRecorder(ITextViewer viewer) {
	if(viewer instanceof ITextViewerExtension) {
		ITextViewerExtension viewerExtension = (ITextViewerExtension) viewer;
		viewerExtension.appendVerifyKeyListener(this);
		// Minor leak issue: we should remove verifyKeyRecorder if viewer is unconfigured
	} else {
		// Ignore
	}
	lastKeyEvent = KeyCommand.OTHER;
}
 
Example #24
Source File: MarkUtils.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Set Mark at offset, and potentially save the marks in the Mark Rings
 * 
 * @param editor
 * @param ve
 * @param offset - the offset in document (absolute) coords
 * @param save - true if we're (potentially) saving in the Mark Rings
 * @return the mark position in document coords
 */
public static int setMark(ITextEditor editor, ITextViewerExtension ve, int offset, boolean save) {
	int result = -1;
	if (ve != null) {
		int localMark = ve.getMark();
		ve.setMark(offset);
		result = ve.getMark();
		if (save) {
			MarkRing.addMark(editor, ve.getRewriteTarget().getDocument(), localMark, result);
			EmacsPlusUtils.showMessage(editor, MARK_SET, false);
		}
	}
	return result;
}
 
Example #25
Source File: MarkUtils.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get the current Mark position
 * 
 * @param editor
 * @return the Mark position in model coords (-1 if not set)
 */
public static int getMark(ITextEditor editor) {
	int result = -1;
	ITextViewerExtension ive = getITextViewer(editor);
	if (ive != null) {
		result = ive.getMark();
	}
	return result;
}
 
Example #26
Source File: SurroundWithTemplateProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void setRedraw(ITextViewer viewer, boolean redraw) {
if (viewer instanceof ITextViewerExtension) {
	ITextViewerExtension extension= (ITextViewerExtension) viewer;
	IRewriteTarget target= extension.getRewriteTarget();
	target.setRedraw(redraw);
}
  }
 
Example #27
Source File: TemplateProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void beginCompoundChange(ITextViewer viewer) {
	if (viewer instanceof ITextViewerExtension) {
		ITextViewerExtension extension= (ITextViewerExtension) viewer;
		IRewriteTarget target= extension.getRewriteTarget();
		target.beginCompoundChange();
	}
}
 
Example #28
Source File: TextViewerMoveLinesAction.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ends the compound change.
 */
private void beginCompoundEdit() {
	ITextViewer viewer= getTextViewer();
	if (fEditInProgress || viewer == null || !(viewer instanceof ITextViewerExtension))
		return;

	fEditInProgress= true;

	fStrategy.arm(viewer);

	IRewriteTarget target= ((ITextViewerExtension) viewer).getRewriteTarget();
	if (target != null) {
		target.beginCompoundChange();
	}
}
 
Example #29
Source File: SmartBackspaceManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void ensureListenerRemoved() {
	if (fBackspaceListener != null) {
		ITextViewer viewer= fViewer;
		if (viewer instanceof ITextViewerExtension)
			((ITextViewerExtension) viewer).removeVerifyKeyListener(fBackspaceListener);
		else
			viewer.getTextWidget().removeVerifyKeyListener(fBackspaceListener);
		fBackspaceListener= null;
	}
}
 
Example #30
Source File: SmartBackspaceManager.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void ensureListenerInstalled() {
	if (fBackspaceListener == null) {
		fBackspaceListener= new BackspaceListener();
		ITextViewer viewer= fViewer;
		if (viewer instanceof ITextViewerExtension)
			((ITextViewerExtension) viewer).prependVerifyKeyListener(fBackspaceListener);
		else
			viewer.getTextWidget().addVerifyKeyListener(fBackspaceListener);
	}
}