Search in sources :

Example 41 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project dbeaver by dbeaver.

the class AggregateColumnsPanel method createContents.

@Override
public Control createContents(final IResultSetPresentation presentation, Composite parent) {
    this.presentation = presentation;
    this.panelSettings = ResultSetUtils.getViewerSettings(SETTINGS_SECTION_AGGREGATE);
    loadSettings();
    this.aggregateTable = new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION);
    this.aggregateTable.setHeaderVisible(true);
    this.aggregateTable.setLinesVisible(true);
    new TreeColumn(this.aggregateTable, SWT.LEFT).setText("Function");
    new TreeColumn(this.aggregateTable, SWT.RIGHT).setText("Value");
    if (this.presentation instanceof ISelectionProvider) {
        ((ISelectionProvider) this.presentation).addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                if (presentation.getController().getVisiblePanel() == AggregateColumnsPanel.this) {
                    refresh(false);
                }
            }
        });
    }
    MenuManager menuMgr = new MenuManager();
    menuMgr.addMenuListener(new IMenuListener() {

        @Override
        public void menuAboutToShow(IMenuManager manager) {
            manager.add(new CopyAction());
            manager.add(new CopyAllAction());
            manager.add(new Separator());
            fillToolBar(manager);
        }
    });
    menuMgr.setRemoveAllWhenShown(true);
    this.aggregateTable.setMenu(menuMgr.createContextMenu(this.aggregateTable));
    aggregateTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            presentation.getController().updatePanelActions();
        }
    });
    return this.aggregateTable;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 42 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project erlide_eclipse by erlang.

the class MarkOccurencesSupport method installOccurrencesFinder.

protected void installOccurrencesFinder(final boolean forceUpdate) {
    fMarkOccurrenceAnnotations = true;
    fPostSelectionListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final ISelection selection = event.getSelection();
            editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) selection, editor.getModule());
        }
    };
    final ISelectionProvider selectionProvider = editor.getSelectionProvider();
    if (selectionProvider != null) {
        ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fPostSelectionListener);
        if (forceUpdate) {
            fForcedMarkOccurrencesSelection = selectionProvider.getSelection();
            final IErlModule module = editor.getModule();
            if (module != null) {
                editor.markOccurencesHandler.updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, module);
            }
        }
    }
    if (fOccurrencesFinderJobCanceler == null) {
        fOccurrencesFinderJobCanceler = new OccurrencesFinderJobCanceler();
        fOccurrencesFinderJobCanceler.install();
    }
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ISelection(org.eclipse.jface.viewers.ISelection) IErlModule(org.erlide.engine.model.root.IErlModule) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 43 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project erlide_eclipse by erlang.

the class ImplementorsSearchGroup method dispose.

/*
     * Overrides method declared in ActionGroup
     */
@Override
public void dispose() {
    final ISelectionProvider provider = fSite.getSelectionProvider();
    if (provider != null) {
        disposeAction(fFindImplementorsAction, provider);
        disposeAction(fFindImplementorsInProjectAction, provider);
        disposeAction(fFindImplementorsInWorkingSetAction, provider);
    }
    fFindImplementorsAction = null;
    fFindImplementorsInProjectAction = null;
    fFindImplementorsInWorkingSetAction = null;
    updateGlobalActionHandlers();
    super.dispose();
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 44 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project liferay-ide by liferay.

the class KaleoContentAssistProcessor method _addProposals.

private void _addProposals(ContentAssistRequest request, KaleoTemplateContext context) {
    ISelectionProvider selectionProvider = _sourceViewer.getSelectionProvider();
    ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
    int offset = request.getReplacementBeginPosition();
    if (selection.getOffset() == offset) {
        offset = selection.getOffset() + selection.getLength();
    }
    String prefix = extractPrefix(_sourceViewer, offset);
    _addProposals(request, context, _getCurrentNode(request), prefix);
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 45 with ISelectionProvider

use of org.eclipse.jface.viewers.ISelectionProvider in project liferay-ide by liferay.

the class AddMacroLibrary method run.

public void run(IAction action) {
    ISelectionProvider provider = part.getSite().getSelectionProvider();
    if (null != provider) {
        if (provider.getSelection() instanceof IStructuredSelection) {
            try {
                IStructuredSelection selection = (IStructuredSelection) provider.getSelection();
                Object[] obj = selection.toArray();
                List documents = new ArrayList();
                for (int i = 0; i < obj.length; i++) {
                    if (obj[i] instanceof IFile) {
                        IFile file = (IFile) obj[i];
                        documents.add(file);
                    } else if (obj[i] instanceof JarEntryFile) {
                        JarEntryFile jef = (JarEntryFile) obj[i];
                        documents.add(jef);
                        System.out.println(jef.getFullPath().makeAbsolute());
                        System.out.println(jef.getFullPath().makeRelative());
                        IPath path = jef.getFullPath();
                        System.out.println(path);
                        System.out.println(jef.getName());
                        IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(jef.getFullPath());
                        System.out.println(resource);
                    } else if (obj[i] instanceof IStorage) {
                    }
                }
                IProject project = null;
                if (documents.size() > 0) {
                    // what project?
                    HashSet projects = new HashSet();
                    IProject[] p = ResourcesPlugin.getWorkspace().getRoot().getProjects();
                    for (int i = 0; i < p.length; i++) {
                        projects.add(p[i]);
                    }
                    ProjectSelectionDialog dialog = new ProjectSelectionDialog(Display.getCurrent().getActiveShell(), projects);
                    dialog.setTitle(Messages.AddMacroLibrary_Title);
                    dialog.setMessage(Messages.AddMacroLibrary_Message);
                    int rtn = dialog.open();
                    if (rtn == IDialogConstants.OK_ID) {
                        if (dialog.getFirstResult() instanceof IJavaProject) {
                            project = ((IJavaProject) dialog.getFirstResult()).getProject();
                        } else {
                            MessageDialog.openError(Display.getCurrent().getActiveShell(), Messages.AddMacroLibrary_Error, Messages.AddMacroLibrary_ErrorDesc);
                        }
                    }
                }
                if (null != project) {
                    ConfigurationManager.getInstance(project).associateMappingLibraries(documents, Display.getCurrent().getActiveShell());
                }
            } catch (Exception e) {
                Plugin.error(e);
            }
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) ProjectSelectionDialog(org.eclipse.jdt.internal.ui.preferences.ProjectSelectionDialog) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStorage(org.eclipse.core.resources.IStorage) IProject(org.eclipse.core.resources.IProject) IJavaProject(org.eclipse.jdt.core.IJavaProject) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ArrayList(java.util.ArrayList) List(java.util.List) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) IResource(org.eclipse.core.resources.IResource) HashSet(java.util.HashSet)

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