List of usage examples for java.awt.event KeyEvent VK_F3
int VK_F3
To view the source code for java.awt.event KeyEvent VK_F3.
Click Source Link
From source file:statechum.analysis.learning.Visualiser.java
protected void setVisualiserKeyBindings() { persistAction = new graphAction("saveLayout", "save the layout of the visible graph") { /** Serial number. */ private static final long serialVersionUID = 1L; @Override//from w ww .j av a2 s . c o m public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { XMLEncoder encoder = null; try { if (propName >= 0) { String fileName = getLayoutFileName(graphs.get(currentGraph)); encoder = new XMLEncoder(new FileOutputStream(fileName)); Map<Integer, DoublePair> layout = ((XMLPersistingLayout) viewer.getModel().getGraphLayout()) .persist(); encoder.writeObject(layout); XMLAffineTransformSerialised trV = new XMLAffineTransformSerialised(); trV.setFromAffineTransform(viewer.getViewTransformer().getTransform()); encoder.writeObject(trV); XMLAffineTransformSerialised trL = new XMLAffineTransformSerialised(); trL.setFromAffineTransform(viewer.getLayoutTransformer().getTransform()); encoder.writeObject(trL); ((XMLModalGraphMouse) viewer.getGraphMouse()).store(encoder); encoder.writeObject(layoutOptions.get(currentGraph)); encoder.close(); encoder = null; } } catch (Exception e1) { e1.printStackTrace(); } finally { if (encoder != null) { encoder.close(); encoder = null; } } } }; keyToActionMap.put(KeyEvent.VK_F2, persistAction); keyToActionMap.put(KeyEvent.VK_F3, new graphAction("loadLayout", "loads the previously saved layout into the visible graph") { /** Serial number. */ private static final long serialVersionUID = 2L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { reloadLayout(false, true); } }); keyToActionMap.put(KeyEvent.VK_F9, new graphAction("loadPreviousLayout", "loads the layout of the previous graph in the list") { /** Serial number. */ private static final long serialVersionUID = 3L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { if (currentGraph > 0) { restoreLayout(false, currentGraph - 1); } } }); pickAction = new graphAction("pick", "Switches Jung into picking mode") { /** Serial number. */ private static final long serialVersionUID = 7L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { ((XMLModalGraphMouse) viewer.getGraphMouse()).setMode(ModalGraphMouse.Mode.PICKING); } }; keyToActionMap.put(KeyEvent.VK_F11, pickAction); transformAction = new graphAction("transform", "Switches Jung into transformation mode") { /** Serial number. */ private static final long serialVersionUID = 8L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { ((XMLModalGraphMouse) viewer.getGraphMouse()).setMode(ModalGraphMouse.Mode.TRANSFORMING); } }; keyToActionMap.put(KeyEvent.VK_F12, transformAction); keyToActionMap.put(KeyEvent.VK_UP, new graphAction("previous", "loads the previous graph") { /** Serial number. */ private static final long serialVersionUID = 9L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { if (currentGraph > 0) { --currentGraph; reloadLayout(false, true); } } }); keyToActionMap.put(KeyEvent.VK_DOWN, new graphAction("next", "loads the next graph") { /** Serial number. */ private static final long serialVersionUID = 10L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { if (currentGraph < graphs.size() - 1) { ++currentGraph; reloadLayout(false, true); } } }); keyToActionMap.put(KeyEvent.VK_F, new graphAction("negatives", "toggles negatives on or off") { /** Serial number. */ private static final long serialVersionUID = 11L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { LayoutOptions options = layoutOptions.get(currentGraph); if (options != null) { options.showNegatives = !options.showNegatives; reloadLayout(false, false); } } }); keyToActionMap.put(KeyEvent.VK_I, new graphAction("ignored states", "toggles ignored states on or off") { /** Serial number. */ private static final long serialVersionUID = 12L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { LayoutOptions options = layoutOptions.get(currentGraph); if (options != null) { options.showIgnored = !options.showIgnored; reloadLayout(false, false); } } }); keyToActionMap.put(KeyEvent.VK_PAGE_DOWN, new graphAction("refine", "reduces the abstraction level") { /** Serial number. */ private static final long serialVersionUID = 13L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { LayoutOptions options = layoutOptions.get(currentGraph); if (options != null && options.componentsToPick < Integer.MAX_VALUE) { options.componentsToPick++; reloadLayout(false, false); } } }); keyToActionMap.put(KeyEvent.VK_PAGE_UP, new graphAction("abstract", "increases abstraction level") { /** Serial number. */ private static final long serialVersionUID = 14L; @Override public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { LayoutOptions options = layoutOptions.get(currentGraph); if (options != null && options.componentsToPick != Integer.MAX_VALUE && options.componentsToPick > 0) { --options.componentsToPick; reloadLayout(false, false); } } }); }
From source file:de.tor.tribes.ui.windows.DSWorkbenchMainFrame.java
/** * Creates new form MapFrame// w w w . ja va2s .c o m */ DSWorkbenchMainFrame() { initComponents(); setAlwaysOnTop(false); if (!GlobalOptions.isMinimal()) { setTitle("DS Workbench " + Constants.VERSION + Constants.VERSION_ADDITION); } else { setTitle("DS Workbench Mini " + Constants.VERSION + Constants.VERSION_ADDITION); } jExportDialog.pack(); jAddROIDialog.pack(); JOutlookBar outlookBar = new JOutlookBar(); outlookBar.addBar("Navigation", jNavigationPanel); outlookBar.addBar("Information", jInformationPanel); outlookBar.addBar("Karte", jMapPanel); outlookBar.addBar("ROI", jROIPanel); outlookBar.setVisibleBar(1); jSettingsScrollPane.setViewportView(outlookBar); mAbout = new AboutDialog(this, true); mAbout.pack(); chooser.setDialogTitle("Speichern unter..."); chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() { @Override public boolean accept(File f) { return (f != null) && (f.isDirectory() || f.getName().endsWith(".png")); } @Override public String getDescription() { return "PNG Image (*.png)"; } }); chooser.addChoosableFileFilter(new javax.swing.filechooser.FileFilter() { @Override public boolean accept(File f) { return (f != null) && (f.isDirectory() || f.getName().endsWith(".jpeg")); } @Override public String getDescription() { return "JPEG Image (*.jpeg)"; } }); //Schedule Backup new Timer("BackupTimer", true).schedule(new BackupTask(), 60 * 10000, 60 * 10000); //give focus to map panel if mouse enters map jMapPanelHolder.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { jMapPanelHolder.requestFocusInWindow(); } }); getContentPane().setBackground(Constants.DS_BACK); pack(); capabilityInfoPanel1.addActionListener(MapPanel.getSingleton()); // <editor-fold defaultstate="collapsed" desc=" Add global KeyListener "> Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (event.getID() == KeyEvent.KEY_PRESSED) { KeyEvent e = (KeyEvent) event; if (DSWorkbenchMainFrame.getSingleton().isActive()) { //move shortcuts if (e.getKeyCode() == KeyEvent.VK_DOWN) { scroll(0.0, 2.0); } else if (e.getKeyCode() == KeyEvent.VK_UP) { scroll(0.0, -2.0); } else if (e.getKeyCode() == KeyEvent.VK_LEFT) { scroll(-2.0, 0.0); } else if (e.getKeyCode() == KeyEvent.VK_RIGHT) { scroll(2.0, 0.0); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //shot minimap tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_AXE); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack axe tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_RAM); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack ram tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SNOB); } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack snob tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SPY); } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack sword tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_LIGHT); } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack light tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_HEAVY); } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isShiftDown() && !e.isControlDown() && !e.isAltDown()) { //attack heavy tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_SWORD); } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isControlDown() && !e.isAltDown()) { //search frame shortcut DSWorkbenchSearchFrame.getSingleton() .setVisible(!DSWorkbenchSearchFrame.getSingleton().isVisible()); } } //misc shortcuts if ((e.getKeyCode() == KeyEvent.VK_0) && e.isAltDown()) { //no tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_DEFAULT); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //measure tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MEASURE); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //mark tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MARK); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //tag tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_TAG); } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SUPPORT); } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SELECTION); } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_RADAR); } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //attack ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ATTACK_INGAME); } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { //res ingame tool shortcut MapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SEND_RES_INGAME); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //move minimap tool shortcut MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_MOVE); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //zoom minimap tool shortcut MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_ZOOM); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //shot minimap tool shortcut MinimapPanel.getSingleton().setCurrentCursor(ImageManager.CURSOR_SHOT); } else if ((e.getKeyCode() == KeyEvent.VK_T) && e.isControlDown() && !e.isShiftDown() && !e.isAltDown()) { //search time shortcut ClockFrame.getSingleton().setVisible(!ClockFrame.getSingleton().isVisible()); } else if ((e.getKeyCode() == KeyEvent.VK_S) && e.isAltDown() && !e.isShiftDown() && !e.isControlDown()) { planMapshot(); } else if (e.getKeyCode() == KeyEvent.VK_F2) { DSWorkbenchAttackFrame.getSingleton() .setVisible(!DSWorkbenchAttackFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F3) { DSWorkbenchMarkerFrame.getSingleton() .setVisible(!DSWorkbenchMarkerFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F4) { DSWorkbenchTroopsFrame.getSingleton() .setVisible(!DSWorkbenchTroopsFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F5) { DSWorkbenchRankFrame.getSingleton() .setVisible(!DSWorkbenchRankFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F6) { DSWorkbenchFormFrame.getSingleton() .setVisible(!DSWorkbenchFormFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F7) { if (ServerSettings.getSingleton().isChurch()) { DSWorkbenchChurchFrame.getSingleton() .setVisible(!DSWorkbenchChurchFrame.getSingleton().isVisible()); } } else if (e.getKeyCode() == KeyEvent.VK_F8) { DSWorkbenchConquersFrame.getSingleton() .setVisible(!DSWorkbenchConquersFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F9) { DSWorkbenchNotepad.getSingleton() .setVisible(!DSWorkbenchNotepad.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F10) { DSWorkbenchTagFrame.getSingleton() .setVisible(!DSWorkbenchTagFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F11) { DSWorkbenchStatsFrame.getSingleton() .setVisible(!DSWorkbenchStatsFrame.getSingleton().isVisible()); } else if (e.getKeyCode() == KeyEvent.VK_F12) { DSWorkbenchSettingsDialog.getSingleton().setVisible(true); } else if ((e.getKeyCode() == KeyEvent.VK_1) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 1 centerROI(0); } else if ((e.getKeyCode() == KeyEvent.VK_2) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 2 centerROI(1); } else if ((e.getKeyCode() == KeyEvent.VK_3) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 3 centerROI(2); } else if ((e.getKeyCode() == KeyEvent.VK_4) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 4 centerROI(3); } else if ((e.getKeyCode() == KeyEvent.VK_5) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 5 centerROI(4); } else if ((e.getKeyCode() == KeyEvent.VK_6) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 6 centerROI(5); } else if ((e.getKeyCode() == KeyEvent.VK_7) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 7 centerROI(6); } else if ((e.getKeyCode() == KeyEvent.VK_8) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 8 centerROI(7); } else if ((e.getKeyCode() == KeyEvent.VK_9) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 9 centerROI(8); } else if ((e.getKeyCode() == KeyEvent.VK_0) && e.isControlDown() && e.isAltDown() && !e.isShiftDown()) { //ROI 10 centerROI(9); } else if (e.getKeyCode() == KeyEvent.VK_SPACE) { jMapPanelHolder.requestFocusInWindow(); MapPanel.getSingleton().setSpaceDown(true); } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { jMapPanelHolder.requestFocusInWindow(); MapPanel.getSingleton().setShiftDown(true); } } else if (event.getID() == KeyEvent.KEY_RELEASED) { KeyEvent e = (KeyEvent) event; if (e.getKeyCode() == KeyEvent.VK_SPACE) { MapPanel.getSingleton().setSpaceDown(false); } else if (e.getKeyCode() == KeyEvent.VK_SHIFT) { MapPanel.getSingleton().setShiftDown(false); } } } }, AWTEvent.KEY_EVENT_MASK); // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Load UI Icons "> try { jOnlineLabel.setIcon(new ImageIcon("./graphics/icons/online.png")); jEnableClipboardWatchButton.setIcon(new ImageIcon("./graphics/icons/watch_clipboard.png")); jCenterIngameButton .setIcon(new ImageIcon(DSWorkbenchMainFrame.class.getResource("/res/ui/center_ingame.png"))); jRefreshButton.setIcon(new ImageIcon("./graphics/icons/refresh.png")); jCenterCoordinateIngame.setIcon(new ImageIcon("./graphics/icons/center.png")); } catch (Exception e) { logger.error("Failed to load status icon(s)", e); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Check for desktop support "> if (!Desktop.isDesktopSupported()) { jCenterIngameButton.setEnabled(false); jCenterCoordinateIngame.setEnabled(false); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Restore last map position "> try { String x = GlobalOptions.getSelectedProfile().getProperty("last.x"); String y = GlobalOptions.getSelectedProfile().getProperty("last.y"); centerPosition(Double.parseDouble(x), Double.parseDouble(y)); } catch (Exception e) { centerPosition(ServerSettings.getSingleton().getMapDimension().getCenterX(), ServerSettings.getSingleton().getMapDimension().getCenterY()); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc=" Restore other settings "> jShowMapPopup.setSelected(GlobalOptions.getProperties().getBoolean("show.map.popup")); jShowMouseOverInfo.setSelected(GlobalOptions.getProperties().getBoolean("show.mouseover.info")); jIncludeSupport.setSelected(GlobalOptions.getProperties().getBoolean("include.support")); jHighlightTribeVillages.setSelected(GlobalOptions.getProperties().getBoolean("highlight.tribes.villages")); jShowRuler.setSelected(GlobalOptions.getProperties().getBoolean("show.ruler")); jDisplayChurch.setSelected(GlobalOptions.getProperties().getBoolean("show.church")); jDisplayWatchtower.setSelected(GlobalOptions.getProperties().getBoolean("show.watchtower")); jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch()); jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower()); ServerSettings.getSingleton().addListener(new ServerSettingsListener() { @Override public void fireServerSettingsChanged() { jDisplayChurch.setEnabled(ServerSettings.getSingleton().isChurch()); jDisplayWatchtower.setEnabled(ServerSettings.getSingleton().isWatchtower()); } }); int r = GlobalOptions.getProperties().getInt("radar.size"); int hour = r / 60; jHourField.setText(Integer.toString(hour)); jMinuteField.setText(Integer.toString(r - hour * 60)); // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Skin Setup"> DefaultComboBoxModel gpModel = new DefaultComboBoxModel(GlobalOptions.getAvailableSkins()); jGraphicPacks.setModel(gpModel); String skin = GlobalOptions.getProperty("default.skin"); if (gpModel.getIndexOf(skin) != -1) { jGraphicPacks.setSelectedItem(skin); } else { jGraphicPacks.setSelectedItem("default"); } //</editor-fold> minZoom = GlobalOptions.getProperties().getDouble("map.zoom.min"); maxZoom = GlobalOptions.getProperties().getDouble("map.zoom.max"); dZoomInOutFactor = GlobalOptions.getProperties().getDouble("map.zoom.in.out.factor"); mNotificationHideThread = new NotificationHideThread(); mNotificationHideThread.start(); SystrayHelper.installSystrayIcon(); //update online state onlineStateChanged(); restoreProperties(); }
From source file:com.xyphos.vmtgen.GUI.java
@Override public boolean dispatchKeyEvent(KeyEvent ke) { if (KeyEvent.KEY_PRESSED == ke.getID()) { System.out.println(ke.toString()); switch (ke.getKeyCode()) { case KeyEvent.VK_F1: generateVMT();// w w w .ja v a 2 s . c om return true; case KeyEvent.VK_F2: setAllLocks(true); return true; case KeyEvent.VK_F3: setAllLocks(false); return true; case KeyEvent.VK_F4: toggleAllLocks(); return true; case KeyEvent.VK_F5: showTextureFiles(); return true; case KeyEvent.VK_F6: resetAllInput(); return true; } } return false; }
From source file:org.apache.pdfbox.debugger.PDFDebugger.java
private JMenu createFindMenu() { findMenu = new JMenu("Find"); findMenu.setEnabled(false);/*from w w w .j ava2 s . c om*/ findMenuItem = new JMenuItem("Find..."); findMenuItem.setActionCommand("find"); findMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, SHORCUT_KEY_MASK)); findNextMenuItem = new JMenuItem("Find Next"); if (IS_MAC_OS) { findNextMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, SHORCUT_KEY_MASK)); } else { findNextMenuItem.setAccelerator(KeyStroke.getKeyStroke("F3")); } findPreviousMenuItem = new JMenuItem("Find Previous"); if (IS_MAC_OS) { findPreviousMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_G, SHORCUT_KEY_MASK | InputEvent.SHIFT_DOWN_MASK)); } else { findPreviousMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_DOWN_MASK)); } findMenu.add(findMenuItem); findMenu.add(findNextMenuItem); findMenu.add(findPreviousMenuItem); return findMenu; }
From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java
protected void initListeners() { addKeyListener(new KeyAdapter() { // TODO need to fix focus problems elsewhere for this to always work public void keyPressed(KeyEvent e) { int row = getSelectedRow(); if (row < 0) return; CommonSpreadSheetModel model = (CommonSpreadSheetModel) getModel(); if (e.getKeyCode() == KeyEvent.VK_INSERT) executeAction(MenuActionConstants.ACTION_NEW); else if (e.getKeyCode() == KeyEvent.VK_DELETE) executeAction(MenuActionConstants.ACTION_DELETE); else if (e.getKeyCode() == KeyEvent.VK_F3) GraphicManager.getInstance().doFind(SpreadSheet.this, null); else if (e.getKeyCode() == KeyEvent.VK_F && e.getModifiers() == KeyEvent.CTRL_MASK) GraphicManager.getInstance().doFind(SpreadSheet.this, null); }// ww w .j a v a 2s . c o m }); }
From source file:com.github.fritaly.dualcommander.DualCommander.java
public DualCommander() { // TODO Generate a fat jar at build time super(String.format("Dual Commander %s", Utils.getApplicationVersion())); if (logger.isInfoEnabled()) { logger.info(String.format("Dual Commander %s", Utils.getApplicationVersion())); }/*from w w w. jav a2 s. c o m*/ try { // Apply the JGoodies L&F UIManager.setLookAndFeel(new WindowsLookAndFeel()); } catch (Exception e) { // Not supposed to happen } // Layout, columns & rows setLayout(new MigLayout("insets 0px", "[grow]0px[grow]", "[grow]0px[]")); // Create a menu bar final JMenu fileMenu = new JMenu("File"); fileMenu.add(new JMenuItem(preferencesAction)); fileMenu.add(new JSeparator()); fileMenu.add(new JMenuItem(quitAction)); final JMenu helpMenu = new JMenu("Help"); helpMenu.add(new JMenuItem(aboutAction)); final JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); this.leftPane = new TabbedPane(preferences); this.leftPane.setName("Left"); this.leftPane.addChangeListener(this); this.leftPane.addKeyListener(this); this.leftPane.addFocusListener(this); this.rightPane = new TabbedPane(preferences); this.rightPane.setName("Right"); this.rightPane.addChangeListener(this); this.rightPane.addKeyListener(this); this.rightPane.addFocusListener(this); // Adding the 2 components to the same sizegroup ensures they always // keep the same width getContentPane().add(leftPane, "grow, sizegroup g1"); getContentPane().add(rightPane, "grow, sizegroup g1, wrap"); // The 7 buttons must all have the same width (they must belong to the // same size group) final JPanel buttonPanel = new JPanel( new MigLayout("insets 0px", StringUtils.repeat("[grow, sizegroup g1]", 7), "[grow]")); buttonPanel.add(viewButton, "grow"); buttonPanel.add(editButton, "grow"); buttonPanel.add(copyButton, "grow"); buttonPanel.add(moveButton, "grow"); buttonPanel.add(mkdirButton, "grow"); buttonPanel.add(deleteButton, "grow"); buttonPanel.add(quitButton, "grow"); getContentPane().add(buttonPanel, "grow, span 2"); // Register shortcuts at a global level (not on every component) final InputMap inputMap = this.leftPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, true), "view"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, 0, true), "edit"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0, true), "copy"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0, true), "move"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0, true), "mkdir"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0, true), "delete"); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_DOWN_MASK), "quit"); final ActionMap actionMap = this.leftPane.getActionMap(); actionMap.put("view", viewAction); actionMap.put("edit", editAction); actionMap.put("copy", copyAction); actionMap.put("move", moveAction); actionMap.put("mkdir", mkdirAction); actionMap.put("delete", deleteAction); actionMap.put("quit", quitAction); addWindowListener(this); addKeyListener(this); // Listen to preference change events this.preferences.addPropertyChangeListener(this); // Reload the last configuration and init the left & right panels // accordingly final Preferences prefs = Preferences.userNodeForPackage(this.getClass()); // The user preferences must be loaded first because they're needed to // init the UI this.preferences.init(prefs.node("user.preferences")); this.leftPane.init(prefs.node("left.panel")); this.rightPane.init(prefs.node("right.panel")); if (logger.isInfoEnabled()) { logger.info("Loaded preferences"); } // Init the buttons refreshButtons(this.leftPane.getActiveBrowser().getSelection()); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setExtendedState(JFrame.MAXIMIZED_BOTH); if (logger.isInfoEnabled()) { logger.info("UI initialized"); } }
From source file:com.freedomotic.jfrontend.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 www .j a v a 2s.c om */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jTextField1 = new javax.swing.JTextField(); scrollTxtOut1 = new javax.swing.JScrollPane(); txtOut1 = new javax.swing.JTextArea(); scrollTxtOut2 = new javax.swing.JScrollPane(); txtOut2 = new javax.swing.JTextArea(); jMenuItem4 = new javax.swing.JMenuItem(); jSeparator2 = new javax.swing.JSeparator(); menuBar = new javax.swing.JMenuBar(); mnuOpenNew = new javax.swing.JMenu(); mnuNewEnvironment = new javax.swing.JMenuItem(); mnuOpenEnvironment = new javax.swing.JMenuItem(); mnuSave = new javax.swing.JMenuItem(); mnuSaveAs = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JSeparator(); mnuSwitchUser = new javax.swing.JMenuItem(); mnuExit = new javax.swing.JMenuItem(); mnuEditMode = new javax.swing.JMenu(); mnuSelectEnvironment = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); mnuRenameEnvironment = new javax.swing.JMenuItem(); mnuAddDuplicateEnvironment = new javax.swing.JMenuItem(); mnuChangeRenderer = new javax.swing.JMenuItem(); mnuBackground = new javax.swing.JMenuItem(); mnuDelete = new javax.swing.JMenuItem(); mnuRoomEditMode = new javax.swing.JCheckBoxMenuItem(); jMenu3 = new javax.swing.JMenu(); mnuRenameRoom = new javax.swing.JMenuItem(); mnuAddRoom = new javax.swing.JMenuItem(); mnuRoomBackground = new javax.swing.JMenuItem(); mnuRemoveRoom = new javax.swing.JMenuItem(); mnuObjects = new javax.swing.JMenu(); mnuObjectEditMode = new javax.swing.JCheckBoxMenuItem(); jMenu2 = new javax.swing.JMenu(); mnuAutomations = new javax.swing.JMenuItem(); jMenu1 = new javax.swing.JMenu(); jCheckBoxMarket = new javax.swing.JCheckBoxMenuItem(); mnuPluginConfigure = new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu(); mnuLanguage = new javax.swing.JMenuItem(); mnuPrivileges = new javax.swing.JMenuItem(); mnuWindow = new javax.swing.JMenu(); mnuPluginList = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); mnuHelp = new javax.swing.JMenu(); mnuTutorial = new javax.swing.JMenuItem(); jMenuItem1 = new javax.swing.JMenuItem(); submnuHelp = new javax.swing.JMenuItem(); jTextField1.setText("jTextField1"); scrollTxtOut1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); txtOut1.setEditable(false); txtOut1.setColumns(20); txtOut1.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N txtOut1.setRows(5); txtOut1.setWrapStyleWord(true); txtOut1.setName("txtOutput"); // NOI18N txtOut1.setOpaque(false); scrollTxtOut1.setViewportView(txtOut1); scrollTxtOut2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); txtOut2.setEditable(false); txtOut2.setColumns(20); txtOut2.setFont(new java.awt.Font("Arial", 0, 10)); // NOI18N txtOut2.setRows(5); txtOut2.setWrapStyleWord(true); txtOut2.setName("txtOutput"); // NOI18N txtOut2.setOpaque(false); scrollTxtOut2.setViewportView(txtOut2); jMenuItem4.setText("jMenuItem4"); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Freedomotic"); setBackground(java.awt.SystemColor.window); setBounds(new java.awt.Rectangle(50, 20, 0, 0)); setLocationByPlatform(true); setMinimumSize(new java.awt.Dimension(500, 400)); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } public void windowClosed(java.awt.event.WindowEvent evt) { formWindowClosed(evt); } public void windowActivated(java.awt.event.WindowEvent evt) { drawer.repaint(); } }); addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent evt) { formComponentResized(evt); } }); addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { formMouseMoved(evt); } }); mnuOpenNew.setText(i18n.msg("file")); mnuOpenNew.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuOpenNewActionPerformed(evt); } }); mnuNewEnvironment.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK)); mnuNewEnvironment.setText(i18n.msg("new") + i18n.msg("environment")); mnuNewEnvironment.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuNewEnvironmentActionPerformed(evt); } }); mnuOpenNew.add(mnuNewEnvironment); mnuOpenEnvironment.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK)); mnuOpenEnvironment.setText(i18n.msg("open") + i18n.msg("environment")); mnuOpenEnvironment.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuOpenEnvironmentActionPerformed(evt); } }); mnuOpenNew.add(mnuOpenEnvironment); mnuSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); mnuSave.setText(i18n.msg("save") + i18n.msg("environment")); mnuSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuSaveActionPerformed(evt); } }); mnuOpenNew.add(mnuSave); mnuSaveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)); mnuSaveAs.setText(i18n.msg("save_X_as", new Object[] { i18n.msg("environment") })); mnuSaveAs.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuSaveAsActionPerformed(evt); } }); mnuOpenNew.add(mnuSaveAs); mnuOpenNew.add(jSeparator1); mnuSwitchUser.setText(i18n.msg("change_user")); mnuSwitchUser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuSwitchUserActionPerformed(evt); } }); mnuOpenNew.add(mnuSwitchUser); mnuExit.setText(i18n.msg("exit")); mnuExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuExitActionPerformed(evt); } }); mnuOpenNew.add(mnuExit); menuBar.add(mnuOpenNew); mnuEditMode.setText(i18n.msg("environment")); mnuSelectEnvironment.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0)); mnuSelectEnvironment.setText(i18n.msg("select_X", new Object[] { i18n.msg("area_floor") })); mnuSelectEnvironment.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuSelectEnvironmentActionPerformed(evt); } }); mnuEditMode.add(mnuSelectEnvironment); jMenu4.setText(i18n.msg("area_floor")); mnuRenameEnvironment.setText(i18n.msg("rename")); mnuRenameEnvironment.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuRenameEnvironmentActionPerformed(evt); } }); jMenu4.add(mnuRenameEnvironment); mnuAddDuplicateEnvironment.setText(i18n.msg("add") + "/" + i18n.msg("duplicate")); mnuAddDuplicateEnvironment.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuAddDuplicateEnvironmentActionPerformed(evt); } }); jMenu4.add(mnuAddDuplicateEnvironment); mnuChangeRenderer.setText(i18n.msg("change_X", new Object[] { i18n.msg("renderer") })); mnuChangeRenderer.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuChangeRendererActionPerformed(evt); } }); jMenu4.add(mnuChangeRenderer); mnuBackground.setText(i18n.msg("change_X", new Object[] { i18n.msg("background") })); mnuBackground.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuBackgroundActionPerformed(evt); } }); jMenu4.add(mnuBackground); mnuDelete.setText(i18n.msg("delete")); mnuDelete.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuDeleteActionPerformed(evt); } }); jMenu4.add(mnuDelete); mnuEditMode.add(jMenu4); mnuRoomEditMode.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0)); mnuRoomEditMode.setText(i18n.msg("X_edit_mode", new Object[] { i18n.msg("rooms") })); mnuRoomEditMode.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuRoomEditModeActionPerformed(evt); } }); mnuEditMode.add(mnuRoomEditMode); jMenu3.setText(i18n.msg("rooms")); mnuRenameRoom.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK)); mnuRenameRoom.setText(i18n.msg("rename") + i18n.msg("room")); mnuRenameRoom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuRenameRoomActionPerformed(evt); } }); jMenu3.add(mnuRenameRoom); mnuAddRoom.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); mnuAddRoom.setText(i18n.msg("add") + i18n.msg("room")); mnuAddRoom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuAddRoomActionPerformed(evt); } }); jMenu3.add(mnuAddRoom); mnuRoomBackground.setText(i18n.msg("change_X", new Object[] { i18n.msg("background") })); mnuRoomBackground.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuRoomBackgroundActionPerformed(evt); } }); jMenu3.add(mnuRoomBackground); mnuRemoveRoom.setText(i18n.msg("remove") + i18n.msg("room")); mnuRemoveRoom.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuRemoveRoomActionPerformed(evt); } }); jMenu3.add(mnuRemoveRoom); mnuEditMode.add(jMenu3); menuBar.add(mnuEditMode); mnuObjects.setText(i18n.msg("objects")); mnuObjectEditMode.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F6, 0)); mnuObjectEditMode.setText(i18n.msg("X_edit_mode", new Object[] { i18n.msg("objects") })); mnuObjectEditMode.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuObjectEditModeActionPerformed(evt); } }); mnuObjects.add(mnuObjectEditMode); menuBar.add(mnuObjects); jMenu2.setText(i18n.msg("automations")); mnuAutomations.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F7, 0)); mnuAutomations.setText(i18n.msg("manage") + i18n.msg("automations")); mnuAutomations.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuAutomationsActionPerformed(evt); } }); jMenu2.add(mnuAutomations); menuBar.add(jMenu2); jMenu1.setText(i18n.msg("plugins")); jCheckBoxMarket.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F8, 0)); jCheckBoxMarket.setText(i18n.msg("install_from_marketplace")); jCheckBoxMarket.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCheckBoxMarketActionPerformed(evt); } }); jMenu1.add(jCheckBoxMarket); mnuPluginConfigure.setText(i18n.msg("configure")); mnuPluginConfigure.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuPluginConfigureActionPerformed(evt); } }); jMenu1.add(mnuPluginConfigure); menuBar.add(jMenu1); jMenu5.setText(i18n.msg("settings")); mnuLanguage.setText(i18n.msg("language")); mnuLanguage.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuLanguageActionPerformed(evt); } }); jMenu5.add(mnuLanguage); mnuPrivileges.setText(i18n.msg("privileges")); mnuPrivileges.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuPrivilegesActionPerformed(evt); } }); jMenu5.add(mnuPrivileges); menuBar.add(jMenu5); mnuWindow.setText(i18n.msg("window")); mnuPluginList.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F9, 0)); mnuPluginList.setText(i18n.msg("X_list", new Object[] { i18n.msg("plugins") })); mnuPluginList.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuPluginListActionPerformed(evt); } }); mnuWindow.add(mnuPluginList); jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F11, 0)); jMenuItem3.setText(i18n.msg("fullscreen")); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); mnuWindow.add(jMenuItem3); menuBar.add(mnuWindow); mnuHelp.setText(i18n.msg("help")); mnuTutorial.setText(i18n.msg("tutorial")); mnuTutorial.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnuTutorialActionPerformed(evt); } }); mnuHelp.add(mnuTutorial); jMenuItem1.setText(master.getApi().getI18n().msg("report_issue")); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); mnuHelp.add(jMenuItem1); submnuHelp.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0)); submnuHelp.setText(i18n.msg("about")); submnuHelp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { submnuHelpActionPerformed(evt); } }); mnuHelp.add(submnuHelp); menuBar.add(mnuHelp); setJMenuBar(menuBar); pack(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
/** * Constructs the pane for the spreadsheet. * //from w ww . j a v a 2s . c om * @param name the name of the pane * @param task the owning task * @param workbench the workbench to be edited * @param showImageView shows image window when first showing the window */ public WorkbenchPaneSS(final String name, final Taskable task, final Workbench workbenchArg, final boolean showImageView, final boolean isReadOnly) throws Exception { super(name, task); removeAll(); if (workbenchArg == null) { return; } this.workbench = workbenchArg; this.isReadOnly = isReadOnly; headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems()); Collections.sort(headers); boolean hasOneOrMoreImages = false; // pre load all the data for (WorkbenchRow wbRow : workbench.getWorkbenchRows()) { for (WorkbenchDataItem wbdi : wbRow.getWorkbenchDataItems()) { wbdi.getCellData(); } if (wbRow.getWorkbenchRowImages() != null && wbRow.getWorkbenchRowImages().size() > 0) { hasOneOrMoreImages = true; } } model = new GridTableModel(this); spreadSheet = new WorkbenchSpreadSheet(model, this); spreadSheet.setReadOnly(isReadOnly); model.setSpreadSheet(spreadSheet); Highlighter simpleStriping = HighlighterFactory.createSimpleStriping(); GridCellHighlighter hl = new GridCellHighlighter( new GridCellPredicate(GridCellPredicate.AnyPredicate, null)); Short[] errs = { WorkbenchDataItem.VAL_ERROR, WorkbenchDataItem.VAL_ERROR_EDIT }; ColorHighlighter errColorHighlighter = new ColorHighlighter( new GridCellPredicate(GridCellPredicate.ValidationPredicate, errs), CellRenderingAttributes.errorBackground, null); Short[] newdata = { WorkbenchDataItem.VAL_NEW_DATA }; ColorHighlighter noDataHighlighter = new ColorHighlighter( new GridCellPredicate(GridCellPredicate.MatchingPredicate, newdata), CellRenderingAttributes.newDataBackground, null); Short[] multimatch = { WorkbenchDataItem.VAL_MULTIPLE_MATCH }; ColorHighlighter multiMatchHighlighter = new ColorHighlighter( new GridCellPredicate(GridCellPredicate.MatchingPredicate, multimatch), CellRenderingAttributes.multipleMatchBackground, null); spreadSheet.setHighlighters(simpleStriping, hl, errColorHighlighter, noDataHighlighter, multiMatchHighlighter); //add key mappings for cut, copy, paste //XXX Note: these are shortcuts directly to the SpreadSheet cut,copy,paste methods, NOT to the Specify edit menu. addRecordKeyMappings(spreadSheet, KeyEvent.VK_C, "Copy", new AbstractAction() { public void actionPerformed(ActionEvent ae) { SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { spreadSheet.cutOrCopy(false); } }); } }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); addRecordKeyMappings(spreadSheet, KeyEvent.VK_X, "Cut", new AbstractAction() { public void actionPerformed(ActionEvent ae) { SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { spreadSheet.cutOrCopy(true); } }); } }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); addRecordKeyMappings(spreadSheet, KeyEvent.VK_V, "Paste", new AbstractAction() { public void actionPerformed(ActionEvent ae) { SwingUtilities.invokeLater(new Runnable() { /* (non-Javadoc) * @see java.lang.Runnable#run() */ @Override public void run() { spreadSheet.paste(); } }); } }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); findPanel = spreadSheet.getFindReplacePanel(); UIRegistry.getLaunchFindReplaceAction().setSearchReplacePanel(findPanel); spreadSheet.setShowGrid(true); JTableHeader header = spreadSheet.getTableHeader(); header.addMouseListener(new ColumnHeaderListener()); header.setReorderingAllowed(false); // Turn Off column dragging // Put the model in image mode, and never change it. // Now we're showing/hiding the image column using JXTable's column hiding features. model.setInImageMode(true); int imageColIndex = model.getColumnCount() - 1; imageColExt = spreadSheet.getColumnExt(imageColIndex); imageColExt.setVisible(false); int sgrColIndex = model.getSgrHeading().getViewOrder(); sgrColExt = spreadSheet.getColumnExt(sgrColIndex); sgrColExt.setComparator(((WorkbenchSpreadSheet) spreadSheet).new NumericColumnComparator()); int cmpIdx = 0; for (Comparator<String> cmp : ((WorkbenchSpreadSheet) spreadSheet).getComparators()) { if (cmp != null) { spreadSheet.getColumnExt(cmpIdx++).setComparator(cmp); } } // Start off with the SGR score column hidden showHideSgrCol(false); model.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { setChanged(true); } }); spreadSheet.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { UIRegistry.enableCutCopyPaste(true); UIRegistry.enableFind(findPanel, true); } @Override public void focusLost(FocusEvent e) { UIRegistry.enableCutCopyPaste(true); UIRegistry.enableFind(findPanel, true); } }); if (isReadOnly) { saveBtn = null; } else { saveBtn = createButton(getResourceString("SAVE")); saveBtn.setToolTipText( String.format(getResourceString("WB_SAVE_DATASET_TT"), new Object[] { workbench.getName() })); saveBtn.setEnabled(false); saveBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { UsageTracker.incrUsageCount("WB.SaveDataSet"); UIRegistry.writeSimpleGlassPaneMsg( String.format(getResourceString("WB_SAVING"), new Object[] { workbench.getName() }), WorkbenchTask.GLASSPANE_FONT_SIZE); UIRegistry.getStatusBar().setIndeterminate(workbench.getName(), true); final SwingWorker worker = new SwingWorker() { @SuppressWarnings("synthetic-access") @Override public Object construct() { try { saveObject(); } catch (Exception ex) { UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(WorkbenchPaneSS.class, ex); log.error(ex); return ex; } return null; } // Runs on the event-dispatching thread. @Override public void finished() { Object retVal = get(); if (retVal != null && retVal instanceof Exception) { Exception ex = (Exception) retVal; UIRegistry.getStatusBar().setErrorMessage(getResourceString("WB_ERROR_SAVING"), ex); } UIRegistry.clearSimpleGlassPaneMsg(); UIRegistry.getStatusBar().setProgressDone(workbench.getName()); } }; worker.start(); } }); } Action delAction = addRecordKeyMappings(spreadSheet, KeyEvent.VK_F3, "DelRow", new AbstractAction() { public void actionPerformed(ActionEvent ae) { if (validationWorkerQueue.peek() == null) { deleteRows(); } } }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); if (isReadOnly) { deleteRowsBtn = null; } else { deleteRowsBtn = createIconBtn("DelRec", "WB_DELETE_ROW", delAction); selectionSensitiveButtons.add(deleteRowsBtn); spreadSheet.setDeleteAction(delAction); } //XXX Using the wb ID in the prefname to do pref setting per wb, may result in a bloated prefs file?? doIncrementalValidation = AppPreferences.getLocalPrefs() .getBoolean(wbAutoValidatePrefName + "." + workbench.getId(), true); doIncrementalMatching = AppPreferences.getLocalPrefs() .getBoolean(wbAutoMatchPrefName + "." + workbench.getId(), false); if (isReadOnly) { clearCellsBtn = null; } else { clearCellsBtn = createIconBtn("Eraser", "WB_CLEAR_CELLS", new ActionListener() { public void actionPerformed(ActionEvent ae) { spreadSheet.clearSorter(); if (spreadSheet.getCellEditor() != null) { spreadSheet.getCellEditor().stopCellEditing(); } int[] rows = spreadSheet.getSelectedRowModelIndexes(); int[] cols = spreadSheet.getSelectedColumnModelIndexes(); model.clearCells(rows, cols); } }); selectionSensitiveButtons.add(clearCellsBtn); } Action addAction = addRecordKeyMappings(spreadSheet, KeyEvent.VK_N, "AddRow", new AbstractAction() { public void actionPerformed(ActionEvent ae) { if (workbench.getWorkbenchRows().size() < WorkbenchTask.MAX_ROWS) { if (validationWorkerQueue.peek() == null) { addRowAfter(); } } } }, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); if (isReadOnly) { addRowsBtn = null; } else { addRowsBtn = createIconBtn("AddRec", "WB_ADD_ROW", addAction); addRowsBtn.setEnabled(true); addAction.setEnabled(true); } if (isReadOnly) { carryForwardBtn = null; } else { carryForwardBtn = createIconBtn("CarryForward20x20", IconManager.IconSize.NonStd, "WB_CARRYFORWARD", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { UsageTracker.getUsageCount("WBCarryForward"); configCarryFoward(); } }); carryForwardBtn.setEnabled(true); } toggleImageFrameBtn = createIconBtn("CardImage", IconManager.IconSize.NonStd, "WB_SHOW_IMG_WIN", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { toggleImageFrameVisible(); } }); toggleImageFrameBtn.setEnabled(true); importImagesBtn = createIconBtn("CardImage", IconManager.IconSize.NonStd, "WB_SHOW_IMG_WIN", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { toggleImportImageFrameVisible(); } }); importImagesBtn.setEnabled(true); /*showMapBtn = createIconBtn("ShowMap", IconManager.IconSize.NonStd, "WB_SHOW_MAP", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { showMapOfSelectedRecords(); } });*/ // enable or disable along with Google Earth and Geo Ref Convert buttons if (isReadOnly) { exportKmlBtn = null; } else { exportKmlBtn = createIconBtn("GoogleEarth", IconManager.IconSize.NonStd, "WB_SHOW_IN_GOOGLE_EARTH", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { SwingUtilities.invokeLater(new Runnable() { public void run() { showRecordsInGoogleEarth(); } }); } }); } // readRegisteries(); // enable or disable along with Show Map and Geo Ref Convert buttons if (isReadOnly) { geoRefToolBtn = null; } else { AppPreferences remotePrefs = AppPreferences.getRemote(); final String tool = remotePrefs.get("georef_tool", "geolocate"); String iconName = "GEOLocate20"; //tool.equalsIgnoreCase("geolocate") ? "GeoLocate" : "BioGeoMancer"; String toolTip = tool.equalsIgnoreCase("geolocate") ? "WB_DO_GEOLOCATE_LOOKUP" : "WB_DO_BIOGEOMANCER_LOOKUP"; geoRefToolBtn = createIconBtn(iconName, IconManager.IconSize.NonStd, toolTip, false, new ActionListener() { public void actionPerformed(ActionEvent ae) { spreadSheet.clearSorter(); if (tool.equalsIgnoreCase("geolocate")) { doGeoRef(new edu.ku.brc.services.geolocate.prototype.GeoCoordGeoLocateProvider(), "WB.GeoLocateRows"); } else { doGeoRef(new GeoCoordBGMProvider(), "WB.BioGeomancerRows"); } } }); // only enable it if the workbench has the proper columns in it String[] missingColumnsForBG = getMissingButRequiredColumnsForGeoRefTool(tool); if (missingColumnsForBG.length > 0) { geoRefToolBtn.setEnabled(false); String ttText = "<p>" + getResourceString("WB_ADDITIONAL_FIELDS_REQD") + ":<ul>"; for (String reqdField : missingColumnsForBG) { ttText += "<li>" + reqdField + "</li>"; } ttText += "</ul>"; String origTT = geoRefToolBtn.getToolTipText(); geoRefToolBtn.setToolTipText("<html>" + origTT + ttText); } else { geoRefToolBtn.setEnabled(true); } } if (isReadOnly) { convertGeoRefFormatBtn = null; } else { convertGeoRefFormatBtn = createIconBtn("ConvertGeoRef", IconManager.IconSize.NonStd, "WB_CONVERT_GEO_FORMAT", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { showGeoRefConvertDialog(); } }); // now enable/disable the geo ref related buttons String[] missingGeoRefFields = getMissingGeoRefLatLonFields(); if (missingGeoRefFields.length > 0) { convertGeoRefFormatBtn.setEnabled(false); exportKmlBtn.setEnabled(false); //showMapBtn.setEnabled(false); String ttText = "<p>" + getResourceString("WB_ADDITIONAL_FIELDS_REQD") + ":<ul>"; for (String reqdField : missingGeoRefFields) { ttText += "<li>" + reqdField + "</li>"; } ttText += "</ul>"; String origTT1 = convertGeoRefFormatBtn.getToolTipText(); convertGeoRefFormatBtn.setToolTipText("<html>" + origTT1 + ttText); String origTT2 = exportKmlBtn.getToolTipText(); exportKmlBtn.setToolTipText("<html>" + origTT2 + ttText); //String origTT3 = showMapBtn.getToolTipText(); //showMapBtn.setToolTipText("<html>" + origTT3 + ttText); } else { convertGeoRefFormatBtn.setEnabled(true); exportKmlBtn.setEnabled(true); //showMapBtn.setEnabled(true); } } if (AppContextMgr.isSecurityOn() && !task.getPermissions().canModify()) { exportExcelCsvBtn = null; } else { exportExcelCsvBtn = createIconBtn("Export", IconManager.IconSize.NonStd, "WB_EXPORT_DATA", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { doExcelCsvExport(); } }); exportExcelCsvBtn.setEnabled(true); } uploadDatasetBtn = createIconBtn("Upload", IconManager.IconSize.Std24, "WB_UPLOAD_DATA", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { doDatasetUpload(); } }); uploadDatasetBtn.setVisible(isUploadPermitted() && !UIRegistry.isMobile()); uploadDatasetBtn.setEnabled(canUpload()); if (!uploadDatasetBtn.isEnabled()) { uploadDatasetBtn.setToolTipText(getResourceString("WB_UPLOAD_IN_PROGRESS")); } // listen to selection changes to enable/disable certain buttons spreadSheet.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { JStatusBar statusBar = UIRegistry.getStatusBar(); statusBar.setText(""); currentRow = spreadSheet.getSelectedRow(); updateBtnUI(); } } }); for (int c = 0; c < spreadSheet.getTableHeader().getColumnModel().getColumnCount(); c++) { // TableColumn column = // spreadSheet.getTableHeader().getColumnModel().getColumn(spreadSheet.getTableHeader().getColumnModel().getColumnCount()-1); TableColumn column = spreadSheet.getTableHeader().getColumnModel().getColumn(c); column.setCellRenderer(new WbCellRenderer()); } // setup the JFrame to show images attached to WorkbenchRows imageFrame = new ImageFrame(mapSize, this, this.workbench, task, isReadOnly); // setup the JFrame to show images attached to WorkbenchRows imageImportFrame = new ImageImportFrame(this, this.workbench); setupWorkbenchRowChangeListener(); // setup window minimizing/maximizing listener JFrame topFrame = (JFrame) UIRegistry.getTopWindow(); minMaxWindowListener = new WindowAdapter() { @Override public void windowDeiconified(WindowEvent e) { if (imageFrame != null && imageFrame.isVisible()) { imageFrame.setExtendedState(Frame.NORMAL); } if (mapFrame != null && mapFrame.isVisible()) { mapFrame.setExtendedState(Frame.NORMAL); } } @Override public void windowIconified(WindowEvent e) { if (imageFrame != null && imageFrame.isVisible()) { imageFrame.setExtendedState(Frame.ICONIFIED); } if (mapFrame != null && mapFrame.isVisible()) { mapFrame.setExtendedState(Frame.ICONIFIED); } } }; topFrame.addWindowListener(minMaxWindowListener); if (!isReadOnly) { showHideUploadToolBtn = createIconBtn("ValidateWB", IconManager.IconSize.NonStd, "WB_HIDE_UPLOADTOOLPANEL", false, new ActionListener() { public void actionPerformed(ActionEvent ae) { if (uploadToolPanel.isExpanded()) { hideUploadToolPanel(); showHideUploadToolBtn.setToolTipText(getResourceString("WB_SHOW_UPLOADTOOLPANEL")); } else { showUploadToolPanel(); showHideUploadToolBtn.setToolTipText(getResourceString("WB_HIDE_UPLOADTOOLPANEL")); } } }); showHideUploadToolBtn.setEnabled(true); } // setup the mapping features mapFrame = new JFrame(); mapFrame.setIconImage(IconManager.getImage("AppIcon").getImage()); mapFrame.setTitle(getResourceString("WB_GEO_REF_DATA_MAP")); mapImageLabel = createLabel(""); mapImageLabel.setSize(500, 500); mapFrame.add(mapImageLabel); mapFrame.setSize(500, 500); // start putting together the visible UI CellConstraints cc = new CellConstraints(); JComponent[] compsArray = { addRowsBtn, deleteRowsBtn, clearCellsBtn, /*showMapBtn,*/ exportKmlBtn, geoRefToolBtn, convertGeoRefFormatBtn, exportExcelCsvBtn, uploadDatasetBtn, showHideUploadToolBtn }; Vector<JComponent> availableComps = new Vector<JComponent>( compsArray.length + workBenchPluginSSBtns.size()); for (JComponent c : compsArray) { if (c != null) { availableComps.add(c); } } for (JComponent c : workBenchPluginSSBtns) { availableComps.add(c); } PanelBuilder spreadSheetControlBar = new PanelBuilder(new FormLayout( "f:p:g,4px," + createDuplicateJGoodiesDef("p", "4px", availableComps.size()) + ",4px,", "c:p:g")); int x = 3; for (JComponent c : availableComps) { spreadSheetControlBar.add(c, cc.xy(x, 1)); x += 2; } int h = 0; Vector<WorkbenchTemplateMappingItem> headers = new Vector<WorkbenchTemplateMappingItem>(); headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems()); Collections.sort(headers); for (WorkbenchTemplateMappingItem mi : headers) { //using the workbench data model table. Not the actual specify table the column is mapped to. //This MIGHT be less confusing //System.out.println("setting header renderer for " + mi.getTableName() + "." + mi.getFieldName()); spreadSheet.getColumnModel().getColumn(h++) .setHeaderRenderer(new WbTableHeaderRenderer(mi.getTableName())); } // NOTE: This needs to be done after the creation of the saveBtn. And after the creation of the header renderes. initColumnSizes(spreadSheet, saveBtn); // Create the Form Pane -- needs to be done after initColumnSizes - which also sets cell editors for collumns if (task instanceof SGRTask) { formPane = new SGRFormPane(this, workbench, isReadOnly); } else { formPane = new FormPane(this, workbench, isReadOnly); } // This panel contains just the ResultSetContoller, it's needed so the RSC gets centered PanelBuilder rsPanel = new PanelBuilder(new FormLayout("c:p:g", "c:p:g")); FormValidator dummy = new FormValidator(null); dummy.setEnabled(true); resultsetController = new ResultSetController(dummy, !isReadOnly, !isReadOnly, false, getResourceString("Record"), model.getRowCount(), true); resultsetController.addListener(formPane); if (!isReadOnly) { resultsetController.getDelRecBtn().addActionListener(delAction); } // else // { // resultsetController.getDelRecBtn().setVisible(false); // } rsPanel.add(resultsetController.getPanel(), cc.xy(1, 1)); // This panel is a single row containing the ResultSetContoller and the other controls for the Form Panel String colspec = "f:p:g, p, f:p:g, p"; for (int i = 0; i < workBenchPluginFormBtns.size(); i++) { colspec = colspec + ", f:p, p"; } PanelBuilder resultSetPanel = new PanelBuilder(new FormLayout(colspec, "c:p:g")); // Now put the two panel into the single row panel resultSetPanel.add(rsPanel.getPanel(), cc.xy(2, 1)); if (!isReadOnly) { resultSetPanel.add(formPane.getControlPropsBtn(), cc.xy(4, 1)); } int ccx = 6; for (JComponent c : workBenchPluginFormBtns) { resultSetPanel.add(c, cc.xy(ccx, 1)); ccx += 2; } // Create the main panel that uses card layout for the form and spreasheet mainPanel = new JPanel(cardLayout = new CardLayout()); // Add the Form and Spreadsheet to the CardLayout mainPanel.add(spreadSheet.getScrollPane(), PanelType.Spreadsheet.toString()); mainPanel.add(formPane.getPane(), PanelType.Form.toString()); // The controllerPane is a CardLayout that switches between the Spreadsheet control bar and the Form Control Bar controllerPane = new JPanel(cpCardLayout = new CardLayout()); controllerPane.add(spreadSheetControlBar.getPanel(), PanelType.Spreadsheet.toString()); controllerPane.add(resultSetPanel.getPanel(), PanelType.Form.toString()); JLabel sep1 = new JLabel(IconManager.getIcon("Separator")); JLabel sep2 = new JLabel(IconManager.getIcon("Separator")); ssFormSwitcher = createSwitcher(); // This works setLayout(new BorderLayout()); boolean doDnDImages = AppPreferences.getLocalPrefs().getBoolean("WB_DND_IMAGES", false); JComponent[] ctrlCompArray1 = { importImagesBtn, toggleImageFrameBtn, carryForwardBtn, sep1, saveBtn, sep2, ssFormSwitcher }; JComponent[] ctrlCompArray2 = { toggleImageFrameBtn, carryForwardBtn, sep1, saveBtn, sep2, ssFormSwitcher }; JComponent[] ctrlCompArray = doDnDImages ? ctrlCompArray1 : ctrlCompArray2; Vector<Pair<JComponent, Integer>> ctrlComps = new Vector<Pair<JComponent, Integer>>(); for (JComponent c : ctrlCompArray) { ctrlComps.add(new Pair<JComponent, Integer>(c, null)); } String layoutStr = ""; int compCount = 0; int col = 1; int pos = 0; for (Pair<JComponent, Integer> c : ctrlComps) { JComponent comp = c.getFirst(); if (comp != null) { boolean addComp = !(comp == sep1 || comp == sep2) || compCount > 0; if (!addComp) { c.setFirst(null); } else { if (!StringUtils.isEmpty(layoutStr)) { layoutStr += ","; col++; if (pos < ctrlComps.size() - 1) { //this works because we know ssFormSwitcher is last and always non-null. layoutStr += "6px,"; col++; } } c.setSecond(col); if (comp == sep1 || comp == sep2) { layoutStr += "6px"; compCount = 0; } else { layoutStr += "p"; compCount++; } } } pos++; } PanelBuilder ctrlBtns = new PanelBuilder(new FormLayout(layoutStr, "c:p:g")); for (Pair<JComponent, Integer> c : ctrlComps) { if (c.getFirst() != null) { ctrlBtns.add(c.getFirst(), cc.xy(c.getSecond(), 1)); } } add(mainPanel, BorderLayout.CENTER); FormLayout formLayout = new FormLayout("f:p:g,4px,p", "2px,f:p:g,p:g,p:g"); PanelBuilder builder = new PanelBuilder(formLayout); builder.add(controllerPane, cc.xy(1, 2)); builder.add(ctrlBtns.getPanel(), cc.xy(3, 2)); if (!isReadOnly) { uploadToolPanel = new UploadToolPanel(this, UploadToolPanel.EXPANDED); uploadToolPanel.createUI(); // showHideUploadToolBtn = createIconBtn("ValidateWB", IconManager.IconSize.NonStd, "WB_HIDE_UPLOADTOOLPANEL", false, new ActionListener() // { // public void actionPerformed(ActionEvent ae) // { // if (uploadToolPanel.isExpanded()) // { // hideUploadToolPanel(); // showHideUploadToolBtn.setToolTipText(getResourceString("WB_SHOW_UPLOADTOOLPANEL")); // } else // { // showUploadToolPanel(); // showHideUploadToolBtn.setToolTipText(getResourceString("WB_HIDE_UPLOADTOOLPANEL")); // } // } // }); // showHideUploadToolBtn.setEnabled(true); } builder.add(uploadToolPanel, cc.xywh(1, 3, 3, 1)); builder.add(findPanel, cc.xywh(1, 4, 3, 1)); add(builder.getPanel(), BorderLayout.SOUTH); resultsetController.addListener(new ResultSetControllerListener() { public boolean indexAboutToChange(int oldIndex, int newIndex) { return true; } public void indexChanged(int newIndex) { if (imageFrame != null) { if (newIndex > -1) { int index = spreadSheet.convertRowIndexToModel(newIndex); imageFrame.setRow(workbench.getRow(index)); } else { imageFrame.setRow(null); } } } public void newRecordAdded() { // do nothing } }); //compareSchemas(); if (getIncremental() && workbenchValidator == null) { buildValidator(); } // int c = 0; // Vector<WorkbenchTemplateMappingItem> headers = new Vector<WorkbenchTemplateMappingItem>(); // headers.addAll(workbench.getWorkbenchTemplate().getWorkbenchTemplateMappingItems()); // Collections.sort(headers); // for (WorkbenchTemplateMappingItem mi : headers) // { // //using the workbench data model table. Not the actual specify table the column is mapped to. // //This MIGHT be less confusing // //System.out.println("setting header renderer for " + mi.getTableName() + "." + mi.getFieldName()); // spreadSheet.getColumnModel().getColumn(c++).setHeaderRenderer(new WbTableHeaderRenderer(mi.getTableName())); // } // // // NOTE: This needs to be done after the creation of the saveBtn. And after the creation of the header renderes. // initColumnSizes(spreadSheet, saveBtn); // See if we need to make the Image Frame visible // Commenting this out for now because it is so annoying. if (showImageView || hasOneOrMoreImages) { SwingUtilities.invokeLater(new Runnable() { public void run() { toggleImageFrameVisible(); SwingUtilities.invokeLater(new Runnable() { public void run() { final Frame f = (Frame) UIRegistry.get(UIRegistry.FRAME); f.toFront(); f.requestFocus(); } }); } }); } ((WorkbenchTask) ContextMgr.getTaskByClass(WorkbenchTask.class)).opening(this); ((SGRTask) ContextMgr.getTaskByClass(SGRTask.class)).opening(this); }
From source file:io.heming.accountbook.ui.MainFrame.java
private void initMenuBar() { JMenuBar menuBar = new JMenuBar(); // File menu// w w w .j ava 2 s. co m fileMenu = new JMenu("(F)"); fileMenu.setMnemonic('F'); exportMenuItem = new JMenuItem("(B)..."); exportMenuItem.setIcon(new ImageIcon(getClass().getResource("database-save.png"))); exportMenuItem.setMnemonic('B'); exportMenuItem.addActionListener(e -> exportRecords()); fileMenu.add(exportMenuItem); importMenuItem = new JMenuItem("??(R)..."); importMenuItem.setIcon(new ImageIcon(getClass().getResource("document-import-2.png"))); importMenuItem.setMnemonic('R'); importMenuItem.addActionListener(e -> importRecords()); fileMenu.add(importMenuItem); fileMenu.addSeparator(); quitMenuItem = new JMenuItem("(X)"); quitMenuItem.setIcon(new ImageIcon(getClass().getResource("application-exit-2.png"))); quitMenuItem.setMnemonic('X'); quitMenuItem.addActionListener(e -> quit()); fileMenu.add(quitMenuItem); // View menu viewMenu = new JMenu("(V)"); viewMenu.setMnemonic('V'); searchMenuItem = new JMenuItem("?(S)"); searchMenuItem.setIcon(new ImageIcon(getClass().getResource("edit-find-5.png"))); searchMenuItem.setMnemonic('S'); searchMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); searchMenuItem.addActionListener(e -> searchRecords()); viewMenu.add(searchMenuItem); keywordMenuItem = new JMenuItem("(K)"); keywordMenuItem.setIcon(new ImageIcon(getClass().getResource("text-field.png"))); keywordMenuItem.setMnemonic('K'); keywordMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK)); keywordMenuItem.addActionListener(e -> { keywordTextField.requestFocus(); keywordTextField.selectAll(); }); viewMenu.add(keywordMenuItem); viewMenu.addSeparator(); prevPageMenuItem = new JMenuItem("?(P)"); prevPageMenuItem.setIcon(new ImageIcon(getClass().getResource("go-previous-2.png"))); prevPageMenuItem.setMnemonic('P'); prevPageMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK)); prevPageMenuItem.addActionListener(e -> prevPage()); viewMenu.add(prevPageMenuItem); nextPageMenuItem = new JMenuItem("(N)"); nextPageMenuItem.setIcon(new ImageIcon(getClass().getResource("go-next-2.png"))); nextPageMenuItem.setMnemonic('N'); nextPageMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK)); nextPageMenuItem.addActionListener(e -> nextPage()); viewMenu.add(nextPageMenuItem); firstPageMenuItem = new JMenuItem("(F)"); firstPageMenuItem.setIcon(new ImageIcon(getClass().getResource("go-first.png"))); firstPageMenuItem.setMnemonic('F'); firstPageMenuItem .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.SHIFT_MASK + Event.CTRL_MASK)); firstPageMenuItem.addActionListener(e -> firstPage()); viewMenu.add(firstPageMenuItem); lastPageMenuItem = new JMenuItem("(L)"); lastPageMenuItem.setIcon(new ImageIcon(getClass().getResource("go-last.png"))); lastPageMenuItem.setMnemonic('L'); lastPageMenuItem .setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.SHIFT_MASK + Event.CTRL_MASK)); lastPageMenuItem.addActionListener(e -> lastPage()); viewMenu.add(lastPageMenuItem); // Edit menu editMenu = new JMenu("(E)"); editMenu.setMnemonic('E'); addRecordMenuItem = new JMenuItem("(A)..."); addRecordMenuItem.setIcon(new ImageIcon(getClass().getResource("edit-add-3.png"))); addRecordMenuItem.setMnemonic('A'); addRecordMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK)); addRecordMenuItem.addActionListener(e -> showAddRecordDialog()); editMenu.add(addRecordMenuItem); // deleteRecordMenuItem = new JMenuItem("(D)"); // deleteRecordMenuItem.setIcon(new ImageIcon(getClass().getResource("edit-delete-6.png"))); // deleteRecordMenuItem.setMnemonic('D'); // deleteRecordMenuItem.addActionListener(e -> deleteRecord()); // editMenu.add(deleteRecordMenuItem); editMenu.addSeparator(); categoryMenuItem = new JMenuItem("???(T)..."); categoryMenuItem.setIcon(new ImageIcon(getClass().getResource("view-list-icons-2.png"))); categoryMenuItem.setMnemonic('T'); categoryMenuItem.addActionListener(e -> showCategoryDialog()); editMenu.add(categoryMenuItem); // Help menu helpMenu = new JMenu("(H)"); helpMenu.setMnemonic('H'); helpMenuItem = new JMenuItem("(I)"); helpMenuItem.setIcon(new ImageIcon(getClass().getResource("help-2.png"))); helpMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0)); helpMenuItem.setMnemonic('I'); helpMenuItem.addActionListener(e -> help()); helpMenu.add(helpMenuItem); aboutMenuItem = new JMenuItem("(A)"); aboutMenuItem.setIcon(new ImageIcon(getClass().getResource("help-about-2.png"))); aboutMenuItem.setMnemonic('A'); aboutMenuItem.addActionListener(e -> about()); helpMenu.add(aboutMenuItem); // Add menu to menu bar menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(viewMenu); menuBar.add(helpMenu); setJMenuBar(menuBar); }
From source file:com.igormaznitsa.zxpoly.MainForm.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.// w w w. ja v a2s . c om */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; scrollPanel = new javax.swing.JScrollPane(); jSeparator2 = new javax.swing.JSeparator(); panelIndicators = new javax.swing.JPanel(); filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 0)); labelTurbo = new javax.swing.JLabel(); labelMouseUsage = new javax.swing.JLabel(); labelZX128 = new javax.swing.JLabel(); labelTapeUsage = new javax.swing.JLabel(); labelDiskUsage = new javax.swing.JLabel(); menuBar = new javax.swing.JMenuBar(); menuFile = new javax.swing.JMenu(); menuFileLoadSnapshot = new javax.swing.JMenuItem(); menuFileLoadTap = new javax.swing.JMenuItem(); menuLoadDrive = new javax.swing.JMenu(); menuFileSelectDiskA = new javax.swing.JMenuItem(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); menuFileOptions = new javax.swing.JMenuItem(); jSeparator3 = new javax.swing.JPopupMenu.Separator(); menuFileExit = new javax.swing.JMenuItem(); menuTap = new javax.swing.JMenu(); menuTapeRewindToStart = new javax.swing.JMenuItem(); menuTapPrevBlock = new javax.swing.JMenuItem(); menuTapPlay = new javax.swing.JCheckBoxMenuItem(); menuTapNextBlock = new javax.swing.JMenuItem(); menuTapGotoBlock = new javax.swing.JMenuItem(); menuService = new javax.swing.JMenu(); menuFileReset = new javax.swing.JMenuItem(); menuResetKeyboard = new javax.swing.JMenuItem(); menuServiceSaveScreen = new javax.swing.JMenuItem(); menuTapExportAs = new javax.swing.JMenu(); menuTapExportAsWav = new javax.swing.JMenuItem(); menuTracer = new javax.swing.JMenu(); menuTraceCPU0 = new javax.swing.JCheckBoxMenuItem(); menuTraceCPU1 = new javax.swing.JCheckBoxMenuItem(); menuTraceCPU2 = new javax.swing.JCheckBoxMenuItem(); menuTraceCPU3 = new javax.swing.JCheckBoxMenuItem(); menuOptions = new javax.swing.JMenu(); menuOptionsShowIndicators = new javax.swing.JCheckBoxMenuItem(); menuOptionsZX128Mode = new javax.swing.JCheckBoxMenuItem(); menuOptionsTurbo = new javax.swing.JCheckBoxMenuItem(); menuHelp = new javax.swing.JMenu(); menuHelpAbout = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setLocationByPlatform(true); addWindowFocusListener(new java.awt.event.WindowFocusListener() { public void windowGainedFocus(java.awt.event.WindowEvent evt) { formWindowGainedFocus(evt); } public void windowLostFocus(java.awt.event.WindowEvent evt) { formWindowLostFocus(evt); } }); scrollPanel.setViewportView(jSeparator2); getContentPane().add(scrollPanel, java.awt.BorderLayout.CENTER); panelIndicators.setBorder(javax.swing.BorderFactory.createEtchedBorder()); panelIndicators.setLayout(new java.awt.GridBagLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.weightx = 1000.0; panelIndicators.add(filler1, gridBagConstraints); labelTurbo.setText(" "); labelTurbo.setToolTipText("Shows turbo mode on"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 0; panelIndicators.add(labelTurbo, gridBagConstraints); labelMouseUsage.setText(" "); labelMouseUsage.setToolTipText("Indicates kempston mouse activation, ESC - deactivate mouse"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 6; gridBagConstraints.gridy = 0; panelIndicators.add(labelMouseUsage, gridBagConstraints); labelZX128.setText(" "); labelZX128.setToolTipText("Shows that active ZX128 emulation mode"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 7; gridBagConstraints.gridy = 0; panelIndicators.add(labelZX128, gridBagConstraints); labelTapeUsage.setText(" "); labelTapeUsage.setToolTipText("Shows tape activity"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 8; gridBagConstraints.gridy = 0; panelIndicators.add(labelTapeUsage, gridBagConstraints); labelDiskUsage.setText(" "); labelDiskUsage.setToolTipText("Shows disk activity"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 9; gridBagConstraints.gridy = 0; panelIndicators.add(labelDiskUsage, gridBagConstraints); getContentPane().add(panelIndicators, java.awt.BorderLayout.SOUTH); menuFile.setText("File"); menuFileLoadSnapshot.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/snapshot.png"))); // NOI18N menuFileLoadSnapshot.setText("Load Snapshot"); menuFileLoadSnapshot.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuFileLoadSnapshotActionPerformed(evt); } }); menuFile.add(menuFileLoadSnapshot); menuFileLoadTap.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/cassette.png"))); // NOI18N menuFileLoadTap.setText("Load TAPE"); menuFileLoadTap.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuFileLoadTapActionPerformed(evt); } }); menuFile.add(menuFileLoadTap); menuLoadDrive.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/disk.png"))); // NOI18N menuLoadDrive.setText("Load Disk.."); menuFileSelectDiskA.setText("Drive A"); menuFileSelectDiskA.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuFileSelectDiskAActionPerformed(evt); } }); menuLoadDrive.add(menuFileSelectDiskA); jMenuItem1.setText("Drive B"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); menuLoadDrive.add(jMenuItem1); jMenuItem2.setText("Drive C"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); menuLoadDrive.add(jMenuItem2); jMenuItem3.setText("Drive D"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); menuLoadDrive.add(jMenuItem3); menuFile.add(menuLoadDrive); menuFile.add(jSeparator1); menuFileOptions.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/settings.png"))); // NOI18N menuFileOptions.setText("Options"); menuFileOptions.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuFileOptionsActionPerformed(evt); } }); menuFile.add(menuFileOptions); menuFile.add(jSeparator3); menuFileExit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK)); menuFileExit.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/reset.png"))); // NOI18N menuFileExit.setText("Exit"); menuFileExit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuFileExitActionPerformed(evt); } }); menuFile.add(menuFileExit); menuBar.add(menuFile); menuTap.setText("Tape"); menuTapeRewindToStart.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/zxpoly/icons/tape_previous.png"))); // NOI18N menuTapeRewindToStart.setText("Rewind to start"); menuTapeRewindToStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTapeRewindToStartActionPerformed(evt); } }); menuTap.add(menuTapeRewindToStart); menuTapPrevBlock.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/zxpoly/icons/tape_backward.png"))); // NOI18N menuTapPrevBlock.setText("Prev block"); menuTapPrevBlock.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTapPrevBlockActionPerformed(evt); } }); menuTap.add(menuTapPrevBlock); menuTapPlay.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, 0)); menuTapPlay.setText("Play"); menuTapPlay.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/tape_play.png"))); // NOI18N menuTapPlay.setInheritsPopupMenu(true); menuTapPlay.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTapPlayActionPerformed(evt); } }); menuTap.add(menuTapPlay); menuTapNextBlock.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/zxpoly/icons/tape_forward.png"))); // NOI18N menuTapNextBlock.setText("Next block"); menuTapNextBlock.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTapNextBlockActionPerformed(evt); } }); menuTap.add(menuTapNextBlock); menuTapGotoBlock.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/tape_pos.png"))); // NOI18N menuTapGotoBlock.setText("Go to block"); menuTapGotoBlock.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTapGotoBlockActionPerformed(evt); } }); menuTap.add(menuTapGotoBlock); menuBar.add(menuTap); menuService.setText("Service"); menuFileReset.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F12, 0)); menuFileReset.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/reset2.png"))); // NOI18N menuFileReset.setText("Reset"); menuFileReset.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuFileResetActionPerformed(evt); } }); menuService.add(menuFileReset); menuResetKeyboard.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/keyboard.png"))); // NOI18N menuResetKeyboard.setText("Reset keyboard"); menuResetKeyboard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuResetKeyboardActionPerformed(evt); } }); menuService.add(menuResetKeyboard); menuServiceSaveScreen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F8, 0)); menuServiceSaveScreen.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/photo.png"))); // NOI18N menuServiceSaveScreen.setText("Make Screenshot"); menuServiceSaveScreen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuServiceSaveScreenActionPerformed(evt); } }); menuService.add(menuServiceSaveScreen); menuTapExportAs.setIcon(new javax.swing.ImageIcon( getClass().getResource("/com/igormaznitsa/zxpoly/icons/tape_record.png"))); // NOI18N menuTapExportAs.setText("Export TAPE as.."); menuTapExportAsWav.setText("WAV file"); menuTapExportAsWav.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTapExportAsWavActionPerformed(evt); } }); menuTapExportAs.add(menuTapExportAsWav); menuService.add(menuTapExportAs); menuTracer.setText("Trace"); menuTraceCPU0.setText("CPU0"); menuTraceCPU0.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTraceCPU0ActionPerformed(evt); } }); menuTracer.add(menuTraceCPU0); menuTraceCPU1.setText("CPU1"); menuTraceCPU1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTraceCPU1ActionPerformed(evt); } }); menuTracer.add(menuTraceCPU1); menuTraceCPU2.setText("CPU2"); menuTraceCPU2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTraceCPU2ActionPerformed(evt); } }); menuTracer.add(menuTraceCPU2); menuTraceCPU3.setText("CPU3"); menuTraceCPU3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuTraceCPU3ActionPerformed(evt); } }); menuTracer.add(menuTraceCPU3); menuService.add(menuTracer); menuBar.add(menuService); menuOptions.setText("Options"); menuOptionsShowIndicators.setSelected(true); menuOptionsShowIndicators.setText("Indicator panel"); menuOptionsShowIndicators.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/indicator.png"))); // NOI18N menuOptionsShowIndicators.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuOptionsShowIndicatorsActionPerformed(evt); } }); menuOptions.add(menuOptionsShowIndicators); menuOptionsZX128Mode.setSelected(true); menuOptionsZX128Mode.setText("ZX 128 Mode"); menuOptionsZX128Mode.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/zx128.png"))); // NOI18N menuOptionsZX128Mode.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuOptionsZX128ModeActionPerformed(evt); } }); menuOptions.add(menuOptionsZX128Mode); menuOptionsTurbo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0)); menuOptionsTurbo.setSelected(true); menuOptionsTurbo.setText("Turbo"); menuOptionsTurbo.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/turbo.png"))); // NOI18N menuOptionsTurbo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuOptionsTurboActionPerformed(evt); } }); menuOptions.add(menuOptionsTurbo); menuBar.add(menuOptions); menuHelp.setText("Help"); menuHelpAbout.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0)); menuHelpAbout.setIcon( new javax.swing.ImageIcon(getClass().getResource("/com/igormaznitsa/zxpoly/icons/info.png"))); // NOI18N menuHelpAbout.setText("About"); menuHelpAbout.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { menuHelpAboutActionPerformed(evt); } }); menuHelp.add(menuHelpAbout); menuBar.add(menuHelp); setJMenuBar(menuBar); pack(); }