Search in sources :

Example 1 with TreeObject

use of org.mongodb.meclipse.views.objects.TreeObject in project meclipse by flaper87.

the class MeclipseView method makeActions.

private void makeActions() {
    final MeclipseView mView = this;
    connection = new Action() {

        public void run() {
            ConnectionWizard wizard = new ConnectionWizard();
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            WizardDialog dialog = new WizardDialog(shell, wizard);
            dialog.create();
            dialog.open();
            mView.refreshMe();
        }
    };
    connection.setText(getCaption("connection.new"));
    connection.setToolTipText(getCaption("connection.new"));
    connection.setImageDescriptor(Images.getDescriptor(Images.PageCommit));
    doubleClickAction = new Action() {

        public void run() {
            ISelection selection = viewer.getSelection();
            TreeObject obj = (TreeObject) ((IStructuredSelection) selection).getFirstElement();
            obj.doubleClickAction();
        }
    };
}
Also used : Action(org.eclipse.jface.action.Action) Shell(org.eclipse.swt.widgets.Shell) ConnectionWizard(org.mongodb.meclipse.wizards.ConnectionWizard) ISelection(org.eclipse.jface.viewers.ISelection) TreeObject(org.mongodb.meclipse.views.objects.TreeObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with TreeObject

use of org.mongodb.meclipse.views.objects.TreeObject in project meclipse by flaper87.

the class MeclipseView method hookContextMenu.

private void hookContextMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            if (selection.isEmpty()) {
                MeclipseView.this.fillContextMenu(manager);
                return;
            }
            TreeObject obj = (TreeObject) selection.getFirstElement();
            manager.add(new Separator());
            obj.fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(menuMgr, viewer);
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) TreeObject(org.mongodb.meclipse.views.objects.TreeObject) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener) Separator(org.eclipse.jface.action.Separator)

Aggregations

IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TreeObject (org.mongodb.meclipse.views.objects.TreeObject)2 Action (org.eclipse.jface.action.Action)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1 ISelection (org.eclipse.jface.viewers.ISelection)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 Menu (org.eclipse.swt.widgets.Menu)1 Shell (org.eclipse.swt.widgets.Shell)1 ConnectionWizard (org.mongodb.meclipse.wizards.ConnectionWizard)1