Search in sources :

Example 56 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project translationstudio8 by heartsome.

the class MenuItemProviders method autoResizeRowMenuItemProvider.

public static IMenuItemProvider autoResizeRowMenuItemProvider() {
    return new IMenuItemProvider() {

        public void addMenuItem(final NatTable natTable, final Menu popupMenu) {
            MenuItem autoResizeRows = new MenuItem(popupMenu, SWT.PUSH);
            autoResizeRows.setText("Auto resize row");
            autoResizeRows.setEnabled(true);
            autoResizeRows.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent event) {
                    int rowPosition = getNatEventData(event).getRowPosition();
                    natTable.doCommand(new InitializeAutoResizeRowsCommand(natTable, rowPosition, natTable.getConfigRegistry(), new GC(natTable)));
                }
            });
        }
    };
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) InitializeAutoResizeRowsCommand(net.sourceforge.nattable.resize.command.InitializeAutoResizeRowsCommand) NatTable(net.sourceforge.nattable.NatTable) MenuItem(org.eclipse.swt.widgets.MenuItem) Menu(org.eclipse.swt.widgets.Menu) GC(org.eclipse.swt.graphics.GC)

Example 57 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.

the class ScriptValuesModDialog method buildingFolderMenu.

private void buildingFolderMenu() {
    // styledTextPopupmenu = new Menu(, SWT.POP_UP);
    MenuItem addNewItem = new MenuItem(cMenu, SWT.PUSH);
    addNewItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.AddNewTab"));
    addNewItem.setImage(imageAddScript);
    addNewItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            addCtab("", "", ADD_BLANK);
        }
    });
    MenuItem copyItem = new MenuItem(cMenu, SWT.PUSH);
    copyItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.AddCopy"));
    copyItem.setImage(imageDuplicateScript);
    copyItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            CTabItem item = folder.getSelection();
            StyledTextComp st = (StyledTextComp) item.getControl();
            addCtab(item.getText(), st.getText(), ADD_COPY);
        }
    });
    new MenuItem(cMenu, SWT.SEPARATOR);
    MenuItem setActiveScriptItem = new MenuItem(cMenu, SWT.PUSH);
    setActiveScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.SetTransformScript"));
    setActiveScriptItem.setImage(imageActiveScript);
    setActiveScriptItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            CTabItem item = folder.getSelection();
            for (int i = 0; i < folder.getItemCount(); i++) {
                if (folder.getItem(i).equals(item)) {
                    if (item.getImage().equals(imageActiveScript)) {
                        strActiveScript = "";
                    } else if (item.getImage().equals(imageActiveStartScript)) {
                        strActiveStartScript = "";
                    } else if (item.getImage().equals(imageActiveEndScript)) {
                        strActiveEndScript = "";
                    }
                    item.setImage(imageActiveScript);
                    strActiveScript = item.getText();
                } else if (folder.getItem(i).getImage().equals(imageActiveScript)) {
                    folder.getItem(i).setImage(imageInactiveScript);
                }
            }
            modifyScriptTree(item, SET_ACTIVE_ITEM);
        }
    });
    MenuItem setStartScriptItem = new MenuItem(cMenu, SWT.PUSH);
    setStartScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.SetStartScript"));
    setStartScriptItem.setImage(imageActiveStartScript);
    setStartScriptItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            CTabItem item = folder.getSelection();
            for (int i = 0; i < folder.getItemCount(); i++) {
                if (folder.getItem(i).equals(item)) {
                    if (item.getImage().equals(imageActiveScript)) {
                        strActiveScript = "";
                    } else if (item.getImage().equals(imageActiveStartScript)) {
                        strActiveStartScript = "";
                    } else if (item.getImage().equals(imageActiveEndScript)) {
                        strActiveEndScript = "";
                    }
                    item.setImage(imageActiveStartScript);
                    strActiveStartScript = item.getText();
                } else if (folder.getItem(i).getImage().equals(imageActiveStartScript)) {
                    folder.getItem(i).setImage(imageInactiveScript);
                }
            }
            modifyScriptTree(item, SET_ACTIVE_ITEM);
        }
    });
    MenuItem setEndScriptItem = new MenuItem(cMenu, SWT.PUSH);
    setEndScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.SetEndScript"));
    setEndScriptItem.setImage(imageActiveEndScript);
    setEndScriptItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            CTabItem item = folder.getSelection();
            for (int i = 0; i < folder.getItemCount(); i++) {
                if (folder.getItem(i).equals(item)) {
                    if (item.getImage().equals(imageActiveScript)) {
                        strActiveScript = "";
                    } else if (item.getImage().equals(imageActiveStartScript)) {
                        strActiveStartScript = "";
                    } else if (item.getImage().equals(imageActiveEndScript)) {
                        strActiveEndScript = "";
                    }
                    item.setImage(imageActiveEndScript);
                    strActiveEndScript = item.getText();
                } else if (folder.getItem(i).getImage().equals(imageActiveEndScript)) {
                    folder.getItem(i).setImage(imageInactiveScript);
                }
            }
            modifyScriptTree(item, SET_ACTIVE_ITEM);
        }
    });
    new MenuItem(cMenu, SWT.SEPARATOR);
    MenuItem setRemoveScriptItem = new MenuItem(cMenu, SWT.PUSH);
    setRemoveScriptItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.RemoveScriptType"));
    setRemoveScriptItem.setImage(imageInactiveScript);
    setRemoveScriptItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            CTabItem item = folder.getSelection();
            input.setChanged(true);
            if (item.getImage().equals(imageActiveScript)) {
                strActiveScript = "";
            } else if (item.getImage().equals(imageActiveStartScript)) {
                strActiveStartScript = "";
            } else if (item.getImage().equals(imageActiveEndScript)) {
                strActiveEndScript = "";
            }
            item.setImage(imageInactiveScript);
        }
    });
    folder.setMenu(cMenu);
}
Also used : StyledTextComp(org.pentaho.di.ui.core.widget.StyledTextComp) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 58 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.

