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

📄 editkeybindings.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: EditKeyBindings.java * * Copyright (c) 2003 Sun Microsystems and Static Free Software * * Electric(tm) 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 3 of the License, or * (at your option) any later version. * * Electric(tm) 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 Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.user.dialogs;import com.sun.electric.tool.user.dialogs.options.PreferencePanel;import com.sun.electric.tool.user.menus.EMenu;import com.sun.electric.tool.user.menus.EMenuBar;import com.sun.electric.tool.user.menus.EMenuItem;import com.sun.electric.tool.user.ui.KeyBindings;import com.sun.electric.tool.user.ui.KeyStrokePair;import com.sun.electric.tool.user.ui.TopLevel;import java.util.ArrayList;import java.util.Iterator;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.event.TreeSelectionListener;import javax.swing.tree.DefaultMutableTreeNode;import javax.swing.tree.DefaultTreeModel;import javax.swing.tree.TreePath;import javax.swing.tree.TreeSelectionModel;/** * Class to manage bindings of keystrokes to pulldown menus. */public class EditKeyBindings extends PreferencePanel implements TreeSelectionListener {        /** MenuBarGroup for building dialog tree */            EMenuBar menuBar;        /** class to encapsulate a tree node for displaying key bindings.     * The toString() method is overridden to show the key binding next to the     * command name.  This class encapsulates both JMenuItem and Menu, note     * that both extend JMenuItem.     */    private class KeyBoundTreeNode    {        private EMenuItem menuItem;        KeyBoundTreeNode(EMenuItem menuItem) {            this.menuItem = menuItem;        }                public EMenuItem getMenuItem() { return menuItem; }                /**          * Convert to String to show on dialog tree         */        public String toString() {            if (menuItem != EMenuItem.SEPARATOR) {                StringBuffer buf = new StringBuffer(menuItem.getDescription());                KeyBindings bindings = menuBar.getKeyBindings(menuItem);                if (bindings == null) return buf.toString();                Iterator it = bindings.getKeyStrokePairs();                if (!it.hasNext()) return buf.toString();                buf.append("   [ "+bindings.bindingsToString()+" ]");                return buf.toString();            }            return "---------------";               // separator        }    }    /** Creates new form EditKeyBindings */    public EditKeyBindings(EMenuBar menuBar, java.awt.Frame parent, boolean modal) {		super(parent, modal);        this.menuBar = menuBar;        initComponents();        buildCommandsTree();    }    // -------------------------- Preference Panel Stuff -----------------------    public JPanel getPanel() {        return editKeyBindingsPanel;    }    public String getName() { return "Key Bindings"; }	/**	 * Method called when the factory reset is requested for just this panel.	 * @return true if the panel can be reset "in place" without redisplay.	 */	public boolean resetThis()	{        menuBar.resetAllKeyBindings();        // update tree view        DefaultTreeModel model = (DefaultTreeModel)commandsTree.getModel();        model.reload();        EMenuItem item = getSelectedMenuItem();        updateListBox(item);		return true;	}	public void reset()    {        menuBar.resetAllKeyBindings();    }    // -------------------------------------------------------------------------    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        java.awt.GridBagConstraints gridBagConstraints;        editKeyBindingsPanel = new javax.swing.JPanel();        jPanel1 = new javax.swing.JPanel();        jScrollPane1 = new javax.swing.JScrollPane();        commandsTree = new javax.swing.JTree();        jPanel2 = new javax.swing.JPanel();        add = new javax.swing.JButton();        remove = new javax.swing.JButton();        resetitem = new javax.swing.JButton();        jPanel4 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        bindingsJList = new javax.swing.JList();        getContentPane().setLayout(new java.awt.GridBagLayout());        setTitle("Edit Key Bindings");        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                exitForm(evt);            }        });        editKeyBindingsPanel.setLayout(new java.awt.GridBagLayout());        jPanel1.setLayout(new java.awt.GridLayout(1, 0));        jPanel1.setPreferredSize(new java.awt.Dimension(350, 363));        jScrollPane1.setViewportView(commandsTree);        jPanel1.add(jScrollPane1);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 0;        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;        gridBagConstraints.weightx = 1.0;        gridBagConstraints.weighty = 1.0;        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);        editKeyBindingsPanel.add(jPanel1, gridBagConstraints);        jPanel2.setLayout(new java.awt.GridBagLayout());        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());        add.setText("Add");        add.setToolTipText("add a shortcut");        add.setPreferredSize(new java.awt.Dimension(68, 28));        add.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                addActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 0;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;        gridBagConstraints.insets = new java.awt.Insets(2, 4, 2, 4);        jPanel2.add(add, gridBagConstraints);        remove.setText("Remove");        remove.setToolTipText("remove a shortcut");        remove.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                removeActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 1;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;        gridBagConstraints.insets = new java.awt.Insets(2, 4, 2, 4);        jPanel2.add(remove, gridBagConstraints);        resetitem.setText("Reset");        resetitem.setToolTipText("reset to default setting");        resetitem.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                resetitemActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 2;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;        gridBagConstraints.insets = new java.awt.Insets(2, 4, 2, 4);        jPanel2.add(resetitem, gridBagConstraints);        jPanel4.setLayout(new java.awt.GridBagLayout());        jLabel1.setText("Shortcuts:");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        jPanel4.add(jLabel1, gridBagConstraints);        bindingsJList.setBorder(javax.swing.BorderFactory.createEtchedBorder());

⌨️ 快捷键说明

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