📄 elanframe2.java
字号:
// Mac L&F menuMacNativeLF = new JCheckBoxMenuItem(); menuMacNativeLF.setText("Use Mac Look And Feel"); menuMacNativeLF.setActionCommand("MacNativeLF"); menuMacNativeLF.addActionListener(this); Boolean macNativePref = (Boolean) Preferences.get("UseMacLF", null); menuOptions.add(menuMacNativeLF); if ((macNativePref != null) && !macNativePref.booleanValue()) { menuMacNativeLF.setState(false); try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(this); } catch (Exception e) { e.printStackTrace(); } } else { menuMacNativeLF.setState(true); } // use reflection to make this compile on all systems try { Class macHandler = Class.forName( "mpi.eudico.client.mac.MacAppHandler"); Class macList = Class.forName( "mpi.eudico.client.mac.MacApplicationListener"); java.lang.reflect.Constructor con = macHandler.getConstructor(new Class[] { macList }); con.newInstance(new Object[] { this }); } catch (Exception ex) { System.out.println("Could not load Mac application handler."); } } updateLocale(); } /** * DOCUMENT ME! * * @param e DOCUMENT ME! */ public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("DiscoverDoc")) { if (elanP2P != null) { Command c = ELANCommandFactory.createCommand(null, ELANCommandFactory.DISCOVER_DOC); c.execute(elanP2P, new Object[] { this }); } } else if (command.equals("PublishDoc")) { if (elanP2P != null) { Command c = ELANCommandFactory.createCommand(null, ELANCommandFactory.PUBLISH_DOC); c.execute(elanP2P, new Object[] { this, transcriptionForThisFrame }); } } else if (command.equals("Use Native Media Platform")) { boolean useNativeMedia = menuItemNativeMedia.getState(); if (useNativeMedia) { System.out.println( "Setting preferred media framework to Native"); System.setProperty("PreferredMediaFramework", "NativeWindows"); } else { System.out.println("Setting preferred media framework to JMF"); System.setProperty("PreferredMediaFramework", "JMF"); } } else if (command.equals("Use detached media window")) { Preferences.set("PreferredMediaWindow", new Boolean(menuItemPermanentDetached.getState()), null); } else if (command.equals("MacNativeLF")) { switchMacLF(); } } private void initMenusAndCommands() { // instantiate CommandActions, also UndoCA and RedoCA /* sample: CommandAction playSelectionCA = ELANCommandFactory.getCommandAction(ELANCommandFactory.PLAY_SELECTION); */ // instantiate JMenuItems, where possible with CommandActions as args for constructor /* sample: playSelectionItem = new JMenuItem(playSelectionCA); playSelectionItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK)); menuInvisible.add(playSelectionItem); // add to menu, if only for button then to invisible menu */ // add actions with accelerator keys and without a menu item to the input // and action map InputMap inputMap = menuBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = menuBar.getActionMap(); if (inputMap instanceof ComponentInputMap && (actionMap != null)) { Action[] invActions = new Action[] { ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PLAY_PAUSE), //ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.NEW_ANNOTATION), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.GO_TO_BEGIN), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.GO_TO_END), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.SECOND_LEFT), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.SECOND_RIGHT), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PLAY_SELECTION), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PLAY_AROUND_SELECTION), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PREVIOUS_ANNOTATION), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.NEXT_ANNOTATION), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.ANNOTATION_UP), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.ANNOTATION_DOWN), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PREVIOUS_SCROLLVIEW), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.NEXT_SCROLLVIEW), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PREVIOUS_FRAME), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.NEXT_FRAME), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PIXEL_LEFT), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PIXEL_RIGHT), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.CLEAR_SELECTION), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.SELECTION_BOUNDARY), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.SELECTION_MODE), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.LOOP_MODE), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.MODIFY_ANNOTATION_TIME), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PLAYBACK_RATE_TOGGLE), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PLAYBACK_VOLUME_TOGGLE), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.NEXT_ACTIVE_TIER), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.PREVIOUS_ACTIVE_TIER), //,ELANCommandFactory.getCommandAction(transcriptionForThisFrame, // ELANCommandFactory.STRUCTURED_SEARCH_MULTIPLE_DLG), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.NEW_ANNOTATION_ALT), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.MODIFY_ANNOTATION_ALT), ELANCommandFactory.getCommandAction(transcriptionForThisFrame, ELANCommandFactory.DELETE_ANNOTATION_ALT), new NextWindowMA("Menu.Window.Next"), new PrevWindowMA("Menu.Window.Previous") }; String id = "Act-"; String nextId; for (int i = 0; i < invActions.length; i++) { nextId = id + i; inputMap.put((KeyStroke) invActions[i].getValue( Action.ACCELERATOR_KEY), nextId); actionMap.put(nextId, invActions[i]); registeredActions.put(nextId, invActions[i]); } } MenuAction ma; menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.CLOSE)), 3); menuFile.insertSeparator(4); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.SAVE)), 5); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.SAVE_AS)), 6); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.SAVE_AS_TEMPLATE)), 7); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.SAVE_SELECTION_AS_EAF)), 8); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.MERGE_TRANSCRIPTIONS)), 9); ma = new MenuAction("Menu.File.Backup.Auto"); menuActions.add(ma); menuBackup = new JMenu(ma); menuFile.add(menuBackup, 10); ButtonGroup backupGroup = new ButtonGroup(); // retrieve the stored value for backup interval Integer buDelay = (Integer) Preferences.get("BackUpDelay", null); JRadioButtonMenuItem neverMI = new JRadioButtonMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.BACKUP_NEVER)); if ((buDelay == null) || ((buDelay != null) && (buDelay.compareTo(Constants.BACKUP_NEVER) == 0))) { neverMI.setSelected(true); } JRadioButtonMenuItem backup1MI = new JRadioButtonMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.BACKUP_1)); if ((buDelay != null) && (buDelay.compareTo(Constants.BACKUP_1) == 0)) { backup1MI.setSelected(true); } JRadioButtonMenuItem backup5MI = new JRadioButtonMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.BACKUP_5)); if ((buDelay != null) && (buDelay.compareTo(Constants.BACKUP_5) == 0)) { backup5MI.setSelected(true); } JRadioButtonMenuItem backup10MI = new JRadioButtonMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.BACKUP_10)); if ((buDelay != null) && (buDelay.compareTo(Constants.BACKUP_10) == 0)) { backup10MI.setSelected(true); } JRadioButtonMenuItem backup20MI = new JRadioButtonMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.BACKUP_20)); if ((buDelay != null) && (buDelay.compareTo(Constants.BACKUP_20) == 0)) { backup20MI.setSelected(true); } JRadioButtonMenuItem backup30MI = new JRadioButtonMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.BACKUP_30)); if ((buDelay != null) && (buDelay.compareTo(Constants.BACKUP_30) == 0)) { backup30MI.setSelected(true); } backupGroup.add(neverMI); backupGroup.add(backup1MI); backupGroup.add(backup5MI); backupGroup.add(backup10MI); backupGroup.add(backup20MI); backupGroup.add(backup30MI); menuBackup.add(neverMI); menuBackup.add(backup1MI); menuBackup.add(backup5MI); menuBackup.add(backup10MI); menuBackup.add(backup20MI); menuBackup.add(backup30MI); menuFile.insertSeparator(11); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.PAGESETUP)), 12); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.PREVIEW)), 13); menuFile.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.PRINT)), 14); ma = new MenuAction("Menu.File.Export"); menuActions.add(ma); menuExport = new JMenu(ma); menuFile.add(menuExport, 16); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_SHOEBOX))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_CHAT))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_TAB))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_TIGER))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_INTERLINEAR))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_HTML))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_TRAD_TRANSCRIPT))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_SMIL))); menuExport.add(new ElanMenuItem(ELANCommandFactory.getCommandAction( transcriptionForThisFrame, ELANCommandFactory.EXPORT_QT_SUB)));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -