/** * Returns MenuItem, which is associated with "WATCH" action command. * * @return "WATCH" menu item */ public JCheckBoxMenuItem getWatchMenuItem() { for (Component component : fileMenu.getMenuComponents()) { if (component instanceof JCheckBoxMenuItem && ((JCheckBoxMenuItem) component).getActionCommand().equals(ActionCommands.WATCH.toString())) { return (JCheckBoxMenuItem) component; } } throw new IllegalStateException("StayOpenCheckBoxMenuItem with actionCommand '" + ActionCommands.WATCH + "' not found"); } }
/** * Copies values that are stored in menu items into <code>GCPreferences</code> instance. * * @param gui source to copy values from * @return <code>GCPreferences</code> with current values */ private GCPreferences copyPreferencesFromGui(GCViewerGui gui) { GCPreferences preferences = gui.getPreferences(); for (Entry<String, JCheckBoxMenuItem> menuEntry : ((GCViewerGuiMenuBar)gui.getJMenuBar()).getViewMenuItems().entrySet()) { JCheckBoxMenuItem item = menuEntry.getValue(); preferences.setGcLineProperty(item.getActionCommand(), item.getState()); } preferences.setWindowWidth(gui.getWidth()); preferences.setWindowHeight(gui.getHeight()); preferences.setWindowX(gui.getX()); preferences.setWindowY(gui.getY()); OpenFile openFileAction = (OpenFile)gui.getActionMap().get(ActionCommands.OPEN_FILE.toString()); if (openFileAction.getLastSelectedFiles().length != 0) { preferences.setLastFile(openFileAction.getLastSelectedFiles()[0].getAbsolutePath()); } // recent files List<String> recentFileList = new LinkedList<String>(); for (GCResourceGroup urlSet : ((GCViewerGuiMenuBar) gui.getJMenuBar()).getRecentGCResourcesModel().getResourceNameGroups()) { recentFileList.add(urlSet.getUrlGroupString()); } preferences.setRecentFiles(recentFileList); return preferences; }
public static void setCheckedForAction (JCheckBoxMenuItem _item, String _action, boolean _state) { if(_item==null) return; if(_item.getActionCommand().equals(_action)) _item.setSelected(_state); }
JCheckBoxMenuItem item = menuEntry.getValue(); item.setState(preferences.getGcLineProperty(menuEntry.getKey())); viewMenuActionListener.actionPerformed(new ActionEvent(item, 0, item.getActionCommand()));
private void storePreferences(GCPreferences preferences) { for (Entry<String, JCheckBoxMenuItem> menuEntry : gcLineMenuItems.entrySet()) { JCheckBoxMenuItem item = menuEntry.getValue(); preferences.setGcLineProperty(item.getActionCommand(), item.getState()); } preferences.setWindowWidth(getWidth()); preferences.setWindowHeight(getHeight()); preferences.setWindowX(getX()); preferences.setWindowY(getY()); if (openFileAction.getLastSelectedFiles().length != 0) { preferences.setLastFile(openFileAction.getLastSelectedFiles()[0].getAbsolutePath()); } // recent files List<String> recentFileList = new LinkedList<String>(); for (Component recentMenuItem : recentURLsMenu.getMenuComponents()) { final OpenRecent openRecent = (OpenRecent)((JMenuItem)recentMenuItem).getAction(); final URL[] urls = openRecent.getURLs(); final StringBuffer sb = new StringBuffer(); for (int j=0; j<urls.length; j++) { sb.append(urls[j]); sb.append(';'); } recentFileList.add(sb.toString()); } preferences.setRecentFiles(recentFileList); preferences.store(); }
private void updateViewMenu() { if (viewMenu != null) { Component[] components = viewMenu.getMenuComponents(); for (Component component : components) { if (component instanceof JRadioButtonMenuItem) { JRadioButtonMenuItem mi = (JRadioButtonMenuItem) component; if (((ViewTypeAction) mi.getAction()).viewType == viewType) { mi.setSelected(true); } } else if (component instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem mi = (JCheckBoxMenuItem) component; if (mi.getActionCommand().equals(ACTION_VIEW_HIDDEN)) mi.setSelected(getFileChooser().isFileHidingEnabled()); } } } }
if (c instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem item = (JCheckBoxMenuItem) c; String cmd = item.getActionCommand(); if (cmd.equals("resize")) { item.setSelected(activeViewer.isRelayoutOnResize()); if (c instanceof JCheckBoxMenuItem) { JCheckBoxMenuItem item = (JCheckBoxMenuItem) c; String cmd = item.getActionCommand(); if (cmd.equals("satellite")) { item.setSelected(ViewMenuAction.isSatelliteShown());