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

📄 textattributespanel.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: TextAttributesPanel.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.hierarchy.Cell;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.CodeExpression;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.TextDescriptor;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.User;import java.util.Iterator;import javax.swing.JPanel;/** * A Panel to display Code, Units, ShowStyle, and isParameter/isInherits * information about a Variable (or TextDescriptor, if passed Variable is null). */public class TextAttributesPanel extends JPanel{    private static final String displaynone = "None";	private boolean updateChangesInstantly;	private boolean loading = false;    private Variable var;    private TextDescriptor td;    private Variable.Key varKey;    private ElectricObject owner;    private TextDescriptor.Unit initialUnit;    private Object initialDispPos;      // this needs to be an object because one choice, "none" is a string                                        // instead of a TextDescriptor.DispPos    private CodeExpression.Code initialCode;    /**     * Create a Panel for editing attribute specific     * text options of a Variable     */    public TextAttributesPanel(boolean updateChangesInstantly)    {    	this.updateChangesInstantly = updateChangesInstantly;        initComponents();        // add variable code types        for (Iterator<CodeExpression.Code> it = CodeExpression.Code.getCodes(); it.hasNext(); ) {            code.addItem(it.next());        }        // populate units dialog box        for (Iterator<TextDescriptor.Unit> it = TextDescriptor.Unit.getUnits(); it.hasNext(); ) {            units.addItem(it.next());        }        // populate show style dialog box        populateShowComboBox(true);        // default settings        // set code        initialCode = CodeExpression.Code.NONE;        code.setSelectedItem(CodeExpression.Code.NONE);        // set units        initialUnit = TextDescriptor.Unit.NONE;        units.setSelectedItem(initialUnit);        // set show style        initialDispPos = TextDescriptor.DispPos.NAMEVALUE;        show.setSelectedItem(initialDispPos);        // dialog is disabled by default        setVariable(null, null);        // listeners        code.addActionListener(new java.awt.event.ActionListener()        {            public void actionPerformed(java.awt.event.ActionEvent evt) { fieldChanged(); }        });        units.addActionListener(new java.awt.event.ActionListener()        {            public void actionPerformed(java.awt.event.ActionEvent evt) { fieldChanged(); }        });        show.addActionListener(new java.awt.event.ActionListener()        {            public void actionPerformed(java.awt.event.ActionEvent evt) { fieldChanged(); }        });    }	private void fieldChanged()	{		if (!updateChangesInstantly) return;		if (loading) return;		applyChanges();	}    /**     * Set the Variable that can be edited through this Panel.     * <p>if owner.getTextDescriptor(varKey) returns non-null td, display and allow editing of the td text options     * <p>else if varKey is non-null, display and allow editing of default values.     * <p>if varKey is null, the entire Panel is disabled.     * @param varKey the key of a variable to be changed     * @param owner the owner of the variable     */    public synchronized void setVariable(Variable.Key varKey, ElectricObject owner) {        loading = true;		// default information        if (Job.getDebug())        {	        attrInfo1.setText("YOU ARE RUNNING IN DEBUG MODE, SO:");	        attrInfo2.setText("To create a parameter on a cell");        	attrInfo3.setText("its name must start with 'ATTR_'");        } else        {	        attrInfo1.setText("");	        attrInfo2.setText("");	        attrInfo3.setText("");        }		// do not allow empty var names        if (varKey != null) {            if (varKey.getName().trim().equals("")) varKey = null;        }        this.varKey = varKey;        this.owner = owner;        boolean enabled = owner != null && varKey != null;        // update enabled state of everything        // can't just enable all children because objects might be inside JPanel        code.setEnabled(enabled);        units.setEnabled(enabled);        show.setEnabled(enabled);        if (!enabled) return;        // if td is null (implies var is null)        // then use the current panel values to apply to varName.        td = owner.getTextDescriptor(varKey);        if (td == null) return;        var = owner.getParameterOrVariable(varKey);        // otherwise, use td        // set code        initialCode = CodeExpression.Code.NONE;        if (var != null) {            initialCode = var.getCode();            code.setSelectedItem(initialCode);        } else {            // var null, disable code            code.setEnabled(false);        }        // set units        initialUnit = td.getUnit();        units.setSelectedItem(td.getUnit());        // set show style		if (td.isDisplay())			initialDispPos = td.getDispPart();		else			initialDispPos = displaynone;        // show style is none if var non-null and isDisplay is false        if (var != null) {            // make sure "none" is a choice            populateShowComboBox(true);            if (!var.isDisplay()) {                show.setSelectedIndex(0);            } else {                show.setSelectedItem(initialDispPos);                if (!td.isParam()) {                    show.setEnabled(false);                }            }        } else {            populateShowComboBox(false);            show.setSelectedItem(initialDispPos);        }		if (owner instanceof Cell && !td.isInherit())		{	        attrInfo1.setText("NOTE: This cell attribute is NOT");	        attrInfo2.setText("inherited by instances of the cell");		}        loading = false;    }    /**     * Method to modify a TextDescriptor to match the settings in this panel.     * @param td the input TextDescriptor.     * @return the TextDescriptor with code/units/display in this panel.     */    public TextDescriptor withPanelValues(TextDescriptor td)    {        // change the units        TextDescriptor.Unit newUnit = (TextDescriptor.Unit)units.getSelectedItem();        td = td.withUnit(newUnit);        // change the show style        Object newDispObj = show.getSelectedItem();        if (newDispObj == displaynone)        {            td = td.withDisplay(false);        } else        {            td = td.withDisplay(true);        	TextDescriptor.DispPos newDisp = (TextDescriptor.DispPos)newDispObj;            td = td.withDispPart(newDisp);        }		return td;    }    /**     * Method to modify a variable value to match the Code settings in this panel.     * @param value the input value     * @return the value with code in this panel.     */    public Object withPanelCode(Object value)

⌨️ 快捷键说明

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