Search in sources :

Example 31 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.

the class DeleteLineAction method getSelection.

/**
 * Returns the editor's selection.
 *
 * @param editor the editor
 * @return the editor's selection
 */
private static ITextSelection getSelection(ITextEditor editor) {
    ISelectionProvider selectionProvider = editor.getSelectionProvider();
    if (selectionProvider == null)
        return null;
    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof ITextSelection))
        return null;
    return (ITextSelection) selection;
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 32 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.

the class IncrementalFindTarget method install.

/**
 * 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);
    ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
    if (commandService != null)
        commandService.addExecutionListener(this);
    fInstalled = true;
}
Also used : ITextViewerExtension(org.eclipse.jface.text.ITextViewerExtension) StyledText(org.eclipse.swt.custom.StyledText) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 33 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.

the class JoinLinesAction method getSelection.

/**
 * Returns the editor's selection.
 *
 * @param editor the editor
 * @return the editor's selection
 */
private static ITextSelection getSelection(ITextEditor editor) {
    ISelectionProvider selectionProvider = editor.getSelectionProvider();
    if (selectionProvider == null)
        return null;
    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof ITextSelection))
        return null;
    return (ITextSelection) selection;
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 34 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.

the class AbstractTemplatesPage method setupSelectionProvider.

/**
 * Setup a selection listener to monitor the editor
 */
private void setupSelectionProvider() {
    ISelectionProvider selectionProvider = fViewer.getSelectionProvider();
    fSelectionChangedListener = new SelectionChangedListener();
    if (selectionProvider instanceof IPostSelectionProvider)
        ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fSelectionChangedListener);
    else
        selectionProvider.addSelectionChangedListener(fSelectionChangedListener);
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 35 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.

the class QuickDiffRestoreAction method getSelection.

/**
 * Returns the selection of the editor this action belongs to.
 *
 * @return the editor's selection, or <code>null</code>
 */
protected ITextSelection getSelection() {
    if (getTextEditor() == null)
        return null;
    ISelectionProvider sp = getTextEditor().getSelectionProvider();
    if (sp == null)
        return null;
    ISelection s = sp.getSelection();
    if (s instanceof ITextSelection)
        return (ITextSelection) s;
    return null;
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection) ITextSelection(org.eclipse.jface.text.ITextSelection)

Aggregations

ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)170 ISelection (org.eclipse.jface.viewers.ISelection)61 TreeViewer (org.eclipse.jface.viewers.TreeViewer)40 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)30 ITextSelection (org.eclipse.jface.text.ITextSelection)26 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)24 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)23 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)21 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)17 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)15 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)13 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)13 IPostSelectionProvider (org.eclipse.jface.viewers.IPostSelectionProvider)13 IEditorPart (org.eclipse.ui.IEditorPart)13 Shell (org.eclipse.swt.widgets.Shell)12 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)10 IDocument (org.eclipse.jface.text.IDocument)9