📄 userinterfacemain.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: UserInterfaceMain.java * * Copyright (c) 2005 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;import com.sun.electric.database.Snapshot;import com.sun.electric.database.change.DatabaseChangeEvent;import com.sun.electric.database.change.DatabaseChangeListener;import com.sun.electric.database.geometry.Dimension2D;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.EDatabase;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.text.Pref;import com.sun.electric.database.text.Version;import com.sun.electric.database.topology.Geometric;import com.sun.electric.database.variable.EditWindow_;import com.sun.electric.tool.AbstractUserInterface;import com.sun.electric.tool.Client;import com.sun.electric.tool.Job;import com.sun.electric.tool.Listener;import com.sun.electric.tool.Tool;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.user.dialogs.OpenFile;import com.sun.electric.tool.user.dialogs.Progress;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.ErrorLoggerTree;import com.sun.electric.tool.user.ui.ToolBar;import com.sun.electric.tool.user.ui.TopLevel;import com.sun.electric.tool.user.ui.WindowContent;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.AWTEvent;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Dimension;import java.awt.EventQueue;import java.awt.Font;import java.awt.Toolkit;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.beans.PropertyChangeEvent;import java.lang.reflect.Method;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.logging.Logger;import javax.swing.BorderFactory;import javax.swing.ImageIcon;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.SwingUtilities;import javax.swing.event.EventListenerList;/** * Class to build the UserInterface for the main GUI version of the user interface. */public class UserInterfaceMain extends AbstractUserInterface{ static final Logger logger = Logger.getLogger("com.sun.electric.tool.user"); /** * Describe the windowing mode. The current modes are MDI and SDI. */ public static enum Mode { MDI, SDI };// /** Property fired if ability to Undo changes */ public static final String propUndoEnabled = "UndoEnabled";// /** Property fired if ability to Redo changes */ public static final String propRedoEnabled = "RedoEnabled"; static volatile boolean initializationFinished = false; private static volatile boolean undoEnabled = false; private static volatile boolean redoEnabled = false;// private static final EventListenerList undoRedoListenerList = new EventListenerList(); private static EventListenerList listenerList = new EventListenerList(); private static Snapshot currentSnapshot = EDatabase.clientDatabase().getInitialSnapshot();// private static EDatabase database = EDatabase.clientDatabase(); /** The progress during input. */ protected static Progress progress = null; private SplashWindow sw = null; public UserInterfaceMain(List<String> argsList, Mode mode, boolean showSplash) { new EventProcessor(); SwingUtilities.invokeLater(new InitializationRun(argsList, mode, showSplash)); } protected void dispatchServerEvent(ServerEvent serverEvent) throws Exception { } public void addEvent(Client.ServerEvent serverEvent) { SwingUtilities.invokeLater(serverEvent); } public void initializeInitJob(Job job, Object mode) { // Only valid for Mac OS X if (!Client.isOSMac()) return; if (mode != Mode.MDI) new EventProcessor(); SwingUtilities.invokeLater(new InitializationSetJob(job)); } private static String getMacClassName() { return "com.sun.electric.tool.user.MacOSXInterface"; } private class InitializationSetJob implements Runnable { Job initJob; public InitializationSetJob(Job job) { this.initJob = job; } public void run() { if (!Client.isOSMac()) return; try { Class<?> osXClass = Class.forName(getMacClassName()); Method osXSetJobMethod = null; // find the necessary methods on the Mac OS/X class try { osXSetJobMethod = osXClass.getMethod("setInitJob", new Class[] {Job.class}); } catch (NoSuchMethodException e) { osXSetJobMethod = null; } if (osXSetJobMethod != null) { try { osXSetJobMethod.invoke(osXClass, new Object[] {initJob}); } catch (Exception e) { System.out.println("Error initializing Mac OS/X interface"); } } } catch (ClassNotFoundException e) {} } } private class InitializationRun implements Runnable { List<String> argsList; Mode mode; boolean showSplash; InitializationRun(List<String> argsList, Mode mode, boolean showSplash) { this.argsList = argsList; this.mode = mode; this.showSplash = showSplash; } public void run() { assert SwingUtilities.isEventDispatchThread(); // see if there is a Mac OS/X interface if (Client.isOSMac()) { try { Class<?> osXClass = Class.forName(getMacClassName()); Method osXRegisterMethod = null; // find the necessary methods on the Mac OS/X class try { osXRegisterMethod = osXClass.getMethod("registerMacOSXApplication", new Class[] {List.class}); } catch (NoSuchMethodException e) { osXRegisterMethod = null; } if (osXRegisterMethod != null) { try { osXRegisterMethod.invoke(osXClass, new Object[] {argsList}); } catch (Exception e) { System.out.println("Error initializing Mac OS/X interface"); } } } catch (ClassNotFoundException e) {} } //runThreadStatusTimer(); if (showSplash) sw = new SplashWindow(mode); TopLevel.OSInitialize(mode); } } /** * Method is called when initialization was finished. */ public void finishInitialization() { initializationFinished = true; if (sw != null) { sw.removeNotify(); sw = null; } TopLevel.InitializeWindows(); WindowFrame.wantToOpenCurrentLibrary(true, null); } public EditWindow_ getCurrentEditWindow_() { return EditWindow.getCurrent(); } public EditWindow_ needCurrentEditWindow_() { return EditWindow.needCurrent(); } public Cell getCurrentCell() { return WindowFrame.getCurrentCell(); } /** * Method to get the current Cell in a given Library. * @param lib the library to query. * @return the current Cell in the Library. * @return the current cell in the library; null if there is no current Cell. */ public Cell getCurrentCell(Library lib) { return lib.getCurCell(); } /** * Method to set the current Cell in a Library. * @param lib the library in which to set a current cell. * @param curCell the new current Cell in the Library (can be null). */ public void setCurrentCell(Library lib, Cell curCell) { lib.setCurCell(curCell); } public Cell needCurrentCell() { return WindowFrame.needCurCell(); } /** * Method to adjust reference point in WindowFrame containing the cell */ public void adjustReferencePoint(Cell theCell, double cX, double cY) { // adjust all windows showing this cell for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); WindowContent content = wf.getContent(); if (!(content instanceof EditWindow_)) continue; Cell cell = content.getCell(); if (cell != theCell) continue; EditWindow_ wnd = (EditWindow_)content; Point2D off = wnd.getOffset(); off.setLocation(off.getX()-cX, off.getY()-cY); wnd.setOffset(off); } } public void repaintAllWindows() { WindowFrame.repaintAllWindows(); }// public void loadComponentMenuForTechnology()// {// WindowFrame wf = WindowFrame.getCurrentWindowFrame(false);// if (wf != null) wf.loadComponentMenuForTechnology();// } public void alignToGrid(Point2D pt) { EditWindow.gridAlign(pt); } public Dimension2D getGridAlignment() { return User.getAlignmentToGrid(); } public int getDefaultTextSize() { return EditWindow.getDefaultFontSize(); } public EditWindow_ displayCell(Cell cell) { WindowFrame wf = WindowFrame.createEditWindow(cell); if (wf.getContent() instanceof EditWindow_) return (EditWindow_)wf.getContent(); return null; } // ErrorLogger functions public void termLogging(final ErrorLogger log, boolean explain, boolean terminate) { if (!log.isPersistent() && log.getNumLogs() == 0) return; ErrorLoggerTree.addLogger(log, explain, terminate); } public void updateNetworkErrors(Cell cell, List<ErrorLogger.MessageLog> errors) { ErrorLoggerTree.updateNetworkErrors(cell, errors); } public void updateIncrementalDRCErrors(Cell cell, List<ErrorLogger.MessageLog> newErrors, List<ErrorLogger.MessageLog> delErrors) { ErrorLoggerTree.updateDrcErrors(cell, newErrors, delErrors); } /** * Method to return the error message associated with the current error. * Highlights associated graphics if "showhigh" is nonzero. Fills "g1" and "g2" * with associated geometry modules (if nonzero). */ public String reportLog(ErrorLogger.MessageLog log, boolean showhigh, Geometric [] gPair) { EDatabase database = EDatabase.clientDatabase(); // if two highlights are requested, find them if (gPair != null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -