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

📄 attributes.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: Attributes.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.Export;import com.sun.electric.database.hierarchy.Cell.CellGroup;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.VarContext;import com.sun.electric.database.variable.Variable;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.user.CircuitChangeJobs;import com.sun.electric.tool.user.Highlight2;import com.sun.electric.tool.user.HighlightListener;import com.sun.electric.tool.user.Highlighter;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.UserInterfaceMain;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.TopLevel;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.Component;import java.awt.Frame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.awt.geom.Point2D;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;import javax.swing.DefaultListModel;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JOptionPane;import javax.swing.JRadioButton;import javax.swing.ListCellRenderer;import javax.swing.ListSelectionModel;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;/** * Class to handle the "Attributes" dialog. */public class Attributes extends EModelessDialog implements HighlightListener, DatabaseChangeListener{    private static Attributes theDialog = null;    private DefaultListModel listModel;    private JList list;    private ElectricObject selectedObject;    private Cell selectedCell;    private NodeInst selectedNode;    private ArcInst selectedArc;    private Export selectedExport;    private PortInst selectedPort;    private Variable.Key selectedVarKey;    private JRadioButton currentButton;    private String initialName;    private String initialValue;	private boolean showParamsOnly = !Job.getDebug();    private TextAttributesPanel attrPanel;    private TextInfoPanel textPanel;    private VariableCellRenderer cellRenderer;    private boolean loading = false;    /**     * Method to show the Attributes dialog.     */    public static void showDialog()    {        if (theDialog == null)        {        	JFrame jf = null;            if (TopLevel.isMDIMode()) jf = TopLevel.getCurrentJFrame();            theDialog = new Attributes(jf);        }        theDialog.loadAttributesInfo(false);        if (!theDialog.isVisible())		{        	theDialog.pack();        	theDialog.ensureProperSize();    		theDialog.setVisible(true);		}		theDialog.toFront();   }    /**     * Reloads the dialog when Highlights change     */    public void highlightChanged(Highlighter which)    {        if (!isVisible()) return;        loadAttributesInfo(false);    }    /**     * Called when by a Highlighter when it loses focus. The argument     * is the Highlighter that has gained focus (may be null).     * @param highlighterGainedFocus the highlighter for the current window (may be null).     */    public void highlighterLostFocus(Highlighter highlighterGainedFocus) {        if (!isVisible()) return;        loadAttributesInfo(false);    }    /**     * Reload if the database has changed in a way we care about     * @param e database change event     */    public void databaseChanged(DatabaseChangeEvent e) {        if (!isVisible()) return;		// update dialog		if (e.objectChanged(selectedObject))		{            loadAttributesInfo(true);		}    }    /**     * Creates new form Attributes.     */    private Attributes(Frame parent)    {        super(parent, false);        initComponents();        if (showParamsOnly) {            getContentPane().remove(debugSelect);            mainLabel.setText("Parameters:");            setTitle("Edit Parameters");            pack();        } else {            mainLabel.setText("Parameters and Variables (Debug Mode):");            setTitle("Edit Parameters and Variables");        }        UserInterfaceMain.addDatabaseChangeListener(this);        Highlighter.addHighlightListener(this);        // make the list        listModel = new DefaultListModel();        list = new JList(listModel);        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);        cellRenderer = new VariableCellRenderer();        list.setCellRenderer(cellRenderer);        listPane.setViewportView(list);        list.addMouseListener(new MouseAdapter()		{            public void mouseClicked(MouseEvent evt) { listClick(); }        });        // have the radio buttons at the top reevaluate        currentCell.addActionListener(new ActionListener()		{            public void actionPerformed(ActionEvent evt) { objectSelectorActionPerformed(evt); }        });        currentNode.addActionListener(new ActionListener()		{            public void actionPerformed(ActionEvent evt) { objectSelectorActionPerformed(evt); }        });        currentArc.addActionListener(new ActionListener()		{            public void actionPerformed(ActionEvent evt) { objectSelectorActionPerformed(evt); }        });        currentExport.addActionListener(new ActionListener()		{            public void actionPerformed(ActionEvent evt) { objectSelectorActionPerformed(evt); }        });        currentPort.addActionListener(new ActionListener()		{            public void actionPerformed(ActionEvent evt) { objectSelectorActionPerformed(evt); }        });        currentPort.setEnabled(false);        java.awt.GridBagConstraints gridBagConstraints;        attrPanel = new TextAttributesPanel(true);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 4;        gridBagConstraints.gridwidth = 5;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        getContentPane().add(attrPanel, gridBagConstraints);        textPanel = new TextInfoPanel(true, showParamsOnly);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 5;        gridBagConstraints.gridwidth = 5;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        getContentPane().add(textPanel, gridBagConstraints);        pack();        loadAttributesInfo(false);        name.getDocument().addDocumentListener(new TextInfoDocumentListener(this));        value.getDocument().addDocumentListener(new TextInfoDocumentListener(this));        finishInitialization();    }	protected void escapePressed() { done(null); }	/**	 * Class to handle special changes to changes to a Attributes edit fields.	 */	private static class TextInfoDocumentListener implements DocumentListener	{		Attributes dialog;		TextInfoDocumentListener(Attributes dialog) { this.dialog = dialog; }		public void changedUpdate(DocumentEvent e) { dialog.fieldChanged(); }		public void insertUpdate(DocumentEvent e) { dialog.fieldChanged(); }		public void removeUpdate(DocumentEvent e) { dialog.fieldChanged(); }	}	private void fieldChanged()	{		if (loading) return;        Variable var = getSelectedVariable();        if (var == null) return;        // see if value changed        String varValue = value.getText().trim();        if (!varValue.equals(initialValue))        {            // generate Job to update value            new ChangeAttribute(var.getKey(), selectedObject, getVariableObject(varValue));            initialValue = varValue;        }	}    /**     * Method called when the user clicks on one of the top radio buttons.     * Changes the object being examined for attributes.     */    private void objectSelectorActionPerformed(ActionEvent evt)    {        currentButton = (JRadioButton)evt.getSource();        if (currentButton == currentCell) selectedObject = selectedCell;        else if (currentButton == currentNode) selectedObject = selectedNode;        else if (currentButton == currentArc) selectedObject = selectedArc;        else if (currentButton == currentExport) selectedObject = selectedExport;        else if (currentButton == currentPort) selectedObject = selectedPort;        updateList();        checkName();    }    /**     * Method called when the user clicks in the list of attribute names.     */    private void listClick()    {        showSelectedAttribute(null);    }    /**     * Method to reload the entire dialog from the current highlighting.     */    private void loadAttributesInfo(boolean keepObj)    {    	loading = true;    	if (!keepObj)    	{	        // determine what attributes can be set	        selectedObject = null;	        selectedCell = null;	        selectedNode = null;	        selectedArc = null;	        selectedExport = null;	        selectedPort = null;	        selectedVarKey = null;	        currentButton = currentCell;	        // update current window	        EditWindow curWnd = EditWindow.getCurrent();	        selectedCell = WindowFrame.needCurCell();   selectedObject = selectedCell;	        if (curWnd == null) selectedCell = null;	        if (selectedCell != null)	        {                if (showParamsOnly) {                    if (!selectedCell.isIcon() && !selectedCell.isSchematic()) {                        selectedCell = null;                    } else {                        mainLabel.setText("Parameters on " + selectedCell.getName() + ":");                    }                }                else if (curWnd.getHighlighter().getNumHighlights() == 1)	            {	                Highlight2 high = curWnd.getHighlighter().getHighlights().iterator().next();	                ElectricObject eobj = high.getElectricObject();

⌨️ 快捷键说明

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