Search in sources :

Example 11 with IStructuredSelection

use of org.eclipse.jface.viewers.IStructuredSelection in project translationstudio8 by heartsome.

the class OpenActionProvider method fillContextMenu.

public void fillContextMenu(IMenuManager aMenu) {
    if (!contribute || getContext().getSelection().isEmpty()) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
    openFileAction.selectionChanged(selection);
    if (openFileAction.isEnabled()) {
        aMenu.insertAfter(ICommonMenuConstants.GROUP_OPEN, openFileAction);
    }
//		addOpenWithMenu(aMenu);
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 12 with IStructuredSelection

use of org.eclipse.jface.viewers.IStructuredSelection in project translationstudio8 by heartsome.

the class OpenActionProvider method fillActionBars.

public void fillActionBars(IActionBars theActionBars) {
    if (!contribute) {
        return;
    }
    IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof IFile) {
        openFileAction.selectionChanged(selection);
        theActionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, openFileAction);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 13 with IStructuredSelection

use of org.eclipse.jface.viewers.IStructuredSelection in project translationstudio8 by heartsome.

the class ResourceMgmtActionProvider method makeActions.

protected void makeActions() {
    IShellProvider sp = new IShellProvider() {

        public Shell getShell() {
            return shell;
        }
    };
    openProjectAction = new OpenResourceAction(sp);
    openProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_openProjectAction);
    closeProjectAction = new CloseResourceAction(sp);
    closeProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_closeProjectAction);
    //
    // closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(sp);
    // closeUnrelatedProjectsAction.setText("关闭无关的项目");
    refreshAction = new RefreshAction(sp) {

        public void run() {
            final IStatus[] errorStatus = new IStatus[1];
            errorStatus[0] = Status.OK_STATUS;
            final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus);
            WorkspaceJob job = new //$NON-NLS-1$
            WorkspaceJob(//$NON-NLS-1$
            "refresh") {

                public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                    try {
                        op.run(monitor);
                        if (shell != null && !shell.isDisposed()) {
                            shell.getDisplay().asyncExec(new Runnable() {

                                public void run() {
                                    StructuredViewer viewer = getActionSite().getStructuredViewer();
                                    if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
                                        viewer.refresh();
                                    }
                                }
                            });
                        }
                    } catch (InvocationTargetException e) {
                        String msg = NLS.bind(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_logTitle, getClass().getName(), e.getTargetException());
                        throw new CoreException(new Status(IStatus.ERROR, NavigatorPlugin.PLUGIN_ID, IStatus.ERROR, msg, e.getTargetException()));
                    } catch (InterruptedException e) {
                        return Status.CANCEL_STATUS;
                    }
                    return errorStatus[0];
                }
            };
            ISchedulingRule rule = op.getRule();
            if (rule != null) {
                job.setRule(rule);
            }
            job.setUser(true);
            job.schedule();
        }
    };
    refreshAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_refreshAction);
    //$NON-NLS-1$
    refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));
    //$NON-NLS-1$
    refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));
    refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);
    if (getContext() == null) {
        refreshAction.setEnabled(false);
    } else {
        IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
        refreshAction.selectionChanged(selection);
        refreshAction.setEnabled(!selection.isEmpty());
    }
// buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD);
// buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);
}
Also used : IShellProvider(org.eclipse.jface.window.IShellProvider) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CloseResourceAction(org.eclipse.ui.actions.CloseResourceAction) IStatus(org.eclipse.core.runtime.IStatus) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) OpenResourceAction(org.eclipse.ui.actions.OpenResourceAction) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RefreshAction(org.eclipse.ui.actions.RefreshAction) CoreException(org.eclipse.core.runtime.CoreException) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer)

Example 14 with IStructuredSelection

use of org.eclipse.jface.viewers.IStructuredSelection in project translationstudio8 by heartsome.

the class WorkManagementActionProvider method setContext.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.actions.ActionGroup#setContext(org.eclipse.ui.actions.
	 * ActionContext)
	 */
public void setContext(ActionContext context) {
    super.setContext(context);
    if (context != null && context.getSelection() instanceof IStructuredSelection) {
        IStructuredSelection sSel = (IStructuredSelection) context.getSelection();
        addBookmarkAction.selectionChanged(sSel);
        addTaskAction.selectionChanged(sSel);
    } else {
        addBookmarkAction.selectionChanged(StructuredSelection.EMPTY);
        addTaskAction.selectionChanged(StructuredSelection.EMPTY);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 15 with IStructuredSelection

use of org.eclipse.jface.viewers.IStructuredSelection in project translationstudio8 by heartsome.

the class PortingActionProvider method fillContextMenu.

public void fillContextMenu(IMenuManager aMenu) {
    if (!contribute) {
        return;
    }
    Assert.isTrue(!disposed);
    ISelection selection = getContext().getSelection();
    if (!(selection instanceof IStructuredSelection) || ((IStructuredSelection) selection).size() > 1) {
        addSimplePortingMenus(aMenu);
    } else {
        addImportMenu(aMenu);
        addExportMenu(aMenu);
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)600 ISelection (org.eclipse.jface.viewers.ISelection)177 GridData (org.eclipse.swt.layout.GridData)97 ArrayList (java.util.ArrayList)88 Composite (org.eclipse.swt.widgets.Composite)80 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)78 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)77 SelectionEvent (org.eclipse.swt.events.SelectionEvent)74 GridLayout (org.eclipse.swt.layout.GridLayout)73 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)67 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)60 List (java.util.List)56 TableViewer (org.eclipse.jface.viewers.TableViewer)51 Button (org.eclipse.swt.widgets.Button)51 Iterator (java.util.Iterator)46 IResource (org.eclipse.core.resources.IResource)42 RepositoryNode (org.talend.repository.model.RepositoryNode)41 IFile (org.eclipse.core.resources.IFile)40 TreeViewer (org.eclipse.jface.viewers.TreeViewer)39 Label (org.eclipse.swt.widgets.Label)38