use of org.eclipse.jface.text.ITextViewerExtension in project eclipse.platform.text by eclipse.
the class IncrementalFindTarget method uninstall.
/**
* Uninstalls itself. I.e. removes all listeners installed in <code>install</code>.
*/
private void uninstall() {
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);
}
ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
if (commandService != null)
commandService.removeExecutionListener(this);
fInstalled = false;
}
use of org.eclipse.jface.text.ITextViewerExtension in project eclipse.platform.text by eclipse.
the class MarkRegionTarget method setMarkAtCursor.
@Override
public void setMarkAtCursor(boolean set) {
if (!(fViewer instanceof ITextViewerExtension))
return;
ITextViewerExtension viewerExtension = ((ITextViewerExtension) fViewer);
if (set) {
Point selection = fViewer.getSelectedRange();
viewerExtension.setMark(selection.x);
// $NON-NLS-1$
fStatusLine.setErrorMessage("");
fStatusLine.setMessage(EditorMessages.Editor_mark_status_message_mark_set);
} else {
viewerExtension.setMark(-1);
// $NON-NLS-1$
fStatusLine.setErrorMessage("");
fStatusLine.setMessage(EditorMessages.Editor_mark_status_message_mark_cleared);
}
}
use of org.eclipse.jface.text.ITextViewerExtension in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method getAdapter.
@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Class<T> required) {
if (IEditorStatusLine.class.equals(required)) {
if (fEditorStatusLine == null) {
IStatusLineManager statusLineManager = getStatusLineManager();
ISelectionProvider selectionProvider = getSelectionProvider();
if (statusLineManager != null && selectionProvider != null)
fEditorStatusLine = new EditorStatusLine(statusLineManager, selectionProvider);
}
return (T) fEditorStatusLine;
}
if (IVerticalRulerInfo.class.equals(required)) {
if (fVerticalRuler != null)
return (T) fVerticalRuler;
}
if (IMarkRegionTarget.class.equals(required)) {
if (fMarkRegionTarget == null) {
IStatusLineManager manager = getStatusLineManager();
if (manager != null)
fMarkRegionTarget = (fSourceViewer == null ? null : new MarkRegionTarget(fSourceViewer, manager));
}
return (T) fMarkRegionTarget;
}
if (IDeleteLineTarget.class.equals(required)) {
if (fDeleteLineTarget == null) {
fDeleteLineTarget = new TextViewerDeleteLineTarget(fSourceViewer);
}
return (T) fDeleteLineTarget;
}
if (IncrementalFindTarget.class.equals(required)) {
if (fIncrementalFindTarget == null) {
IStatusLineManager manager = getStatusLineManager();
if (manager != null)
fIncrementalFindTarget = (fSourceViewer == null ? null : new IncrementalFindTarget(fSourceViewer, manager));
}
return (T) fIncrementalFindTarget;
}
if (IFindReplaceTarget.class.equals(required)) {
if (fFindReplaceTarget == null) {
IFindReplaceTarget target = (fSourceViewer == null ? null : fSourceViewer.getFindReplaceTarget());
if (target != null) {
fFindReplaceTarget = new FindReplaceTarget(this, target);
if (fFindScopeHighlightColor != null)
fFindReplaceTarget.setScopeHighlightColor(fFindScopeHighlightColor);
}
}
return (T) fFindReplaceTarget;
}
if (ITextOperationTarget.class.equals(required))
return (fSourceViewer == null ? null : (T) fSourceViewer.getTextOperationTarget());
if (IRewriteTarget.class.equals(required)) {
if (fSourceViewer instanceof ITextViewerExtension) {
ITextViewerExtension extension = (ITextViewerExtension) fSourceViewer;
return (T) extension.getRewriteTarget();
}
return null;
}
if (Control.class.equals(required))
return fSourceViewer != null ? (T) fSourceViewer.getTextWidget() : null;
if (IColumnSupport.class.equals(required)) {
if (fColumnSupport == null)
fColumnSupport = createColumnSupport();
return (T) fColumnSupport;
}
return super.getAdapter(required);
}
use of org.eclipse.jface.text.ITextViewerExtension in project eclipse.platform.text by eclipse.
the class CompletionProposalPopup2 method insertProposal.
/**
* Applies the given proposal at the given offset. The given character is the
* one that triggered the insertion of this proposal.
*
* @param p the completion proposal
* @param trigger the trigger character
* @param stateMask the state mask of the keyboard event triggering the insertion
* @param offset the offset
* @since 2.1
*/
private void insertProposal(ICompletionProposal p, char trigger, int stateMask, final int offset) {
fInserting = true;
IRewriteTarget target = null;
IEditingSupportRegistry registry = null;
try {
IDocument document = fViewer.getDocument();
if (fViewer instanceof ITextViewerExtension) {
ITextViewerExtension extension = (ITextViewerExtension) fViewer;
target = extension.getRewriteTarget();
}
if (target != null)
target.beginCompoundChange();
if (fViewer instanceof IEditingSupportRegistry) {
registry = (IEditingSupportRegistry) fViewer;
registry.register(fModificationEditingSupport);
}
if (p instanceof ICompletionProposalExtension2) {
ICompletionProposalExtension2 e = (ICompletionProposalExtension2) p;
e.apply(fViewer, trigger, stateMask, offset);
} else if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension e = (ICompletionProposalExtension) p;
e.apply(document, trigger, offset);
} else {
p.apply(document);
}
Point selection = p.getSelection(document);
if (selection != null) {
fViewer.setSelectedRange(selection.x, selection.y);
fViewer.revealRange(selection.x, selection.y);
}
IContextInformation info = p.getContextInformation();
if (info != null) {
int position;
if (p instanceof ICompletionProposalExtension) {
ICompletionProposalExtension e = (ICompletionProposalExtension) p;
position = e.getContextInformationPosition();
} else {
if (selection == null)
selection = fViewer.getSelectedRange();
position = selection.x + selection.y;
}
fContentAssistant.showContextInformation(info, position);
}
fContentAssistant.fireProposalChosen(p);
} finally {
if (target != null)
target.endCompoundChange();
if (registry != null)
registry.unregister(fModificationEditingSupport);
fInserting = false;
}
}
use of org.eclipse.jface.text.ITextViewerExtension in project eclipse.platform.text by eclipse.
the class ContentAssistant2 method uninstallKeyListener.
/**
* Uninstall the key listener from the text viewer's widget.
*/
private void uninstallKeyListener() {
if (fKeyListenerHooked) {
StyledText text = fViewer.getTextWidget();
if (Helper2.okToUse(text)) {
if (fViewer instanceof ITextViewerExtension) {
ITextViewerExtension e = (ITextViewerExtension) fViewer;
e.removeVerifyKeyListener(fInternalListener);
} else {
text.removeVerifyKeyListener(fInternalListener);
}
fKeyListenerHooked = false;
}
}
}
Aggregations