/** * createMenu * * @param label label of the menu * @param editor SciNotes * @param key KeyStroke * @return createMenu */ public static Menu createMenu(String label, SciNotes editor, KeyStroke key) { StringTokenizer tokens = new StringTokenizer(label, ";\uff1b"); String labelLineNumbering = tokens.nextToken(); String labelOff = tokens.nextToken(); String labelNormal = tokens.nextToken(); String labelWhereami = tokens.nextToken(); final LineNumbersAction ln = new LineNumbersAction(labelLineNumbering, editor); String[] labels = new String[] {labelOff, labelNormal, labelWhereami}; final Menu menu = ScilabMenu.createMenu(); menu.setText(labelLineNumbering); ln.arr[getState()].setSelected(true); for (int i = 0; i < 3; i++) { ((JMenu) menu.getAsSimpleMenu()).add(ln.arr[i]); ln.arr[i].setText(labels[i]); } ((JMenu) menu.getAsSimpleMenu()) .addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { ln.arr[getState()].setSelected(true); } }); return menu; }
/** * Add a MenuItem to this MenuItem * * @param childMenuItem the MenuItem we want to add */ public void add(SwingScilabMenuItem childMenuItem) { System.out.println("SwingScilabMenuItem.add(SwingScilabMenuItem childMenuItem)"); if (meAsAMenu == null) { meAsAMenu = ScilabMenu.createMenu(); meAsAMenu.setText(getText()); ((SwingScilabMenu) meAsAMenu.getAsSimpleMenu()).add(childMenuItem); if (meAsACheckBoxMenuItem == null) { Container parent = getParent(); int index = parent.getComponentZOrder(this); parent.remove(this.getComponent()); parent.add((SwingScilabMenu) meAsAMenu.getAsSimpleMenu(), index); } else { Container parent = ((SwingScilabCheckBoxMenuItem) meAsACheckBoxMenuItem.getAsSimpleCheckBoxMenuItem()) .getParent(); int index = parent.getComponentZOrder( ((SwingScilabCheckBoxMenuItem) meAsACheckBoxMenuItem.getAsSimpleCheckBoxMenuItem())); parent.remove( ((SwingScilabCheckBoxMenuItem) meAsACheckBoxMenuItem.getAsSimpleCheckBoxMenuItem()) .getComponent()); parent.add((SwingScilabMenu) meAsAMenu.getAsSimpleMenu(), index); } } else { ((SwingScilabMenu) meAsAMenu.getAsSimpleMenu()).add(childMenuItem); } }
/** Create and display the context menu */ private void displayContextMenu() { ContextMenu menu = ScilabContextMenu.createContextMenu(); ModifyAction modify = new ModifyAction(SwingScilabVariableBrowser.this); menu.add(modify.createMenuItem()); DeleteAction delete = new DeleteAction(SwingScilabVariableBrowser.this); menu.add(delete.createMenuItem()); ExportToCsvAction csvExport = new ExportToCsvAction( (SwingScilabTab) SwingScilabVariableBrowser.this, UiDataMessages.EXPORTCSV); menu.add(csvExport.createMenuItem(SwingScilabVariableBrowser.this, UiDataMessages.EXPORTCSV)); Menu menuPlot = ScilabMenu.createMenu(); menuPlot.setText(UiDataMessages.PLOTALL); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "plot2d", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "Matplot", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "grayplot", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "Sgrayplot", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "champ", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "histplot", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "mesh", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "surf", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "hist3d", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "contour2d", false)); menuPlot.add( PlotAction.createMenuItem( (SwingScilabTab) SwingScilabVariableBrowser.this, "pie", false)); menu.add(menuPlot); menu.setVisible(true); ((SwingScilabContextMenu) menu.getAsSimpleContextMenu()) .setLocation( MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y); }
/** Creates the menuBar */ public void buildMenuBar() { menuBar = ScilabMenuBar.createMenuBar(); fileMenu = ScilabMenu.createMenu(); fileMenu.setText(MessagesGED.file); fileMenu.setMnemonic('F'); fileMenu.add(CloseAction.createMenu()); menuBar.add(fileMenu); }
/** * Append a CheckBoxMenuItem to a Scilab Menu * * @param newCheckBoxMenuItem the CheckBoxMenuItem to add to the Menu * @see org.scilab.modules.gui.menu.Menu#add(org.scilab.modules.gui.CheckBoxMenuItem) */ public void add(CheckBoxMenuItem newCheckBoxMenuItem) { if (meAsAMenu == null) { meAsAMenu = ScilabMenu.createMenu(); meAsAMenu.setText(getText()); meAsAMenu.add(newCheckBoxMenuItem); Container parent = getParent(); int index = parent.getComponentZOrder(this); parent.remove(this.getComponent()); parent.add((SwingScilabMenu) meAsAMenu.getAsSimpleMenu(), index); } else { meAsAMenu.add(newCheckBoxMenuItem); } }
/** Initialize the tab */ private void initTab() { final TextBox infobar = ScilabTextBox.createTextBox(); setWindowIcon("system-search"); updateUI(); CommonCallBack callback = new CommonCallBack(null) { @Override public void callBack() { ClosingOperationsManager.startClosingOperation((SwingScilabTab) SearchFile.this); } @Override public void actionPerformed(ActionEvent e) { callBack(); } }; setCallback(callback); MenuBar menubar = ScilabMenuBar.createMenuBar(); Menu fileMenu = ScilabMenu.createMenu(); fileMenu.setText(SciNotesMessages.FILE); fileMenu.setMnemonic('F'); MenuItem menu = ScilabMenuItem.createMenuItem(); menu.setCallback(callback); ((SwingScilabMenuItem) menu.getAsSimpleMenuItem()) .setAccelerator(SciNotes.getActionKeys().get("scinotes-exit")); menu.setText(SciNotesMessages.EXIT); fileMenu.add(menu); menubar.add(fileMenu); addMenuBar(menubar); addInfoBar(infobar); setPreferredSize(new Dimension(650, 250)); }
/** Creates the menuBar */ public void buildMenuBar() { menuBar = ScilabMenuBar.createMenuBar(); fileMenu = ScilabMenu.createMenu(); fileMenu.setText(UiDataMessages.FILE); fileMenu.setMnemonic('F'); fileMenu.add(RefreshAction.createMenuItem(UiDataMessages.REFRESH)); fileMenu.addSeparator(); fileMenu.add(CloseAction.createMenu()); menuBar.add(fileMenu); filterMenu = ScilabMenu.createMenu(); filterMenu.setText(UiDataMessages.FILTER); filterMenu.setMnemonic('I'); filterScilabVarCheckBox = ScilabVarFilteringAction.createCheckBoxMenu(); filterScilabVarCheckBox.setChecked(true); filterMenu.add(filterScilabVarCheckBox); filterMenu.addSeparator(); filterBooleanCheckBox = BooleanFilteringAction.createCheckBoxMenu(); filterBooleanCheckBox.setChecked(true); filterMenu.add(filterBooleanCheckBox); filterDoubleCheckBox = DoubleFilteringAction.createCheckBoxMenu(); filterDoubleCheckBox.setChecked(true); filterMenu.add(filterDoubleCheckBox); filterPolynomialCheckBox = PolynomialFilteringAction.createCheckBoxMenu(); filterPolynomialCheckBox.setChecked(true); filterMenu.add(filterPolynomialCheckBox); filterFunctionLibCheckBox = FunctionLibFilteringAction.createCheckBoxMenu(); filterMenu.add(filterFunctionLibCheckBox); filterStringCheckBox = StringFilteringAction.createCheckBoxMenu(); filterStringCheckBox.setChecked(true); filterMenu.add(filterStringCheckBox); filterSparseCheckBox = SparseFilteringAction.createCheckBoxMenu(); filterSparseCheckBox.setChecked(true); filterMenu.add(filterSparseCheckBox); filterSparseBoolCheckBox = SparseBoolFilteringAction.createCheckBoxMenu(); filterSparseBoolCheckBox.setChecked(true); filterMenu.add(filterSparseBoolCheckBox); filterIntegerCheckBox = IntegerFilteringAction.createCheckBoxMenu(); filterIntegerCheckBox.setChecked(true); filterMenu.add(filterIntegerCheckBox); filterGraphicHandlesCheckBox = GraphicHandlesFilteringAction.createCheckBoxMenu(); filterGraphicHandlesCheckBox.setChecked(true); filterMenu.add(filterGraphicHandlesCheckBox); filterUncompiledFuncCheckBox = UncompiledFunctionFilteringAction.createCheckBoxMenu(); filterMenu.add(filterUncompiledFuncCheckBox); filtercompiledFuncCheckBox = CompiledFunctionFilteringAction.createCheckBoxMenu(); filterMenu.add(filtercompiledFuncCheckBox); filterListCheckBox = ListFilteringAction.createCheckBoxMenu(); filterListCheckBox.setChecked(true); filterMenu.add(filterListCheckBox); filterTListCheckBox = TListFilteringAction.createCheckBoxMenu(); filterTListCheckBox.setChecked(true); filterMenu.add(filterTListCheckBox); filterMListCheckBox = MListFilteringAction.createCheckBoxMenu(); filterMListCheckBox.setChecked(true); filterMenu.add(filterMListCheckBox); filterPointerCheckBox = PointerFilteringAction.createCheckBoxMenu(); filterPointerCheckBox.setChecked(true); filterMenu.add(filterPointerCheckBox); filterIntrinsicFunctionCheckBox = IntrinsicFunctionFilteringAction.createCheckBoxMenu(); filterMenu.add(filterIntrinsicFunctionCheckBox); filterMatlabSparseCheckBox = MatlabSparseFilteringAction.createCheckBoxMenu(); filterMenu.add(filterMatlabSparseCheckBox); filterImplicitPolynomialCheckBox = ImplicitPolynomialFilteringAction.createCheckBoxMenu(); filterMenu.add(filterImplicitPolynomialCheckBox); menuBar.add(filterMenu); helpMenu = ScilabMenu.createMenu(); helpMenu.setText("?"); helpMenu.setMnemonic('?'); helpMenu.add(HelpAction.createMenuItem(UiDataMessages.HELP)); menuBar.add(helpMenu); }