the class ScriptValuesModDialog method buildingTreeMenu.

private void buildingTreeMenu() {
    // styledTextPopupmenu = new Menu(, SWT.POP_UP);
    MenuItem addDeleteItem = new MenuItem(tMenu, SWT.PUSH);
    addDeleteItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Delete.Label"));
    addDeleteItem.setImage(imageDeleteScript);
    addDeleteItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            if (wTree.getSelectionCount() <= 0) {
                return;
            }
            TreeItem tItem = wTree.getSelection()[0];
            if (tItem != null) {
                MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
                messageBox.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.DeleteItem.Label"));
                messageBox.setMessage(BaseMessages.getString(PKG, "ScriptValuesDialogMod.ConfirmDeleteItem.Label", tItem.getText()));
                switch(messageBox.open()) {
                    case SWT.YES:
                        modifyCTabItem(tItem, DELETE_ITEM, "");
                        tItem.dispose();
                        input.setChanged();
                        break;
                    default:
                        break;
                }
            }
        }
    });
    MenuItem renItem = new MenuItem(tMenu, SWT.PUSH);
    renItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Rename.Label"));
    renItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            renameFunction(wTree.getSelection()[0]);
        }
    });
    new MenuItem(tMenu, SWT.SEPARATOR);
    MenuItem helpItem = new MenuItem(tMenu, SWT.PUSH);
    helpItem.setText(BaseMessages.getString(PKG, "ScriptValuesDialogMod.Sample.Label"));
    helpItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            String strFunctionName = wTree.getSelection()[0].getText();
            String strFunctionNameWithArgs = strFunctionName;
            strFunctionName = strFunctionName.substring(0, strFunctionName.indexOf('('));
            String strHelpTabName = strFunctionName + "_Sample";
            if (getCTabPosition(strHelpTabName) == -1) {
                addCtab(strHelpTabName, scVHelp.getSample(strFunctionName, strFunctionNameWithArgs), 0);
            }
            if (getCTabPosition(strHelpTabName) != -1) {
                setActiveCtab(strHelpTabName);
            }
        }
    });
    wTree.addListener(SWT.MouseDown, new Listener() {

        public void handleEvent(Event e) {
            if (wTree.getSelectionCount() <= 0) {
                return;
            }
            TreeItem tItem = wTree.getSelection()[0];
            if (tItem != null) {
                TreeItem pItem = tItem.getParentItem();
                if (pItem != null && pItem.equals(wTreeScriptsItem)) {
                    if (folder.getItemCount() > 1) {
                        tMenu.getItem(0).setEnabled(true);
                    } else {
                        tMenu.getItem(0).setEnabled(false);
                    }
                    tMenu.getItem(1).setEnabled(true);
                    tMenu.getItem(3).setEnabled(false);
                } else if (tItem.equals(wTreeClassesitem)) {
                    tMenu.getItem(0).setEnabled(false);
                    tMenu.getItem(1).setEnabled(false);
                    tMenu.getItem(3).setEnabled(false);
                } else if (tItem.getData() != null && tItem.getData().equals("jsFunction")) {
                    tMenu.getItem(0).setEnabled(false);
                    tMenu.getItem(1).setEnabled(false);
                    tMenu.getItem(3).setEnabled(true);
                } else {
                    tMenu.getItem(0).setEnabled(false);
                    tMenu.getItem(1).setEnabled(false);
                    tMenu.getItem(3).setEnabled(false);
                }
            }
        }
    });
    wTree.setMenu(tMenu);
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeItem(org.eclipse.swt.widgets.TreeItem) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 59 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.

