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

📄 cellbrowser.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: CellBrowser.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.database.change.DatabaseChangeEvent;import com.sun.electric.database.change.DatabaseChangeListener;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.hierarchy.View;import com.sun.electric.database.text.TextUtils;import com.sun.electric.tool.user.CellChangeJobs;import com.sun.electric.tool.user.CircuitChanges;import com.sun.electric.tool.user.UserInterfaceMain;import com.sun.electric.tool.user.menus.CellMenu;import com.sun.electric.tool.user.ui.PaletteFrame;import com.sun.electric.tool.user.ui.TopLevel;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.Frame;import java.awt.GridBagConstraints;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.util.ArrayList;import java.util.Collections;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;import java.util.prefs.Preferences;import java.util.regex.Matcher;import java.util.regex.Pattern;import javax.swing.JCheckBox;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JTextField;import javax.swing.ListSelectionModel;/** * Class to browse the list of cells and do specific things to them (delete, rename). * * <p>The CellBrowser is a general purpose browser that can browse * by Library, View, and Cell.  It can filter Cell names using a regular * expression. * <p>The DoAction class is checked to adjust several configurable features: * <p>- What action to perform * <p>- What buttons are available * <p>- What additional JComponents are included * <p>- If the Cell List is multi- or single-select. */public class CellBrowser extends EDialog implements DatabaseChangeListener {    private static Preferences prefs = Preferences.userNodeForPackage(CellBrowser.class);    private static final String prefFilter = "CellBrowser-Filter";    private static final String prefSelectedLib = "CellBrowser-SelectedLib";    private static final String prefSelectedView = "CellBrowser-SelectedView";    private static final String prefSelectedCell = "CellBrowser-SelectedCell";    private static final String prefEditInNewWindow = "CellBrowser-EditInNewWindow";    private static final String prefSortLexically = "CellBrowser-SortLexically";    private String lastSelectedLib = null;    private String lastSelectedView = null;    private String lastSelectedCell = null;    private String lastFilter = "";    private static Pattern lastPattern = null;    private static boolean confirmDelete = true;	private boolean cancelled;    private DoAction action;    private List<Cell> cellList = null;                       // list of cells displayed    private List<String> cellListNames = null;                  // list of cells by name displayed (matches cellList)	/**	 * Class to do a cell browser action.	 */    public static class DoAction {		public String title;        public String name;        private DoAction(String name, String title) {            this.name = name;            this.title = title;        }        public String toString() { return name; }        public static final DoAction newInstance = new DoAction("New Cell Instance", "Create a Cell Instance");        public static final DoAction editCell = new DoAction("Edit Cell", "Edit a Cell");        public static final DoAction renameCell = new DoAction("Rename Cell", "Rename Cells");        public static final DoAction duplicateCell = new DoAction("Duplicate Cell", "Duplicate a Cell");        public static final DoAction deleteCell = new DoAction("Delete Cell", "Delete Cells");        public static final DoAction selectCellToAssoc = new DoAction("Select Cell", "Which Cell is Associated with this Data?");        public static final DoAction selectCellToCopy = new DoAction("Select Cell", "Copy Parameters from which Cell?");    }    /** Creates new form CellBrowser */    public CellBrowser(Frame parent, boolean modal, DoAction action) {        super(parent, modal);        this.action = action;		cancelled = false;        initComponents();                       // init components (netbeans generated method)        setTitle(action.title);                  // set the dialog title        doAction.setText(action.name);          // set the action button's text        getRootPane().setDefaultButton(doAction); // return will do action        lastFilter = prefs.get(action+prefFilter, "");        lastPattern = Pattern.compile(lastFilter);        lastSelectedCell = prefs.get(action+prefSelectedCell, null);        cellFilter.setText(lastFilter);         // restore last filter        initExtras();                           // set up an extra components        initComboBoxes();                       // set up the combo boxes        UserInterfaceMain.addDatabaseChangeListener(this);		finishInitialization();        pack();    }    public void databaseChanged(DatabaseChangeEvent e) {        if (!isVisible()) return;        // would take too long to search for change we care about, just reload it        updateCellList();    }//     public void databaseEndChangeBatch(Undo.ChangeBatch batch) {//         if (!isVisible()) return;//         // would take too long to search for change we care about, just reload it//         updateCellList();//     }//     public void databaseChanged(Undo.Change evt) {}//     public boolean isGUIListener() { return true; }    	protected void escapePressed() { cancelActionPerformed(null); }    /** 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.     */    private void initComponents() {//GEN-BEGIN:initComponents        java.awt.GridBagConstraints gridBagConstraints;        jLabel1 = new javax.swing.JLabel();        libraryComboBox = new javax.swing.JComboBox();        jLabel2 = new javax.swing.JLabel();        viewComboBox = new javax.swing.JComboBox();        jLabel3 = new javax.swing.JLabel();        cellFilter = new javax.swing.JTextField();        jSeparator1 = new javax.swing.JSeparator();        jPanel1 = new javax.swing.JPanel();        cancel = new javax.swing.JButton();        doAction = new javax.swing.JButton();        done = new javax.swing.JButton();        jScrollPane1 = new javax.swing.JScrollPane();        jList1 = new javax.swing.JList();        extrasPanel = new javax.swing.JPanel();        getContentPane().setLayout(new java.awt.GridBagLayout());        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                closeDialog(evt);            }        });        jLabel1.setText("Library:");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);        getContentPane().add(jLabel1, gridBagConstraints);        libraryComboBox.setFont(new java.awt.Font("Dialog", 0, 12));        libraryComboBox.setMinimumSize(new java.awt.Dimension(32, 20));        libraryComboBox.setPreferredSize(new java.awt.Dimension(32, 20));        libraryComboBox.addItemListener(new java.awt.event.ItemListener() {            public void itemStateChanged(java.awt.event.ItemEvent evt) {                libraryComboBoxItemStateChanged(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);        getContentPane().add(libraryComboBox, gridBagConstraints);        jLabel2.setText("View:");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 1;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4);        getContentPane().add(jLabel2, gridBagConstraints);        viewComboBox.setFont(new java.awt.Font("Dialog", 0, 12));        viewComboBox.setMinimumSize(new java.awt.Dimension(32, 20));        viewComboBox.setPreferredSize(new java.awt.Dimension(32, 20));        viewComboBox.addItemListener(new java.awt.event.ItemListener() {            public void itemStateChanged(java.awt.event.ItemEvent evt) {                viewComboBoxItemStateChanged(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 1;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);        getContentPane().add(viewComboBox, gridBagConstraints);        jLabel3.setText("Filter:");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 2;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(7, 4, 7, 4);        getContentPane().add(jLabel3, gridBagConstraints);        cellFilter.addKeyListener(new java.awt.event.KeyAdapter() {            public void keyReleased(java.awt.event.KeyEvent evt) {                cellFilterKeyReleased(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridy = 2;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);        getContentPane().add(cellFilter, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 3;        gridBagConstraints.gridwidth = 2;        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;        gridBagConstraints.insets = new java.awt.Insets(6, 6, 6, 6);        getContentPane().add(jSeparator1, gridBagConstraints);        jPanel1.setLayout(new java.awt.GridBagLayout());        cancel.setText("Cancel");        cancel.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                cancelActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.weightx = 1.0;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        jPanel1.add(cancel, gridBagConstraints);        doAction.setText("doAction");        doAction.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                doActionActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.weightx = 1.0;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        jPanel1.add(doAction, gridBagConstraints);        done.setText("Done");

⌨️ 快捷键说明

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