📄 getinfonode.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: GetInfoNode.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.geometry.Orientation;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.network.Netlist;import com.sun.electric.database.network.Network;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.Connection;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.Variable;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.PrimitiveNodeSize;import com.sun.electric.technology.Technology;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.technology.technologies.Schematics;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.tecEdit.Manipulate;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.Frame;import java.awt.GridBagConstraints;import java.awt.Insets;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.ListSelectionModel;import javax.swing.SwingUtilities;import javax.swing.UIManager;/** * Class to handle the "Node Properties" dialog. */public class GetInfoNode extends EModelessDialog implements HighlightListener, DatabaseChangeListener{ private static GetInfoNode theDialog = null; private NodeInst shownNode = null; private PortProto shownPort = null; private double initialXPos, initialYPos; private String initialXSize, initialYSize; private boolean initialMirrorX, initialMirrorY; private int initialRotation, initialPopupIndex; private boolean initialEasyToSelect, initialInvisibleOutsideCell, initialLocked, initialExpansion; private String initialName, initialTextField; private String initialPopupEntry; private DefaultListModel listModel; private JList list; private List<AttributesTable.AttValPair> allAttributes; private List<ArcInst> portObjects; private boolean bigger; private boolean scalableTrans; private boolean swapXY; private AttributesTable attributesTable; private EditWindow wnd; private static Preferences prefs = Preferences.userNodeForPackage(GetInfoNode.class); /** * Method to show the Node Properties 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 GetInfoNode(jf); } theDialog.loadInfo(); if (!theDialog.isVisible()) { theDialog.pack(); theDialog.ensureProperSize(); theDialog.setVisible(true); theDialog.name.requestFocus(); } 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; // update dialog if we care about the changes if (e.objectChanged(shownNode) || shownPort instanceof Export && e.objectChanged((Export)shownPort)) { loadInfo(); } } /** Creates new form Node Properties */ private GetInfoNode(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(rotation); EDialog.makeTextFieldSelectAllOnTab(textField); EDialog.makeTextFieldSelectAllOnTab(xPos); EDialog.makeTextFieldSelectAllOnTab(xSize); EDialog.makeTextFieldSelectAllOnTab(yPos); EDialog.makeTextFieldSelectAllOnTab(ySize); // make type a selectable but not editable field type.setEditable(false); type.setBorder(null); type.setForeground(UIManager.getColor("Label.foreground")); type.setFont(UIManager.getFont("Label.font")); bigger = prefs.getBoolean("GetInfoNode-bigger", false); int buttonSelected = prefs.getInt("GetInfoNode-buttonSelected", 0); // start small if (bigger == false) { getContentPane().remove(moreStuffTop); getContentPane().remove(listPane); getContentPane().remove(moreStuffBottom); more.setText("More"); pack(); } else { more.setText("Less"); } // make the list listModel = new DefaultListModel(); list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listPane.setViewportView(list); allAttributes = new ArrayList<AttributesTable.AttValPair>(); portObjects = new ArrayList<ArcInst>(); attributesTable = new AttributesTable(null, true, false, false); switch (buttonSelected) { case 0: ports.setSelected(true); break; case 1: attributes.setSelected(true); break; case 2: busMembers.setSelected(true); break; } 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; // must have a single node selected NodeInst ni = null; PortProto pp = null; int nodeCount = 0; if (wnd != null) { for(Highlight2 h : wnd.getHighlighter().getHighlights()) { if (!h.isHighlightEOBJ()) continue; ElectricObject eobj = h.getElectricObject(); if (eobj instanceof PortInst) { pp = ((PortInst)eobj).getPortProto(); eobj = ((PortInst)eobj).getNodeInst(); } if (eobj instanceof NodeInst) { ni = (NodeInst)eobj; nodeCount++; } } } showAllButton.setEnabled(false); if (nodeCount > 1) ni = null; if (ni == null) { if (shownNode != null) { // no node selected, disable the dialog type.setText(""); name.setEditable(false); name.setText(""); xSize.setEditable(false); xSize.setText(""); ySize.setEditable(false); ySize.setText(""); xPos.setEditable(false); xPos.setText(""); yPos.setEditable(false); yPos.setText(""); rotation.setEditable(false); rotation.setText(""); mirrorX.setEnabled(false); mirrorX.setSelected(false); mirrorY.setEnabled(false); mirrorY.setSelected(false); apply.setEnabled(false); // in "more" version expanded.setEnabled(false); unexpanded.setEnabled(false); easyToSelect.setEnabled(false); easyToSelect.setSelected(false); invisibleOutsideCell.setEnabled(false); invisibleOutsideCell.setSelected(false); textFieldLabel.setText(""); textField.setText(""); textField.setEditable(false); popupLabel.setText(""); popup.removeAllItems(); popup.setEnabled(false); ports.setEnabled(false); attributes.setEnabled(false); attributesTable.setElectricObject(null); attributesTable.setEnabled(false); busMembers.setEnabled(false); listPane.setEnabled(false); listModel.clear(); locked.setEnabled(false); locked.setSelected(false); see.setEnabled(false); editParameters.setEnabled(false); colorAndPattern.setEnabled(false); shownNode = null; shownPort = null; } return; } shownNode = ni; shownPort = pp; EDialog.focusClearOnTextField(name); // in small version NodeProto np = ni.getProto(); name.setEditable(true); boolean sizeEditable = true; xPos.setEditable(true); yPos.setEditable(true); rotation.setEditable(true); mirrorX.setEnabled(true); mirrorY.setEnabled(true); apply.setEnabled(true); initialName = ni.getName(); initialXPos = ni.getAnchorCenterX(); initialYPos = ni.getAnchorCenterY();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -