📄 jbrowseoptionpane.java
字号:
/* Arguments */ JPanel argPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); cbxShowArguments = new JextCheckBox( props.getProperty("options.jbrowse.showArgs") + " "); argPanel.add(cbxShowArguments); cbxShowArguments.addActionListener(this); /* Argument Names */ cbxShowArgumentNames = new JextCheckBox( props.getProperty("options.jbrowse.showArgNames")); argPanel.add(cbxShowArgumentNames); displayPanel.addComponent(argPanel); cbxShowArgumentNames.addActionListener(this); /* qualify nested class/interface names */ cbxShowNestedName = new JextCheckBox( props.getProperty("options.jbrowse.showNestedName")); displayPanel.addComponent(cbxShowNestedName); cbxShowNestedName.addActionListener(this); /* class/interface modifiers */ cbxShowIconKeywords = new JextCheckBox( props.getProperty("options.jbrowse.showIconKeywords")); displayPanel.addComponent(cbxShowIconKeywords); cbxShowIconKeywords.addActionListener(this); /* misc. detail modifiers */ cbxShowMiscMod = new JextCheckBox( props.getProperty("options.jbrowse.showMiscMod")); displayPanel.addComponent(cbxShowMiscMod); cbxShowMiscMod.addActionListener(this); /* Alpha Sort Methods */ cbxAlphaSort = new JextCheckBox( props.getProperty("options.jbrowse.alphaSort")); displayPanel.addComponent(cbxAlphaSort); cbxAlphaSort.addActionListener(this); /* Line Numbers */ cbxShowLineNum = new JextCheckBox( props.getProperty("options.jbrowse.showLineNums")); displayPanel.addComponent(cbxShowLineNum); cbxShowLineNum.addActionListener(this); /* Display Style */ String[] styleNames = { props.getProperty("options.jbrowse.umlStyle"), props.getProperty("options.jbrowse.javaStyle"), props.getProperty("options.jbrowse.customStyle") }; cmbStyle = new JComboBox(styleNames); cmbStyle.setRenderer(new ModifiedCellRenderer()); cmbStyle.addActionListener(this); displayPanel.addComponent(props.getProperty("options.jbrowse.displayStyle"), cmbStyle); /* Custom Display Style Options */ JLabel customOptionsLabel = new JLabel( props.getProperty("options.jbrowse.customOptions")); displayPanel.addComponent(customOptionsLabel); cbxVisSymbols = new JextCheckBox( props.getProperty("options.jbrowse.custVisAsSymbol")); cbxAbstractItalic = new JextCheckBox( props.getProperty("options.jbrowse.custAbsAsItalic")); cbxStaticUlined = new JextCheckBox( props.getProperty("options.jbrowse.custStaAsUlined")); cbxTypeIsSuffixed = new JextCheckBox( props.getProperty("options.jbrowse.custTypeIsSuffixed")); cbxVisSymbols.addActionListener(this); cbxAbstractItalic.addActionListener(this); cbxStaticUlined.addActionListener(this); cbxTypeIsSuffixed.addActionListener(this); displayPanel.addComponent(cbxVisSymbols); displayPanel.addComponent(cbxAbstractItalic); displayPanel.addComponent(cbxStaticUlined); displayPanel.addComponent(cbxTypeIsSuffixed); addComponent(displayPanel); isInitGui = true; } // initGui(): void //------------------------------------------------------------------------- /** * This method sets the GUI representation of the model to the state * specified by the current option object's state. */ public void initModel() { batchUpdate = true; // General Options cbxStatusBar.getModel().setSelected( options.getShowStatusBar() );// cbxUseFrame.getModel().setSelected( options.getUseFrame() ); // Filter Options cbxShowAttributes.getModel().setSelected( filterOpt.getShowAttributes() ); cbxShowPrimitives.getModel().setSelected( filterOpt.getShowPrimitives() ); cbxShowGeneralizations.getModel().setSelected( filterOpt.getShowGeneralizations() ); cbxShowThrows.getModel().setSelected( filterOpt.getShowThrows() ); cmbTopLevelVis.setSelectedIndex( filterOpt.getTopLevelVisIndex() ); cmbMemberVis.setSelectedIndex( filterOpt.getMemberVisIndex() ); // Display Options cbxShowArguments.getModel().setSelected( displayOpt.getShowArguments() ); cbxShowArgumentNames.getModel().setSelected( displayOpt.getShowArgumentNames() ); cbxShowNestedName.getModel().setSelected( displayOpt.getShowNestedName() ); cbxShowIconKeywords.getModel().setSelected( displayOpt.getShowIconKeywords() ); cbxShowMiscMod.getModel().setSelected( displayOpt.getShowMiscMod() ); cbxAlphaSort.getModel().setSelected( displayOpt.getAlphaSort() ); cbxShowLineNum.getModel().setSelected( displayOpt.getShowLineNum() ); cmbStyle.setSelectedIndex(displayOpt.getStyleIndex() ); cbxVisSymbols.getModel().setSelected( displayOpt.getVisSymbols() ); cbxAbstractItalic.getModel().setSelected( displayOpt.getAbstractItalic() ); cbxStaticUlined.getModel().setSelected( displayOpt.getStaticUlined() ); cbxTypeIsSuffixed.getModel().setSelected( displayOpt.getTypeIsSuffixed() ); // Set enabled/disabled on showArgumentNames, showPrimitives checkboxes if(cbxShowArguments.getModel().isSelected()) { cbxShowArgumentNames.getModel().setEnabled(true); } else { cbxShowArgumentNames.getModel().setSelected(false); cbxShowArgumentNames.getModel().setEnabled(false); } if(cbxShowAttributes.getModel().isSelected()) { cbxShowPrimitives.getModel().setEnabled(true); } else { cbxShowPrimitives.getModel().setSelected(false); cbxShowPrimitives.getModel().setEnabled(false); } refreshDisplayOptions(styleIndex); isInitModel = true; batchUpdate = false; } // initModel(): void //------------------------------------------------------------------------- /** * The method called by the File->Plugin Options save button for * setting the JBrowse plugin options for all future sessions. * It saves the current view state to the associated property values. */ public void save() { options.save(props); } // save(): void //------------------------------------------------------------------------- /** * Set the enabled and selected/index state of all the display options * that are dependant on the cmbStyle control. The state to be set to * is determined by the passed styleIndex value. This method is called * on init() and upon each change to the sytleIndex via its associated * cmbStyle JComboBox. */ private void refreshDisplayOptions(int styleIndex) { if (styleIndex == Options.Display.STYLE_UML) { // UML cbxVisSymbols.getModel().setSelected(true); cbxAbstractItalic.getModel().setSelected(true); cbxStaticUlined.getModel().setSelected(true); cbxTypeIsSuffixed.getModel().setSelected(true); cbxVisSymbols.getModel().setEnabled(false); cbxAbstractItalic.getModel().setEnabled(false); cbxStaticUlined.getModel().setEnabled(false); cbxTypeIsSuffixed.getModel().setEnabled(false); } else if (styleIndex == Options.Display.STYLE_JAVA) { // Java cbxVisSymbols.getModel().setSelected(false); cbxAbstractItalic.getModel().setSelected(false); cbxStaticUlined.getModel().setSelected(false); cbxTypeIsSuffixed.getModel().setSelected(false); cbxVisSymbols.getModel().setEnabled(false); cbxAbstractItalic.getModel().setEnabled(false); cbxStaticUlined.getModel().setEnabled(false); cbxTypeIsSuffixed.getModel().setEnabled(false); } else if (styleIndex == Options.Display.STYLE_CUSTOM) { // Custom cbxVisSymbols.getModel().setEnabled(true); cbxAbstractItalic.getModel().setEnabled(true); cbxStaticUlined.getModel().setEnabled(true); cbxTypeIsSuffixed.getModel().setEnabled(true); } else { // error, unknown style index } } // refreshDisplayOptions(int index): void public Options getOptions() { return options; } //------------------------------------------------------------------------- /** * The method that sets the option object's state to reflect the values * specified by the current state of the JBrowseOptionPane. */ public void setOptions() { // General Options options.setShowStatusBar( cbxStatusBar.getModel().isSelected() );// options.setUseFrame( cbxUseFrame.getModel().isSelected() ); // Filter Options filterOpt.setShowAttributes( cbxShowAttributes.getModel().isSelected() ); filterOpt.setShowPrimitives( cbxShowPrimitives.getModel().isSelected() ); filterOpt.setShowGeneralizations( cbxShowGeneralizations.getModel().isSelected() ); filterOpt.setShowThrows( cbxShowThrows.getModel().isSelected() ); filterOpt.setTopLevelVisIndex( topLevelVisIndex ); filterOpt.setMemberVisIndex( memberVisIndex ); // Display Options displayOpt.setShowArguments( cbxShowArguments.getModel().isSelected() ); displayOpt.setShowArgumentNames( cbxShowArgumentNames.getModel().isSelected() ); displayOpt.setShowNestedName( cbxShowNestedName.getModel().isSelected() ); displayOpt.setShowIconKeywords( cbxShowIconKeywords.getModel().isSelected() ); displayOpt.setShowMiscMod( cbxShowMiscMod.getModel().isSelected() ); displayOpt.setAlphaSort( cbxAlphaSort.getModel().isSelected() ); displayOpt.setShowLineNum( cbxShowLineNum.getModel().isSelected() ); displayOpt.setStyleIndex( styleIndex ); displayOpt.setVisSymbols( cbxVisSymbols.getModel().isSelected() ); displayOpt.setAbstractItalic( cbxAbstractItalic.getModel().isSelected() ); displayOpt.setStaticUlined( cbxStaticUlined.getModel().isSelected() ); displayOpt.setTypeIsSuffixed( cbxTypeIsSuffixed.getModel().isSelected() ); } // setOptions(): void //------------------------------------------------------------------------- protected void addComponent(Component comp) { GridBagConstraints cons = new GridBagConstraints(); cons.gridy = y++; cons.gridheight = 1; cons.gridwidth = cons.REMAINDER; cons.fill = GridBagConstraints.HORIZONTAL; cons.anchor = GridBagConstraints.CENTER; cons.weightx = 1.0f; gridBag.setConstraints(comp,cons); add(comp); } // addComponent(Component): void //========================================================================= /** * This class is used to for panels that require a gridBag layout for * placement into (for example) an OptionPane. */ static class OptionPanel extends JPanel { /** * Creates a new option pane. * @param name The internal name */ public OptionPanel() { setLayout(gridBag = new GridBagLayout()); } // protected members /** * The layout manager. */ protected GridBagLayout gridBag; /** * The number of components already added to the layout manager. */ protected int y; /** * Adds a labeled component to the option pane. * @param label The label * @param comp The component */ protected void addComponent(String label, Component comp) { GridBagConstraints cons = new GridBagConstraints(); cons.gridy = y++; cons.gridheight = 1; cons.gridwidth = 3; cons.fill = GridBagConstraints.BOTH; cons.weightx = 1.0f; cons.gridx = 0; JLabel l = new JLabel(label,SwingConstants.RIGHT); gridBag.setConstraints(l,cons); add(l); cons.gridx = 3; cons.gridwidth = 1; gridBag.setConstraints(comp,cons); add(comp); } /** * Adds a component to the option pane. * @param comp The component */ protected void addComponent(Component comp) { GridBagConstraints cons = new GridBagConstraints(); cons.gridy = y++; cons.gridheight = 1; cons.gridwidth = cons.REMAINDER; cons.fill = GridBagConstraints.HORIZONTAL; cons.anchor = GridBagConstraints.WEST; cons.weightx = 1.0f; gridBag.setConstraints(comp,cons); add(comp); } } // static class OptionPanel extends JPanel} // public class JBrowseOptionPane extends JPanel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -