Java Code Examples for org.eclipse.swt.custom.StyledText#addFocusListener()

The following examples show how to use org.eclipse.swt.custom.StyledText#addFocusListener() . 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: StyledTextSelectionListener.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
public StyledTextSelectionListener(IWorkbenchPartSite site, StyledText widget,
		ISelectionProvider selectionProviderOnFocusGain) {
	super(site, selectionProviderOnFocusGain, widget);
	site.setSelectionProvider(selectionProviderOnFocusGain);
	widget.addFocusListener(this);
	widget.addDisposeListener(this);
}
 
Example 2
Source File: TypingRunDetector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds the selection listener to the text widget underlying the viewer, if
 * not already done.
 */
private void ensureSelectionListenerAdded() {
	if (fSelectionListener == null) {
		fSelectionListener= new SelectionListener();
		StyledText textWidget= fViewer.getTextWidget();
		textWidget.addFocusListener(fSelectionListener);
		textWidget.addKeyListener(fSelectionListener);
		textWidget.addMouseListener(fSelectionListener);
	}
}
 
Example 3
Source File: FindReplaceDialog.java    From Rel with Apache License 2.0 5 votes vote down vote up
/**
 * Create the dialog.
 * 
 * @param parent
 * @param style
 */
public FindReplaceDialog(Shell parent, StyledText text) {
	super(parent, SWT.DIALOG_TRIM | SWT.RESIZE);
	this.text = text;
	setText("Find/Replace");
	text.addExtendedModifyListener(textModifyListener);
	text.addSelectionListener(textSelectionListener);
	text.addFocusListener(textFocusListener);
	text.addLineBackgroundListener(textLineBackgroundListener);
	originalTextSelection = text.getSelectionRange();
}
 
Example 4
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);
}