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

📄 getinfoexport.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: GetInfoExport.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.geometry.Poly;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.Variable;import com.sun.electric.tool.Client;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;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 java.awt.Frame;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import javax.swing.JFrame;/** * Class to handle the "Export Get-Info" dialog. */public class GetInfoExport extends EModelessDialog implements HighlightListener, DatabaseChangeListener{	private static GetInfoExport theDialog = null;	private Export shownExport;	private String initialName;	private String initialRefName;	private String initialCharacteristicName;	private boolean initialBodyOnly, initialAlwaysDrawn;    private TextInfoPanel textPanel;	/**	 * Method to show the Export Get-Info dialog.	 */	public static void showDialog()	{        if (Client.getOperatingSystem() == Client.OS.UNIX) {            // JKG 07Apr2006:            // On Linux, if a dialog is built, closed using setVisible(false),            // and then requested again using setVisible(true), it does            // not appear on top. I've tried using toFront(), requestFocus(),            // but none of that works.  Instead, I brute force it and            // rebuild the dialog from scratch each time.            if (theDialog != null) theDialog.dispose();            theDialog = null;        }		if (theDialog == null)		{			JFrame jf = null;            if (TopLevel.isMDIMode()) jf = TopLevel.getCurrentJFrame();            theDialog = new GetInfoExport(jf);		}        theDialog.loadExportInfo();        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;		loadExportInfo();	}    /**     * 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;        loadExportInfo();    }    /**     * Respond to database changes     * @param e database change event     */    public void databaseChanged(DatabaseChangeEvent e) {        if (!isVisible()) return;        // update dialog if we care about the changes		if (e.objectChanged(shownExport))            loadExportInfo();    }	private void loadExportInfo()	{        // update current window        EditWindow curWnd = EditWindow.getCurrent();        if (curWnd == null)        {            disableDialog();            return;        }		// must have a single export selected		Export pp = null;		int exportCount = 0;        for(Highlight2 h : curWnd.getHighlighter().getHighlights())        {            if (!h.isHighlightText()) continue;            if (h.getVarKey() != Export.EXPORT_NAME) continue;            ElectricObject eobj = h.getElectricObject();            if (eobj instanceof Export)            {                pp = (Export)eobj;                exportCount++;            }        }		if (exportCount > 1) pp = null;        boolean enabled = true;        if (pp == null) enabled = false;        EDialog.focusClearOnTextField(theText);        // set enabled state of dialog        theText.setEditable(enabled);        bodyOnly.setEnabled(enabled);        alwaysDrawn.setEnabled(enabled);        characteristics.setEnabled(enabled);        refName.setEditable(enabled);        if (!enabled) {            disableDialog();			return;		}        // set name		initialName = pp.getName();		theText.setText(initialName);		// set location		Poly poly = pp.getOriginalPort().getPoly();		centerLoc.setText("Center: (" + TextUtils.formatDouble(poly.getCenterX()) + "," + TextUtils.formatDouble(poly.getCenterY()) + ")");		// set Body and Always Drawn check boxes		initialBodyOnly = pp.isBodyOnly();		bodyOnly.setSelected(initialBodyOnly);		initialAlwaysDrawn = pp.isAlwaysDrawn();		alwaysDrawn.setSelected(initialAlwaysDrawn);        // set characteristic and reference name		PortCharacteristic initialCharacteristic = pp.getCharacteristic();		initialCharacteristicName = initialCharacteristic.getName();		characteristics.setSelectedItem(initialCharacteristicName);		initialRefName = "";		if (initialCharacteristic == PortCharacteristic.REFBASE ||			initialCharacteristic == PortCharacteristic.REFIN ||			initialCharacteristic == PortCharacteristic.REFOUT)		{			Variable var = pp.getVar(Export.EXPORT_REFERENCE_NAME);			if (var != null)				initialRefName = var.describe(-1);			refName.setEditable(true);		} else		{			refName.setEditable(false);		}		refName.setText(initialRefName);        // set text info panel        textPanel.setTextDescriptor(Export.EXPORT_NAME, pp);		shownExport = pp;        EDialog.focusOnTextField(theText);	}    private void disableDialog() {        shownExport = null;        theText.setText("");        refName.setText("");		centerLoc.setText("");        textPanel.setTextDescriptor(null, null);    }	/** Creates new form Export Get-Info */	private GetInfoExport(Frame parent)	{		super(parent, false);		initComponents();        getRootPane().setDefaultButton(ok);		// make all text fields select-all when entered	    EDialog.makeTextFieldSelectAllOnTab(refName);	    EDialog.makeTextFieldSelectAllOnTab(theText);        // add myself as a listener for highlight changes        UserInterfaceMain.addDatabaseChangeListener(this);        Highlighter.addHighlightListener(this);        // set characteristic combo box		List<PortCharacteristic> chars = PortCharacteristic.getOrderedCharacteristics();		for(PortCharacteristic ch : chars)		{			characteristics.addItem(ch.getName());		}        // add textPanel        textPanel = new TextInfoPanel(false, false);        java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 0;        gridBagConstraints.gridy = 2;        gridBagConstraints.gridwidth = 4;        gridBagConstraints.insets = new java.awt.Insets(2, 4, 2, 4);        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.weightx = 1.0;        getContentPane().add(textPanel, gridBagConstraints);        pack();		loadExportInfo();		finishInitialization();	}	protected void escapePressed() { cancelActionPerformed(null); }	private static class ChangeExport extends Job	{		private Export pp;		private String oldName;		private String newName;		private boolean newBodyOnly, newAlwaysDrawn;		private String newCharName;		private String newRefName;		protected ChangeExport(Export pp,                String oldName,                String newName,                boolean newBodyOnly, boolean newAlwaysDrawn,                String newCharName, String newRefName)		{			super("Modify Export", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.pp = pp;            this.oldName = oldName;			this.newName = newName;            this.newBodyOnly = newBodyOnly;            this.newAlwaysDrawn = newAlwaysDrawn;            this.newCharName = newCharName;            this.newRefName = newRefName;			startJob();		}		public boolean doIt() throws JobException		{		    // change the name			if (!oldName.equals(newName)) pp.rename(newName);			// change the body-only			pp.setBodyOnly(newBodyOnly);			// change always drawn			pp.setAlwaysDrawn(newAlwaysDrawn);

⌨️ 快捷键说明

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