List of usage examples for java.awt.event KeyEvent VK_S
int VK_S
To view the source code for java.awt.event KeyEvent VK_S.
Click Source Link
From source file:edu.ku.brc.specify.tasks.subpane.qb.QueryBldrPane.java
/** * create the query builder UI./*from w w w. ja v a 2 s .c om*/ */ protected void createUI() { removeAll(); JMenuItem saveItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE")); Action saveActionListener = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (saveQuery(false)) { try { String selId = null; if (selectedQFP != null && selectedQFP.getQueryField() != null) { selId = selectedQFP.getQueryField().getStringId(); } final String selectedFldId = selId; setupUI(true); SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { if (selectedFldId != null) { for (QueryFieldPanel qfp : queryFieldItems) { if (qfp.getQueryField() != null && selectedFldId.equals(qfp.getQueryField().getStringId())) { selectQFP(qfp); return; } } selectQFP(queryFieldItems.get(0)); } } }); } catch (Exception ex) { } setSaveBtnEnabled(false); } } }; saveItem.addActionListener(saveActionListener); JMenuItem saveAsItem = new JMenuItem(UIRegistry.getResourceString("QB_SAVE_AS")); Action saveAsActionListener = new AbstractAction() { public void actionPerformed(ActionEvent e) { if (saveQuery(true)) { setSaveBtnEnabled(false); } } }; saveAsItem.addActionListener(saveAsActionListener); JComponent[] itemSample = { saveItem, saveAsItem }; saveBtn = new DropDownButton(UIRegistry.getResourceString("QB_SAVE"), null, 1, java.util.Arrays.asList(itemSample)); saveBtn.addActionListener(saveActionListener); String ACTION_KEY = "SAVE"; KeyStroke ctrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); InputMap inputMap = saveBtn.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(ctrlS, ACTION_KEY); ActionMap actionMap = saveBtn.getActionMap(); actionMap.put(ACTION_KEY, saveActionListener); ACTION_KEY = "SAVE_AS"; KeyStroke ctrlA = KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); inputMap.put(ctrlA, ACTION_KEY); actionMap.put(ACTION_KEY, saveAsActionListener); saveBtn.setActionMap(actionMap); UIHelper.setControlSize(saveBtn); //saveBtn.setOverrideBorder(true, BasicBorders.getButtonBorder()); listBoxPanel = new JPanel(new HorzLayoutManager(2, 2)); Vector<TableQRI> list = new Vector<TableQRI>(); for (int k = 0; k < tableTree.getKids(); k++) { list.add(tableTree.getKid(k).getTableQRI()); } Collections.sort(list); DefaultListModel model = new DefaultListModel(); for (TableQRI qri : list) { model.addElement(qri); } tableList = new JList(model); QryListRenderer qr = new QryListRenderer(IconManager.IconSize.Std16); qr.setDisplayKidIndicator(false); tableList.setCellRenderer(qr); JScrollPane spt = new JScrollPane(tableList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); Dimension pSize = spt.getPreferredSize(); pSize.height = 200; spt.setPreferredSize(pSize); JPanel topPanel = new JPanel(new BorderLayout()); scrollPane = new JScrollPane(listBoxPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); tableList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int inx = tableList.getSelectedIndex(); if (inx > -1) { fillNextList(tableList); } else { listBoxPanel.removeAll(); } } } }); addBtn = new JButton(IconManager.getImage("PlusSign", IconManager.IconSize.Std16)); addBtn.setEnabled(false); addBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { BaseQRI qri = (BaseQRI) listBoxList.get(currentInx).getSelectedValue(); if (qri.isInUse) { return; } try { FieldQRI fieldQRI = buildFieldQRI(qri); if (fieldQRI == null) { throw new Exception("null FieldQRI"); } SpQueryField qf = new SpQueryField(); qf.initialize(); qf.setFieldName(fieldQRI.getFieldName()); qf.setStringId(fieldQRI.getStringId()); query.addReference(qf, "fields"); if (!isExportMapping) { addQueryFieldItem(fieldQRI, qf, false); } else { addNewMapping(fieldQRI, qf, null, false); } } catch (Exception ex) { log.error(ex); UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(QueryBldrPane.class, ex); return; } } }); contextPanel = new JPanel(new BorderLayout()); contextPanel.add(createLabel("Search Context", SwingConstants.CENTER), BorderLayout.NORTH); // I18N contextPanel.add(spt, BorderLayout.CENTER); contextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); JPanel schemaPanel = new JPanel(new BorderLayout()); schemaPanel.add(scrollPane, BorderLayout.CENTER); topPanel.add(contextPanel, BorderLayout.WEST); topPanel.add(schemaPanel, BorderLayout.CENTER); add(topPanel, BorderLayout.NORTH); queryFieldsPanel = new JPanel(); queryFieldsPanel.setLayout(new NavBoxLayoutManager(0, 2)); queryFieldsScroll = new JScrollPane(queryFieldsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); queryFieldsScroll.setBorder(null); add(queryFieldsScroll); //if (!isExportMapping) //{ final JPanel mover = buildMoverPanel(false); add(mover, BorderLayout.EAST); // } String searchLbl = schemaMapping == null ? getResourceString("QB_SEARCH") : getResourceString("QB_EXPORT_PREVIEW"); searchBtn = createButton(searchLbl); searchBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { // int m = ae.getModifiers(); // boolean ors = (m & ActionEvent.ALT_MASK) > 0 && (m & ActionEvent.CTRL_MASK) > 0 && (m & ActionEvent.SHIFT_MASK) > 0; // if (ors) // { // System.out.println("Disjunctional conjoinment desire gesture detected"); // } // doSearch(ors); doSearch(false); } }); distinctChk = createCheckBox(UIRegistry.getResourceString("QB_DISTINCT")); distinctChk.setVisible(schemaMapping == null); if (schemaMapping == null) { distinctChk.setSelected(false); distinctChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { if (distinctChk.isSelected()) { UsageTracker.incrUsageCount("QB.DistinctOn"); } else { UsageTracker.incrUsageCount("QB.DistinctOff"); } if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly && distinctChk.isSelected()) { countOnlyChk.setSelected(false); countOnly = false; } query.setCountOnly(countOnly); query.setSelectDistinct(distinctChk.isSelected()); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); } countOnlyChk = createCheckBox(UIRegistry.getResourceString("QB_COUNT_ONLY")); countOnlyChk.setSelected(false); countOnlyChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { //Don't allow change while query is running. if (runningResults.get() == null) { countOnly = !countOnly; if (countOnly) { UsageTracker.incrUsageCount("QB.CountOnlyOn"); } else { UsageTracker.incrUsageCount("QB.CountOnlyOff"); } if ((isTreeLevelSelected() || isAggFieldSelected()) && countOnly && (distinctChk.isSelected() || searchSynonymyChk.isSelected())) { distinctChk.setSelected(false); searchSynonymyChk.setSelected(false); } } else { //This might be awkward and/or klunky... countOnlyChk.setSelected(countOnly); } query.setCountOnly(countOnly); query.setSelectDistinct(distinctChk.isSelected()); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); searchSynonymyChk = createCheckBox(UIRegistry.getResourceString("QB_SRCH_SYNONYMS")); searchSynonymyChk.setSelected(searchSynonymy); searchSynonymyChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* (non-Javadoc) * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { searchSynonymy = !searchSynonymy; if (!searchSynonymy) { UsageTracker.incrUsageCount("QB.SearchSynonymyOff"); } else { UsageTracker.incrUsageCount("QB.SearchSynonymyOn"); } if (isTreeLevelSelected() && countOnly && searchSynonymyChk.isSelected()) { countOnlyChk.setSelected(false); countOnly = false; } query.setSearchSynonymy(searchSynonymy); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); smushedChk = createCheckBox(UIRegistry.getResourceString("QB_SMUSH_RESULTS")); smushedChk.setVisible(isSmushableContext()); if (isSmushableContext()) { smushedChk.setSelected(smushed); smushedChk.setToolTipText( String.format(UIRegistry.getResourceString("QB_SMUSH_RESULTS_HINT"), getCatalogNumberTitle())); smushedChk.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { new SwingWorker() { /* * (non-Javadoc) * * @see edu.ku.brc.helpers.SwingWorker#construct() */ @Override public Object construct() { smushed = !smushed; if (!smushed) { UsageTracker.incrUsageCount("QB.SmushedOff"); } else { UsageTracker.incrUsageCount("QB.SmushedOn"); } query.setSmushed(smushed); setSaveBtnEnabled(thereAreItems()); return null; } }.start(); } }); } PanelBuilder outer = new PanelBuilder( new FormLayout("p, 2dlu, p, 2dlu, p, 2dlu, p, 2dlu, p, 6dlu, p", "p")); CellConstraints cc = new CellConstraints(); outer.add(smushedChk, cc.xy(1, 1)); outer.add(searchSynonymyChk, cc.xy(3, 1)); outer.add(distinctChk, cc.xy(5, 1)); outer.add(countOnlyChk, cc.xy(7, 1)); outer.add(searchBtn, cc.xy(9, 1)); outer.add(saveBtn, cc.xy(11, 1)); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(outer.getPanel(), BorderLayout.EAST); JButton helpBtn = UIHelper.createHelpIconButton(getHelpBtnContext()); bottom.add(helpBtn, BorderLayout.WEST); add(bottom, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); }
From source file:oct.analysis.application.OCTAnalysisUI.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//from ww w . j a va2 s . com */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { bindingGroup = new org.jdesktop.beansbinding.BindingGroup(); lrpButtonGroup = new javax.swing.ButtonGroup(); analysisToolBarBtnGroup = new javax.swing.ButtonGroup(); toolsToolBarBtnGroup = new javax.swing.ButtonGroup(); lrpSelectionWidthBean = new oct.analysis.application.dat.LRPSelectionWidthBean(); resizeOCTSelectionMouseMonitor = new oct.analysis.application.comp.ResizeOCTSelectionMouseMonitor(); octAnalysisPanel = new oct.analysis.application.OCTImagePanel(); filterPanel = new javax.swing.JPanel(); filtersToolbar = new javax.swing.JToolBar(); jPanel1 = new javax.swing.JPanel(); lrpSmoothingPanel = new javax.swing.JPanel(); lrpSmoothingSlider = new javax.swing.JSlider(); octSmoothingPanel = new javax.swing.JPanel(); octSmoothingSlider = new javax.swing.JSlider(); sharpRadiusPanel = new javax.swing.JPanel(); octSharpRadiusSlider = new javax.swing.JSlider(); octSharpWeightPanel = new javax.swing.JPanel(); octSharpWeightSlider = new javax.swing.JSlider(); analysisToolsToolBar = new javax.swing.JToolBar(); foveaSelectButton = new javax.swing.JToggleButton(); singleSelectButton = new javax.swing.JToggleButton(); screenSelectButton = new javax.swing.JToggleButton(); jLabel1 = new javax.swing.JLabel(); lrpWidthTextField = new javax.swing.JFormattedTextField(); displayPanel = new javax.swing.JPanel(); positionPanel = new javax.swing.JPanel(); mousePositionLabel = new oct.analysis.application.comp.MousePositionListeningLabel(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); jPanel2 = new javax.swing.JPanel(); mouseDistanceToFoveaLabel = new oct.analysis.application.comp.MouseDistanceToFoveaListeningLabel(); filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); dispControlPanel = new javax.swing.JPanel(); dispSelectionsCheckBox = new javax.swing.JCheckBox(); filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); dispSegmentationCheckBox = new javax.swing.JCheckBox(); filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); scaleBarCheckBox = new javax.swing.JCheckBox(); filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); imageLabel = new javax.swing.JLabel(); logModeOCTButton = new javax.swing.JRadioButton(); linearOCTModeButton = new javax.swing.JRadioButton(); appMenuBar = new javax.swing.JMenuBar(); fileMenu = new javax.swing.JMenu(); newAnalysisMenuItem = new javax.swing.JMenuItem(); openAnalysisMenuItem = new javax.swing.JMenuItem(); saveAnalysisMenuItem = new javax.swing.JMenuItem(); exportAnalysisResultsMenuItem = new javax.swing.JMenuItem(); Exit = new javax.swing.JMenuItem(); analysisMenu = new javax.swing.JMenu(); equidistantAutoMenuItem = new javax.swing.JMenuItem(); equidistantInteractiveMenuItem = new javax.swing.JMenuItem(); autoEzMenuItem = new javax.swing.JMenuItem(); interactiveEzMenuItem = new javax.swing.JMenuItem(); singleLRPAnalysisMenuItem = new javax.swing.JMenuItem(); autoMirrorMenuItem = new javax.swing.JMenuItem(); interactiveMirrorAnalysisMenuItem = new javax.swing.JMenuItem(); autoFoveaFindMenuItem = new javax.swing.JMenuItem(); interactiveFindFoveaMenuItem = new javax.swing.JMenuItem(); toolsMenu = new javax.swing.JMenu(); foveaSelectMenuItem = new javax.swing.JCheckBoxMenuItem(); singleSelectMenuItem = new javax.swing.JCheckBoxMenuItem(); lrpMenuItem = new javax.swing.JMenuItem(); toolbarsMenu = new javax.swing.JMenu(); filtersTBMenuItem = new javax.swing.JCheckBoxMenuItem(); org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding( org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, lrpWidthTextField, org.jdesktop.beansbinding.ELProperty.create("${value}"), lrpSelectionWidthBean, org.jdesktop.beansbinding.BeanProperty.create("lrpSelectionWidth")); bindingGroup.addBinding(binding); lrpSelectionWidthBean.addPropertyChangeListener(new java.beans.PropertyChangeListener() { public void propertyChange(java.beans.PropertyChangeEvent evt) { lrpSelectionWidthBeanPropertyChange(evt); } }); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("OCT Reflectivity Analytics"); setIconImage(new ImageIcon(getClass().getResource("/oct/rsc/icon/logo.png")).getImage()); setLocationByPlatform(true); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); } }); octAnalysisPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); octAnalysisPanel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { octAnalysisPanelMouseClicked(evt); } }); octAnalysisPanel.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { octAnalysisPanelKeyPressed(evt); } public void keyTyped(java.awt.event.KeyEvent evt) { octAnalysisPanelKeyTyped(evt); } }); javax.swing.GroupLayout octAnalysisPanelLayout = new javax.swing.GroupLayout(octAnalysisPanel); octAnalysisPanel.setLayout(octAnalysisPanelLayout); octAnalysisPanelLayout.setHorizontalGroup(octAnalysisPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); octAnalysisPanelLayout.setVerticalGroup(octAnalysisPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE)); filterPanel.setLayout(new java.awt.BorderLayout()); filtersToolbar.setBorder(javax.swing.BorderFactory.createEtchedBorder()); filtersToolbar.setOrientation(javax.swing.SwingConstants.VERTICAL); filtersToolbar.setRollover(true); filtersToolbar.setName("OCT Filters Toolbar"); // NOI18N lrpSmoothingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("LRP Smoothing Factor")); lrpSmoothingSlider.setMajorTickSpacing(5); lrpSmoothingSlider.setMaximum(51); lrpSmoothingSlider.setMinimum(1); lrpSmoothingSlider.setMinorTickSpacing(1); lrpSmoothingSlider.setPaintLabels(true); lrpSmoothingSlider.setPaintTicks(true); lrpSmoothingSlider.setSnapToTicks(true); lrpSmoothingSlider .setToolTipText("Adjust the smoothing applied to LRPs (values of 0 and 1 have the same effect)"); lrpSmoothingSlider.setValue(5); lrpSmoothingSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { lrpSmoothingSliderStateChanged(evt); } }); javax.swing.GroupLayout lrpSmoothingPanelLayout = new javax.swing.GroupLayout(lrpSmoothingPanel); lrpSmoothingPanel.setLayout(lrpSmoothingPanelLayout); lrpSmoothingPanelLayout.setHorizontalGroup( lrpSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( lrpSmoothingSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); lrpSmoothingPanelLayout.setVerticalGroup( lrpSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( lrpSmoothingSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); octSmoothingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("OCT Smoothing Factor")); octSmoothingSlider.setMajorTickSpacing(5); octSmoothingSlider.setMaximum(50); octSmoothingSlider.setMinorTickSpacing(1); octSmoothingSlider.setPaintLabels(true); octSmoothingSlider.setPaintTicks(true); octSmoothingSlider.setSnapToTicks(true); octSmoothingSlider .setToolTipText("Adjust the smoothing of the OCT image (performed using a 3x3 Gausian blur)"); octSmoothingSlider.setValue(0); octSmoothingSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { octSmoothingSliderStateChanged(evt); } }); javax.swing.GroupLayout octSmoothingPanelLayout = new javax.swing.GroupLayout(octSmoothingPanel); octSmoothingPanel.setLayout(octSmoothingPanelLayout); octSmoothingPanelLayout.setHorizontalGroup( octSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( octSmoothingSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)); octSmoothingPanelLayout.setVerticalGroup( octSmoothingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( octSmoothingSlider, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)); sharpRadiusPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("OCT Sharpen Radius")); octSharpRadiusSlider.setMajorTickSpacing(20); octSharpRadiusSlider.setMaximum(200); octSharpRadiusSlider.setMinorTickSpacing(5); octSharpRadiusSlider.setPaintLabels(true); octSharpRadiusSlider.setPaintTicks(true); octSharpRadiusSlider.setSnapToTicks(true); octSharpRadiusSlider.setToolTipText( "Adjust the number of pixels (as a radius) used to sharpen OCT at each given point"); octSharpRadiusSlider.setValue(0); octSharpRadiusSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { octSharpRadiusSliderStateChanged(evt); } }); javax.swing.GroupLayout sharpRadiusPanelLayout = new javax.swing.GroupLayout(sharpRadiusPanel); sharpRadiusPanel.setLayout(sharpRadiusPanelLayout); sharpRadiusPanelLayout.setHorizontalGroup( sharpRadiusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( octSharpRadiusSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)); sharpRadiusPanelLayout.setVerticalGroup( sharpRadiusPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( octSharpRadiusSlider, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)); octSharpWeightPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("OCT Sharpen Weight Factor")); octSharpWeightSlider.setMajorTickSpacing(10); octSharpWeightSlider.setMinorTickSpacing(2); octSharpWeightSlider.setPaintLabels(true); octSharpWeightSlider.setPaintTicks(true); octSharpWeightSlider.setToolTipText("Adjust the weighting factor given to the sharpened pixel information"); octSharpWeightSlider.setValue(0); octSharpWeightSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { octSharpWeightSliderStateChanged(evt); } }); javax.swing.GroupLayout octSharpWeightPanelLayout = new javax.swing.GroupLayout(octSharpWeightPanel); octSharpWeightPanel.setLayout(octSharpWeightPanelLayout); octSharpWeightPanelLayout.setHorizontalGroup( octSharpWeightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(octSharpWeightSlider, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); octSharpWeightPanelLayout.setVerticalGroup(octSharpWeightPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(octSharpWeightSlider, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(octSmoothingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lrpSmoothingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(sharpRadiusPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(octSharpWeightPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))); jPanel1Layout .setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(sharpRadiusPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lrpSmoothingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(6, 6, 6) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(octSharpWeightPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(octSmoothingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE))); filtersToolbar.add(jPanel1); filterPanel.add(filtersToolbar, java.awt.BorderLayout.CENTER); filtersToolbar.addAncestorListener(new ToolbarFloatListener(filtersToolbar, this)); analysisToolsToolBar.setBorder(javax.swing.BorderFactory.createEtchedBorder()); analysisToolsToolBar.setRollover(true); foveaSelectButton.setAction(foveaSelectMenuItem.getAction()); toolsToolBarBtnGroup.add(foveaSelectButton); foveaSelectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/FVselect.png"))); // NOI18N foveaSelectButton.setToolTipText("Fovea Selection Selector Tool"); foveaSelectButton.setEnabled(false); foveaSelectButton.setFocusable(false); foveaSelectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); foveaSelectButton.setSelectedIcon( new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/FVselectSelected.png"))); // NOI18N foveaSelectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); foveaSelectButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { foveaSelectButtonActionPerformed(evt); } }); analysisToolsToolBar.add(foveaSelectButton); singleSelectButton.setAction(singleSelectMenuItem.getAction()); toolsToolBarBtnGroup.add(singleSelectButton); singleSelectButton .setIcon(new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/SingleSelectIcon.png"))); // NOI18N singleSelectButton.setToolTipText("Selection Selector Tool"); singleSelectButton.setEnabled(false); singleSelectButton.setFocusable(false); singleSelectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); singleSelectButton.setSelectedIcon( new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/SingleSelectSelectedIcon.png"))); // NOI18N singleSelectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); singleSelectButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { singleSelectButtonActionPerformed(evt); } }); analysisToolsToolBar.add(singleSelectButton); toolsToolBarBtnGroup.add(screenSelectButton); screenSelectButton.setIcon( new javax.swing.ImageIcon(getClass().getResource("/oct/rsc/icon/mouse-pointer-th_19x25.png"))); // NOI18N screenSelectButton.setToolTipText("Selection Pointer Tool"); screenSelectButton.setEnabled(false); screenSelectButton.setFocusable(false); screenSelectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); screenSelectButton.setName(""); // NOI18N screenSelectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); screenSelectButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { screenSelectButtonActionPerformed(evt); } }); analysisToolsToolBar.add(screenSelectButton); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setLabelFor(lrpWidthTextField); jLabel1.setText("LRP Selection Width:"); jLabel1.setToolTipText("Width (in pixels) of the LRP selections on the OCT"); jLabel1.setFocusable(false); jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jLabel1.setMaximumSize(new java.awt.Dimension(105, 14)); analysisToolsToolBar.add(jLabel1); lrpWidthTextField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory( new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0")))); lrpWidthTextField.setHorizontalAlignment(javax.swing.JTextField.CENTER); lrpWidthTextField.setText("5"); lrpWidthTextField.setToolTipText("Set the width of the LRP selections (in pixels)"); lrpWidthTextField.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR)); lrpWidthTextField.setMaximumSize(new java.awt.Dimension(35, 25)); lrpWidthTextField.setMinimumSize(new java.awt.Dimension(35, 25)); lrpWidthTextField.setPreferredSize(new java.awt.Dimension(35, 25)); analysisToolsToolBar.add(lrpWidthTextField); displayPanel.setLayout(new javax.swing.BoxLayout(displayPanel, javax.swing.BoxLayout.LINE_AXIS)); positionPanel.setBorder(javax.swing.BorderFactory .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Position")); positionPanel.setPreferredSize(new java.awt.Dimension(80, 47)); mousePositionLabel.setText("Mouse Position"); javax.swing.GroupLayout positionPanelLayout = new javax.swing.GroupLayout(positionPanel); positionPanel.setLayout(positionPanelLayout); positionPanelLayout.setHorizontalGroup( positionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( mousePositionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)); positionPanelLayout.setVerticalGroup( positionPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( mousePositionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)); displayPanel.add(positionPanel); displayPanel.add(filler1); jPanel2.setBorder(javax.swing.BorderFactory .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "To Fovea")); jPanel2.setPreferredSize(new java.awt.Dimension(60, 47)); mouseDistanceToFoveaLabel.setText("Distance"); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout .setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(mouseDistanceToFoveaLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent( mouseDistanceToFoveaLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)); displayPanel.add(jPanel2); displayPanel.add(filler4); dispControlPanel.setBorder(javax.swing.BorderFactory .createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Display Control")); dispControlPanel.setLayout(new javax.swing.BoxLayout(dispControlPanel, javax.swing.BoxLayout.LINE_AXIS)); dispSelectionsCheckBox.setSelected(true); dispSelectionsCheckBox.setText("LRP Selections"); dispSelectionsCheckBox.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { dispSelectionsCheckBoxStateChanged(evt); } }); dispControlPanel.add(dispSelectionsCheckBox); dispControlPanel.add(filler2); dispSegmentationCheckBox.setText("Segmentation"); dispSegmentationCheckBox.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { dispSegmentationCheckBoxStateChanged(evt); } }); dispSegmentationCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { dispSegmentationCheckBoxActionPerformed(evt); } }); dispControlPanel.add(dispSegmentationCheckBox); dispControlPanel.add(filler3); scaleBarCheckBox.setText("Scale Bars"); scaleBarCheckBox.setToolTipText("Show or hide scale bars on the image"); scaleBarCheckBox.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { scaleBarCheckBoxStateChanged(evt); } }); scaleBarCheckBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { scaleBarCheckBoxActionPerformed(evt); } }); dispControlPanel.add(scaleBarCheckBox); dispControlPanel.add(filler5); imageLabel.setText("Image:"); dispControlPanel.add(imageLabel); lrpButtonGroup.add(logModeOCTButton); logModeOCTButton.setSelected(true); logModeOCTButton.setText("Logrithmic OCT"); logModeOCTButton.setToolTipText("Display the OCT image as a Logrithmic Image"); logModeOCTButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { logModeOCTButtonActionPerformed(evt); } }); dispControlPanel.add(logModeOCTButton); lrpButtonGroup.add(linearOCTModeButton); linearOCTModeButton.setText("Linear OCT"); linearOCTModeButton.setToolTipText("Display the OCT image as a Linear Image"); linearOCTModeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { linearOCTModeButtonActionPerformed(evt); } }); dispControlPanel.add(linearOCTModeButton); displayPanel.add(dispControlPanel); fileMenu.setText("File"); newAnalysisMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); newAnalysisMenuItem.setText("New Analysis"); newAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { newAnalysisMenuItemActionPerformed(evt); } }); fileMenu.add(newAnalysisMenuItem); openAnalysisMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); openAnalysisMenuItem.setText("Open Analysis"); openAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { openAnalysisMenuItemActionPerformed(evt); } }); fileMenu.add(openAnalysisMenuItem); saveAnalysisMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); saveAnalysisMenuItem.setText("Save Analysis"); saveAnalysisMenuItem.setEnabled(false); saveAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { saveAnalysisMenuItemActionPerformed(evt); } }); fileMenu.add(saveAnalysisMenuItem); exportAnalysisResultsMenuItem.setAccelerator(javax.swing.KeyStroke .getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK)); exportAnalysisResultsMenuItem.setText("Export Analysis Results"); exportAnalysisResultsMenuItem.setEnabled(false); exportAnalysisResultsMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exportAnalysisResultsMenuItemActionPerformed(evt); } }); fileMenu.add(exportAnalysisResultsMenuItem); Exit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK)); Exit.setText("Quit"); Exit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExitActionPerformed(evt); } }); fileMenu.add(Exit); appMenuBar.add(fileMenu); analysisMenu.setText("Analysis"); analysisMenu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { analysisMenuActionPerformed(evt); } }); equidistantAutoMenuItem.setText("Equidistant (automatic)"); equidistantAutoMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { equidistantAutoMenuItemActionPerformed(evt); } }); analysisMenu.add(equidistantAutoMenuItem); equidistantInteractiveMenuItem.setText("Equidistant (interactive)"); equidistantInteractiveMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { equidistantInteractiveMenuItemActionPerformed(evt); } }); analysisMenu.add(equidistantInteractiveMenuItem); autoEzMenuItem.setText("EZ (automatic)"); autoEzMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { autoEzMenuItemActionPerformed(evt); } }); analysisMenu.add(autoEzMenuItem); interactiveEzMenuItem.setText("EZ (interactive)"); interactiveEzMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { interactiveEzMenuItemActionPerformed(evt); } }); analysisMenu.add(interactiveEzMenuItem); singleLRPAnalysisMenuItem.setText("Single"); singleLRPAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { singleLRPAnalysisMenuItemActionPerformed(evt); } }); analysisMenu.add(singleLRPAnalysisMenuItem); autoMirrorMenuItem.setText("Mirror (automatic)"); autoMirrorMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { autoMirrorMenuItemActionPerformed(evt); } }); analysisMenu.add(autoMirrorMenuItem); interactiveMirrorAnalysisMenuItem.setText("Mirror (interactive)"); interactiveMirrorAnalysisMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { interactiveMirrorAnalysisMenuItemActionPerformed(evt); } }); analysisMenu.add(interactiveMirrorAnalysisMenuItem); autoFoveaFindMenuItem.setText("Find Fovea (automatic)"); autoFoveaFindMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { autoFoveaFindMenuItemActionPerformed(evt); } }); analysisMenu.add(autoFoveaFindMenuItem); interactiveFindFoveaMenuItem.setText("Find Fovea (interactive)"); interactiveFindFoveaMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { interactiveFindFoveaMenuItemActionPerformed(evt); } }); analysisMenu.add(interactiveFindFoveaMenuItem); appMenuBar.add(analysisMenu); toolsMenu.setText("Tools"); toolsMenu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { toolsMenuActionPerformed(evt); } }); foveaSelectMenuItem.setText("Select Fovea"); foveaSelectMenuItem.setEnabled(false); foveaSelectMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { foveaSelectMenuItemActionPerformed(evt); } }); toolsMenu.add(foveaSelectMenuItem); singleSelectMenuItem.setText("Select Single"); singleSelectMenuItem.setEnabled(false); singleSelectMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { singleSelectMenuItemActionPerformed(evt); } }); toolsMenu.add(singleSelectMenuItem); lrpMenuItem.setText("Generate LRPs"); lrpMenuItem.setEnabled(false); lrpMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { lrpMenuItemActionPerformed(evt); } }); toolsMenu.add(lrpMenuItem); appMenuBar.add(toolsMenu); toolbarsMenu.setText("Toolbars"); filtersTBMenuItem.setSelected(true); filtersTBMenuItem.setText("Filters Toolbar"); filtersTBMenuItem.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { filtersTBMenuItemActionPerformed(evt); } }); toolbarsMenu.add(filtersTBMenuItem); appMenuBar.add(toolbarsMenu); setJMenuBar(appMenuBar); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(octAnalysisPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(displayPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 736, Short.MAX_VALUE)) .addComponent(filterPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(analysisToolsToolBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(analysisToolsToolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(octAnalysisPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(displayPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(filterPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); analysisToolsToolBar.setFloatable(false); bindingGroup.bind(); pack(); }
From source file:haven.GameUI.java
public boolean globtype(char key, KeyEvent ev) { if (key == ':') { entercmd();/*from w w w . ja va2 s .c o m*/ return (true); } else if (key == ' ') { toggleui(); return (true); } else if (key == 3) { if (chat.visible && !chat.hasfocus) { setfocus(chat); } else { if (chat.sz.y == 0) { chat.resize(chat.savedw, chat.savedh); setfocus(chat); } else { chat.resize(0, 0); } } Utils.setprefb("chatvis", chat.sz.y != 0); } else if (key == 16) { /* if((polity != null) && polity.show(!polity.visible)) { polity.raise(); fitwdg(polity); setfocus(polity); } */ return (true); } else if ((key == 27) && (map != null) && !map.hasfocus) { setfocus(map); return (true); } else if (key != 0) { boolean alt = ev.isAltDown(); boolean ctrl = ev.isControlDown(); boolean shift = ev.isShiftDown(); int keycode = ev.getKeyCode(); if (alt && keycode >= KeyEvent.VK_0 && keycode <= KeyEvent.VK_9) { beltwdg.setCurrentBelt(Utils.floormod(keycode - KeyEvent.VK_0 - 1, 10)); return true; } else if (alt && keycode == KeyEvent.VK_S) { studywnd.show(!studywnd.visible); if (studywnd.visible) studywnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_M) { if (mmapwnd != null) { mmapwnd.togglefold(); return true; } } else if (alt && keycode == KeyEvent.VK_C) { craftwnd.show(!craftwnd.visible); if (craftwnd.visible) craftwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_B) { buildwnd.toggle(); if (buildwnd.visible) buildwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_N) { Config.nightvision.set(!Config.nightvision.get()); } else if (alt && keycode == KeyEvent.VK_G) { if (map != null) map.gridOverlay.setVisible(!map.gridOverlay.isVisible()); return true; } else if (alt && keycode == KeyEvent.VK_R) { if (mmap != null) mmap.toggleCustomIcons(); return true; } else if (alt && keycode == KeyEvent.VK_D) { if (map != null) map.toggleGobRadius(); return true; } else if (alt && keycode == KeyEvent.VK_Q) { Config.showQuality.set(!Config.showQuality.get()); return true; } else if (alt && keycode == KeyEvent.VK_K) { deckwnd.show(!deckwnd.visible); deckwnd.c = new Coord(sz.sub(deckwnd.sz).div(2)); if (deckwnd.visible) deckwnd.raise(); return true; } else if (alt && keycode == KeyEvent.VK_F) { if (map != null) { map.toggleFriendlyFire(); msg("Friendly fire prevention is now turned " + (map.isPreventFriendlyFireEnabled() ? "on" : "off")); } return true; } else if (alt && keycode == KeyEvent.VK_I) { Config.showGobInfo.set(!Config.showGobInfo.get()); return true; } else if (alt && keycode == KeyEvent.VK_W) { Config.screenshotMode = !Config.screenshotMode; return true; } else if (alt && keycode == KeyEvent.VK_T) { Config.disableTileTransitions.set(!Config.disableTileTransitions.get()); ui.sess.glob.map.rebuild(); return true; } else if (keycode == KeyEvent.VK_Q && ev.getModifiers() == 0) { /* // get all forageables from config List<String> names = new ArrayList<String>(); for (CustomIconGroup group : ui.sess.glob.icons.config.groups) { if ("Forageables".equals(group.name)) { for (CustomIconMatch match : group.matches) if (match.show) names.add(match.value); break; } } tasks.add(new Forager(11 * Config.autopickRadius.get(), 1, names.toArray(new String[names.size()]))); */ ContextTaskFinder.checkForageables(tasks, ui); return true; } else if (keycode == KeyEvent.VK_E && ev.getModifiers() == 0) { ContextTaskFinder.findHandTask(tasks, ui); return true; } else if (keycode == KeyEvent.VK_F && ev.getModifiers() == 0) { ContextTaskFinder.findBuilding(tasks, ui); return true; } else if (keycode >= KeyEvent.VK_NUMPAD1 && keycode <= KeyEvent.VK_NUMPAD4) { tasks.add(new MileStoneTask(Utils.floormod(keycode - KeyEvent.VK_NUMPAD0 - 1, 10))); return true; } else if (keycode == KeyEvent.VK_W && ev.getModifiers() == 0) { tasks.add(new Drunkard()); return true; } else if (shift && keycode == KeyEvent.VK_I) { Config.hideKinInfoForNonPlayers.set(!Config.hideKinInfoForNonPlayers.get()); return true; } else if (ctrl && keycode == KeyEvent.VK_H) { Config.hideModeEnabled.set(!Config.hideModeEnabled.get()); return true; } else if (alt && keycode == KeyEvent.VK_P) { Config.showGobPaths.set(!Config.showGobPaths.get()); return true; } else if (shift && keycode == KeyEvent.VK_W) { if (Config.showQualityMode.get() == 1) { Config.showQualityMode.set(2); } else { Config.showQualityMode.set(1); } return true; } else if (keycode == KeyEvent.VK_TAB && Config.agroclosest.get()) { if (map != null) map.aggroclosest(); return true; } else if (ctrl && keycode == KeyEvent.VK_F) { Config.displayFPS.set(!Config.displayFPS.get()); return true; } else if (keycode == KeyEvent.VK_Z && ev.getModifiers() == 0) { tasks.killAllTasks(); return true; } else if (keycode == 192 && ev.getModifiers() == 0) { getparent(GameUI.class).menu.wdgmsg("act", "travel", "hearth"); return true; } else if (shift && keycode == KeyEvent.VK_S) { HavenPanel.screenshot = true; return true; } } return (super.globtype(key, ev)); }
From source file:org.sikuli.ide.SikuliIDE.java
private void initFileMenu() throws NoSuchMethodException { JMenuItem jmi;//w ww . j av a 2s . c o m int scMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); _fileMenu.setMnemonic(java.awt.event.KeyEvent.VK_F); if (showAbout) { _fileMenu.add( createMenuItem("About SikuliX", KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, scMask), new FileAction(FileAction.ABOUT))); _fileMenu.addSeparator(); } _fileMenu.add(createMenuItem(_I("menuFileNew"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, scMask), new FileAction(FileAction.NEW))); jmi = _fileMenu.add(createMenuItem(_I("menuFileOpen"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask), new FileAction(FileAction.OPEN))); jmi.setName("OPEN"); recentMenu = new JMenu(_I("menuRecent")); if (Settings.experimental) { _fileMenu.add(recentMenu); } if (Settings.isMac() && !Settings.handlesMacBundles) { _fileMenu.add(createMenuItem("Open folder.sikuli ...", null, // KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, scMask), new FileAction(FileAction.OPEN_FOLDER))); } jmi = _fileMenu.add(createMenuItem(_I("menuFileSave"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, scMask), new FileAction(FileAction.SAVE))); jmi.setName("SAVE"); jmi = _fileMenu.add(createMenuItem(_I("menuFileSaveAs"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.SHIFT_MASK | scMask), new FileAction(FileAction.SAVE_AS))); jmi.setName("SAVE_AS"); if (Settings.isMac() && !Settings.handlesMacBundles) { _fileMenu.add(createMenuItem(_I("Save as folder.sikuli ..."), // KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, // InputEvent.SHIFT_MASK | scMask), null, new FileAction(FileAction.SAVE_AS_FOLDER))); } //TODO _fileMenu.add(createMenuItem(_I("menuFileSaveAll"), _fileMenu.add(createMenuItem("Save all", KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, InputEvent.CTRL_MASK | scMask), new FileAction(FileAction.SAVE_ALL))); _fileMenu.add(createMenuItem(_I("menuFileExport"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, InputEvent.SHIFT_MASK | scMask), new FileAction(FileAction.EXPORT))); jmi = _fileMenu.add( createMenuItem(_I("menuFileCloseTab"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, scMask), new FileAction(FileAction.CLOSE_TAB))); jmi.setName("CLOSE_TAB"); if (showPrefs) { _fileMenu.addSeparator(); _fileMenu.add(createMenuItem(_I("menuFilePreferences"), KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, scMask), new FileAction(FileAction.PREFERENCES))); } if (showQuit) { _fileMenu.addSeparator(); _fileMenu.add(createMenuItem(_I("menuFileQuit"), null, new FileAction(FileAction.QUIT))); } }
From source file:lejos.pc.charting.LogChartFrame.java
/** All the setup of components, etc. What's scary is Swing is a "lightweight" GUI framework... * @throws Exception//from w w w . j a v a 2 s.com */ private void jbInit() throws Exception { this.setJMenuBar(menuBar); this.setSize(new Dimension(819, 613)); this.setMinimumSize(new Dimension(819, 613)); this.setTitle("NXT Charting Logger"); this.setEnabled(true); // enforce minimum window size this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { JFrame theFrame = (JFrame) e.getSource(); Dimension d1 = theFrame.getMinimumSize(); Dimension d2 = theFrame.getSize(); boolean enforce = false; if (theFrame.getWidth() < d1.getWidth()) { d2.setSize(d1.getWidth(), d2.getHeight()); enforce = true; } if (theFrame.getHeight() < d1.getHeight()) { d2.setSize(d2.getWidth(), d1.getHeight()); enforce = true; } if (enforce) theFrame.setSize(d2); } }); this.getContentPane().setLayout(gridBagLayout1); MenuActionListener menuItemActionListener = new MenuActionListener(); MenuEventListener menuListener = new MenuEventListener(); menu = new JMenu("Edit"); menu.setMnemonic(KeyEvent.VK_E); menuBar.add(menu); menuItem = new JMenuItem("Copy Chart Image", KeyEvent.VK_I); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Copy Data Log", KeyEvent.VK_D); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("View"); menu.setMnemonic(KeyEvent.VK_V); menu.setActionCommand("VIEW_MENU"); menu.addMenuListener(menuListener); menuBar.add(menu); menuItem = new JMenuItem("Expand Chart", KeyEvent.VK_F); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Chart in New Window", KeyEvent.VK_N); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); menuBar.add(menu); menuItem = new JMenuItem("Chart controls", KeyEvent.VK_C); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("Generate sample data", KeyEvent.VK_G); menuItem.addActionListener(menuItemActionListener); menu.add(menuItem); menuItem = new JMenuItem("About", KeyEvent.VK_A); menuItem.addActionListener(menuItemActionListener); jTabbedPane1.setPreferredSize(new Dimension(621, 199)); jTabbedPane1.setMinimumSize(new Dimension(621, 199)); menu.add(menuItem); jButtonConnect.setText("Connect"); jButtonConnect.setBounds(new Rectangle(25, 65, 115, 25)); jButtonConnect.setToolTipText("Connect/disconnect toggle"); jButtonConnect.setMnemonic('C'); jButtonConnect.setSelected(true); jButtonConnect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButtonConnect_actionPerformed(e); } }); UIPanel.setSize(new Dimension(820, 200)); UIPanel.setLayout(null); UIPanel.setPreferredSize(new Dimension(300, 200)); UIPanel.setMinimumSize(new Dimension(300, 200)); UIPanel.setBounds(new Rectangle(0, 350, 820, 200)); UIPanel.setMaximumSize(new Dimension(300, 32767)); connectionPanel.setBounds(new Rectangle(10, 10, 175, 100)); connectionPanel.setBorder(BorderFactory.createTitledBorder("Connection")); connectionPanel.setLayout(null); connectionPanel.setFont(new Font("Tahoma", 0, 11)); jLabel1logfilename.setText("Log File:"); jLabel1logfilename.setBounds(new Rectangle(10, 125, 165, 20)); jLabel1logfilename.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel1logfilename.setHorizontalAlignment(SwingConstants.LEFT); jLabel1logfilename.setToolTipText("Specify the name of your log file here"); jTextFieldNXTName.setBounds(new Rectangle(5, 40, 165, 20)); jTextFieldNXTName.setToolTipText( "The name or Address of the NXT. Leave empty and the first one found will be used."); jTextFieldNXTName.requestFocus(); jTextAreaStatus.setLineWrap(true); jTextAreaStatus.setFont(new Font("Tahoma", 0, 11)); jTextAreaStatus.setWrapStyleWord(true); jTextAreaStatus.setBackground(SystemColor.window); dataLogTextArea.setLineWrap(false); dataLogTextArea.setFont(new Font("Tahoma", 0, 11)); dataLogTextArea.setBackground(SystemColor.window); FQPathTextArea.setBounds(new Rectangle(5, 170, 185, 40)); FQPathTextArea.setLineWrap(true); FQPathTextArea.setText(getCanonicalName(new File(".", ""))); FQPathTextArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); FQPathTextArea.setRows(2); FQPathTextArea.setFont(new Font("Tahoma", 0, 9)); FQPathTextArea.setOpaque(false); FQPathTextArea.setEditable(false); selectFolderButton.setText("Folder..."); selectFolderButton.setBounds(new Rectangle(120, 125, 70, 20)); selectFolderButton.setMargin(new Insets(1, 1, 1, 1)); selectFolderButton.setFocusable(false); selectFolderButton.setMnemonic('F'); selectFolderButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectFolderButton_actionPerformed(e); } }); // domain display limits GUI chartOptionsPanel.setLayout(null); chartDomLimitsPanel.setBounds(new Rectangle(5, 35, 180, 135)); chartDomLimitsPanel.setLayout(gridLayout1); chartDomLimitsPanel.setBorder(BorderFactory.createTitledBorder("Domain Display Limiting")); domainDisplayLimitSlider.setEnabled(false); domainDisplayLimitSlider.setMaximum(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.setMinimum(MINDOMAIN_LIMIT); domainDisplayLimitSlider.setValue(MAXDOMAIN_DATAPOINT_LIMIT); domainDisplayLimitSlider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { domainDisplayLimitSlider_stateChanged(e); } }); useTimeRadioButton.setText("By Time"); useTimeRadioButton.setEnabled(false); useTimeRadioButton.setMnemonic('I'); useTimeRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); useDataPointsRadioButton.setText("By Data Points"); ButtonGroup bg1 = new ButtonGroup(); bg1.add(useTimeRadioButton); bg1.add(useDataPointsRadioButton); useDataPointsRadioButton.setSelected(true); useDataPointsRadioButton.setEnabled(false); useDataPointsRadioButton.setMnemonic('P'); useDataPointsRadioButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { domainDisplayLimitRadioButton_actionPerformed(e); } }); datasetLimitEnableCheckBox.setText("Enable"); datasetLimitEnableCheckBox.setRolloverEnabled(true); datasetLimitEnableCheckBox.setMnemonic('A'); datasetLimitEnableCheckBox.setToolTipText("Enable Domain Clipping"); datasetLimitEnableCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { datasetLimitEnableCheckBox_actionPerformed(e); } }); domainLimitLabel.setText(String.format("%1$,d datapoints", MAXDOMAIN_DATAPOINT_LIMIT).toString()); domainLimitLabel.setEnabled(false); gridLayout1.setRows(5); gridLayout1.setColumns(1); jLabel1.setText("Chart Title:"); jLabel1.setBounds(new Rectangle(200, 10, 85, 20)); jLabel1.setPreferredSize(new Dimension(115, 14)); jLabel2.setText("Range Axis 1 Label:"); jLabel2.setBounds(new Rectangle(200, 35, 115, 20)); jLabel2.setSize(new Dimension(115, 20)); jLabel3.setText("Range Axis 2 Label:"); jLabel3.setBounds(new Rectangle(200, 60, 115, 20)); jLabel3.setSize(new Dimension(115, 20)); jLabel4.setText("Range Axis 3 Label:"); jLabel4.setBounds(new Rectangle(200, 85, 115, 20)); jLabel4.setSize(new Dimension(115, 20)); jLabel6.setText("Range Axis 4 Label:"); jLabel6.setBounds(new Rectangle(200, 110, 115, 20)); jLabel6.setSize(new Dimension(115, 20)); titleLabelChangeNotifier notifier = new titleLabelChangeNotifier(); chartTitleTextField.setBounds(new Rectangle(315, 10, 290, 20)); chartTitleTextField.getDocument().addDocumentListener(notifier); axis1LabelTextField.setBounds(new Rectangle(315, 35, 290, 20)); axis1LabelTextField.getDocument().addDocumentListener(notifier); axis2LabelTextField.setBounds(new Rectangle(315, 60, 290, 20)); axis2LabelTextField.getDocument().addDocumentListener(notifier); axis3LabelTextField.setBounds(new Rectangle(315, 85, 290, 20)); axis3LabelTextField.getDocument().addDocumentListener(notifier); axis4LabelTextField.setBounds(new Rectangle(315, 110, 290, 20)); showCommentsCheckBox.setText("Show Comment Markers"); showCommentsCheckBox.setBounds(new Rectangle(200, 140, 185, 25)); showCommentsCheckBox.setToolTipText("Show/Hide any comment markers on the chart"); showCommentsCheckBox.setRolloverEnabled(true); showCommentsCheckBox.setSelected(true); showCommentsCheckBox.setMnemonic('M'); showCommentsCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { customChartPanel.setCommentsVisible(e.getStateChange() == ItemEvent.SELECTED); } }); scrollDomainCheckBox.setText("Scroll Domain"); scrollDomainCheckBox.setBounds(new Rectangle(10, 5, 175, 20)); scrollDomainCheckBox.setSize(new Dimension(175, 25)); scrollDomainCheckBox.setSelected(true); scrollDomainCheckBox.setMnemonic('O'); scrollDomainCheckBox.setToolTipText("Checked to scroll domain as new data is received"); scrollDomainCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scrollDomainCheckBox_actionPerformed(e); } }); axis4LabelTextField.getDocument().addDocumentListener(notifier); logFileTextField.setBounds(new Rectangle(10, 145, 180, 20)); logFileTextField.setText("NXTData.txt"); logFileTextField.setPreferredSize(new Dimension(180, 20)); logFileTextField.setToolTipText("File name. Leave empty to not log to file."); statusScrollPane.setOpaque(false); dataLogScrollPane.setOpaque(false); customChartPanel.setMinimumSize(new Dimension(400, 300)); customChartPanel.setPreferredSize(new Dimension(812, 400)); jLabel5.setText("NXT Name/Address:"); jLabel5.setBounds(new Rectangle(5, 20, 160, 20)); jLabel5.setToolTipText(jTextFieldNXTName.getToolTipText()); jLabel5.setHorizontalTextPosition(SwingConstants.RIGHT); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); connectionPanel.add(jTextFieldNXTName, null); connectionPanel.add(jButtonConnect, null); connectionPanel.add(jLabel5, null); dataLogScrollPane.setViewportView(dataLogTextArea); jTabbedPane1.addTab("Data Log", dataLogScrollPane); statusScrollPane.setViewportView(jTextAreaStatus); jTabbedPane1.addTab("Status", statusScrollPane); jTabbedPane1.addTab("Chart", chartOptionsPanel); chartDomLimitsPanel.add(datasetLimitEnableCheckBox, null); chartDomLimitsPanel.add(useDataPointsRadioButton, null); chartDomLimitsPanel.add(useTimeRadioButton, null); chartDomLimitsPanel.add(domainDisplayLimitSlider, null); chartDomLimitsPanel.add(domainLimitLabel, null); chartOptionsPanel.add(scrollDomainCheckBox, null); chartOptionsPanel.add(showCommentsCheckBox, null); chartOptionsPanel.add(axis4LabelTextField, null); chartOptionsPanel.add(axis3LabelTextField, null); chartOptionsPanel.add(axis2LabelTextField, null); chartOptionsPanel.add(axis1LabelTextField, null); chartOptionsPanel.add(chartTitleTextField, null); chartOptionsPanel.add(jLabel6, null); chartOptionsPanel.add(jLabel4, null); chartOptionsPanel.add(jLabel3, null); chartOptionsPanel.add(jLabel2, null); chartOptionsPanel.add(jLabel1, null); chartOptionsPanel.add(chartDomLimitsPanel, null); tglbtnpauseplay = new JToggleButton(""); tglbtnpauseplay.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (lpm == null) return; boolean doPause = false; if (e.getStateChange() == ItemEvent.SELECTED) { doPause = true; } lpm.setReaderPaused(doPause); } }); // tglbtnpauseplay.addChangeListener(new ChangeListener() { // public void stateChanged(ChangeEvent e) { // System.out.println(e.toString()); // //lpm.setReaderPaused(doPause) // } // }); tglbtnpauseplay .setSelectedIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/play.png"))); tglbtnpauseplay.setIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/pause.png"))); tglbtnpauseplay.setBounds(571, 135, 30, 30); chartOptionsPanel.add(tglbtnpauseplay); jTabbedPane1.setToolTipTextAt(0, "The tab-delimited log of the data sent from the NXT"); jTabbedPane1.setToolTipTextAt(1, "Status output"); jTabbedPane1.setToolTipTextAt(2, "Chart options"); jTabbedPane1.setMnemonicAt(0, KeyEvent.VK_D); jTabbedPane1.setMnemonicAt(1, KeyEvent.VK_S); jTabbedPane1.setMnemonicAt(2, KeyEvent.VK_T); this.getContentPane().add(customChartPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); this.getContentPane().add(UIPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -107, 0)); this.getContentPane().add(jTabbedPane1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); UIPanel.add(connectionPanel, null); UIPanel.add(selectFolderButton, null); UIPanel.add(logFileTextField, null); UIPanel.add(jLabel1logfilename, null); UIPanel.add(FQPathTextArea, null); ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent evt) { String theData = null; for (;;) { theData = LogChartFrame.this.logDataQueue.poll(); if (theData == null) break; try { dataLogTextArea.getDocument().insertString(dataLogTextArea.getDocument().getLength(), theData, null); } catch (BadLocationException e) { System.out.print( "BadLocationException in datalog textarea updater thread:" + e.toString() + "\n"); } } } }; this.updateLogTextAreaTimer = new Timer(1000, taskPerformer); this.updateLogTextAreaTimer.start(); }
From source file:GUI.MainWindow.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor./*from w w w . j av a 2s.co m*/ */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { ImportScanScreen = new javax.swing.JDialog(); jLabel1 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); ImportFile = new javax.swing.JList(); jLabel2 = new javax.swing.JLabel(); FileType = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); FileSize = new javax.swing.JTextField(); ProgressBar = new javax.swing.JProgressBar(); VulnTreeContextMenu = new javax.swing.JPopupMenu(); MergeButton = new javax.swing.JMenuItem(); LookupCVE = new javax.swing.JMenuItem(); AddToPersonalVulns = new javax.swing.JMenuItem(); ClearHash = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); DeleteButton = new javax.swing.JMenuItem(); VulnAffectedHostsContextMenu = new javax.swing.JPopupMenu(); AddHostsButton = new javax.swing.JMenuItem(); EditHostname = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JPopupMenu.Separator(); DeleteHost = new javax.swing.JMenuItem(); VulnReferencesContextMenu = new javax.swing.JPopupMenu(); InsertReference = new javax.swing.JMenuItem(); EditReferenceOption = new javax.swing.JMenuItem(); LaunchInBrowser = new javax.swing.JMenuItem(); jSeparator3 = new javax.swing.JPopupMenu.Separator(); DeleteReferenceOption = new javax.swing.JMenuItem(); ManageAffectedHosts = new javax.swing.JDialog(); jScrollPane5 = new javax.swing.JScrollPane(); ListOfHosts = new javax.swing.JList(); jScrollPane9 = new javax.swing.JScrollPane(); ListOfOpenPorts = new javax.swing.JList(); jLabel5 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); MainScreenBottomPanel = new javax.swing.JPanel(); jLabel20 = new javax.swing.JLabel(); VulnTreeFilter = new javax.swing.JTextField(); ExtraInfoLabel = new javax.swing.JLabel(); jSplitPane2 = new javax.swing.JSplitPane(); ViewModeTabPane = new javax.swing.JTabbedPane(); jScrollPane1 = new javax.swing.JScrollPane(); VulnTree = new javax.swing.JTree(); jScrollPane3 = new javax.swing.JScrollPane(); HostTree = new javax.swing.JTree(); RightPanelCardLayout = new javax.swing.JPanel(); RightPanelVulnView = new javax.swing.JPanel(); VulnerabilityTopPanel = new javax.swing.JPanel(); jPanel8 = new javax.swing.JPanel(); jLabel9 = new javax.swing.JLabel(); VulnTitleTextField = new javax.swing.JTextField(); jPanel9 = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); VulnCVSSVectorTextField = new javax.swing.JTextField(); jLabel11 = new javax.swing.JLabel(); VulnRiskCategory = new javax.swing.JTextField(); jLabel12 = new javax.swing.JLabel(); VulnScore = new javax.swing.JTextField(); EditRiskButton = new javax.swing.JButton(); jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane3 = new javax.swing.JSplitPane(); VulnRecommendationsPanel = new javax.swing.JPanel(); jLabel8 = new javax.swing.JLabel(); jScrollPane7 = new javax.swing.JScrollPane(); VulnRecommendationTextPane = new javax.swing.JTextPane(); jSplitPane4 = new javax.swing.JSplitPane(); VulnReferencesPanel = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jScrollPane6 = new javax.swing.JScrollPane(); VulnReferencesList = new javax.swing.JList(); jScrollPane4 = new javax.swing.JScrollPane(); VulnAffectedHostsTable = new javax.swing.JTable(); VulnDescriptionPanel = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); jScrollPane8 = new javax.swing.JScrollPane(); VulnDescriptionTextPane = new javax.swing.JTextPane(); RightPanelHostsView = new javax.swing.JPanel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem3 = new javax.swing.JMenuItem(); jMenuItem4 = new javax.swing.JMenuItem(); jMenuItem5 = new javax.swing.JMenuItem(); jMenuItem11 = new javax.swing.JMenuItem(); exitButton = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem7 = new javax.swing.JMenuItem(); jMenuItem10 = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); jMenuItem9 = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem8 = new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu(); increaseFont = new javax.swing.JMenuItem(); decreaseFont = new javax.swing.JMenuItem(); ImportScanScreen.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); ImportScanScreen.setTitle("Report Compiler - Import Scan Screen"); ImportScanScreen.setMinimumSize(new java.awt.Dimension(382, 220)); ImportScanScreen.setModal(true); ImportScanScreen.addWindowListener(new java.awt.event.WindowAdapter() { public void windowActivated(java.awt.event.WindowEvent evt) { ImportScanScreenWindowActivated(evt); } }); jLabel1.setText("File Name:"); ImportFile.setModel(new javax.swing.AbstractListModel() { String[] strings = { "One" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); ImportFile.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); ImportFile.setEnabled(false); jScrollPane2.setViewportView(ImportFile); jLabel2.setText("File Type:"); FileType.setEnabled(false); jLabel3.setText("File Size:"); FileSize.setEnabled(false); ProgressBar.setIndeterminate(true); javax.swing.GroupLayout ImportScanScreenLayout = new javax.swing.GroupLayout( ImportScanScreen.getContentPane()); ImportScanScreen.getContentPane().setLayout(ImportScanScreenLayout); ImportScanScreenLayout .setHorizontalGroup( ImportScanScreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10) .addGroup(ImportScanScreenLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2) .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)))); ImportScanScreenLayout.setVerticalGroup(ImportScanScreenLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ImportScanScreenLayout.createSequentialGroup().addGap(10, 10, 10).addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel2) .addGap(6, 6, 6) .addComponent(FileType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, 0).addComponent(jLabel3).addGap(6, 6, 6) .addComponent(FileSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10).addComponent(ProgressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); MergeButton.setText("Merge"); MergeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MergeButtonActionPerformed(evt); } }); VulnTreeContextMenu.add(MergeButton); LookupCVE.setText("Lookup CVE(s)"); LookupCVE.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LookupCVEActionPerformed(evt); } }); VulnTreeContextMenu.add(LookupCVE); AddToPersonalVulns.setText("Add to Personal Vulns"); AddToPersonalVulns.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddToPersonalVulnsActionPerformed(evt); } }); VulnTreeContextMenu.add(AddToPersonalVulns); ClearHash.setText("Clear Hash(s)"); ClearHash.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ClearHashActionPerformed(evt); } }); VulnTreeContextMenu.add(ClearHash); VulnTreeContextMenu.add(jSeparator1); DeleteButton.setText("Delete"); DeleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteButtonActionPerformed(evt); } }); VulnTreeContextMenu.add(DeleteButton); VulnAffectedHostsContextMenu.setMinimumSize(new java.awt.Dimension(20, 20)); AddHostsButton.setText("Add Host"); AddHostsButton.setActionCommand("AddHost"); AddHostsButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddHostsButtonActionPerformed(evt); } }); VulnAffectedHostsContextMenu.add(AddHostsButton); EditHostname.setText("Edit Hostname"); EditHostname.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditHostnameActionPerformed(evt); } }); VulnAffectedHostsContextMenu.add(EditHostname); VulnAffectedHostsContextMenu.add(jSeparator2); DeleteHost.setText("Delete Host ('del' is hotkey)"); DeleteHost.setActionCommand("DeleteHost"); DeleteHost.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteHostActionPerformed(evt); } }); VulnAffectedHostsContextMenu.add(DeleteHost); InsertReference.setText("Insert Reference"); InsertReference.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { InsertReferenceActionPerformed(evt); } }); VulnReferencesContextMenu.add(InsertReference); EditReferenceOption.setText("Edit Reference"); EditReferenceOption.setToolTipText(""); EditReferenceOption.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditReferenceOptionActionPerformed(evt); } }); VulnReferencesContextMenu.add(EditReferenceOption); LaunchInBrowser.setText("Launch in Browser"); LaunchInBrowser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { LaunchInBrowserActionPerformed(evt); } }); VulnReferencesContextMenu.add(LaunchInBrowser); VulnReferencesContextMenu.add(jSeparator3); DeleteReferenceOption.setText("Delete Reference"); DeleteReferenceOption.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteReferenceOptionActionPerformed(evt); } }); VulnReferencesContextMenu.add(DeleteReferenceOption); ManageAffectedHosts.setTitle("Report Compiler - Manage Affected Hosts"); ManageAffectedHosts.addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { ManageAffectedHostsWindowOpened(evt); } }); jScrollPane5.setViewportView(ListOfHosts); jScrollPane9.setViewportView(ListOfOpenPorts); jLabel5.setText("Hosts"); jLabel13.setText("Ports"); javax.swing.GroupLayout ManageAffectedHostsLayout = new javax.swing.GroupLayout( ManageAffectedHosts.getContentPane()); ManageAffectedHosts.getContentPane().setLayout(ManageAffectedHostsLayout); ManageAffectedHostsLayout.setHorizontalGroup( ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addGap(25, 25, 25) .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addGap(18, 18, 18) .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel13).addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); ManageAffectedHostsLayout.setVerticalGroup( ManageAffectedHostsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ManageAffectedHostsLayout.createSequentialGroup().addContainerGap() .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5).addComponent(jLabel13)) .addGap(13, 13, 13) .addGroup(ManageAffectedHostsLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE) .addComponent(jScrollPane9)) .addContainerGap(36, Short.MAX_VALUE))); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Report Compiler - Main Window"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); jLabel20.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel20.setText("Tree Filter:"); VulnTreeFilter.addCaretListener(new javax.swing.event.CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent evt) { VulnTreeFilterCaretUpdate(evt); } }); ExtraInfoLabel.setFont( ExtraInfoLabel.getFont().deriveFont(ExtraInfoLabel.getFont().getStyle() | java.awt.Font.BOLD)); ExtraInfoLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); javax.swing.GroupLayout MainScreenBottomPanelLayout = new javax.swing.GroupLayout(MainScreenBottomPanel); MainScreenBottomPanel.setLayout(MainScreenBottomPanelLayout); MainScreenBottomPanelLayout.setHorizontalGroup(MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel20) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(VulnTreeFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 354, Short.MAX_VALUE) .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 556, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); MainScreenBottomPanelLayout.setVerticalGroup(MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(MainScreenBottomPanelLayout.createSequentialGroup().addContainerGap() .addGroup(MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(MainScreenBottomPanelLayout.createSequentialGroup() .addComponent(ExtraInfoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGap(20, 20, 20)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, MainScreenBottomPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel20).addComponent(VulnTreeFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); getContentPane().add(MainScreenBottomPanel, java.awt.BorderLayout.SOUTH); jSplitPane2.setDividerLocation(200); jSplitPane2.setDividerSize(20); jSplitPane2.setOneTouchExpandable(true); ViewModeTabPane.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { ViewModeTabPaneStateChanged(evt); } }); javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode( "NOT IMPLEMENTED"); VulnTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); VulnTree.setCellRenderer(new VulnerabilityViewTreeCellRenderer(true)); VulnTree.setRootVisible(false); VulnTree.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { VulnTreeMouseClicked(evt); } }); VulnTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() { public void valueChanged(javax.swing.event.TreeSelectionEvent evt) { VulnTreeValueChanged(evt); } }); VulnTree.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { VulnTreeKeyPressed(evt); } }); jScrollPane1.setViewportView(VulnTree); ViewModeTabPane.addTab("Vuln View", jScrollPane1); jScrollPane3.setEnabled(false); treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("root"); HostTree.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1)); HostTree.setRootVisible(false); jScrollPane3.setViewportView(HostTree); ViewModeTabPane.addTab("Host View", jScrollPane3); jSplitPane2.setLeftComponent(ViewModeTabPane); RightPanelCardLayout.setLayout(new java.awt.CardLayout()); RightPanelVulnView.setLayout(new java.awt.BorderLayout()); VulnerabilityTopPanel.setLayout(new java.awt.BorderLayout()); jPanel8.setLayout(new javax.swing.BoxLayout(jPanel8, javax.swing.BoxLayout.LINE_AXIS)); jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jLabel9.setLabelFor(VulnTitleTextField); jLabel9.setText("Title: "); jPanel8.add(jLabel9); VulnTitleTextField.setColumns(80); jPanel8.add(VulnTitleTextField); VulnerabilityTopPanel.add(jPanel8, java.awt.BorderLayout.NORTH); jPanel9.setLayout(new javax.swing.BoxLayout(jPanel9, javax.swing.BoxLayout.LINE_AXIS)); jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel10.setText("CVSS:"); jPanel9.add(jLabel10); VulnCVSSVectorTextField.setEditable(false); VulnCVSSVectorTextField.setColumns(81); jPanel9.add(VulnCVSSVectorTextField); jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel11.setText("Category:"); jPanel9.add(jLabel11); VulnRiskCategory.setEditable(false); VulnRiskCategory.setColumns(8); jPanel9.add(VulnRiskCategory); jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel12.setText("Score:"); jPanel9.add(jLabel12); VulnScore.setEditable(false); VulnScore.setColumns(4); jPanel9.add(VulnScore); EditRiskButton.setText("Edit Risk"); EditRiskButton.setToolTipText("Click here to see the Risk Calculator where scores can be modified"); EditRiskButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EditRiskButtonActionPerformed(evt); } }); jPanel9.add(EditRiskButton); VulnerabilityTopPanel.add(jPanel9, java.awt.BorderLayout.CENTER); RightPanelVulnView.add(VulnerabilityTopPanel, java.awt.BorderLayout.NORTH); jSplitPane1.setDividerLocation(200); jSplitPane1.setDividerSize(20); jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane1.setOneTouchExpandable(true); jSplitPane3.setDividerLocation(200); jSplitPane3.setDividerSize(20); jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane3.setOneTouchExpandable(true); VulnRecommendationsPanel.setLayout(new java.awt.BorderLayout()); jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel8.setText("Recommendation"); VulnRecommendationsPanel.add(jLabel8, java.awt.BorderLayout.PAGE_START); jScrollPane7.setViewportView(VulnRecommendationTextPane); VulnRecommendationsPanel.add(jScrollPane7, java.awt.BorderLayout.CENTER); jSplitPane3.setLeftComponent(VulnRecommendationsPanel); jSplitPane4.setDividerSize(20); jSplitPane4.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane4.setOneTouchExpandable(true); VulnReferencesPanel.setLayout(new java.awt.BorderLayout()); jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel4.setText("Affected Hosts"); VulnReferencesPanel.add(jLabel4, java.awt.BorderLayout.PAGE_END); jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel7.setText("References"); VulnReferencesPanel.add(jLabel7, java.awt.BorderLayout.PAGE_START); VulnReferencesList.setModel(new DefaultListModel()); VulnReferencesList.setToolTipText("Right click on this area to see options for references."); VulnReferencesList.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { VulnReferencesListMouseClicked(evt); } }); VulnReferencesList.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { VulnReferencesListKeyPressed(evt); } }); jScrollPane6.setViewportView(VulnReferencesList); VulnReferencesPanel.add(jScrollPane6, java.awt.BorderLayout.CENTER); jSplitPane4.setTopComponent(VulnReferencesPanel); jScrollPane4.setToolTipText( "Right click on this area to insert new affected hosts. Select one or more and press 'del' to delete or use the right click 'delete' option."); jScrollPane4.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jScrollPane4MouseClicked(evt); } }); jScrollPane4.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { jScrollPane4KeyPressed(evt); } }); VulnAffectedHostsTable.setAutoCreateRowSorter(true); VulnAffectedHostsTable.setModel(new AffectedHostsTableModel()); /*new javax.swing.table.DefaultTableModel( new Object[][]{}, new String[]{ "IP Address", "Hostname", "Portnumber", "Protocol" } ) { Class[] types = new Class[]{ Host.class, java.lang.String.class, java.lang.Integer.class, java.lang.String.class }; public Class getColumnClass(int columnIndex) { return types[columnIndex]; } }*///); VulnAffectedHostsTable.setToolTipText(""); VulnAffectedHostsTable.setCellSelectionEnabled(true); VulnAffectedHostsTable.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { VulnAffectedHostsTableMouseClicked(evt); } }); VulnAffectedHostsTable.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { VulnAffectedHostsTableKeyPressed(evt); } }); jScrollPane4.setViewportView(VulnAffectedHostsTable); VulnAffectedHostsTable.getColumnModel().getSelectionModel() .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION); jSplitPane4.setRightComponent(jScrollPane4); jSplitPane3.setRightComponent(jSplitPane4); jSplitPane1.setBottomComponent(jSplitPane3); VulnDescriptionPanel.setMinimumSize(new java.awt.Dimension(0, 50)); VulnDescriptionPanel.setLayout(new java.awt.BorderLayout()); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jLabel6.setText("Description"); VulnDescriptionPanel.add(jLabel6, java.awt.BorderLayout.PAGE_START); jScrollPane8.setViewportView(VulnDescriptionTextPane); VulnDescriptionPanel.add(jScrollPane8, java.awt.BorderLayout.CENTER); jSplitPane1.setTopComponent(VulnDescriptionPanel); RightPanelVulnView.add(jSplitPane1, java.awt.BorderLayout.CENTER); RightPanelCardLayout.add(RightPanelVulnView, "vulnView"); javax.swing.GroupLayout RightPanelHostsViewLayout = new javax.swing.GroupLayout(RightPanelHostsView); RightPanelHostsView.setLayout(RightPanelHostsViewLayout); RightPanelHostsViewLayout.setHorizontalGroup(RightPanelHostsViewLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1103, Short.MAX_VALUE)); RightPanelHostsViewLayout.setVerticalGroup(RightPanelHostsViewLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 739, Short.MAX_VALUE)); RightPanelCardLayout.add(RightPanelHostsView, "hostView"); jSplitPane2.setRightComponent(RightPanelCardLayout); getContentPane().add(jSplitPane2, java.awt.BorderLayout.CENTER); jMenu1.setMnemonic('F'); jMenu1.setText("File"); jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem3.setText("New (Clear Tree)"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu1.add(jMenuItem3); jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem4.setText("Open"); jMenuItem4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem4ActionPerformed(evt); } }); jMenu1.add(jMenuItem4); jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem5.setText("Save"); jMenuItem5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem5ActionPerformed(evt); } }); jMenu1.add(jMenuItem5); jMenuItem11.setText("Save As"); jMenuItem11.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem11ActionPerformed(evt); } }); jMenu1.add(jMenuItem11); exitButton.setText("Exit"); exitButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exitButtonActionPerformed(evt); } }); jMenu1.add(exitButton); jMenuBar1.add(jMenu1); jMenu2.setMnemonic('V'); jMenu2.setText("Vulnerabilities"); jMenu2.setToolTipText( "All vulnerability related operations. Import from a tool, create an entirely new one etc"); jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem1.setText("Import from Tool"); jMenuItem1.setToolTipText("Select one or more files to import simultaneously. "); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenu2.add(jMenuItem1); jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_INSERT, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem2.setText("Create New Vulnerability"); jMenuItem2.setToolTipText( "Add a new vulnerability to your test. When finished you can save it to your Personal Vulnerability database by right clicking on the issue in the tree"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jMenu2.add(jMenuItem2); jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem7.setText("Manage Personal Vulns"); jMenuItem7.setToolTipText( "Allows you to delete or edit the text for vulnerabilities in your Personal Database"); jMenuItem7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem7ActionPerformed(evt); } }); jMenu2.add(jMenuItem7); jMenuItem10.setText("Auto Merge"); jMenuItem10.setToolTipText( "Use this to automatically replace the title, description, recommendation, references, and risk score with vulnerabilities in your personal database."); jMenuItem10.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem10ActionPerformed(evt); } }); jMenu2.add(jMenuItem10); jMenuBar1.add(jMenu2); jMenu4.setText("Hosts"); jMenuItem9.setText("Import Hosts by Nmap"); jMenuItem9.setEnabled(false); jMenu4.add(jMenuItem9); jMenuBar1.add(jMenu4); jMenu3.setMnemonic('E'); jMenu3.setText("Export"); jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); jMenuItem8.setText("Excel Vulnerability List"); jMenuItem8.setToolTipText( "This can be used to send a high level debrief to clients in a spreadsheet format. Report Compiler also imports vulnerabilities back from these excel files if necessary."); jMenuItem8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem8ActionPerformed(evt); } }); jMenu3.add(jMenuItem8); jMenuBar1.add(jMenu3); jMenu5.setText("Options"); increaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_EQUALS, java.awt.event.InputEvent.CTRL_MASK)); increaseFont.setText("Increase Font"); increaseFont.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { increaseFontActionPerformed(evt); } }); jMenu5.add(increaseFont); decreaseFont.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS, java.awt.event.InputEvent.CTRL_MASK)); decreaseFont.setText("Decrease Font"); decreaseFont.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { decreaseFontActionPerformed(evt); } }); jMenu5.add(decreaseFont); jMenuBar1.add(jMenu5); setJMenuBar(jMenuBar1); pack(); setLocationRelativeTo(null); }
From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java
private JMenuBar criaMenuBar() { menuBar = new JMenuBar(); menuBar.setBackground(parentFrame.corDefault); JMenu menuArquivo = new JMenu(GERAL.ARQUIVO); menuArquivo.setMnemonic('A'); menuArquivo.setMnemonic(KeyEvent.VK_A); menuArquivo.setBackground(parentFrame.corDefault); JMenu avaliadores = new JMenu(); MenuSilvinha menuSilvinha = new MenuSilvinha(parentFrame, null); menuSilvinha.criaMenuAvaliadores(avaliadores); // menuArquivo.add(avaliadores); // menuArquivo.add(new JSeparator()); JMenuItem btnAbrir = new JMenuItem(GERAL.BTN_ABRIR); btnAbrir.addActionListener(this); btnAbrir.setActionCommand("Abrir"); btnAbrir.setMnemonic('A'); btnAbrir.setAccelerator(// w w w. j a v a 2 s. co m javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, ActionEvent.CTRL_MASK)); btnAbrir.setMnemonic(KeyEvent.VK_A); btnAbrir.setToolTipText(GERAL.DICA_ABRIR); btnAbrir.getAccessibleContext().setAccessibleDescription(GERAL.DICA_ABRIR); menuArquivo.add(btnAbrir); JMenuItem btnAbrirUrl = new JMenuItem(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.BTN_ABRIR_URL); btnAbrirUrl.addActionListener(this); btnAbrirUrl.setActionCommand("AbrirURL"); btnAbrirUrl.setMnemonic('U'); btnAbrirUrl.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, ActionEvent.CTRL_MASK)); btnAbrirUrl.setMnemonic(KeyEvent.VK_U); btnAbrirUrl.setToolTipText(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.DICA_ABRIR); btnAbrirUrl.getAccessibleContext() .setAccessibleDescription(br.org.acessobrasil.silvinha2.mli.XHTML_Panel.DICA_ABRIR); menuArquivo.add(btnAbrirUrl); btnSalvar = new JMenuItem(GERAL.BTN_SALVAR); btnSalvar.addActionListener(this); btnSalvar.setActionCommand("Salvar"); btnSalvar.setMnemonic('S'); btnSalvar.setAccelerator( javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, ActionEvent.CTRL_MASK)); btnSalvar.setMnemonic(KeyEvent.VK_S); btnSalvar.getAccessibleContext().setAccessibleDescription(GERAL.SALVA_REAVALIA); menuArquivo.add(btnSalvar); JMenuItem btnSalvarAs = new JMenuItem(GERAL.BTN_SALVAR_COMO); btnSalvarAs.addActionListener(this); btnSalvarAs.setActionCommand("SaveAs"); btnSalvarAs.setMnemonic('c'); btnSalvarAs.setMnemonic(KeyEvent.VK_C); // btnSalvarAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, // ActionEvent.CTRL_MASK)); btnSalvarAs.setToolTipText(GERAL.DICA_SALVAR_COMO); btnSalvarAs.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR_COMO); menuArquivo.add(btnSalvarAs); menuArquivo.add(new JSeparator()); JMenuItem btnFechar = new JMenuItem(GERAL.SAIR); btnFechar.addActionListener(this); btnFechar.setActionCommand("Sair"); btnFechar.setMnemonic('a'); btnFechar.setMnemonic(KeyEvent.VK_A); btnFechar.setToolTipText(GERAL.DICA_SAIR); btnFechar.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SAIR); menuArquivo.add(btnFechar); menuBar.add(menuArquivo); menuBar.add(this.criaMenuEditar()); menuBar.add(avaliadores); JMenu menuSimuladores = new JMenu(); menuSilvinha.criaMenuSimuladores(menuSimuladores); menuBar.add(menuSimuladores); JMenu mnFerramenta = new JMenu(); menuSilvinha.criaMenuFerramentas(mnFerramenta); menuBar.add(mnFerramenta); JMenu menuAjuda = new JMenu(GERAL.AJUDA); menuSilvinha.criaMenuAjuda(menuAjuda); menuBar.add(menuAjuda); return menuBar; }
From source file:com.opendoorlogistics.studio.AppFrame.java
@SuppressWarnings("serial") private List<MyAction> initFileActions() { ArrayList<MyAction> ret = new ArrayList<>(); ret.add(new MyAction("New", "Create new file", null, "document-new-6.png", false, KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK)) { @Override//from www. j a va 2s. c o m public void actionPerformed(ActionEvent e) { createNewDatastore(); } }); ret.add(new MyAction("Open", "Open file", null, "document-open-3.png", false, KeyStroke.getKeyStroke(KeyEvent.VK_O, java.awt.Event.CTRL_MASK)) { @Override public void actionPerformed(ActionEvent e) { openDatastoreWithUserPrompt(); } }); ret.add(null); ret.add(new MyAction("Close", "Close file", null, "document-close-4.png", true, KeyStroke.getKeyStroke(KeyEvent.VK_W, java.awt.Event.CTRL_MASK)) { @Override public void actionPerformed(ActionEvent e) { if (!canCloseDatastore()) { return; } closeDatastore(); } }); ret.add(null); ret.add(new MyAction("Save", "Save file", null, "document-save-2.png", true, KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)) { @Override public void actionPerformed(ActionEvent e) { saveDatastoreWithoutUserPrompt(loaded.getLastFile()); } @Override public void updateEnabled() { setEnabled(loaded != null && loaded.getLastFile() != null); } }); ret.add(new MyAction("Save as", "Save file as", null, "document-save-as-2.png", true, KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK | Event.ALT_MASK)) { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = SupportedFileType.EXCEL.createFileChooser(); if (loaded.getLastFile() != null) { chooser.setSelectedFile(loaded.getLastFile()); } else { File file = PreferencesManager.getSingleton().getFile(PrefKey.LAST_IO_DIR); IOUtils.setFile(file, chooser); } if (chooser.showSaveDialog(AppFrame.this) == JFileChooser.APPROVE_OPTION) { saveDatastoreWithoutUserPrompt(chooser.getSelectedFile()); } } }); return ret; }
From source file:com.emental.mindraider.ui.frames.MindRaiderMainWindow.java
/** * Build main menu./*from ww w .j a v a 2s .com*/ * * @param spiders */ private void buildMenu(final SpidersGraph spiders) { JMenuBar menuBar; JMenu menu, submenu; JMenuItem menuItem, subMenuItem; JRadioButtonMenuItem rbMenuItem; // create the menu bar menuBar = new JMenuBar(); setJMenuBar(menuBar); // - main menu ------------------------------------------------------- menu = new JMenu(MindRaiderConstants.MR_TITLE); menu.setMnemonic(KeyEvent.VK_M); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.setActiveNotebookAsHome")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.profile.setHomeNotebook(); } }); menu.add(menuItem); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.preferences")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new PreferencesJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.exit"), KeyEvent.VK_X); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exitMindRaider(); } }); menu.add(menuItem); menuBar.add(menu); // - Find ---------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.search")); menu.setMnemonic(KeyEvent.VK_F); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchNotebooks")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchFulltext")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_F, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new FtsJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsInNotebook")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); // search by tag menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchConceptsByTag")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenConceptByTagJDialog(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.previousNote")); menuItem.setEnabled(true); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.ALT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.recentConcepts.moveOneNoteBack(); } }); menu.add(menuItem); // global RDF search // menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.searchRdql")); // menuItem.setEnabled(false); // menuItem.setMnemonic(KeyEvent.VK_R); // menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, // ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); // menuItem.addActionListener(new ActionListener() { // // public void actionPerformed(ActionEvent e) { // // TODO rdql to be implemented // } // }); // menu.add(menuItem); menuBar.add(menu); // - view ------------------------------------------------------------ menu = new JMenu(Messages.getString("MindRaiderJFrame.view")); menu.setMnemonic(KeyEvent.VK_V); // TODO localize L&F menu ButtonGroup lfGroup = new ButtonGroup(); submenu = new JMenu(Messages.getString("MindRaiderJFrame.lookAndFeel")); logger.debug("Look and feel is: " + MindRaider.profile.getLookAndFeel()); // {{debug}} submenu.setMnemonic(KeyEvent.VK_L); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelNative")); if (MindRaider.LF_NATIVE.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_NATIVE); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); subMenuItem = new JRadioButtonMenuItem(Messages.getString("MindRaiderJFrame.lookAndFeelJava")); if (MindRaider.LF_JAVA_DEFAULT.equals(MindRaider.profile.getLookAndFeel())) { subMenuItem.setSelected(true); } subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setLookAndFeel(MindRaider.LF_JAVA_DEFAULT); } }); submenu.add(subMenuItem); lfGroup.add(subMenuItem); menu.add(submenu); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.leftSideBar")); menuItem.setMnemonic(KeyEvent.VK_L); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (leftSidebarSplitPane.getDividerLocation() == 1) { leftSidebarSplitPane.resetToPreferredSizes(); } else { closeLeftSidebar(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rightSideBar")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().toggleRightSidebar(); } }); menu.add(menuItem); // TODO tips to be implemented // JCheckBoxMenuItem helpCheckbox=new JCheckBoxMenuItem("Tips",true); // menu.add(helpCheckbox); // TODO localize menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.toolbar")); menuItem.setMnemonic(KeyEvent.VK_T); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.masterToolBar.toggleVisibility(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rdfNavigatorDashboard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.spidersGraph.getGlPanel().toggleControlPanel(); } }); menu.add(menuItem); JCheckBoxMenuItem checkboxMenuItem; ButtonGroup colorSchemeGroup; // if (!MindRaider.OUTLINER_PERSPECTIVE.equals(MindRaider.profile // .getUiPerspective())) { menu.addSeparator(); // Facets submenu = new JMenu(Messages.getString("MindRaiderJFrame.facet")); submenu.setMnemonic(KeyEvent.VK_F); colorSchemeGroup = new ButtonGroup(); String[] facetLabels = FacetCustodian.getInstance().getFacetLabels(); if (!ArrayUtils.isEmpty(facetLabels)) { for (String facetLabel : facetLabels) { rbMenuItem = new JRadioButtonMenuItem(facetLabel); rbMenuItem.addActionListener(new FacetActionListener(facetLabel)); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); if (BriefFacet.LABEL.equals(facetLabel)) { rbMenuItem.setSelected(true); } } } menu.add(submenu); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.graphLabelAsUri")); checkboxMenuItem.setMnemonic(KeyEvent.VK_G); checkboxMenuItem.setState(MindRaider.spidersGraph.isUriLabels()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setUriLabels(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphShowLabelsAsUris(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.predicateNodes")); checkboxMenuItem.setMnemonic(KeyEvent.VK_P); checkboxMenuItem.setState(!MindRaider.spidersGraph.getHidePredicates()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.hidePredicates(!j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphHidePredicates(!j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.multilineLabels")); checkboxMenuItem.setMnemonic(KeyEvent.VK_M); checkboxMenuItem.setState(MindRaider.spidersGraph.isMultilineNodes()); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); MindRaider.spidersGraph.setMultilineNodes(j.getState()); MindRaider.spidersGraph.renderModel(); MindRaider.profile.setGraphMultilineLabels(j.getState()); MindRaider.profile.save(); } } }); menu.add(checkboxMenuItem); // } menu.addSeparator(); // Antialias checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.antiAliased"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_A); checkboxMenuItem.setState(SpidersGraph.antialiased); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.antialiased = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Enable hyperbolic checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.hyperbolic"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_H); checkboxMenuItem.setState(SpidersGraph.hyperbolic); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.hyperbolic = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Show FPS checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fps"), true); checkboxMenuItem.setMnemonic(KeyEvent.VK_F); checkboxMenuItem.setState(SpidersGraph.fps); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); SpidersGraph.fps = j.getState(); MindRaider.spidersGraph.renderModel(); } } }); menu.add(checkboxMenuItem); // Graph color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorScheme")); submenu.setMnemonic(KeyEvent.VK_C); String[] allProfilesUris = MindRaider.spidersColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.spidersColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.spidersColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); MindRaider.spidersGraph .setRenderingProfile(MindRaider.spidersColorProfileRegistry.getCurrentProfile()); MindRaider.spidersGraph.renderModel(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); // Annotation color scheme submenu = new JMenu(Messages.getString("MindRaiderJFrame.colorSchemeAnnotation")); submenu.setMnemonic(KeyEvent.VK_A); allProfilesUris = MindRaider.annotationColorProfileRegistry.getAllProfilesUris(); colorSchemeGroup = new ButtonGroup(); for (int i = 0; i < allProfilesUris.length; i++) { rbMenuItem = new UriJRadioButtonMenuItem( MindRaider.annotationColorProfileRegistry.getColorProfileByUri(allProfilesUris[i]).getLabel(), allProfilesUris[i]); rbMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof UriJRadioButtonMenuItem) { MindRaider.annotationColorProfileRegistry .setCurrentProfile(((UriJRadioButtonMenuItem) e.getSource()).uri); OutlineJPanel.getInstance().conceptJPanel.refresh(); } } }); colorSchemeGroup.add(rbMenuItem); submenu.add(rbMenuItem); } menu.add(submenu); menu.addSeparator(); checkboxMenuItem = new JCheckBoxMenuItem(Messages.getString("MindRaiderJFrame.fullScreen")); checkboxMenuItem.setMnemonic(KeyEvent.VK_U); checkboxMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F11, 0)); checkboxMenuItem.setState(false); checkboxMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem j = (JCheckBoxMenuItem) e.getSource(); if (j.getState()) { Gfx.toggleFullScreen(MindRaiderMainWindow.this); } else { Gfx.toggleFullScreen(null); } } } }); menu.add(checkboxMenuItem); menuBar.add(menu); // - outline // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.notebook")); menu.setMnemonic(KeyEvent.VK_N); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.newNotebook")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO clear should be optional - only if creation finished // MindRider.spidersGraph.clear(); new NewOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new OpenOutlineJDialog(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.close")); menuItem.setMnemonic(KeyEvent.VK_C); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { MindRaider.outlineCustodian.close(); OutlineJPanel.getInstance().refresh(); MindRaider.spidersGraph.renderModel(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setEnabled(false); // TODO discard method must be implemented menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(MindRaiderMainWindow.this, Messages.getString( "MindRaiderJFrame.confirmDiscardNotebook", MindRaider.profile.getActiveOutline())); if (result == JOptionPane.YES_OPTION) { if (MindRaider.profile.getActiveOutlineUri() != null) { try { MindRaider.labelCustodian .discardOutline(MindRaider.profile.getActiveOutlineUri().toString()); MindRaider.outlineCustodian.close(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToDiscardNotebook"), e1); } } } } }); menu.add(menuItem); menu.addSeparator(); // export submenu = new JMenu(Messages.getString("MindRaiderJFrame.export")); submenu.setMnemonic(KeyEvent.VK_E); // Atom subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportActiveOutlineToAtom(); } }); submenu.add(subMenuItem); // OPML subMenuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.opml")); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "opml"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "OPML-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".xml"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_OPML, dstFileName); Launcher.launchViaStart(dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutline() == null) { JOptionPane.showMessageDialog(MindRaiderMainWindow.this, Messages.getString("MindRaiderJFrame.exportNotebookWarning"), Messages.getString("MindRaiderJFrame.exportError"), JOptionPane.ERROR_MESSAGE); return; } JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.export")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseExportDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "export" + File.separator + "twiki"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String dstFileName = fc.getSelectedFile().getAbsolutePath() + File.separator + "TWIKI-EXPORT-" + MindRaider.outlineCustodian.getActiveNotebookNcName() + ".txt"; logger.debug(Messages.getString("MindRaiderJFrame.exportingToFile", dstFileName)); MindRaider.outlineCustodian.exportOutline(OutlineCustodian.FORMAT_TWIKI, dstFileName); } else { logger.debug(Messages.getString("MindRaiderJFrame.exportCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); // import submenu = new JMenu(Messages.getString("MindRaiderJFrame.import")); submenu.setMnemonic(KeyEvent.VK_I); subMenuItem = new JMenuItem("Atom"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importFromAtom(); } }); submenu.add(subMenuItem); // TWiki subMenuItem = new JMenuItem("TWiki"); subMenuItem.setEnabled(true); subMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // choose file to be transformed OutlineJPanel.getInstance().clear(); MindRaider.profile.setActiveOutlineUri(null); JFileChooser fc = new JFileChooser(); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File file = fc.getSelectedFile(); MindRaider.profile.deleteActiveModel(); logger.debug( Messages.getString("MindRaiderJFrame.importingTWikiTopic", file.getAbsolutePath())); // perform it async final SwingWorker worker = new SwingWorker() { public Object construct() { ProgressDialogJFrame progressDialogJFrame = new ProgressDialogJFrame( Messages.getString("MindRaiderJFrame.twikiImport"), Messages.getString("MindRaiderJFrame.processingTopicTWiki")); try { MindRaider.outlineCustodian.importNotebook(OutlineCustodian.FORMAT_TWIKI, (file != null ? file.getAbsolutePath() : null), progressDialogJFrame); } finally { if (progressDialogJFrame != null) { progressDialogJFrame.dispose(); } } return null; } }; worker.start(); } else { logger.debug(Messages.getString("MindRaiderJFrame.openCommandCancelledByUser")); } } }); submenu.add(subMenuItem); menu.add(submenu); menuBar.add(menu); // - note // ---------------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.concept")); menu.setMnemonic(KeyEvent.VK_C); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.new")); menuItem.setMnemonic(KeyEvent.VK_N); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().newConcept(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.open")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK)); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (MindRaider.profile.getActiveOutlineUri() != null) { new OpenNoteJDialog(); } } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.discard")); // do not accelerate this command with DEL - it's already handled // elsewhere menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDiscard(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.up")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptUp(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.promote")); menuItem.setMnemonic(KeyEvent.VK_P); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptPromote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.demote")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDemote(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.down")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, ActionEvent.CTRL_MASK)); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { OutlineJPanel.getInstance().conceptDown(); } }); menu.add(menuItem); menuBar.add(menu); // - Tools ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.tools")); menu.setMnemonic(KeyEvent.VK_T); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.checkAndFix")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Checker.checkAndFixRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.backupRepository")); menuItem.setMnemonic(KeyEvent.VK_B); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Installer.backupRepositoryAsync(); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.rebuildSearchIndex")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SearchCommander.rebuildSearchAndTagIndices(); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.captureScreen")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("MindRaiderJFrame.screenshot")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("MindRaiderJFrame.chooseScreenshotDirectory")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // prepare directory String exportDirectory = MindRaider.profile.getHomeDirectory() + File.separator + "Screenshots"; Utils.createDirectory(exportDirectory); fc.setCurrentDirectory(new File(exportDirectory)); int returnVal = fc.showOpenDialog(MindRaiderMainWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { final String filename = fc.getSelectedFile().getAbsolutePath() + File.separator + "screenshot.jpg"; // do it in async (redraw screen) Thread thread = new Thread() { public void run() { OutputStream file = null; try { file = new FileOutputStream(filename); Robot robot = new Robot(); robot.delay(1000); JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file); encoder.encode(robot.createScreenCapture( new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()))); } catch (Exception e1) { logger.error("Unable to capture screen!", e1); } finally { if (file != null) { try { file.close(); } catch (IOException e1) { logger.error("Unable to close stream", e1); } } } } }; thread.setDaemon(true); thread.start(); } } }); menu.add(menuItem); menuBar.add(menu); // - MindForger ----------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderMainWindow.menuMindForger")); menu.setMnemonic(KeyEvent.VK_O); //menu.setIcon(IconsRegistry.getImageIcon("tasks-internet.png")); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerVideoTutorial")); menuItem.setMnemonic(KeyEvent.VK_G); menuItem.setToolTipText("http://mindraider.sourceforge.net/mindforger.html"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net/mindforger.html"); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.signUp")); menuItem.setMnemonic(KeyEvent.VK_S); menuItem.setToolTipText("http://www.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://www.mindforger.com"); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerUpload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // fork in order to enable status updates in the main window new MindForgerUploadOutlineJDialog(); } }); menuItem.setEnabled(true); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerDownload")); menuItem.setMnemonic(KeyEvent.VK_U); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { downloadAnOutlineFromMindForger(); } }); menuItem.setEnabled(true); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.menuMindForgerMyOutlines")); menuItem.setMnemonic(KeyEvent.VK_O); menuItem.setEnabled(true); menuItem.setToolTipText("http://web.mindforger.com"); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://web.mindforger.com"); } }); menu.add(menuItem); menuBar.add(menu); // - align Help on right ------------------------------------------------------------- menuBar.add(Box.createHorizontalGlue()); // - help ------------------------------------------------------------- menu = new JMenu(Messages.getString("MindRaiderJFrame.help")); menu.setMnemonic(KeyEvent.VK_H); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.documentation")); menuItem.setMnemonic(KeyEvent.VK_D); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { MindRaider.outlineCustodian.loadOutline(new URI(MindRaiderVocabulary .getNotebookUri(OutlineCustodian.MR_DOC_NOTEBOOK_DOCUMENTATION_LOCAL_NAME))); OutlineJPanel.getInstance().refresh(); } catch (Exception e1) { logger.error(Messages.getString("MindRaiderJFrame.unableToLoadHelp", e1.getMessage())); } } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.webHomepage")); menuItem.setMnemonic(KeyEvent.VK_H); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://mindraider.sourceforge.net"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.reportBug")); menuItem.setMnemonic(KeyEvent.VK_R); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Launcher.launchInBrowser("http://sourceforge.net/forum/?group_id=128454"); } }); menu.add(menuItem); menuItem = new JMenuItem(Messages.getString("MindRaiderMainWindow.updateCheck")); menuItem.setMnemonic(KeyEvent.VK_F); menuItem.setEnabled(true); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // just open html page at: // http://mindraider.sourceforge.net/update-7.2.html // this page will either contain "you have the last version" or will ask user to // download the latest version from main page Launcher.launchInBrowser("http://mindraider.sourceforge.net/" + "update-" + MindRaiderConstants.majorVersion + "." + MindRaiderConstants.minorVersion + ".html"); } }); menu.add(menuItem); menu.addSeparator(); menuItem = new JMenuItem(Messages.getString("MindRaiderJFrame.about", MindRaiderConstants.MR_TITLE)); menuItem.setMnemonic(KeyEvent.VK_A); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutJDialog(); } }); menu.add(menuItem); menuBar.add(menu); }
From source file:org.jab.docsearch.DocSearch.java
private JToolBar createToolBar() { // tool bar/* w w w . j a va 2 s. com*/ JToolBar toolBar = new JToolBar(); // file open JButton buttonOpen = new JButton(new ImageIcon(getClass().getResource("/icons/fileopen.png"))); buttonOpen.setToolTipText(I18n.getString("tooltip.open")); buttonOpen.setActionCommand("ac_open"); buttonOpen.addActionListener(this); buttonOpen.setMnemonic(KeyEvent.VK_O); buttonOpen.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonOpen); // file save JButton buttonSave = new JButton(new ImageIcon(getClass().getResource("/icons/filesave.png"))); buttonSave.setToolTipText(I18n.getString("tooltip.save")); buttonSave.setActionCommand("ac_save"); buttonSave.addActionListener(this); buttonSave.setMnemonic(KeyEvent.VK_S); buttonSave.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonSave); toolBar.addSeparator(); // open browser JButton buttonBrowser = new JButton(new ImageIcon(getClass().getResource("/icons/html.png"))); buttonBrowser.setToolTipText(I18n.getString("tooltip.open_in_browser")); buttonBrowser.setActionCommand("ac_openinbrowser"); buttonBrowser.addActionListener(this); buttonBrowser.setMnemonic(KeyEvent.VK_E); buttonBrowser.setEnabled(!env.isWebStart()); // disable in WebStart toolBar.add(buttonBrowser); toolBar.addSeparator(); // home JButton buttonHome = new JButton(new ImageIcon(getClass().getResource("/icons/home.png"))); buttonHome.setToolTipText(I18n.getString("tooltip.home")); buttonHome.setActionCommand("ac_home"); buttonHome.addActionListener(this); buttonHome.setMnemonic(KeyEvent.VK_H); toolBar.add(buttonHome); // refresh JButton buttonRefresh = new JButton(new ImageIcon(getClass().getResource("/icons/refresh.png"))); buttonRefresh.setToolTipText(I18n.getString("tooltip.refresh")); buttonRefresh.setActionCommand("ac_refresh"); buttonRefresh.addActionListener(this); buttonRefresh.setMnemonic(KeyEvent.VK_L); toolBar.add(buttonRefresh); toolBar.addSeparator(); // result JButton buttonResult = new JButton(new ImageIcon(getClass().getResource("/icons/search_results.png"))); buttonResult.setToolTipText(I18n.getString("tooltip.results")); buttonResult.setActionCommand("ac_result"); buttonResult.addActionListener(this); buttonResult.setMnemonic(KeyEvent.VK_R); toolBar.add(buttonResult); toolBar.addSeparator(); // bookmark JButton buttonBookMark = new JButton(new ImageIcon(getClass().getResource("/icons/bookmark.png"))); buttonBookMark.setToolTipText(I18n.getString("tooltip.add_bookmark")); buttonBookMark.setActionCommand("ac_addbookmark"); buttonBookMark.addActionListener(this); buttonBookMark.setMnemonic(KeyEvent.VK_M); toolBar.add(buttonBookMark); toolBar.addSeparator(); // print JButton buttonPrint = new JButton(new ImageIcon(getClass().getResource("/icons/fileprint.png"))); buttonPrint.setToolTipText(I18n.getString("tooltip.print")); buttonPrint.setActionCommand("ac_print"); buttonPrint.addActionListener(this); buttonPrint.setMnemonic(KeyEvent.VK_P); toolBar.add(buttonPrint); toolBar.addSeparator(); // setting JButton buttonSetting = new JButton(new ImageIcon(getClass().getResource("/icons/configure.png"))); buttonSetting.setToolTipText(I18n.getString("tooltip.settings")); buttonSetting.setActionCommand("ac_settings"); buttonSetting.addActionListener(this); buttonSetting.setMnemonic(KeyEvent.VK_HOME); toolBar.add(buttonSetting); toolBar.addSeparator(); // stop buttonStop = new JButton(new ImageIcon(getClass().getResource("/icons/stop.png"))); buttonStop.setToolTipText(I18n.getString("tooltip.stop")); buttonStop.setActionCommand("ac_stop"); buttonStop.addActionListener(this); buttonStop.setMnemonic(KeyEvent.VK_X); toolBar.add(buttonStop); toolBar.addSeparator(); // toolBar.setFloatable(false); // finished return toolBar; }