the class UserDefinedJavaClassDialog method buildingTreeMenu.

private void buildingTreeMenu() {
    // styledTextPopupmenu = new Menu(, SWT.POP_UP);
    MenuItem addDeleteItem = new MenuItem(tMenu, SWT.PUSH);
    addDeleteItem.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Delete.Label"));
    addDeleteItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            if (wTree.getSelectionCount() <= 0) {
                return;
            }
            TreeItem tItem = wTree.getSelection()[0];
            if (tItem != null) {
                MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
                messageBox.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.DeleteItem.Label"));
                messageBox.setMessage(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.ConfirmDeleteItem.Label", tItem.getText()));
                switch(messageBox.open()) {
                    case SWT.YES:
                        modifyCTabItem(tItem, TabActions.DELETE_ITEM, "");
                        tItem.dispose();
                        input.setChanged();
                        break;
                    default:
                        break;
                }
            }
        }
    });
    MenuItem renItem = new MenuItem(tMenu, SWT.PUSH);
    renItem.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Rename.Label"));
    renItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            renameFunction(wTree.getSelection()[0]);
        }
    });
    new MenuItem(tMenu, SWT.SEPARATOR);
    MenuItem helpItem = new MenuItem(tMenu, SWT.PUSH);
    helpItem.setText(BaseMessages.getString(PKG, "UserDefinedJavaClassDialog.Sample.Label"));
    helpItem.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event e) {
            String snippitFullName = wTree.getSelection()[0].getText();
            String sampleTabName = snippitFullName.replace("Implement ", "").replace(' ', '_') + "_Sample";
            if (getCTabPosition(sampleTabName) == -1) {
                addCtab(sampleTabName, snippitsHelper.getSample(snippitFullName), TabAddActions.ADD_DEFAULT);
            }
            if (getCTabPosition(sampleTabName) != -1) {
                setActiveCtab(sampleTabName);
            }
        }
    });
    wTree.addListener(SWT.MouseDown, new Listener() {

        public void handleEvent(Event e) {
            if (wTree.getSelectionCount() <= 0) {
                return;
            }
            TreeItem tItem = wTree.getSelection()[0];
            if (tItem != null) {
                TreeItem pItem = tItem.getParentItem();
                if (pItem != null && pItem.equals(wTreeClassesItem)) {
                    if (folder.getItemCount() > 1) {
                        tMenu.getItem(0).setEnabled(true);
                    } else {
                        tMenu.getItem(0).setEnabled(false);
                    }
                    tMenu.getItem(1).setEnabled(true);
                    tMenu.getItem(3).setEnabled(false);
                } else if (tItem.equals(wTreeClassesItem)) {
                    tMenu.getItem(0).setEnabled(false);
                    tMenu.getItem(1).setEnabled(false);
                    tMenu.getItem(3).setEnabled(false);
                } else if (pItem != null && pItem.getData() != null && pItem.getData().equals("Snippits Category")) {
                    tMenu.getItem(0).setEnabled(false);
                    tMenu.getItem(1).setEnabled(false);
                    tMenu.getItem(3).setEnabled(true);
                } else {
                    tMenu.getItem(0).setEnabled(false);
                    tMenu.getItem(1).setEnabled(false);
                    tMenu.getItem(3).setEnabled(false);
                }
            }
        }
    });
    wTree.setMenu(tMenu);
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) TreeItem(org.eclipse.swt.widgets.TreeItem) FocusEvent(org.eclipse.swt.events.FocusEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CTabFolderEvent(org.eclipse.swt.custom.CTabFolderEvent) MouseEvent(org.eclipse.swt.events.MouseEvent) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 60 with MenuItem

use of org.eclipse.swt.widgets.MenuItem in project pentaho-kettle by pentaho.

the class JobGraph method addToolBar.

private void addToolBar() {
    try {
        toolbar = (XulToolbar) getXulDomContainer().getDocumentRoot().getElementById("nav-toolbar");
        ToolBar swtToolbar = (ToolBar) toolbar.getManagedObject();
        swtToolbar.setBackground(GUIResource.getInstance().getColorDemoGray());
        swtToolbar.pack();
        // Added 1/11/2016 to implement dropdown option for "Run"
        ToolItem runItem = new ToolItem(swtToolbar, SWT.DROP_DOWN, 0);
        runItem.setImage(GUIResource.getInstance().getImage("ui/images/run.svg"));
        runItem.setToolTipText(BaseMessages.getString(PKG, "Spoon.Tooltip.RunTranformation"));
        runItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (e.detail == SWT.DROP_DOWN) {
                    Menu menu = new Menu(shell, SWT.POP_UP);
                    MenuItem item1 = new MenuItem(menu, SWT.PUSH);
                    item1.setText(BaseMessages.getString(PKG, "Spoon.Run.Run"));
                    item1.setAccelerator(SWT.F9);
                    item1.addSelectionListener(new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent e1) {
                            runJob();
                        }
                    });
                    MenuItem item2 = new MenuItem(menu, SWT.PUSH);
                    item2.setText(BaseMessages.getString(PKG, "Spoon.Run.RunOptions"));
                    item2.setAccelerator(SWT.F8);
                    item2.addSelectionListener(new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent e2) {
                            runOptionsJob();
                        }
                    });
                    menu.setLocation(shell.getDisplay().map(mainComposite.getParent(), null, mainComposite.getLocation()));
                    menu.setVisible(true);
                } else {
                    runJob();
                }
            }
        });
        // Hack alert : more XUL limitations...
        // 
        ToolItem sep = new ToolItem(swtToolbar, SWT.SEPARATOR);
        zoomLabel = new Combo(swtToolbar, SWT.DROP_DOWN);
        zoomLabel.setItems(TransPainter.magnificationDescriptions);
        zoomLabel.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent arg0) {
                readMagnification();
            }
        });
        zoomLabel.addKeyListener(new KeyAdapter() {

            public void keyPressed(KeyEvent event) {
                if (event.character == SWT.CR) {
                    readMagnification();
                }
            }
        });
        setZoomLabel();
        zoomLabel.pack();
        sep.setWidth(80);
        sep.setControl(zoomLabel);
        swtToolbar.pack();
    } catch (Throwable t) {
        log.logError(Const.getStackTracker(t));
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Title"), BaseMessages.getString(PKG, "Spoon.Exception.ErrorReadingXULFile.Message", XUL_FILE_JOB_GRAPH), new Exception(t));
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MenuItem(org.eclipse.swt.widgets.MenuItem) Combo(org.eclipse.swt.widgets.Combo) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException) KeyEvent(org.eclipse.swt.events.KeyEvent) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) XulMenu(org.pentaho.ui.xul.containers.XulMenu) Menu(org.eclipse.swt.widgets.Menu) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

MenuItem (org.eclipse.swt.widgets.MenuItem)386 Menu (org.eclipse.swt.widgets.Menu)259 SelectionEvent (org.eclipse.swt.events.SelectionEvent)247 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)208 Event (org.eclipse.swt.widgets.Event)58 ArrayList (java.util.ArrayList)55 Point (org.eclipse.swt.graphics.Point)52 GridData (org.eclipse.swt.layout.GridData)49 Listener (org.eclipse.swt.widgets.Listener)48 SelectionListener (org.eclipse.swt.events.SelectionListener)46 Composite (org.eclipse.swt.widgets.Composite)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Rectangle (org.eclipse.swt.graphics.Rectangle)35 Label (org.eclipse.swt.widgets.Label)34 Shell (org.eclipse.swt.widgets.Shell)34 Table (org.eclipse.swt.widgets.Table)33 MenuEvent (org.eclipse.swt.events.MenuEvent)32 Button (org.eclipse.swt.widgets.Button)32 List (java.util.List)31 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)29