List of usage examples for javax.swing KeyStroke getKeyStroke
public static KeyStroke getKeyStroke(int keyCode, int modifiers)
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
/** * Adds a Key mappings.//from w w w . j ava2 s .c o m * @param comp comp * @param keyCode keyCode * @param actionName actionName * @param action action * @return the action */ public Action addRecordKeyMappings(final JComponent comp, final int keyCode, final String actionName, final Action action, int modifiers) { InputMap inputMap = comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = comp.getActionMap(); inputMap.put(KeyStroke.getKeyStroke(keyCode, modifiers), actionName); actionMap.put(actionName, action); //UIRegistry.registerAction(actionName, action); return action; }
From source file:Clavis.Windows.WShedule.java
public synchronized void create() { initComponents();/*from www . j a va2 s . co m*/ this.setModal(true); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { close(); } }); this.setTitle(lingua.translate("Registos de emprstimo para o recurso") + ": " + lingua.translate(mat.getTypeOfMaterialName()).toLowerCase() + " " + lingua.translate(mat.getDescription())); KeyQuest.addtoPropertyListener(jPanelInicial, true); String dat = new TimeDate.Date().toString(); String[] auxiliar = prefs.get("datainicio", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } inicio = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); auxiliar = prefs.get("datafim", dat).split("/"); if (auxiliar[0].length() > 1) { if (auxiliar[0].charAt(0) == '0') { auxiliar[0] = auxiliar[0].replaceFirst("0", ""); } } if (auxiliar[1].length() > 1) { if (auxiliar[1].charAt(0) == '0') { auxiliar[1] = auxiliar[1].replaceFirst("0", ""); } } if (auxiliar[2].length() > 1) { if (auxiliar[2].charAt(0) == '0') { auxiliar[2] = auxiliar[2].replaceFirst("0", ""); } } fim = new TimeDate.Date(Integer.valueOf(auxiliar[0]), Integer.valueOf(auxiliar[1]), Integer.valueOf(auxiliar[2])); SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy"); Date date; try { date = sdf.parse(fim.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerFim.setDate(date); try { date = sdf.parse(inicio.toString()); } catch (ParseException ex) { date = new Date(); } jXDatePickerInicio.setDate(date); andamento = 0; if (DataBase.DataBase.testConnection(url)) { DataBase.DataBase db = new DataBase.DataBase(url); java.util.List<Keys.Request> requisicoes = Clavis.RequestList .simplifyRequests(db.getRequestsByMaterialByDateInterval(mat, inicio, fim)); db.close(); estado = lingua.translate("Todos"); DefaultTableModel modelo = (DefaultTableModel) jTable1.getModel(); if (requisicoes.size() > 0) { valores = new String[requisicoes.size()][4]; lista = new java.util.ArrayList<>(); requisicoes.stream().map((req) -> { if (mat.getMaterialTypeID() == 1) { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0); valores[andamento][2] = req.getBeginDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = lingua.translate(multipla[0]) + ""; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0), req.getBeginDate().toString(), valores[andamento][3], req.getSubject().getName() }; modelo.addRow(ob); } else { valores[andamento][0] = req.getPerson().getName(); valores[andamento][1] = req.getBeginDate().toString(); valores[andamento][2] = req.getEndDate().toString(); String[] multipla = req.getActivity().split(":::"); if (multipla.length > 1) { Components.PopUpMenu pop = new Components.PopUpMenu(multipla, lingua); pop.create(); jTable1.addMouseListener(new MouseAdapter() { int x = andamento; int y = 3; @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { int row = jTable1.rowAtPoint(e.getPoint()); int col = jTable1.columnAtPoint(e.getPoint()); if ((row == x) && (col == y)) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (pop.isShowing()) { pop.setVisible(false); } } } }); valores[andamento][3] = multipla[0]; } else { valores[andamento][3] = lingua.translate(req.getActivity()); } if (valores[andamento][3].equals("")) { valores[andamento][3] = lingua.translate("Sem descrio"); } Object[] ob = { req.getPerson().getName(), req.getBeginDate().toString(), req.getEndDate().toString(), valores[andamento][3] }; modelo.addRow(ob); } return req; }).map((req) -> { lista.add(req); return req; }).forEach((_item) -> { andamento++; }); } } jComboBoxEstado.setSelectedIndex(prefs.getInt("comboboxvalue", 0)); String[] opcoes = { lingua.translate("Ver detalhes da requisio"), lingua.translate("Ver requisices com a mesma data"), lingua.translate("Ver requisices com o mesmo estado") }; ActionListener[] eventos = new ActionListener[opcoes.length]; eventos[0] = (ActionEvent r) -> { Border border = BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(new org.jdesktop.swingx.border.DropShadowBorder(Color.BLACK, 3, 0.5f, 6, false, false, true, true), BorderFactory.createLineBorder(Color.BLACK, 1)), BorderFactory.createEmptyBorder(0, 10, 0, 10)); int val = jTable1.getSelectedRow(); Keys.Request req = lista.get(val); javax.swing.JPanel pan = new javax.swing.JPanel(null); pan.setPreferredSize(new Dimension(500, 300)); pan.setBounds(0, 20, 500, 400); pan.setBackground(Components.MessagePane.BACKGROUND_COLOR); javax.swing.JLabel lrecurso1 = new javax.swing.JLabel(lingua.translate("Recurso") + ": "); lrecurso1.setBounds(10, 20, 120, 26); lrecurso1.setFocusable(true); lrecurso1.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso1); javax.swing.JLabel lrecurso11 = new javax.swing.JLabel( lingua.translate(req.getMaterial().getTypeOfMaterialName()) + " " + lingua.translate(req.getMaterial().getDescription())); lrecurso11.setBounds(140, 20, 330, 26); lrecurso11.setBorder(border); pan.add(lrecurso11); javax.swing.JLabel lrecurso2 = new javax.swing.JLabel(lingua.translate("Utilizador") + ": "); lrecurso2.setBounds(10, 50, 120, 26); lrecurso2.setFocusable(true); lrecurso2.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso2); javax.swing.JLabel lrecurso22 = new javax.swing.JLabel(req.getPerson().getName()); lrecurso22.setBounds(140, 50, 330, 26); lrecurso22.setBorder(border); pan.add(lrecurso22); javax.swing.JLabel lrecurso3 = new javax.swing.JLabel(lingua.translate("Data inicial") + ": "); lrecurso3.setBounds(10, 80, 120, 26); lrecurso3.setFocusable(true); lrecurso3.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso3); javax.swing.JLabel lrecurso33 = new javax.swing.JLabel( req.getBeginDate().toStringWithMonthWord(lingua)); lrecurso33.setBounds(140, 80, 330, 26); lrecurso33.setBorder(border); pan.add(lrecurso33); javax.swing.JLabel lrecurso4 = new javax.swing.JLabel(lingua.translate("Data final") + ": "); lrecurso4.setBounds(10, 110, 120, 26); lrecurso4.setFocusable(true); lrecurso4.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso4); javax.swing.JLabel lrecurso44 = new javax.swing.JLabel(req.getEndDate().toStringWithMonthWord(lingua)); lrecurso44.setBounds(140, 110, 330, 26); lrecurso44.setBorder(border); pan.add(lrecurso44); javax.swing.JLabel lrecurso5 = new javax.swing.JLabel(lingua.translate("Atividade") + ": "); lrecurso5.setBounds(10, 140, 120, 26); lrecurso5.setFocusable(true); lrecurso5.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso5); javax.swing.JLabel lrecurso55; if (req.getActivity().equals("")) { lrecurso55 = new javax.swing.JLabel(lingua.translate("Sem descrio")); } else { String[] saux = req.getActivity().split(":::"); String atividade; boolean situacao = false; if (saux.length > 1) { situacao = true; atividade = saux[0]; } else { atividade = req.getActivity(); } if (req.getSubject().getId() > 0) { lrecurso55 = new javax.swing.JLabel( lingua.translate(atividade) + ": " + req.getSubject().getName()); } else { lrecurso55 = new javax.swing.JLabel(lingua.translate(atividade)); } if (situacao) { Components.PopUpMenu pop = new Components.PopUpMenu(saux, lingua); pop.create(); lrecurso55.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { pop.show(e.getComponent(), e.getX(), e.getY()); } @Override public void mouseExited(MouseEvent e) { pop.setVisible(false); } }); } } lrecurso55.setBounds(140, 140, 330, 26); lrecurso55.setBorder(border); pan.add(lrecurso55); int distancia = 170; if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso6 = new javax.swing.JLabel(lingua.translate("Horrio") + ": "); lrecurso6.setBounds(10, distancia, 120, 26); lrecurso6.setFocusable(true); lrecurso6.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso6); javax.swing.JLabel lrecurso66 = new javax.swing.JLabel( req.getTimeBegin().toString(0) + " - " + req.getTimeEnd().toString(0)); lrecurso66.setBounds(140, distancia, 330, 26); lrecurso66.setBorder(border); pan.add(lrecurso66); distancia = 200; } if (req.getBeginDate().isBigger(req.getEndDate()) == 0) { javax.swing.JLabel lrecurso7 = new javax.swing.JLabel(lingua.translate("Dia da semana") + ": "); lrecurso7.setBounds(10, distancia, 120, 26); lrecurso7.setFocusable(true); lrecurso7.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso7); javax.swing.JLabel lrecurso77 = new javax.swing.JLabel( lingua.translate(req.getWeekDay().perDayName())); lrecurso77.setBounds(140, distancia, 330, 26); lrecurso77.setBorder(border); pan.add(lrecurso77); if (distancia == 200) { distancia = 230; } else { distancia = 200; } } if (req.isTerminated() || req.isActive()) { javax.swing.JLabel lrecurso8 = new javax.swing.JLabel(lingua.translate("Levantamento") + ": "); lrecurso8.setBounds(10, distancia, 120, 26); lrecurso8.setFocusable(true); lrecurso8.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso8); javax.swing.JLabel lrecurso88; if ((req.getLiftDate() != null) && (req.getLiftTime() != null)) { lrecurso88 = new javax.swing.JLabel(req.getLiftDate().toString() + " " + lingua.translate("s") + " " + req.getLiftTime().toString(0)); } else { lrecurso88 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso88.setBounds(140, distancia, 330, 26); lrecurso88.setBorder(border); pan.add(lrecurso88); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; default: distancia = 200; break; } } if (req.isTerminated()) { javax.swing.JLabel lrecurso9 = new javax.swing.JLabel(lingua.translate("Entrega") + ": "); lrecurso9.setBounds(10, distancia, 120, 26); lrecurso9.setFocusable(true); lrecurso9.setHorizontalAlignment(javax.swing.JLabel.LEFT); pan.add(lrecurso9); javax.swing.JLabel lrecurso99; if ((req.getDeliveryDate() != null) && (req.getDeliveryTime() != null)) { lrecurso99 = new javax.swing.JLabel(req.getDeliveryDate().toString() + " " + lingua.translate("s") + " " + req.getDeliveryTime().toString(0)); } else { lrecurso99 = new javax.swing.JLabel(lingua.translate("sem dados para apresentar")); } lrecurso99.setBounds(140, distancia, 330, 26); lrecurso99.setBorder(border); pan.add(lrecurso99); switch (distancia) { case 200: distancia = 230; break; case 230: distancia = 260; break; case 260: distancia = 290; break; default: distancia = 200; break; } } Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO, Clavis.KeyQuest.getSystemColor(), lingua.translate(""), 500, 400, pan, "", new String[] { lingua.translate("Voltar") }); mensagem.showMessage(); }; eventos[1] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 2).toString(); SimpleDateFormat sdf_auxiliar = new SimpleDateFormat("dd/MM/yyyy"); Date data_auxiliar; try { data_auxiliar = sdf_auxiliar.parse(val); Calendar cal = Calendar.getInstance(); cal.setTime(data_auxiliar); int dia = cal.get(Calendar.DAY_OF_MONTH); int mes = cal.get(Calendar.MONTH) + 1; int ano = cal.get(Calendar.YEAR); inicio = new TimeDate.Date(dia, mes, ano); fim = new TimeDate.Date(dia, mes, ano); } catch (ParseException ex) { data_auxiliar = new Date(); } jXDatePickerFim.setDate(data_auxiliar); jXDatePickerInicio.setDate(data_auxiliar); refreshTable(jComboBoxEstado.getSelectedIndex()); }; eventos[2] = (ActionEvent r) -> { String val = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 3).toString(); for (int i = 0; i < jComboBoxEstado.getItemCount(); i++) { if (jComboBoxEstado.getItemAt(i).equals(val)) { jComboBoxEstado.setSelectedIndex(i); } } }; KeyStroke[] strokes = new KeyStroke[opcoes.length]; strokes[0] = KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK); strokes[1] = KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK); strokes[2] = KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK); Components.PopUpMenu pop = new Components.PopUpMenu(opcoes, eventos, strokes); pop.create(); mouseaction = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { jTable1.setRowSelectionInterval(jTable1.rowAtPoint(ponto), jTable1.rowAtPoint(new java.awt.Point(e.getX(), e.getY()))); } } @Override public void mouseReleased(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { if (jTable1.getSelectedRow() >= 0) { java.awt.Point ponto = new java.awt.Point(e.getX(), e.getY()); if (jTable1.rowAtPoint(ponto) > -1) { pop.show(e.getComponent(), e.getX(), e.getY()); } } } } }; jTable1.addMouseListener(mouseaction); }
From source file:com.marginallyclever.makelangelo.MainGUI.java
public void updateMenuBar() { JMenu menu, subMenu;/*from ww w . ja v a 2 s . c om*/ ButtonGroup group; int i; if (settingsPane != null) { buttonAdjustMachineSize.setEnabled(!isrunning); buttonAdjustPulleySize.setEnabled(!isrunning); buttonJogMotors .setEnabled(connectionToRobot != null && connectionToRobot.isRobotConfirmed() && !isrunning); buttonChangeTool.setEnabled(!isrunning); buttonAdjustTool.setEnabled(!isrunning); } if (preparePane != null) { buttonHilbertCurve.setEnabled(!isrunning); buttonText2GCODE.setEnabled(!isrunning); } if (driveControls != null) { boolean x = connectionToRobot != null && connectionToRobot.isRobotConfirmed(); driveControls.updateButtonAccess(x, isrunning); } menuBar.removeAll(); // File menu menu = new JMenu(translator.get("MenuMakelangelo")); menu.setMnemonic(KeyEvent.VK_F); menuBar.add(menu); subMenu = new JMenu(translator.get("MenuPreferences")); buttonAdjustSounds = new JMenuItem(translator.get("MenuSoundsTitle")); buttonAdjustSounds.addActionListener(this); subMenu.add(buttonAdjustSounds); buttonAdjustGraphics = new JMenuItem(translator.get("MenuGraphicsTitle")); buttonAdjustGraphics.addActionListener(this); subMenu.add(buttonAdjustGraphics); buttonAdjustLanguage = new JMenuItem(translator.get("MenuLanguageTitle")); buttonAdjustLanguage.addActionListener(this); subMenu.add(buttonAdjustLanguage); menu.add(subMenu); buttonCheckForUpdate = new JMenuItem(translator.get("MenuUpdate"), KeyEvent.VK_U); buttonCheckForUpdate.addActionListener(this); buttonCheckForUpdate.setEnabled(true); menu.add(buttonCheckForUpdate); buttonAbout = new JMenuItem(translator.get("MenuAbout"), KeyEvent.VK_A); buttonAbout.addActionListener(this); menu.add(buttonAbout); menu.addSeparator(); buttonExit = new JMenuItem(translator.get("MenuQuit"), KeyEvent.VK_Q); buttonExit.addActionListener(this); menu.add(buttonExit); // Connect menu subMenu = new JMenu(translator.get("MenuConnect")); subMenu.setEnabled(!isrunning); group = new ButtonGroup(); String[] connections = connectionManager.listConnections(); buttonPorts = new JRadioButtonMenuItem[connections.length]; for (i = 0; i < connections.length; ++i) { buttonPorts[i] = new JRadioButtonMenuItem(connections[i]); if (connectionToRobot != null && connectionToRobot.getRecentConnection().equals(connections[i]) && connectionToRobot.isConnectionOpen()) { buttonPorts[i].setSelected(true); } buttonPorts[i].addActionListener(this); group.add(buttonPorts[i]); subMenu.add(buttonPorts[i]); } subMenu.addSeparator(); buttonRescan = new JMenuItem(translator.get("MenuRescan"), KeyEvent.VK_N); buttonRescan.addActionListener(this); subMenu.add(buttonRescan); buttonDisconnect = new JMenuItem(translator.get("MenuDisconnect"), KeyEvent.VK_D); buttonDisconnect.addActionListener(this); buttonDisconnect.setEnabled(connectionToRobot != null && connectionToRobot.isConnectionOpen()); subMenu.add(buttonDisconnect); menuBar.add(subMenu); // view menu menu = new JMenu(translator.get("MenuPreview")); buttonZoomOut = new JMenuItem(translator.get("ZoomOut")); buttonZoomOut.addActionListener(this); buttonZoomOut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, ActionEvent.ALT_MASK)); menu.add(buttonZoomOut); buttonZoomIn = new JMenuItem(translator.get("ZoomIn"), KeyEvent.VK_EQUALS); buttonZoomIn.addActionListener(this); buttonZoomIn.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ActionEvent.ALT_MASK)); menu.add(buttonZoomIn); buttonZoomToFit = new JMenuItem(translator.get("ZoomFit")); buttonZoomToFit.addActionListener(this); menu.add(buttonZoomToFit); menuBar.add(menu); // finish menuBar.updateUI(); }
From source file:edu.ku.brc.ui.UIRegistry.java
/** * Adds Key navigation bindings to a component. (Is this needed?) * @param comp the component/*w w w . j av a2 s.c o m*/ */ public void addNavBindings(JComponent comp) { InputMap inputMap = comp.getInputMap(); //Ctrl-b to go backward one character KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_B, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); inputMap.put(key, DefaultEditorKit.backwardAction); //Ctrl-f to go forward one character key = KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); inputMap.put(key, DefaultEditorKit.forwardAction); //Ctrl-p to go up one line key = KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); inputMap.put(key, DefaultEditorKit.upAction); //Ctrl-n to go down one line key = KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); inputMap.put(key, DefaultEditorKit.downAction); }
From source file:edu.ku.brc.ui.UIRegistry.java
public JMenu createEditMenu() { JMenu menu = new JMenu(getResourceString("EDIT")); menu.setMnemonic(KeyEvent.VK_E); // Undo and redo are actions of our own creation. undoAction = (UndoAction) makeAction(UndoAction.class, this, "Undo", null, null, new Integer(KeyEvent.VK_Z), KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(UNDO, menu.add(undoAction)); actionMap.put(UNDO, undoAction);/*from w w w . ja v a 2 s . c o m*/ redoAction = (RedoAction) makeAction(RedoAction.class, this, "Redo", null, null, new Integer(KeyEvent.VK_Y), KeyStroke.getKeyStroke(KeyEvent.VK_Y, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(REDO, menu.add(redoAction)); actionMap.put(REDO, redoAction); menu.addSeparator(); // These actions come from the default editor kit. Get the ones we want // and stick them in the menu. Action cutAction = makeAction(DefaultEditorKit.CutAction.class, null, "Cut", null, "Cut selection to clipboard", // I18N ???? new Integer(KeyEvent.VK_X), KeyStroke.getKeyStroke(KeyEvent.VK_X, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(CUT, menu.add(cutAction)); cutAction.setEnabled(false); actionMap.put(CUT, cutAction); Action copyAction = makeAction(DefaultEditorKit.CopyAction.class, null, "Copy", null, "Copy selection to clipboard", new Integer(KeyEvent.VK_C), KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); register(COPY, menu.add(copyAction)); copyAction.setEnabled(false); actionMap.put(COPY, copyAction); Action pasteAction = makeAction(DefaultEditorKit.PasteAction.class, null, "Paste", null, "Paste contents of clipboard", new Integer(KeyEvent.VK_V), KeyStroke.getKeyStroke(KeyEvent.VK_V, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); pasteAction.setEnabled(false); register(PASTE, menu.add(pasteAction)); actionMap.put(PASTE, pasteAction); /* menu.addSeparator(); Action selectAllAction = makeAction(SelectAllAction.class, this, "Select All", null, "Select all text", new Integer(KeyEvent.VK_A), KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(selectAllAction); */ launchFindReplaceAction = (LaunchFindReplaceAction) makeAction(LaunchFindReplaceAction.class, this, "Find", null, null, new Integer(KeyEvent.VK_F), KeyStroke.getKeyStroke(KeyEvent.VK_F, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); //menu.add(launchFindReplaceAction); // launchFindReplaceAction.setEnabled(false); // register(FIND, menu.add(launchFindReplaceAction)); // actionMap.put(FIND, launchFindReplaceAction); launchFindReplaceAction.setEnabled(false); register(FIND, menu.add(launchFindReplaceAction)); actionMap.put(FIND, launchFindReplaceAction); return menu; }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Configures the assertions file menu. Called at startup * and whenever an assertions file is opened or saved since * the list of recent assertions files is presented on the * file menu.// w ww .ja va2 s.c o m */ private void setupAssertionsFileMenu() { fileAssertionsMenu.removeAll(); fileOpenTriplesFile = new JMenuItem("Open Assertions File"); fileOpenTriplesFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_MASK)); fileOpenTriplesFile.setMnemonic('A'); fileOpenTriplesFile.setToolTipText("Open an asserted triples file"); fileOpenTriplesFile.addActionListener(new FileAssertedTriplesOpenListener()); fileAssertionsMenu.add(fileOpenTriplesFile); fileOpenTriplesUrl = new JMenuItem("Open Assertions Url"); fileOpenTriplesUrl.setMnemonic('U'); fileOpenTriplesUrl.setToolTipText("Access asserted triples from a URL"); fileOpenTriplesUrl.addActionListener(new FileAssertedTriplesUrlOpenListener()); fileAssertionsMenu.add(fileOpenTriplesUrl); fileAssertionsMenu.addSeparator(); // Create menu options to open recently accessed ontology files fileOpenRecentTriplesFile = new JMenuItem[recentAssertionsFiles.size()]; for (int recentFileNumber = 0; recentFileNumber < recentAssertionsFiles.size(); ++recentFileNumber) { fileOpenRecentTriplesFile[recentFileNumber] = new JMenuItem( recentAssertionsFiles.get(recentFileNumber).getName()); fileOpenRecentTriplesFile[recentFileNumber] .setToolTipText(recentAssertionsFiles.get(recentFileNumber).getAbsolutePath()); fileOpenRecentTriplesFile[recentFileNumber] .addActionListener(new RecentAssertedTriplesFileOpenListener()); fileAssertionsMenu.add(fileOpenRecentTriplesFile[recentFileNumber]); } if (fileOpenRecentTriplesFile.length > 0) { fileAssertionsMenu.addSeparator(); } fileSaveTriplesToFile = new JMenuItem("Save Assertions Text"); fileSaveTriplesToFile .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_MASK | KeyEvent.CTRL_MASK)); fileSaveTriplesToFile.setMnemonic(KeyEvent.VK_S); fileSaveTriplesToFile.setToolTipText("Write the asserted triples to a file"); fileSaveTriplesToFile.addActionListener(new FileAssertedTriplesSaveListener()); fileAssertionsMenu.add(fileSaveTriplesToFile); fileSaveSerializedModel = new JMenuItem("Save Model (processed triples)"); fileSaveSerializedModel .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.ALT_MASK | KeyEvent.CTRL_MASK)); fileSaveSerializedModel.setMnemonic(KeyEvent.VK_M); fileSaveSerializedModel.setToolTipText("Write the triples from the current model to a file"); fileSaveSerializedModel.addActionListener(new ModelSerializerListener()); fileAssertionsMenu.add(fileSaveSerializedModel); fileAssertionsMenu.addSeparator(); fileExit = new JMenuItem("Exit"); fileExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK)); fileExit.setMnemonic(KeyEvent.VK_X); fileExit.setToolTipText("Exit the application"); fileExit.addActionListener(new EndApplicationListener()); fileAssertionsMenu.add(fileExit); }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Configures the SPARQL file menu. Called at startup * and whenever an SPARQL file is opened or saved since * the list of recent SPARQL files is presented on the * file menu.//from ww w . j a v a 2s . com */ private void setupSparqlFileMenu() { fileSparqlMenu.removeAll(); fileOpenSparqlFile = new JMenuItem("Open SPARQL File"); fileOpenSparqlFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.ALT_MASK)); fileOpenSparqlFile.setMnemonic(KeyEvent.VK_S); fileOpenSparqlFile.setToolTipText("Open a SPARQL query file"); fileOpenSparqlFile.addActionListener(new FileSparqlOpenListener()); fileSparqlMenu.add(fileOpenSparqlFile); fileSparqlMenu.addSeparator(); // Create menu options to open recently accessed SPARQL files fileOpenRecentSparqlFile = new JMenuItem[recentSparqlFiles.size()]; for (int recentFileNumber = 0; recentFileNumber < recentSparqlFiles.size(); ++recentFileNumber) { fileOpenRecentSparqlFile[recentFileNumber] = new JMenuItem( recentSparqlFiles.get(recentFileNumber).getName()); fileOpenRecentSparqlFile[recentFileNumber] .setToolTipText(recentSparqlFiles.get(recentFileNumber).getAbsolutePath()); fileOpenRecentSparqlFile[recentFileNumber].addActionListener(new RecentSparqlFileOpenListener()); fileSparqlMenu.add(fileOpenRecentSparqlFile[recentFileNumber]); } if (fileOpenRecentSparqlFile.length > 0) { fileSparqlMenu.addSeparator(); } fileSaveSparqlQueryToFile = new JMenuItem("Save SPARQL Query"); fileSaveSparqlQueryToFile .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.ALT_MASK | KeyEvent.CTRL_MASK)); fileSaveSparqlQueryToFile.setMnemonic(KeyEvent.VK_Q); fileSaveSparqlQueryToFile.setToolTipText("Write the SPARQL query to a file"); fileSaveSparqlQueryToFile.addActionListener(new FileSparqlSaveListener()); fileSparqlMenu.add(fileSaveSparqlQueryToFile); fileSaveSparqlResultsToFile = new JMenuItem("Save SPARQL Results"); fileSaveSparqlResultsToFile .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, KeyEvent.ALT_MASK | KeyEvent.CTRL_MASK)); fileSaveSparqlResultsToFile.setMnemonic(KeyEvent.VK_R); fileSaveSparqlResultsToFile.setToolTipText("Write the current SPARQL results to a file"); fileSaveSparqlResultsToFile.addActionListener(new FileSparqlResultsSaveListener()); fileSparqlMenu.add(fileSaveSparqlResultsToFile); fileSparqlMenu.addSeparator(); fileClearSparqlHistory = new JMenuItem("Clear SPARQL Query History"); fileClearSparqlHistory.setMnemonic(KeyEvent.VK_C); fileClearSparqlHistory.setToolTipText("Clear the history of executed SPARQL queries"); fileClearSparqlHistory.addActionListener(new FileClearSparqlHistoryListener()); fileSparqlMenu.add(fileClearSparqlHistory); }
From source file:com.maxl.java.amikodesk.AMiKoDesk.java
private static void createAndShowFullGUI() { // Create and setup window final JFrame jframe = new JFrame(Constants.APP_NAME); jframe.setName(Constants.APP_NAME + ".main"); int min_width = CML_OPT_WIDTH; int min_height = CML_OPT_HEIGHT; jframe.setPreferredSize(new Dimension(min_width, min_height)); jframe.setMinimumSize(new Dimension(min_width, min_height)); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screen.width - min_width) / 2; int y = (screen.height - min_height) / 2; jframe.setBounds(x, y, min_width, min_height); // Set application icon if (Utilities.appCustomization().equals("ywesee")) { ImageIcon img = new ImageIcon(Constants.AMIKO_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("desitin")) { ImageIcon img = new ImageIcon(Constants.DESITIN_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("meddrugs")) { ImageIcon img = new ImageIcon(Constants.MEDDRUGS_ICON); jframe.setIconImage(img.getImage()); } else if (Utilities.appCustomization().equals("zurrose")) { ImageIcon img = new ImageIcon(Constants.AMIKO_ICON); jframe.setIconImage(img.getImage()); }//from ww w . j a v a 2 s . c o m // ------ Setup menubar ------ JMenuBar menu_bar = new JMenuBar(); // menu_bar.add(Box.createHorizontalGlue()); // --> aligns menu items to the right! // -- Menu "Datei" -- JMenu datei_menu = new JMenu("Datei"); if (Utilities.appLanguage().equals("fr")) datei_menu.setText("Fichier"); menu_bar.add(datei_menu); JMenuItem print_item = new JMenuItem("Drucken..."); JMenuItem settings_item = new JMenuItem(m_rb.getString("settings") + "..."); JMenuItem quit_item = new JMenuItem("Beenden"); if (Utilities.appLanguage().equals("fr")) { print_item.setText("Imprimer"); quit_item.setText("Terminer"); } datei_menu.add(print_item); datei_menu.addSeparator(); datei_menu.add(settings_item); datei_menu.addSeparator(); datei_menu.add(quit_item); // -- Menu "Aktualisieren" -- JMenu update_menu = new JMenu("Aktualisieren"); if (Utilities.appLanguage().equals("fr")) update_menu.setText("Mise jour"); menu_bar.add(update_menu); final JMenuItem updatedb_item = new JMenuItem("Aktualisieren via Internet..."); updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.CTRL_MASK)); JMenuItem choosedb_item = new JMenuItem("Aktualisieren via Datei..."); update_menu.add(updatedb_item); update_menu.add(choosedb_item); if (Utilities.appLanguage().equals("fr")) { updatedb_item.setText("Tlcharger la banque de donnes..."); updatedb_item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK)); choosedb_item.setText("Ajourner la banque de donnes..."); } // -- Menu "Hilfe" -- JMenu hilfe_menu = new JMenu("Hilfe"); if (Utilities.appLanguage().equals("fr")) hilfe_menu.setText("Aide"); menu_bar.add(hilfe_menu); JMenuItem about_item = new JMenuItem("ber " + Constants.APP_NAME + "..."); JMenuItem ywesee_item = new JMenuItem(Constants.APP_NAME + " im Internet"); if (Utilities.appCustomization().equals("meddrugs")) ywesee_item.setText("med-drugs im Internet"); JMenuItem report_item = new JMenuItem("Error Report..."); JMenuItem contact_item = new JMenuItem("Kontakt..."); if (Utilities.appLanguage().equals("fr")) { // Extrawunsch med-drugs if (Utilities.appCustomization().equals("meddrugs")) about_item.setText(Constants.APP_NAME); else about_item.setText("A propos de " + Constants.APP_NAME + "..."); contact_item.setText("Contact..."); if (Utilities.appCustomization().equals("meddrugs")) ywesee_item.setText("med-drugs sur Internet"); else ywesee_item.setText(Constants.APP_NAME + " sur Internet"); report_item.setText("Rapport d'erreur..."); } hilfe_menu.add(about_item); hilfe_menu.add(ywesee_item); hilfe_menu.addSeparator(); hilfe_menu.add(report_item); hilfe_menu.addSeparator(); hilfe_menu.add(contact_item); // Menu "Abonnieren" (only for ywesee) JMenu subscribe_menu = new JMenu("Abonnieren"); if (Utilities.appLanguage().equals("fr")) subscribe_menu.setText("Abonnement"); if (Utilities.appCustomization().equals("ywesee")) { menu_bar.add(subscribe_menu); } jframe.setJMenuBar(menu_bar); // ------ Setup toolbar ------ JToolBar toolBar = new JToolBar("Database"); toolBar.setPreferredSize(new Dimension(jframe.getWidth(), 64)); final JToggleButton selectAipsButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "aips32x32_bright.png")); final JToggleButton selectFavoritesButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "favorites32x32_bright.png")); final JToggleButton selectInteractionsButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "interactions32x32_bright.png")); final JToggleButton selectShoppingCartButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "shoppingcart32x32_bright.png")); final JToggleButton selectComparisonCartButton = new JToggleButton( new ImageIcon(Constants.IMG_FOLDER + "comparisoncart32x32_bright.png")); final JToggleButton list_of_buttons[] = { selectAipsButton, selectFavoritesButton, selectInteractionsButton, selectShoppingCartButton, selectComparisonCartButton }; if (Utilities.appLanguage().equals("de")) { setupButton(selectAipsButton, "Kompendium", "aips32x32_gray.png", "aips32x32_dark.png"); setupButton(selectFavoritesButton, "Favoriten", "favorites32x32_gray.png", "favorites32x32_dark.png"); setupButton(selectInteractionsButton, "Interaktionen", "interactions32x32_gray.png", "interactions32x32_dark.png"); setupButton(selectShoppingCartButton, "Warenkorb", "shoppingcart32x32_gray.png", "shoppingcart32x32_dark.png"); setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png", "comparisoncart32x32_dark.png"); } else if (Utilities.appLanguage().equals("fr")) { setupButton(selectAipsButton, "Compendium", "aips32x32_gray.png", "aips32x32_dark.png"); setupButton(selectFavoritesButton, "Favorites", "favorites32x32_gray.png", "favorites32x32_dark.png"); setupButton(selectInteractionsButton, "Interactions", "interactions32x32_gray.png", "interactions32x32_dark.png"); setupButton(selectShoppingCartButton, "Panier", "shoppingcart32x32_gray.png", "shoppingcart32x32_dark.png"); setupButton(selectComparisonCartButton, "Preisvergleich", "comparisoncart32x32_gray.png", "comparisoncart32x32_dark.png"); } // Add to toolbar and set up toolBar.setBackground(m_toolbar_bg); toolBar.add(selectAipsButton); toolBar.addSeparator(); toolBar.add(selectFavoritesButton); toolBar.addSeparator(); toolBar.add(selectInteractionsButton); if (!Utilities.appCustomization().equals("zurrose")) { toolBar.addSeparator(); toolBar.add(selectShoppingCartButton); } if (Utilities.appCustomization().equals("zurrorse")) { toolBar.addSeparator(); toolBar.add(selectComparisonCartButton); } toolBar.setRollover(true); toolBar.setFloatable(false); // Progress indicator (not working...) toolBar.addSeparator(new Dimension(32, 32)); toolBar.add(m_progress_indicator); // ------ Setup settingspage ------ final SettingsPage settingsPage = new SettingsPage(jframe, m_rb); // Attach observer to it settingsPage.addObserver(new Observer() { public void update(Observable o, Object arg) { System.out.println(arg); if (m_shopping_cart != null) { // Refresh some stuff m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } } }); jframe.addWindowListener(new WindowListener() { // Use WindowAdapter! @Override public void windowOpened(WindowEvent e) { } @Override public void windowClosed(WindowEvent e) { m_web_panel.dispose(); Runtime.getRuntime().exit(0); } @Override public void windowClosing(WindowEvent e) { // Save shopping cart int index = m_shopping_cart.getCartIndex(); if (index > 0 && m_web_panel != null) m_web_panel.saveShoppingCartWithIndex(index); } @Override public void windowIconified(WindowEvent e) { } @Override public void windowDeiconified(WindowEvent e) { } @Override public void windowActivated(WindowEvent e) { } @Override public void windowDeactivated(WindowEvent e) { } }); print_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { m_web_panel.print(); } }); settings_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { settingsPage.display(); } }); quit_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { try { // Save shopping cart int index = m_shopping_cart.getCartIndex(); if (index > 0 && m_web_panel != null) m_web_panel.saveShoppingCartWithIndex(index); // Save settings WindowSaver.saveSettings(); m_web_panel.dispose(); Runtime.getRuntime().exit(0); } catch (Exception e) { System.out.println(e); } } }); subscribe_menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI( "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3UM84Z6WLFKZE")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } @Override public void menuDeselected(MenuEvent event) { // do nothing } @Override public void menuCanceled(MenuEvent event) { // do nothing } }); contact_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI .create("mailto:zdavatz@ywesee.com?subject=AmiKo%20Desktop%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("desitin")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI .create("mailto:info@desitin.ch?subject=AmiKo%20Desktop%20Desitin%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("meddrugs")) { if (Desktop.isDesktopSupported()) { try { URI mail_to_uri = URI.create( "mailto:med-drugs@just-medical.com?subject=med-drugs%20desktop%20Feedback"); Desktop.getDesktop().mail(mail_to_uri); } catch (IOException e) { // TODO: } } else { AmiKoDialogs cd = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); cd.ContactDialog(); } } else if (Utilities.appCustomization().equals("zurrose")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } }); report_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { // Check first m_application_folder otherwise resort to // pre-installed report String report_file = m_application_data_folder + "\\" + Constants.DEFAULT_AMIKO_REPORT_BASE + Utilities.appLanguage() + ".html"; if (!(new File(report_file)).exists()) report_file = System.getProperty("user.dir") + "/dbs/" + Constants.DEFAULT_AMIKO_REPORT_BASE + Utilities.appLanguage() + ".html"; // Open report file in browser if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new File(report_file).toURI()); } catch (IOException e) { // TODO: } } } }); ywesee_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (Utilities.appCustomization().equals("ywesee")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("http://www.ywesee.com/AmiKo/Desktop")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("desitin")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse( new URI("http://www.desitin.ch/produkte/arzneimittel-kompendium-apps/")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("meddrugs")) { if (Desktop.isDesktopSupported()) { try { if (Utilities.appLanguage().equals("de")) Desktop.getDesktop().browse(new URI("http://www.med-drugs.ch")); else if (Utilities.appLanguage().equals("fr")) Desktop.getDesktop() .browse(new URI("http://www.med-drugs.ch/index.cfm?&newlang=fr")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } else if (Utilities.appCustomization().equals("zurrose")) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("www.zurrose.ch/amiko")); } catch (IOException e) { // TODO: } catch (URISyntaxException r) { // TODO: } } } } }); about_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { AmiKoDialogs ad = new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()); ad.AboutDialog(); } }); // Container final Container container = jframe.getContentPane(); container.setBackground(Color.WHITE); container.setLayout(new BorderLayout()); // ==== Toolbar ===== container.add(toolBar, BorderLayout.NORTH); // ==== Left panel ==== JPanel left_panel = new JPanel(); left_panel.setBackground(Color.WHITE); left_panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(2, 2, 2, 2); // ---- Search field ---- final SearchField searchField = new SearchField("Suche Prparat"); if (Utilities.appLanguage().equals("fr")) searchField.setText("Recherche Specialit"); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(searchField, gbc); left_panel.add(searchField, gbc); // ---- Buttons ---- // Names String l_title = "Prparat"; String l_author = "Inhaberin"; String l_atccode = "Wirkstoff / ATC Code"; String l_regnr = "Zulassungsnummer"; String l_ingredient = "Wirkstoff"; String l_therapy = "Therapie"; String l_search = "Suche"; if (Utilities.appLanguage().equals("fr")) { l_title = "Spcialit"; l_author = "Titulaire"; l_atccode = "Principe Active / Code ATC"; l_regnr = "Nombre Enregistration"; l_ingredient = "Principe Active"; l_therapy = "Thrapie"; l_search = "Recherche"; } ButtonGroup bg = new ButtonGroup(); JToggleButton but_title = new JToggleButton(l_title); setupToggleButton(but_title); bg.add(but_title); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_title, gbc); left_panel.add(but_title, gbc); JToggleButton but_auth = new JToggleButton(l_author); setupToggleButton(but_auth); bg.add(but_auth); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_auth, gbc); left_panel.add(but_auth, gbc); JToggleButton but_atccode = new JToggleButton(l_atccode); setupToggleButton(but_atccode); bg.add(but_atccode); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_atccode, gbc); left_panel.add(but_atccode, gbc); JToggleButton but_regnr = new JToggleButton(l_regnr); setupToggleButton(but_regnr); bg.add(but_regnr); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_regnr, gbc); left_panel.add(but_regnr, gbc); JToggleButton but_therapy = new JToggleButton(l_therapy); setupToggleButton(but_therapy); bg.add(but_therapy); gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = gbc.gridheight = 1; gbc.weightx = gbc.weighty = 0.0; // --> container.add(but_therapy, gbc); left_panel.add(but_therapy, gbc); // ---- Card layout ---- final CardLayout cardl = new CardLayout(); cardl.setHgap(-4); // HACK to make things look better!! final JPanel p_results = new JPanel(cardl); m_list_titles = new ListPanel(); m_list_auths = new ListPanel(); m_list_regnrs = new ListPanel(); m_list_atccodes = new ListPanel(); m_list_ingredients = new ListPanel(); m_list_therapies = new ListPanel(); // Contraints gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy += 1; gbc.gridwidth = 1; gbc.gridheight = 10; gbc.weightx = 1.0; gbc.weighty = 1.0; // p_results.add(m_list_titles, l_title); p_results.add(m_list_auths, l_author); p_results.add(m_list_regnrs, l_regnr); p_results.add(m_list_atccodes, l_atccode); p_results.add(m_list_ingredients, l_ingredient); p_results.add(m_list_therapies, l_therapy); // --> container.add(p_results, gbc); left_panel.add(p_results, gbc); left_panel.setBorder(null); // First card to show cardl.show(p_results, l_title); // ==== Right panel ==== JPanel right_panel = new JPanel(); right_panel.setBackground(Color.WHITE); right_panel.setLayout(new GridBagLayout()); // ---- Section titles ---- m_section_titles = null; if (Utilities.appLanguage().equals("de")) { m_section_titles = new IndexPanel(SectionTitle_DE); } else if (Utilities.appLanguage().equals("fr")) { m_section_titles = new IndexPanel(SectionTitle_FR); } m_section_titles.setMinimumSize(new Dimension(150, 150)); m_section_titles.setMaximumSize(new Dimension(320, 1000)); // ---- Fachinformation ---- m_web_panel = new WebPanel2(); m_web_panel.setMinimumSize(new Dimension(320, 150)); // Add JSplitPane on the RIGHT final int Divider_location = 150; final int Divider_size = 10; final JSplitPane split_pane_right = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, m_section_titles, m_web_panel); split_pane_right.setOneTouchExpandable(true); split_pane_right.setDividerLocation(Divider_location); split_pane_right.setDividerSize(Divider_size); // Add JSplitPane on the LEFT JSplitPane split_pane_left = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left_panel, split_pane_right /* right_panel */); split_pane_left.setOneTouchExpandable(true); split_pane_left.setDividerLocation(320); // Sets the pane divider location split_pane_left.setDividerSize(Divider_size); container.add(split_pane_left, BorderLayout.CENTER); // Add status bar on the bottom JPanel statusPanel = new JPanel(); statusPanel.setPreferredSize(new Dimension(jframe.getWidth(), 16)); statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); container.add(statusPanel, BorderLayout.SOUTH); final JLabel m_status_label = new JLabel(""); m_status_label.setHorizontalAlignment(SwingConstants.LEFT); statusPanel.add(m_status_label); // Add mouse listener searchField.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { searchField.setText(""); } }); final String final_title = l_title; final String final_author = l_author; final String final_atccode = l_atccode; final String final_regnr = l_regnr; final String final_therapy = l_therapy; final String final_search = l_search; // Internal class that implements switching between buttons final class Toggle { public void toggleButton(JToggleButton jbn) { for (int i = 0; i < list_of_buttons.length; ++i) { if (jbn == list_of_buttons[i]) list_of_buttons[i].setSelected(true); else list_of_buttons[i].setSelected(false); } } } ; // ------ Add toolbar action listeners ------ selectAipsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectAipsButton); // Set state 'aips' if (!m_curr_uistate.getUseMode().equals("aips")) { m_curr_uistate.setUseMode("aips"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); m_query_str = searchField.getText(); int num_hits = retrieveAipsSearchResults(false); m_status_label.setText(med_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); // if (med_index < 0 && prev_med_index >= 0) med_index = prev_med_index; m_web_panel.updateText(); if (num_hits == 0) { m_web_panel.emptyPage(); } } }); } } }); selectFavoritesButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectFavoritesButton); // Set state 'favorites' if (!m_curr_uistate.getUseMode().equals("favorites")) { m_curr_uistate.setUseMode("favorites"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); // m_query_str = searchField.getText(); // Clear the search container med_search.clear(); for (String regnr : favorite_meds_set) { List<Medication> meds = m_sqldb.searchRegNr(regnr); if (!meds.isEmpty()) { // Add med database ID med_search.add(meds.get(0)); } } // Sort list of meds Collections.sort(med_search, new Comparator<Medication>() { @Override public int compare(final Medication m1, final Medication m2) { return m1.getTitle().compareTo(m2.getTitle()); } }); sTitle(); cardl.show(p_results, final_title); m_status_label.setText(med_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } }); } } }); selectInteractionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectInteractionsButton); // Set state 'interactions' if (!m_curr_uistate.getUseMode().equals("interactions")) { m_curr_uistate.setUseMode("interactions"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_query_str = searchField.getText(); retrieveAipsSearchResults(false); // Switch to interaction mode m_web_panel.updateInteractionsCart(); m_web_panel.repaint(); m_web_panel.validate(); } }); } } }); selectShoppingCartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String email_adr = m_prefs.get("emailadresse", ""); if (email_adr != null && email_adr.length() > 2) // Two chars is the minimum lenght for an email address m_preferences_ok = true; if (m_preferences_ok) { m_preferences_ok = false; // Check always new Toggle().toggleButton(selectShoppingCartButton); // Set state 'shopping' if (!m_curr_uistate.getUseMode().equals("shopping")) { m_curr_uistate.setUseMode("shopping"); // Show middle pane split_pane_right.setDividerSize(Divider_size); split_pane_right.setDividerLocation(Divider_location); m_section_titles.setVisible(true); // Set right panel title m_web_panel.setTitle(m_rb.getString("shoppingCart")); // Switch to shopping cart int index = 1; if (m_shopping_cart != null) { index = m_shopping_cart.getCartIndex(); m_web_panel.loadShoppingCartWithIndex(index); // m_shopping_cart.printShoppingBasket(); } // m_web_panel.updateShoppingHtml(); m_web_panel.updateListOfPackages(); if (m_first_pass == true) { m_first_pass = false; if (Utilities.appCustomization().equals("ywesee")) med_search = m_sqldb.searchAuth("ibsa"); else if (Utilities.appCustomization().equals("desitin")) med_search = m_sqldb.searchAuth("desitin"); sAuth(); cardl.show(p_results, final_author); } } } else { selectShoppingCartButton.setSelected(false); settingsPage.display(); } } }); selectComparisonCartButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { new Toggle().toggleButton(selectComparisonCartButton); // Set state 'comparison' if (!m_curr_uistate.getUseMode().equals("comparison")) { m_curr_uistate.setUseMode("comparison"); // Hide middle pane m_section_titles.setVisible(false); split_pane_right.setDividerLocation(0); split_pane_right.setDividerSize(0); // SwingUtilities.invokeLater(new Runnable() { @Override public void run() { m_start_time = System.currentTimeMillis(); // Set right panel title m_web_panel.setTitle(getTitle("priceComp")); if (med_index >= 0) { if (med_id != null && med_index < med_id.size()) { Medication m = m_sqldb.getMediWithId(med_id.get(med_index)); String atc_code = m.getAtcCode(); if (atc_code != null) { String atc = atc_code.split(";")[0]; m_web_panel.fillComparisonBasket(atc); m_web_panel.updateComparisonCartHtml(); // Update pane on the left retrieveAipsSearchResults(false); } } } m_status_label.setText(rose_search.size() + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } }); } } }); // ------ Add keylistener to text field (type as you go feature) ------ searchField.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { // keyReleased(KeyEvent e) // invokeLater potentially in the wrong place... more testing // required SwingUtilities.invokeLater(new Runnable() { @Override public void run() { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); m_start_time = System.currentTimeMillis(); m_query_str = searchField.getText(); // Queries for SQLite DB if (!m_query_str.isEmpty()) { if (m_query_type == 0) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchTitle(m_query_str); } else { med_search = m_sqldb.searchTitle(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sTitle(); cardl.show(p_results, final_title); } else if (m_query_type == 1) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchSupplier(m_query_str); } else { med_search = m_sqldb.searchAuth(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sAuth(); cardl.show(p_results, final_author); } else if (m_query_type == 2) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchATC(m_query_str); } else { med_search = m_sqldb.searchATC(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sATC(); cardl.show(p_results, final_atccode); } else if (m_query_type == 3) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchEan(m_query_str); } else { med_search = m_sqldb.searchRegNr(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sRegNr(); cardl.show(p_results, final_regnr); } else if (m_query_type == 4) { if (m_curr_uistate.isComparisonMode()) { rose_search = m_rosedb.searchTherapy(m_query_str); } else { med_search = m_sqldb.searchApplication(m_query_str); if (m_curr_uistate.databaseUsed().equals("favorites")) retrieveFavorites(); } sTherapy(); cardl.show(p_results, final_therapy); } else { // do nothing } int num_hits = 0; if (m_curr_uistate.isComparisonMode()) num_hits = rose_search.size(); else num_hits = med_search.size(); m_status_label.setText(num_hits + " Suchresultate in " + (System.currentTimeMillis() - m_start_time) / 1000.0f + " Sek."); } } }); } }); // Add actionlisteners but_title.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_title); m_curr_uistate.setQueryType(m_query_type = 0); sTitle(); cardl.show(p_results, final_title); } }); but_auth.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_author); m_curr_uistate.setQueryType(m_query_type = 1); sAuth(); cardl.show(p_results, final_author); } }); but_atccode.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_atccode); m_curr_uistate.setQueryType(m_query_type = 2); sATC(); cardl.show(p_results, final_atccode); } }); but_regnr.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_regnr); m_curr_uistate.setQueryType(m_query_type = 3); sRegNr(); cardl.show(p_results, final_regnr); } }); but_therapy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (m_curr_uistate.isLoadCart()) m_curr_uistate.restoreUseMode(); searchField.setText(final_search + " " + final_therapy); m_curr_uistate.setQueryType(m_query_type = 4); sTherapy(); cardl.show(p_results, final_therapy); } }); // Display window jframe.pack(); // jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // jframe.setAlwaysOnTop(true); jframe.setVisible(true); // Check if user has selected an alternative database /* * NOTE: 21/11/2013: This solution is put on ice. Favored is a solution * where the database selected by the user is saved in a default folder * (see variable "m_application_data_folder") */ /* * try { WindowSaver.loadSettings(jframe); String database_path = * WindowSaver.getDbPath(); if (database_path!=null) * m_sqldb.loadDBFromPath(database_path); } catch(IOException e) { * e.printStackTrace(); } */ // Load AIPS database selectAipsButton.setSelected(true); selectFavoritesButton.setSelected(false); m_curr_uistate.setUseMode("aips"); med_search = m_sqldb.searchTitle(""); sTitle(); // Used instead of sTitle (which is slow) cardl.show(p_results, final_title); // Add menu item listeners updatedb_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (m_mutex_update == false) { m_mutex_update = true; String db_file = m_maindb_update.doIt(jframe, Utilities.appLanguage(), Utilities.appCustomization(), m_application_data_folder, m_full_db_update); // ... and update time if (m_full_db_update == true) { DateTime dT = new DateTime(); m_prefs.put("updateTime", dT.now().toString()); } // if (!db_file.isEmpty()) { // Save db path (can't hurt) WindowSaver.setDbPath(db_file); } } } }); choosedb_item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String db_file = m_maindb_update.chooseFromFile(jframe, Utilities.appLanguage(), Utilities.appCustomization(), m_application_data_folder); // ... and update time DateTime dT = new DateTime(); m_prefs.put("updateTime", dT.now().toString()); // if (!db_file.isEmpty()) { // Save db path (can't hurt) WindowSaver.setDbPath(db_file); } } }); /** * Observers */ // Attach observer to 'm_update' m_maindb_update.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); // Reset flag m_full_db_update = true; m_mutex_update = false; // Refresh some stuff after update loadAuthors(); m_emailer.loadMap(); settingsPage.load_gln_codes(); if (m_shopping_cart != null) { m_shopping_cart.load_conditions(); m_shopping_cart.load_glns(); } // Empty shopping basket if (m_curr_uistate.isShoppingMode()) { m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } if (m_curr_uistate.isComparisonMode()) m_web_panel.setTitle(getTitle("priceComp")); } }); // Attach observer to 'm_emailer' m_emailer.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); // Empty shopping basket m_shopping_basket.clear(); int index = m_shopping_cart.getCartIndex(); if (index > 0) m_web_panel.saveShoppingCartWithIndex(index); m_web_panel.updateShoppingHtml(); } }); // Attach observer to "m_comparison_cart" m_comparison_cart.addObserver(new Observer() { @Override public void update(Observable o, Object arg) { System.out.println(arg); m_web_panel.setTitle(getTitle("priceComp")); m_comparison_cart.clearUploadList(); m_web_panel.updateComparisonCartHtml(); new AmiKoDialogs(Utilities.appLanguage(), Utilities.appCustomization()).UploadDialog((String) arg); } }); // If command line options are provided start app with a particular title or eancode if (commandLineOptionsProvided()) { if (!CML_OPT_TITLE.isEmpty()) startAppWithTitle(but_title); else if (!CML_OPT_EANCODE.isEmpty()) startAppWithEancode(but_regnr); else if (!CML_OPT_REGNR.isEmpty()) startAppWithRegnr(but_regnr); } // Start timer Timer global_timer = new Timer(); // Time checks all 2 minutes (120'000 milliseconds) global_timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { checkIfUpdateRequired(updatedb_item); } }, 2 * 60 * 1000, 2 * 60 * 1000); }
From source file:com.diversityarrays.kdxplore.curate.TrialDataEditor.java
@Override public JMenuBar getJMenuBar() { if (menuBar == null) { JMenuItem menuItem;/*from w w w. j av a 2s . co m*/ // JMenu windowsMenu = new JMenu("Graphs & Plots"); showAll.setEnabled(false); menuItem = windowsMenu.add(showAll); menuItem.setMnemonic('B'); menuItem.setAccelerator( KeyStroke.getKeyStroke('B', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); closeAll.setEnabled(false); windowsMenu.add(closeAll); windowsMenu.addSeparator(); JMenu fileMenu = new JMenu(Msg.MENU_FILE()); menuItem = fileMenu.add(saveChangesAction); menuItem.setMnemonic('S'); menuItem.setAccelerator( KeyStroke.getKeyStroke('S', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem = fileMenu.add(exportCuratedData); // menuItem.setMnemonic('T'); // menuItem.setAccelerator(KeyStroke.getKeyStroke('T', // Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask())); fileMenu.addSeparator(); fileMenu.add(importCuratedData); importCuratedData.setEnabled(true); JMenu editMenu = new JMenu(Msg.MENU_EDIT()); menuItem = editMenu.add(undoAction); menuItem.setMnemonic('Z'); menuItem.setAccelerator( KeyStroke.getKeyStroke('Z', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menuItem = editMenu.add(redoAction); menuItem.setMnemonic('Y'); menuItem.setAccelerator( KeyStroke.getKeyStroke('Y', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); // undockMenuItem = viewMenu.add(undockViewAction); showWarnings.setEnabled(false); JMenu viewMenu = new JMenu(Msg.MENU_VIEW()); viewMenu.add(showWarnings); problemMenu.add(new ReportIssueAction(this)); menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(viewMenu); menuBar.add(windowsMenu); menuBar.add(problemMenu); } return menuBar; }
From source file:com.monead.semantic.workbench.SemanticWorkbench.java
/** * Create the edit menu/*from w ww . ja v a 2 s . c o m*/ * * @return The edit menu */ private JMenu setupEditMenu() { final JMenu menu = new JMenu("Edit"); menu.setMnemonic(KeyEvent.VK_E); menu.setToolTipText("Menu items related to editing the ontology"); editFind = new JMenuItem("Find (in assertions)"); editFind.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK)); editFind.setMnemonic(KeyEvent.VK_F); editFind.setToolTipText("Find text in the assertions editor"); editFind.addActionListener(new FindAssertionsTextListener()); menu.add(editFind); editFindNextMatch = new JMenuItem("Next (matching assertion text)"); editFindNextMatch.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)); editFindNextMatch.setMnemonic(KeyEvent.VK_N); editFindNextMatch.setToolTipText("Find next text match in the assertions editor"); editFindNextMatch.addActionListener(new FindNextAssertionsTextListener()); menu.add(editFindNextMatch); menu.addSeparator(); editCommentToggle = new JMenuItem("Toggle Comment"); editCommentToggle.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_MASK)); editCommentToggle.setMnemonic(KeyEvent.VK_T); editCommentToggle .setToolTipText("Switch the chosen assertion or query lines between commented and not commented"); editCommentToggle.addActionListener(new CommentToggleListener()); editCommentToggle.setEnabled(false); menu.add(editCommentToggle); editInsertPrefixes = new JMenuItem("Insert Prefixes"); editInsertPrefixes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK)); editInsertPrefixes.setMnemonic(KeyEvent.VK_I); editInsertPrefixes.setToolTipText("Insert standard prefixes (namespaces)"); editInsertPrefixes.addActionListener(new InsertPrefixesListener()); menu.add(editInsertPrefixes); menu.addSeparator(); editExpandAllTreeNodes = new JMenuItem("Expand Entire Tree"); editExpandAllTreeNodes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, ActionEvent.ALT_MASK)); editExpandAllTreeNodes.setMnemonic(KeyEvent.VK_E); editExpandAllTreeNodes.setToolTipText("Expand all tree nodes"); editExpandAllTreeNodes.addActionListener(new ExpandTreeListener()); menu.add(editExpandAllTreeNodes); editCollapseAllTreeNodes = new JMenuItem("Collapse Entire Tree"); editCollapseAllTreeNodes.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, ActionEvent.ALT_MASK)); editCollapseAllTreeNodes.setMnemonic(KeyEvent.VK_C); editCollapseAllTreeNodes.setToolTipText("Expand all tree nodes"); editCollapseAllTreeNodes.addActionListener(new CollapseTreeListener()); menu.add(editCollapseAllTreeNodes); menu.addSeparator(); editEditListOfSparqlServiceUrls = new JMenuItem("Edit SPARQL Service URLs List"); editEditListOfSparqlServiceUrls.setMnemonic(KeyEvent.VK_S); editEditListOfSparqlServiceUrls.setToolTipText("Remove unwanted URLs from the dropdown list"); editEditListOfSparqlServiceUrls.addActionListener(new EditListOfSparqlServiceUrls()); menu.add(editEditListOfSparqlServiceUrls); return menu; }