⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 optionsdialog.java

📁 java写的多功能文件编辑器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }  }  private OptionTreeModel createOptionTreeModel()  {    OptionTreeModel paneTreeModel = new OptionTreeModel();    OptionGroup rootGroup = (OptionGroup) paneTreeModel.getRoot();    //Either isLoadingCore or isLoadingPlugs must be true in order to make addOptionPane work.    isLoadingCore = true;    jextGroup = new OptionGroup("jext");    addOptionPane(new GeneralOptions(),      jextGroup);    addOptionPane(new LoadingOptions(),      jextGroup);    addOptionPane(new UIOptions(),           jextGroup);    addOptionPane(new EditorOptions(),       jextGroup);    addOptionPane(new PrintOptions(),        jextGroup);    addOptionPane(new GutterOptions(),       jextGroup);    addOptionPane(new StylesOptions(),       jextGroup);    //addOptionPane(new KeywordsOptions(),     jextGroup);    addOptionPane(new KeyShortcutsOptions(), jextGroup);    addOptionPane(new FileFiltersOptions(),  jextGroup);    addOptionPane(new LangOptions(),         jextGroup);    addOptionPane(new SecurityOptions(),     jextGroup);    addOptionGroup(jextGroup, rootGroup);    isLoadingCore = false;    // initialize the Plugins branch of the options tree    pluginsGroup = new OptionGroup("plugins");    // Query plugins for option panes    Plugin[] plugins = Jext.getPlugins();    isLoadingPlugs = true;//so the added panes are tracked to know what ones must be rebuilt and what ones must be reloaded.    for(int i = 0; i < plugins.length; i++)    {      currPlugin = plugins[i];      try {        currPlugin.createOptionPanes(this);      } catch(AbstractMethodError ame) {//This is when a plugin does not extends        //AbstractOptionPane but implements directly the interface OptionPane, which has now new        //methods        ame.printStackTrace();        Utilities.showError("The option pane of the plugin containing " + plugins[i].getClass().toString() +        " is not supported, and you will not see it in the option dialog. This is related to new Jext " +        "release(from 3.2pre3). You should make aware of this Romain Guy, the plugin's author or " +        "Blaisorblade <blaisorblade_work (at) yahoo.it, who will provide an upgraded version " +        "of the plugin.Thanks");        //I hope this will never happen, but it has happened with the Java plugin(JBrowse option pane).      } catch(Throwable t)  {        t.printStackTrace();      }    }    isLoadingPlugs = false;    // only add the Plugins branch if there are OptionPanes    if (pluginsGroup.getMemberCount() > 0)    {      addOptionGroup(pluginsGroup, rootGroup);    }    return paneTreeModel;  }  public void valueChanged(TreeSelectionEvent evt)  {    TreePath path = evt.getPath();    if (path == null || !(path.getLastPathComponent() instanceof OptionPane))      return;    Object[] nodes = path.getPath();    StringBuffer buf = new StringBuffer();    currPaneName = null;    int lastIdx = nodes.length - 1;    for (int i = paneTree.isRootVisible() ? 0 : 1; i <= lastIdx; i++)    {      if (nodes[i] instanceof OptionPane)      {        currPaneName = ((OptionPane)nodes[i]).getName();      } else if (nodes[i] instanceof OptionGroup) {        currPaneName = ((OptionGroup)nodes[i]).getName();      } else {        continue;      }      if (currPaneName != null)      {        String label = Jext.getProperty("options." + currPaneName + ".label");        if (label == null)        {          buf.append(currPaneName);        } else {          buf.append(label);        }      }      if (i != lastIdx) buf.append(": ");    }    currentLabel.setText(buf.toString());    ((CardLayout) cardPanel.getLayout()).show(cardPanel, currPaneName);  }  class MouseHandler extends MouseAdapter  {    public void mouseClicked(MouseEvent evt)    {      TreePath path = paneTree.getPathForLocation(evt.getX(), evt.getY());      if (path == null) return;      Object node = path.getLastPathComponent();      if (node instanceof OptionGroup)      {        if (paneTree.isCollapsed(path))        {          paneTree.expandPath(path);        } else {          paneTree.collapsePath(path);        }      }    }  }  class PaneNameRenderer extends JLabel implements TreeCellRenderer  {    private Border noFocusBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);    private Border focusBorder = BorderFactory.createLineBorder(UIManager.getColor("Tree.selectionBorderColor"));    private Font paneFont;    private Font groupFont;    public PaneNameRenderer()    {      setOpaque(true);      paneFont = UIManager.getFont("Tree.font");      groupFont = new Font(paneFont.getName(), paneFont.getStyle() | Font.BOLD,                           paneFont.getSize());    }    public Component getTreeCellRendererComponent(JTree tree, Object value,                                                  boolean selected, boolean expanded,                                                  boolean leaf, int row, boolean hasFocus)    {      if (selected)      {        this.setBackground(UIManager.getColor("Tree.selectionBackground"));        this.setForeground(UIManager.getColor("Tree.selectionForeground"));      } else {        this.setBackground(tree.getBackground());        this.setForeground(tree.getForeground());      }      String name = null;      if (value instanceof OptionGroup)      {        name = ((OptionGroup) value).getName();        this.setFont(groupFont);      } else if (value instanceof OptionPane) {        name = ((OptionPane) value).getName();        this.setFont(paneFont);      }      if (name == null)      {        setText(null);      } else {        String label = Jext.getProperty("options." + name + ".label");        if (label == null)        {          setText(name);        } else {          setText(label);        }      }      setBorder(hasFocus ? focusBorder : noFocusBorder);      return this;    }  }  class OptionTreeModel implements TreeModel  {    private OptionGroup root = new OptionGroup("root");    private EventListenerList listenerList = new EventListenerList();    public void addTreeModelListener(TreeModelListener l)    {      listenerList.add(TreeModelListener.class, l);    }    public void removeTreeModelListener(TreeModelListener l)    {      listenerList.remove(TreeModelListener.class, l);    }    public Object getChild(Object parent, int index)    {      if (parent instanceof OptionGroup)      {        return ((OptionGroup)parent).getMember(index);      } else {        return null;      }    }    public int getChildCount(Object parent)    {      if (parent instanceof OptionGroup)      {        return ((OptionGroup)parent).getMemberCount();      } else {        return 0;      }    }    public int getIndexOfChild(Object parent, Object child)    {      if (parent instanceof OptionGroup)      {        return ((OptionGroup) parent).getMemberIndex(child);      } else {        return -1;      }    }    public Object getRoot()    {      return root;    }    public boolean isLeaf(Object node)    {      return node instanceof OptionPane;    }    public void valueForPathChanged(TreePath path, Object newValue)    {      // this model may not be changed by the TableCellEditor    }    protected void fireNodesChanged(Object source, Object[] path,                                    int[] childIndices, Object[] children)    {      Object[] listeners = listenerList.getListenerList();      TreeModelEvent modelEvent = null;      for (int i = listeners.length - 2; i >= 0; i -= 2)      {        if (listeners[i] != TreeModelListener.class)          continue;        if (modelEvent == null)        {          modelEvent = new TreeModelEvent(source, path, childIndices, children);        }        ((TreeModelListener) listeners[i + 1]).treeNodesChanged(modelEvent);      }    }    protected void fireNodesInserted(Object source, Object[] path,                                     int[] childIndices, Object[] children)    {      Object[] listeners = listenerList.getListenerList();      TreeModelEvent modelEvent = null;      for (int i = listeners.length - 2; i >= 0; i -= 2)      {        if (listeners[i] != TreeModelListener.class)          continue;        if (modelEvent == null)        {          modelEvent = new TreeModelEvent(source, path, childIndices, children);        }        ((TreeModelListener)listeners[i + 1]).treeNodesInserted(modelEvent);      }    }    protected void fireNodesRemoved(Object source, Object[] path,                                    int[] childIndices, Object[] children)    {      Object[] listeners = listenerList.getListenerList();      TreeModelEvent modelEvent = null;      for (int i = listeners.length - 2; i >= 0; i -= 2)      {        if (listeners[i] != TreeModelListener.class)          continue;        if (modelEvent == null)        {          modelEvent = new TreeModelEvent(source, path, childIndices, children);        }        ((TreeModelListener) listeners[i + 1]).treeNodesRemoved(modelEvent);      }    }    protected void fireTreeStructureChanged(Object source, Object[] path,                                            int[] childIndices, Object[] children)    {      Object[] listeners = listenerList.getListenerList();      TreeModelEvent modelEvent = null;      for (int i = listeners.length - 2; i >= 0; i -= 2)      {        if (listeners[i] != TreeModelListener.class)          continue;        if (modelEvent == null)        {          modelEvent = new TreeModelEvent(source, path, childIndices, children);        }        ((TreeModelListener) listeners[i + 1]).treeStructureChanged(modelEvent);      }    }  }}// End of OptionsDialog.java

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -