Search in sources :

Example 1 with MdwMenuManager

use of com.centurylink.mdw.plugin.actions.MdwMenuManager in project mdw-designer by CenturyLinkCloud.

the class AutomatedTestView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    GridLayout gridLayout = new GridLayout();
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;
    parent.setLayout(gridLayout);
    counterComposite = createProgressCountPanel(parent);
    counterComposite.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
    SashForm sashForm = createSashForm(parent);
    sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
    // action group
    actionGroup = new AutomatedTestActionGroup(this);
    IActionBars actionBars = getViewSite().getActionBars();
    actionGroup.fillActionBars(actionBars);
    // context menu
    MenuManager menuMgr = new MdwMenuManager("Automated Test");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(this);
    contextMenu = menuMgr.createContextMenu(treeViewer.getTree());
    treeViewer.getTree().setMenu(contextMenu);
    getSite().registerContextMenu(menuMgr, treeViewer);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, MdwPlugin.getPluginId() + ".toolbox_help");
}
Also used : MdwMenuManager(com.centurylink.mdw.plugin.actions.MdwMenuManager) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) MdwMenuManager(com.centurylink.mdw.plugin.actions.MdwMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IActionBars(org.eclipse.ui.IActionBars)

Example 2 with MdwMenuManager

use of com.centurylink.mdw.plugin.actions.MdwMenuManager in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    treeViewer = new TreeViewer(parent) {

        protected void handleTreeExpand(TreeEvent event) {
            if (event.item.getData() instanceof WorkflowProject) {
                final WorkflowProject project = (WorkflowProject) event.item.getData();
                if (project.isFilePersist() && !project.isRemote()) {
                    // authentication not needed
                    project.setUser(new User(System.getProperty("user.name")));
                } else {
                    // user authentication
                    Boolean authenticated = project.isAuthenticated();
                    if (authenticated == null) {
                        // has to be in a separate
                        // thread to take effect
                        event.item.getDisplay().asyncExec(new Runnable() {

                            public void run() {
                                treeViewer.collapseToLevel(project, TreeViewer.ALL_LEVELS);
                            }
                        });
                        return;
                    }
                    if (!authenticated) {
                        LoginDialog loginDialog = new LoginDialog(MdwPlugin.getShell(), project);
                        int res = loginDialog.open();
                        if (res == Dialog.CANCEL || !project.isAuthenticated()) {
                            // has
                            // to
                            // be
                            // in
                            // a
                            // separate
                            // thread
                            // to
                            // take
                            // effect
                            event.item.getDisplay().asyncExec(new Runnable() {

                                public void run() {
                                    treeViewer.collapseToLevel(project, TreeViewer.ALL_LEVELS);
                                }
                            });
                            return;
                        }
                    }
                    super.handleTreeExpand(event);
                    return;
                }
            }
            super.handleTreeExpand(event);
        }
    };
    ProcessExplorerContentProvider contentProvider = new ProcessExplorerContentProvider();
    // for
    WorkflowProjectManager.getInstance().addElementChangeListener(contentProvider);
    // project
    // adds/deletes
    treeViewer.setContentProvider(contentProvider);
    treeViewer.setLabelProvider(new ProcessExplorerLabelProvider());
    treeViewer.setInput(WorkflowProjectManager.getInstance().getWorkflowProjects());
    treeViewer.collapseAll();
    clipboard = new Clipboard(parent.getDisplay());
    // action group
    actionGroup = new ProcessExplorerActionGroup(this);
    actionGroup.fillActionBars(getViewSite().getActionBars());
    // context menu
    MenuManager menuMgr = new MdwMenuManager("Process Explorer");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(this);
    contextMenu = menuMgr.createContextMenu(treeViewer.getTree());
    treeViewer.getTree().setMenu(contextMenu);
    getSite().registerContextMenu(menuMgr, treeViewer);
    treeViewer.addOpenListener(new IOpenListener() {

        public void open(OpenEvent event) {
            for (Object item : getSelection().toList()) {
                if (!actionGroup.getActionHandler().open((WorkflowElement) item))
                    expand(item);
            }
        }
    });
    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            handleSelectionChanged((IStructuredSelection) event.getSelection());
        }
    });
    // drag and drop support
    Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
    dragSource = new ProcessExplorerDragSource(treeViewer);
    treeViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, transfers, dragSource);
    dropTarget = new ProcessExplorerDropTarget(treeViewer);
    treeViewer.addDropSupport(DND.DROP_MOVE | DND.DROP_COPY, transfers, dropTarget);
    contextListener = new ProcessExplorerContextListener();
    getSite().getPage().addPartListener(contextListener);
    MdwPlugin.getPluginWorkbench().getHelpSystem().setHelp(parent, MdwPlugin.getPluginId() + ".process_explorer_help");
}
Also used : MdwMenuManager(com.centurylink.mdw.plugin.actions.MdwMenuManager) User(com.centurylink.mdw.plugin.User) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TreeEvent(org.eclipse.swt.events.TreeEvent) IOpenListener(org.eclipse.jface.viewers.IOpenListener) MdwMenuManager(com.centurylink.mdw.plugin.actions.MdwMenuManager) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) TextTransfer(org.eclipse.swt.dnd.TextTransfer) Transfer(org.eclipse.swt.dnd.Transfer) Clipboard(org.eclipse.swt.dnd.Clipboard) LoginDialog(com.centurylink.mdw.plugin.designer.dialogs.LoginDialog) OpenEvent(org.eclipse.jface.viewers.OpenEvent)

Aggregations

MdwMenuManager (com.centurylink.mdw.plugin.actions.MdwMenuManager)2 IMenuManager (org.eclipse.jface.action.IMenuManager)2 MenuManager (org.eclipse.jface.action.MenuManager)2 User (com.centurylink.mdw.plugin.User)1 LoginDialog (com.centurylink.mdw.plugin.designer.dialogs.LoginDialog)1 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 IOpenListener (org.eclipse.jface.viewers.IOpenListener)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 OpenEvent (org.eclipse.jface.viewers.OpenEvent)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 SashForm (org.eclipse.swt.custom.SashForm)1 Clipboard (org.eclipse.swt.dnd.Clipboard)1 TextTransfer (org.eclipse.swt.dnd.TextTransfer)1 Transfer (org.eclipse.swt.dnd.Transfer)1 TreeEvent (org.eclipse.swt.events.TreeEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 IActionBars (org.eclipse.ui.IActionBars)1