getinfoarc.java
来自「The ElectricTM VLSI Design System is an 」· Java 代码 · 共 1,374 行 · 第 1/4 页
JAVA
1,374 行
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: GetInfoArc.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.DBMath;import com.sun.electric.database.network.Netlist;import com.sun.electric.database.network.Network;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.Name;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.variable.ElectricObject;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.PrimitivePort;import com.sun.electric.technology.technologies.Artwork;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.awt.geom.Point2D;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.prefs.Preferences;import javax.swing.DefaultListModel;import javax.swing.JFrame;import javax.swing.JList;import javax.swing.SwingUtilities;/** * Class to handle the "Arc Get-Info" dialog. */public class GetInfoArc extends EModelessDialog implements HighlightListener, DatabaseChangeListener{ private static GetInfoArc theDialog = null; private static ArcInst shownArc = null; private static Preferences prefs = Preferences.userNodeForPackage(GetInfoArc.class); private String initialName; private double initialWidth; private boolean initialEasyToSelect; private boolean initialRigid, initialFixedAngle, initialSlidable; private int initialExtension, initialDirectional, initialNegated; private EditWindow wnd; private AttributesTable attributesTable; private JList busMembersList; private DefaultListModel busMembersModel; private List<AttributesTable.AttValPair> allAttributes; /** true if need to reload info due to failure to get Examine lock on DB */ private boolean needReload = false; private boolean bigger; /** * Method to show the Arc 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 GetInfoArc(jf); } theDialog.loadInfo(); 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; loadInfo(); } /** * 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; loadInfo(); } /** * Respond to database changes * @param e database change event */ public void databaseChanged(DatabaseChangeEvent e) { if (!isVisible()) return; // check if we need to reload because we couldn't // load before because a Change Job was running if (needReload) { needReload = false; loadInfo(); return; } // update dialog if we care about the changes if (e.objectChanged(shownArc)) loadInfo(); }// /**// * Respond to database changes// * @param batch a batch of changes completed// */// public void databaseEndChangeBatch(Undo.ChangeBatch batch) {// if (!isVisible()) return;// // check if we need to reload because we couldn't// // load before because a Change Job was running// if (needReload) {// needReload = false;// loadInfo();// return;// }// // check if we care about the changes// boolean reload = false;// for (Iterator it = batch.getChanges(); it.hasNext(); ) {// Undo.Change change = it.next();// ElectricObject obj = change.getObject();// if (obj == shownArc) {// reload = true;// break;// }// }// if (reload) {// // update dialog// loadInfo();// }// }// /** Don't do anything on little database changes, only after all database changes */// public void databaseChanged(Undo.Change change) {}// /** This is a GUI listener */// public boolean isGUIListener() { return true; } /** Creates new form Arc Get-Info */ private GetInfoArc(Frame parent) { super(parent, false); initComponents(); getRootPane().setDefaultButton(ok); UserInterfaceMain.addDatabaseChangeListener(this); Highlighter.addHighlightListener(this); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(name); EDialog.makeTextFieldSelectAllOnTab(width); bigger = prefs.getBoolean("GetInfoArc-bigger", false); // start small if (!bigger) { getContentPane().remove(jPanel2); getContentPane().remove(jPanel3); getContentPane().remove(attributesPane); moreLess.setText("More"); pack(); } else { moreLess.setText("Less"); } // initialize the state bit popups negation.addItem("None"); negation.addItem("Head"); negation.addItem("Tail"); negation.addItem("Both"); extension.addItem("Both ends"); extension.addItem("Neither end"); extension.addItem("Head only"); extension.addItem("Tail only"); directionality.addItem("None"); directionality.addItem("Head and Body"); directionality.addItem("Tail and Body"); directionality.addItem("Body only"); directionality.addItem("Head/Tail/Body"); // make the attributes list allAttributes = new ArrayList<AttributesTable.AttValPair>(); attributesTable = new AttributesTable(null, true, false, false); attributesPane.setViewportView(attributesTable); // make list of bus members busMembersModel = new DefaultListModel(); busMembersList = new JList(busMembersModel); finishInitialization(); } protected void escapePressed() { cancelActionPerformed(null); } protected void loadInfo() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { public void run() { doLoadInfo(); } }); return; } doLoadInfo(); } private void doLoadInfo() { // update current window EditWindow curWnd = EditWindow.getCurrent(); if (curWnd != null) wnd = curWnd; if (wnd == null) { disableDialog(); return; } // must have a single node selected ArcInst ai = null; int arcCount = 0; for(Highlight2 h : wnd.getHighlighter().getHighlights()) { if (h.isHighlightEOBJ()) { ElectricObject eobj = h.getElectricObject(); if (eobj instanceof ArcInst) { ai = (ArcInst)eobj; arcCount++; } } } if (arcCount > 1) ai = null; if (ai == null) { if (shownArc != null) disableDialog(); return; } // try to get Examine lock. If fails, set needReload to true to // call loadInfo again when database is done changing if (!Job.acquireExamineLock(false)) { needReload = true; disableDialog(); return; } // else: lock acquired try { EDialog.focusClearOnTextField(name); // enable it name.setEditable(true); width.setEditable(true); easyToSelect.setEnabled(true); rigid.setEnabled(true); fixedAngle.setEnabled(true); slidable.setEnabled(true); directionality.setEnabled(true); extension.setEnabled(true); PortProto headPort = ai.getHeadPortInst().getPortProto(); PortProto tailPort = ai.getTailPortInst().getPortProto(); if (headPort instanceof PrimitivePort && ((PrimitivePort)headPort).isNegatable() || tailPort instanceof PrimitivePort && ((PrimitivePort)tailPort).isNegatable()) negation.setEnabled(true); else negation.setEnabled(false); headSee.setEnabled(true); tailSee.setEnabled(true); apply.setEnabled(true); nameProperties.setEnabled(true); seeAttributes.setEnabled(true); seeBusMembers.setEnabled(true); // get initial values initialName = ai.getName(); initialWidth = ai.getLambdaBaseWidth(); initialEasyToSelect = !ai.isHardSelect(); initialRigid = ai.isRigid(); initialFixedAngle = ai.isFixedAngle(); initialSlidable = ai.isSlidable(); initialNegated = 0; if (ai.isHeadNegated()) { if (ai.isTailNegated()) initialNegated = 3; else initialNegated = 1; } else if (ai.isTailNegated()) initialNegated = 2;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?