/** Intialize me */ private void init() { myTables = new ArrayList(); tableTabbedPane = new JTabbedPane(); tableTabbedPane.setPreferredSize(new Dimension(450, 200)); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); fileMenu.add(GuiUtils.makeMenuItem("New Row", this, "addNewRow")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Open", this, "doOpen")); fileMenu.add(GuiUtils.makeMenuItem("Import", this, "doImport")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Export to File", this, "doSaveAs")); fileMenu.add(GuiUtils.makeMenuItem("Export to Plugin", this, "exportToPlugin")); fileMenu.add( GuiUtils.makeMenuItem("Export Selected to Plugin", this, "exportSelectedToPlugin")); fileMenu.addSeparator(); fileMenu.add(GuiUtils.makeMenuItem("Close", this, "doClose")); JMenu helpMenu = new JMenu("Help"); menuBar.add(helpMenu); helpMenu.add(GuiUtils.makeMenuItem("Parameter Defaults Help", this, "showHelp")); JComponent bottom = GuiUtils.wrap(GuiUtils.makeButton("Close", this, "doClose")); contents = GuiUtils.topCenterBottom(menuBar, GuiUtils.inset(tableTabbedPane, 2), bottom); setMenuBar(menuBar); loadResources(resources); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddMajorVersion = new ActionAddMajorVersion(); if (container instanceof ICFInternetRealProjectObj) { menuItem = new JMenuItem(actionAddMajorVersion); menuAdd.add(menuItem); } actionAddMinorVersion = new ActionAddMinorVersion(); if (container instanceof ICFInternetMajorVersionObj) { menuItem = new JMenuItem(actionAddMinorVersion); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionVersion(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionVersion(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionVersion(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddSecGroupMember = new ActionAddSecGroupMember(); if (container instanceof ICFSecuritySecGroupObj) { menuItem = new JMenuItem(actionAddSecGroupMember); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionSecGroupMember(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
public JMenuBar getPanelMenuBar() { if (panelMenuBar == null) { JMenuItem menuItem; ICFLibAnyObj container = getSwingContainer(); panelMenuBar = new JMenuBar(); menuAdd = new JMenu("Add"); actionAddTextCol = new ActionAddTextCol(); if (container instanceof ICFDbTestTableObj) { menuItem = new JMenuItem(actionAddTextCol); menuAdd.add(menuItem); } actionAddTextType = new ActionAddTextType(); if (container instanceof ICFDbTestSchemaDefObj) { menuItem = new JMenuItem(actionAddTextType); menuAdd.add(menuItem); } if (getSwingContainer() != null) { panelMenuBar.add(menuAdd); } menuSelected = new JMenu("Selected"); menuSelected.setEnabled(false); actionViewSelected = new ViewSelectedActionTextDef(); menuItem = new JMenuItem(actionViewSelected); menuSelected.add(menuItem); actionEditSelected = new EditSelectedActionTextDef(); menuItem = new JMenuItem(actionEditSelected); menuSelected.add(menuItem); actionDeleteSelected = new DeleteSelectedActionTextDef(); menuItem = new JMenuItem(actionDeleteSelected); menuSelected.add(menuItem); panelMenuBar.add(menuSelected); } return (panelMenuBar); }
public CFInternetSwingVersionListJPanel( ICFInternetSwingSchema argSchema, ICFLibAnyObj argContainer, ICFInternetVersionObj argFocus, Collection<ICFInternetVersionObj> argDataCollection, ICFJRefreshCallback refreshCallback, boolean sortByChain) { super(); final String S_ProcName = "construct-schema-focus"; if (argSchema == null) { throw CFLib.getDefaultExceptionFactory() .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema"); } // argFocus is optional; focus may be set later during execution as // conditions of the runtime change. swingSchema = argSchema; swingFocus = argFocus; swingContainer = argContainer; swingRefreshCallback = refreshCallback; swingSortByChain = sortByChain; setSwingDataCollection(argDataCollection); dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel()); dataTable.addMouseListener(getDataListMouseAdapter()); dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); dataTable.setUpdateSelectionOnSort(true); dataTable.setRowHeight(25); getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener()); dataScrollPane = new JScrollPane( dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); dataScrollPane.setColumnHeader( new JViewport() { @Override public Dimension getPreferredSize() { Dimension sz = super.getPreferredSize(); sz.height = 25; return (sz); } }); dataTable.setFillsViewportHeight(true); // Do initial layout setSize(1024, 480); JMenuBar menuBar = getPanelMenuBar(); add(menuBar); menuBar.setBounds(0, 0, 1024, 25); add(dataScrollPane); dataScrollPane.setBounds(0, 25, 1024, 455); adjustListMenuBar(); doLayout(); swingIsInitializing = false; }
public final void initUI() { // File Exit only JMenuBar menubar = new JMenuBar(); JMenu fileM = new JMenu("File"); JMenuItem exitM = new JMenuItem("Exit"); exitM.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileM.add(exitM); menubar.add(fileM); setJMenuBar(menubar); }
private JMenu addMenu( JMenuBar menuBar, String label, int mnemonic, String accessibleDescription) { JMenu menu = new JMenu(label); menu.setMnemonic(mnemonic); menu.getAccessibleContext().setAccessibleDescription(accessibleDescription); menuBar.add(menu); return menu; }
public static void makeMenuBar(JFrame frame, final AirspaceBuilderController controller) { JMenuBar menuBar = new JMenuBar(); final JCheckBoxMenuItem resizeNewShapesItem; final JCheckBoxMenuItem enableEditItem; JMenu menu = new JMenu("File"); { JMenuItem item = new JMenuItem("Open..."); item.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.setActionCommand(OPEN); item.addActionListener(controller); menu.add(item); item = new JMenuItem("Open URL..."); item.setActionCommand(OPEN_URL); item.addActionListener(controller); menu.add(item); item = new JMenuItem("Save..."); item.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.setActionCommand(SAVE); item.addActionListener(controller); menu.add(item); menu.addSeparator(); item = new JMenuItem("Load Demo Shapes"); item.setActionCommand(OPEN_DEMO_AIRSPACES); item.addActionListener(controller); menu.add(item); } menuBar.add(menu); menu = new JMenu("Shape"); { JMenu subMenu = new JMenu("New"); for (final AirspaceFactory factory : defaultAirspaceFactories) { JMenuItem item = new JMenuItem(factory.toString()); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { controller.createNewEntry(factory); } }); subMenu.add(item); } menu.add(subMenu); resizeNewShapesItem = new JCheckBoxMenuItem("Fit new shapes to viewport"); resizeNewShapesItem.setActionCommand(SIZE_NEW_SHAPES_TO_VIEWPORT); resizeNewShapesItem.addActionListener(controller); resizeNewShapesItem.setState(controller.isResizeNewShapesToViewport()); menu.add(resizeNewShapesItem); enableEditItem = new JCheckBoxMenuItem("Enable shape editing"); enableEditItem.setActionCommand(ENABLE_EDIT); enableEditItem.addActionListener(controller); enableEditItem.setState(controller.isEnableEdit()); menu.add(enableEditItem); } menuBar.add(menu); menu = new JMenu("Selection"); { JMenuItem item = new JMenuItem("Deselect"); item.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); item.setActionCommand(CLEAR_SELECTION); item.addActionListener(controller); menu.add(item); item = new JMenuItem("Delete"); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); item.setActionCommand(REMOVE_SELECTED); item.addActionListener(controller); menu.add(item); } menuBar.add(menu); frame.setJMenuBar(menuBar); controller.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (SIZE_NEW_SHAPES_TO_VIEWPORT.equals((e.getPropertyName()))) { resizeNewShapesItem.setSelected(controller.isResizeNewShapesToViewport()); } else if (ENABLE_EDIT.equals(e.getPropertyName())) { enableEditItem.setSelected(controller.isEnableEdit()); } } }); }
/** * Set up the menu bar. * * @return The JMenuBar we set up. */ private JMenuBar setupMenuBar() { JMenuBar menuBar = new JMenuBar(); /* File */ JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); /* File -> Open CSV */ JMenuItem miFileOpenCSV = new JMenuItem( new AbstractAction("Open CSV") { @Override public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(mainFrame, "Open Darwin CSV file ...", FileDialog.LOAD); fd.setVisible(true); File file; if (fd.getDirectory() != null) { file = new File(fd.getDirectory(), fd.getFile()); } else if (fd.getFile() != null) { file = new File(fd.getFile()); } else { return; } // Clear out old file. loadFile(null); // SwingWorker MAGIC! new MainFrameWorker("loading file '" + file + "'", file) { @Override protected Object doInBackground() throws Exception { System.err.println("Loading file: " + input); loadFile((File) input, DarwinCSV.FILE_CSV_DELIMITED); return null; } }.execute(); } }); fileMenu.add(miFileOpenCSV); /* File -> Open CSV without UI */ JMenuItem miFileOpenCSVnoUI = new JMenuItem( new AbstractAction("Open CSV without UI") { @Override public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(mainFrame, "Open Darwin CSV file ...", FileDialog.LOAD); fd.setVisible(true); File file; if (fd.getDirectory() != null) { file = new File(fd.getDirectory(), fd.getFile()); } else if (fd.getFile() != null) { file = new File(fd.getFile()); } else { return; } // Clear out old file loadFile(null); loadFile(file, DarwinCSV.FILE_CSV_DELIMITED); } }); fileMenu.add(miFileOpenCSVnoUI); /* File -> Open tab-delimited */ JMenuItem miFileOpenTab = new JMenuItem( new AbstractAction("Open tab-delimited") { @Override public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog( mainFrame, "Open Darwin tab-delimited file ...", FileDialog.LOAD); fd.setVisible(true); File file; if (fd.getDirectory() != null) { file = new File(fd.getDirectory(), fd.getFile()); } else if (fd.getFile() != null) { file = new File(fd.getFile()); } else { return; } // Clear out old file loadFile(null); // SwingWorker MAGIC! new MainFrameWorker("loading file '" + file + "'", file) { @Override protected Object doInBackground() throws Exception { loadFile((File) input, DarwinCSV.FILE_TAB_DELIMITED); return null; } }.execute(); } }); fileMenu.add(miFileOpenTab); /* File -> Save CSV */ JMenuItem miFileSave = new JMenuItem( new AbstractAction("Save as CSV") { @Override public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog(mainFrame, "Save Darwin CSV file ...", FileDialog.SAVE); fd.setVisible(true); File file; if (fd.getDirectory() != null) { file = new File(fd.getDirectory(), fd.getFile()); } else if (fd.getFile() != null) { file = new File(fd.getFile()); } else { return; } // SwingWorker MAGIC! new MainFrameWorker("saving CSV file '" + file + "'", file) { @Override protected Object doInBackground() throws Exception { currentCSV.saveToFile((File) input, DarwinCSV.FILE_CSV_DELIMITED); return null; } }.execute(); } }); fileMenu.add(miFileSave); /* File -> Exit */ JMenuItem miFileExit = new JMenuItem( new AbstractAction("Exit") { @Override public void actionPerformed(ActionEvent e) { mainFrame.setVisible(false); mainFrame.dispose(); } }); fileMenu.add(miFileExit); /* Match */ JMenu matchMenu = new JMenu("Match"); menuBar.add(matchMenu); /* Match -> Against CSV */ JMenuItem miMatchCSV = new JMenuItem( new AbstractAction("Match against CSV") { @Override public void actionPerformed(ActionEvent e) { FileDialog fd = new FileDialog( mainFrame, "Open Darwin CSV file for matching ...", FileDialog.LOAD); fd.setVisible(true); if (fd.getFile() == null) return; File file = new File(fd.getFile()); if (fd.getDirectory() != null) { file = new File(fd.getDirectory(), fd.getFile()); } // Clear out old match against. matchAgainst(null); // SwingWorker MAGIC! new MainFrameWorker("matching against file '" + file + "'", file) { @Override protected Object doInBackground() throws Exception { matchAgainst(new DarwinCSV((File) input, DarwinCSV.FILE_CSV_DELIMITED)); return null; } }.execute(); } }); matchMenu.add(miMatchCSV); /* Match -> Against ITIS */ JMenuItem miMatchITIS = new JMenuItem( new AbstractAction("Match against ITIS") { @Override public void actionPerformed(ActionEvent e) { DarwinCSV csv = DownloadITIS.getIt(mainFrame); matchAgainst(csv); table.repaint(); } }); matchMenu.add(miMatchITIS); /* TaxonID */ JMenu taxonIDMenu = new JMenu("TaxonIDs"); menuBar.add(taxonIDMenu); /* TaxonID -> Treat TaxonIDs as ... */ JMenu treatTaxonIDsAs = new JMenu("Treat TaxonIDs as ..."); taxonIDMenu.add(treatTaxonIDsAs); /* TaxonID -> Treat -> ITIS TSNs */ JCheckBoxMenuItem miITIS_TSNs = new JCheckBoxMenuItem( new AbstractAction("ITIS TSNs") { @Override public void actionPerformed(ActionEvent e) { // Don't let the user unselect this. ((JCheckBoxMenuItem) e.getSource()).setSelected(true); } }); miITIS_TSNs.setSelected(true); treatTaxonIDsAs.add(miITIS_TSNs); /* TaxonID -> Create family column */ JMenuItem miTaxonID_createFamily = new JMenuItem( new AbstractAction("Create family column") { @Override public void actionPerformed(ActionEvent e) { /* if(currentCSV == null) return; if(currentMatch == null) return; int col = getJTable().getSelectedColumn(); if(col == -1) return; RowIndex rowIndex = currentCSV.getRowIndex(); String colName = rowIndex.getColumnName(col); if(rowIndex.hasColumn(colName + "_family")) { // TODO MessageBox return; } if(Name.class.isAssignableFrom(currentCSV.getRowIndex().getColumnClass(col))) { // A name class! Make a new column! currentCSV.getRowIndex().setColumnClass(colName + "_family", String.class); currentCSV.getRowIndex().createNewColumn(colName + "_family", col + 1, colName, new MapOperation() { @Override public Object mapTo(Object value) { return "family"; } }); // Repaint the table. getJTable().repaint(); } */ } }); taxonIDMenu.add(miTaxonID_createFamily); /* Help */ JMenu helpMenu = new JMenu("Help"); menuBar.add(helpMenu); /* Help -> Memory information */ JMenuItem miHelpMemory = new JMenuItem( new AbstractAction("Memory information") { @Override public void actionPerformed(ActionEvent e) { System.gc(); MessageBox.messageBox( mainFrame, "Memory information", "Maximum memory: " + Runtime.getRuntime().maxMemory() / (1024 * 1024) + " MB\n" + "Total memory: " + Runtime.getRuntime().totalMemory() / (1024 * 1024) + " MB\n" + "Used memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024) + " MB\n" + "Free memory: " + Runtime.getRuntime().freeMemory() / (1024 * 1024) + " MB\n" + "Available memory: " + (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().totalMemory() + Runtime.getRuntime().freeMemory()) / (1024 * 1024) + " MB"); } }); helpMenu.add(miHelpMemory); return menuBar; }
private JMenuBar menuBar() { JMenuBar result = new JMenuBar(); result.add(fileMenu()); return result; }
public EditorServer(String fileName, String name, String desc) { super(); self = this; if (fileName == null || !loadDocument(fileName)) { clients = new Vector(); document = new EditorDocument(name, desc, "", System.currentTimeMillis()); try { // ascii code for first blue line... document.insertString(0, "·-·+·*=·x·\n", document.getStyle("line")); } catch (BadLocationException ble) { System.out.println("EditorServer->const: BadLocationException"); } paragraphs = new Paragraphs(document); lockManager = new LockManager(clients, document, paragraphs); highlights = new Highlights(lockManager, document); nextClientId = 1; } isAudioOptionSelected = false; // to avoid unecessary Audio - Text participant matching documentPanel = new DocumentPanel(); updateParagraphList(); clientsPanel = new ClientsPanel(); clientsPanel.updateClientList(); Icon clockIcon = getImageIcon("images/clock.gif"); Icon clockIcon2 = getImageIcon("images/clock2.gif"); startRTPrecording = new JButton("START RTP Recording", clockIcon); startRTPrecording.setRolloverIcon(clockIcon2); RecordingHandler recHandler = new RecordingHandler(self); startRTPrecording.addActionListener(recHandler); Icon stopIcon = getImageIcon("images/stop.gif"); stopRTPrecording = new JButton("STOP RTP recording", stopIcon); stopRTPrecording.setEnabled(false); stopRTPrecording.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { recorder.endRecording(); stopRTPrecording.setEnabled(false); startRTPrecording.setEnabled(true); } }); Container container = getContentPane(); container.setLayout(new FlowLayout()); container.add(startRTPrecording); container.add(stopRTPrecording); // JTabbedPane tabPane = new JTabbedPane() ; tabPane.add("Document", documentPanel); tabPane.add("Text Clients", clientsPanel); container.add(tabPane, BorderLayout.CENTER); setTitle("EditorServer"); setSize(new Dimension(800, 600)); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { lockManager.saveDocument(null, highlights, self); System.exit(0); } }); JMenuItem mnuSave = new JMenuItem("Save"); mnuSave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser dialog = new JFileChooser(); dialog.addChoosableFileFilter( new MyFileFilter("Collabortive Document File (*.cde)", ".cde")); dialog.setAcceptAllFileFilterUsed(false); if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { lockManager.saveDocument(dialog.getSelectedFile().getPath(), highlights, self); } } }); JMenuItem mnuSaveXML = new JMenuItem("Save XML"); mnuSaveXML.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser dialog = new JFileChooser(); dialog.addChoosableFileFilter(new MyFileFilter("XML File (*.xml)", ".xml")); dialog.setAcceptAllFileFilterUsed(false); if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { lockManager.saveXML(dialog.getSelectedFile().getPath(), highlights, self); } } }); JMenu mnuFile = new JMenu("File"); mnuFile.add(mnuSave); mnuFile.add(mnuSaveXML); JMenuBar menu = new JMenuBar(); menu.add(mnuFile); setJMenuBar(menu); Thread backupThread = new Thread() { public void run() { while (1 == 1) { yield(); try { // sleep(1000) ; sleep(5 * 60 * 1000); lockManager.saveDocument(null, highlights, self); } catch (Exception e) { System.out.println("EditorServer: backupThread. error"); e.printStackTrace(); } } } }; backupThread.setDaemon(true); backupThread.start(); } // endof const WITHOUT audio profile maker