📄 jbrowseoptionpane.java
字号:
/* * JBrowseOptionPane.java - JBrowse options panel * * Copyright (c) 1999 George Latkiewicz (georgel@arvotek.net) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */import javax.swing.*;import javax.swing.border.*;import java.awt.event.*;import java.awt.*;import javax.swing.event.*;import org.jext.gui.*;//=============================================================================public class JBrowseOptionPane extends AbstractOptionPane implements ActionListener{ // protected members /** * The layout manager. */ //protected GridBagLayout gridBag;//it is inherited now! /** * The number of components already added to the layout manager. */ //protected int y;//it is inherited now! // private state boolean isInitGui; boolean isInitModel; // private gui components // general options private JextCheckBox cbxStatusBar;// private JextCheckBox cbxUseFrame; // filter options private JextCheckBox cbxShowAttributes; private JextCheckBox cbxShowPrimitives; private JextCheckBox cbxShowGeneralizations; private JextCheckBox cbxShowThrows; private JComboBox cmbTopLevelVis; private JComboBox cmbMemberVis; private int topLevelVisIndex; private int memberVisIndex; // display options private JextCheckBox cbxShowArguments; private JextCheckBox cbxShowArgumentNames; private JextCheckBox cbxShowNestedName; private JextCheckBox cbxShowIconKeywords; private JextCheckBox cbxShowMiscMod; private JextCheckBox cbxAlphaSort; private JextCheckBox cbxShowLineNum; private JComboBox cmbStyle; private int styleIndex = Options.Display.STYLE_UML; private JextCheckBox cbxVisSymbols; private JextCheckBox cbxAbstractItalic; private JextCheckBox cbxStaticUlined; private JextCheckBox cbxTypeIsSuffixed; // Options object private Options options = new Options(); private Options.Filter filterOpt = options.getFilterOptions(); private Options.Display displayOpt = options.getDisplayOptions(); // Property Accessor private PropertyAccessor props; private boolean batchUpdate = false; //------------------------------------------------------------------------- public JBrowseOptionPane() { /*super(); setName("jbrowse");*/ super("jbrowse"); setLayout(gridBag = new GridBagLayout()); props = new JBrowsePlugin.PropAccessor(); options.load(props); initGui(); // setup display from property values initModel(); // set GUI to model (as defined in Options object) } // public JBrowseOptionPane(): <init> //------------------------------------------------------------------------- public JBrowseOptionPane(String title) { super("jbrowse"); setName(title); setLayout(gridBag = new GridBagLayout()); // It is the instantiating code's responsibility to call: // initGui(), initModel(), and setOptions() before displaying } // public JBrowseOptionPane(String): <init> //------------------------------------------------------------------------- PropertyAccessor getPropertyAccessor() { return props; } //------------------------------------------------------------------------- void setPropertyAccessor(PropertyAccessor props) { this.props = props; } public boolean isInitGui() { return isInitGui; } public boolean isInitModel() { return isInitModel; } //------------------------------------------------------------------------- /** * Update options object to reflect the action by triggering the * appropriate ChangeEvent. */ public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); Object newSource; // General Options if (source == cbxStatusBar) { newSource = options;// } else if (source == cbxUseFrame) {// newSource = options; // Filter Options } else if (source == cbxShowAttributes) { newSource = filterOpt; if(cbxShowAttributes.getModel().isSelected()) { cbxShowPrimitives.getModel().setEnabled(true); } else { cbxShowPrimitives.getModel().setSelected(false); cbxShowPrimitives.getModel().setEnabled(false); } } else if (source == cbxShowPrimitives) { newSource = filterOpt; } else if (source == cbxShowGeneralizations) { newSource = filterOpt; } else if (source == cbxShowThrows) { newSource = filterOpt; } else if (source == cmbTopLevelVis) { newSource = filterOpt; topLevelVisIndex = cmbTopLevelVis.getSelectedIndex(); } else if (source == cmbMemberVis) { newSource = filterOpt; memberVisIndex = cmbMemberVis.getSelectedIndex(); // Display Style Options } else if (source == cmbStyle) { newSource = displayOpt; styleIndex = cmbStyle.getSelectedIndex(); refreshDisplayOptions(styleIndex); } else if (source == cbxShowArguments) { newSource = displayOpt; if(cbxShowArguments.getModel().isSelected()) { cbxShowArgumentNames.getModel().setEnabled(true); } else { cbxShowArgumentNames.getModel().setSelected(false); cbxShowArgumentNames.getModel().setEnabled(false); } } else { // All other (i.e. display) options newSource = displayOpt; } if (!batchUpdate) { // Update Option object to reflect new GUI state. setOptions(); // Forward event, if there is a listener ChangeListener cl = options.getListener(); if (cl != null) { //getParent().setCursor(new Cursor(Cursor.WAIT_CURSOR)); ChangeEvent event = new ChangeEvent(newSource); cl.stateChanged(event); //getParent().setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } } // actionPerformed(ActionEvent): void //------------------------------------------------------------------------- /** * Sets this OptionPane's options object to the state specified by the * the OptionPane's associated PropertyAccessor. */ public void load() { batchUpdate = true; options.load(props); batchUpdate = false; } // load(): void //------------------------------------------------------------------------- /** * Setup the GUI (with no current state). * This should only be called once in the constructor for this * JBrowseOptionPane. */ void initGui() { //------------ // Tile, the Option Panel Label //------------ JLabel titleLabel = new JLabel( props.getProperty("options." + getName() + ".panel_label") + ":", JLabel.LEFT ); titleLabel.setFont(new Font("Helvetica", Font.BOLD + Font.ITALIC, 13)); addComponent(titleLabel); //--------------- // General Options //---------------// OptionPanel generalPanel = new OptionPanel();// TitledBorder generalBorder = new TitledBorder(new BevelBorder(BevelBorder.LOWERED),// " " + props.getProperty("options.jbrowse.generalOptions") + " ",// TitledBorder.CENTER, TitledBorder.TOP);// generalPanel.setBorder(new CompoundBorder(generalBorder, new EmptyBorder(0, 3, 0, 1))); JPanel generalPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 9, 0)); cbxStatusBar = new JextCheckBox( props.getProperty("options.jbrowse.showStatusBar")); generalPanel.add(cbxStatusBar); cbxStatusBar.addActionListener(this);// if ( "jbrowse".equals(getName()) ) {// cbxUseFrame = new JextCheckBox(// props.getProperty("options.jbrowse.useFrame"));// generalPanel.add(cbxUseFrame);// cbxUseFrame.addActionListener(this);// } addComponent(generalPanel); //--------------- // Filter Options //--------------- OptionPanel filterPanel = new OptionPanel(); TitledBorder filterBorder = new TitledBorder(new BevelBorder(BevelBorder.LOWERED), " " + props.getProperty("options.jbrowse.filterOptions") + " ", TitledBorder.CENTER, TitledBorder.TOP); filterPanel.setBorder(new CompoundBorder(filterBorder, new EmptyBorder(0, 3, 1, 1))); /* Attributes */ JPanel attrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); cbxShowAttributes = new JextCheckBox( props.getProperty("options.jbrowse.showAttr") + " "); attrPanel.add(cbxShowAttributes); /* Primitive Attributes */ cbxShowPrimitives = new JextCheckBox( props.getProperty("options.jbrowse.showPrimAttr")); attrPanel.add(cbxShowPrimitives); filterPanel.addComponent(attrPanel); cbxShowAttributes.addActionListener(this); cbxShowPrimitives.addActionListener(this); /* Generalizations */ cbxShowGeneralizations = new JextCheckBox( props.getProperty("options.jbrowse.showGeneralizations") + " "); filterPanel.addComponent(cbxShowGeneralizations); cbxShowGeneralizations.addActionListener(this); /* Throws */ cbxShowThrows = new JextCheckBox( props.getProperty("options.jbrowse.showThrows") + " "); filterPanel.addComponent(cbxShowThrows); cbxShowThrows.addActionListener(this); /* Visibility Level */ JLabel visLevelLabel = new JLabel( props.getProperty("options.jbrowse.visLevelLabel") ); filterPanel.addComponent(visLevelLabel); /* Top-Level Visibility Options */ String[] topLevelVisNames = { "package", "public" }; cmbTopLevelVis = new JComboBox(topLevelVisNames); cmbTopLevelVis.setRenderer(new ModifiedCellRenderer()); filterPanel.addComponent(props.getProperty("options.jbrowse.topLevelVis"), cmbTopLevelVis); cmbTopLevelVis.addActionListener(this); /* Member-Level Visibility Options */ String[] memberVisNames = { "private", "package", "protected", "public" }; cmbMemberVis = new JComboBox(memberVisNames); cmbMemberVis.setRenderer(new ModifiedCellRenderer()); filterPanel.addComponent(props.getProperty("options.jbrowse.memberVis"), cmbMemberVis); cmbMemberVis.addActionListener(this); addComponent(filterPanel); //---------------- // Display Options //---------------- OptionPanel displayPanel = new OptionPanel(); TitledBorder displayBorder = new TitledBorder(new BevelBorder(BevelBorder.LOWERED), " " + props.getProperty("options.jbrowse.displayOptions") + " ", TitledBorder.CENTER, TitledBorder.TOP); displayPanel.setBorder(new CompoundBorder(displayBorder, new EmptyBorder(0, 3, 0, 1)));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -