windowframe.java
来自「The ElectricTM VLSI Design System is an 」· Java 代码 · 共 1,453 行 · 第 1/4 页
JAVA
1,453 行
* @return the current listener. */ public static EventListener getListener() { return curMouseListener; } /** * Method to return the current Cell. */ public static Cell getCurrentCell() { WindowFrame wf = WindowFrame.getCurrentWindowFrame(false); if (wf == null) return null; return wf.getContent().getCell(); } /** * Method to insist on a current Cell. * Prints an error message if there is no current Cell. * @return the current Cell in the current Library. * Returns NULL if there is no current Cell. */ public static Cell needCurCell() { Cell curCell = getCurrentCell(); if (curCell == null) { System.out.println("There is no current cell for this operation. To create one, use the 'New Cell' command from the 'Cell' menu."); } return curCell; } /** * Method to set the cursor that is displayed in the WindowFrame. * @param cursor the cursor to display here. */ public void setCursor(Cursor cursor) { if (!TopLevel.isMDIMode()) { jf.setCursor(cursor); } js.setCursor(cursor); content.setCursor(cursor); } public static void removeLibraryReferences(Library lib) { for (Iterator<WindowFrame> it = getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); WindowContent content = wf.getContent(); Cell cell = content.getCell(); if (cell != null && cell.getLibrary() == lib) content.setCell(null, null, null); content.fullRepaint(); } } /** * Method to request focus on this window */ public void requestFocus() { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { public void run() { requestFocusUnsafe(); } }); return; } requestFocusUnsafe(); } private void requestFocusUnsafe() { if (jif != null) { jif.toFront(); try { jif.setSelected(true); } catch (java.beans.PropertyVetoException e) {} } if (jf != null) { jf.toFront(); jf.requestFocus(); } } public boolean isFocusOwner() { if (jif != null) return jif.isSelected(); if (jf != null) return jf.isFocusOwner(); return false; } /** * Method to set the current WindowFrame. * @param wf the WindowFrame to make current. */ private static void setCurrentWindowFrame(WindowFrame wf) { synchronized(windowList) { if (wf.finished) return; // don't do anything, the window is finished curWindowFrame = wf; // set this to be last in list windowList.remove(wf); windowList.add(wf); } if (wf != null) { wf.currentCellChanged(); if (wf.getContent() != null) { Highlighter highlighter = wf.getContent().getHighlighter(); if (highlighter != null) highlighter.gainedFocus(); } } wantToRedoTitleNames(); } private void currentCellChanged() { if (this != getCurrentWindowFrame(false)) return; Cell cell = getContent().getCell(); if (cell != null) { Job.getUserInterface().setCurrentCell(cell.getLibrary(), cell); // if auto-switching technology, do it autoTechnologySwitch(cell, this); } } public static void wantToRedoTitleNames() { // rebuild window titles for (Iterator<WindowFrame> it = getWindows(); it.hasNext(); ) { WindowFrame w = it.next(); WindowContent content = w.getContent(); if (content != null) content.setWindowTitle(); } WindowMenu.setDynamicMenus(); } public void setWindowSize(Rectangle frameRect) { Dimension frameSize = new Dimension(frameRect.width, frameRect.height); if (TopLevel.isMDIMode()) { jif.setSize(frameSize); jif.setLocation(frameRect.x, frameRect.y); } else { jf.setSize(frameSize); jf.setLocation(frameRect.x, frameRect.y); jf.validate(); } } /** * Method to record that this WindowFrame has been closed. * This method is called from the event handlers on the windows. */ public void finished() { // if this was called from the code, instead of an event handler, // make sure we're not visible anymore if (TopLevel.isMDIMode()) { jif.setVisible(false); } // remove references to this synchronized(windowList) { if (windowList.size() <= 1 && !TopLevel.isMDIMode() && !Client.isOSMac()) { FileMenu.quitCommand(); //JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(), // "Cannot close the last window"); return; } windowList.remove(this); finished = true; if (curWindowFrame == this) curWindowFrame = null; } // tell EditWindow it's finished content.finished(); explorerTab.setModel(null); WindowMenu.setDynamicMenus(); if (!TopLevel.isMDIMode()) { // if SDI mode, TopLevel enclosing frame is closing, dispose of it jf.finished(); } } /** * Method to return the WaveformWindow associated with this frame. * @return the WaveformWindow associated with this frame. */ public WaveformWindow getWaveformWindow() { return (WaveformWindow)content; } /** * Method to return the Explorer tab associated with this WindowFrame. * @return the Explorer tab associated with this WindowFrame. */ public ExplorerTree getExplorerTab() { return explorerTab; } /** * Method to return the component palette associated with this WindowFrame. * @return the component palette associated with this WindowFrame. */ public PaletteFrame getPaletteTab() { return paletteTab; } /** * Method to return the layer visibility tab associated with this WindowFrame. * @return the layer visibility tab associated with this WindowFrame. */ public LayerTab getLayersTab() { return layersTab; } /** * Method to return the TopLevel associated with this WindowFrame. * In SDI mode this returns this WindowFrame's TopLevel Frame. * In MDI mode there is only one TopLevel frame, so this method will * return that Frame. * @return the TopLevel associated with this WindowFrame. */ public TopLevel getFrame() { if (TopLevel.isMDIMode()) { return TopLevel.getCurrentJFrame(); } return jf; } /** * Method to return the JInternalFrame associated with this WindowFrame. * In SDI mode this returns null. * @return the JInternalFrame associated with this WindowFrame. */ public JInternalFrame getInternalFrame() { if (TopLevel.isMDIMode()) { return jif; } return null; } /** * Returns true if this window frame or it's components generated * this event. * @param e the event generated * @return true if this window frame or it's components generated this * event, false otherwise. */ public boolean generatedEvent(java.awt.AWTEvent e) { if (e instanceof InternalFrameEvent) { JInternalFrame source = ((InternalFrameEvent)e).getInternalFrame(); if (source == jif) return true; return false; } return false; } /** * Method to return the number of WindowFrames. * @return the number of WindowFrames. */ public static int getNumWindows() { synchronized(windowList) { return windowList.size(); } } /** * Method to return an Iterator over all WindowFrames. * @return an Iterator over all WindowFrames. */ public static Iterator<WindowFrame> getWindows() { ArrayList<WindowFrame> listCopy = new ArrayList<WindowFrame>(); synchronized(windowList) { listCopy.addAll(windowList); } return listCopy.iterator(); } /** * Centralized version of naming windows. Might move it to class * that would replace WindowContext * @param cell the cell in the window. * @param prefix a prefix for the title. */ public String composeTitle(Cell cell, String prefix, int pageNo) { // StringBuffer should be more efficient StringBuffer title = new StringBuffer(); if (cell != null && cell.isLinked()) { title.append(prefix + cell.libDescribe()); if (cell.isMultiPage()) { title.append(" - Page " + (pageNo+1)); } Library curLib = Library.getCurrent(); if (cell.getLibrary() != curLib && curLib != null) title.append(" - Current library: " + curLib.getName()); } else title.append("***NONE***"); return (title.toString()); } /** * Method to set the description on the window frame */ public void setTitle(String title) { String curTitle = getTitle(); if (title.equals(curTitle)) return; if (TopLevel.isMDIMode()) { if (jif != null) jif.setTitle(title); } else { if (jf != null) jf.setTitle(title); } } /** * Method to get the description on the window frame */ public String getTitle() { if (TopLevel.isMDIMode()) { if (jif != null) return jif.getTitle(); } else { if (jf != null) return jf.getTitle(); } return ""; } private static void removeUIBinding(JComponent comp, KeyStroke key) { removeUIBinding(comp.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT), key); removeUIBinding(comp.getInputMap(JComponent.WHEN_FOCUSED), key); removeUIBinding(comp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW), key); } private static void removeUIBinding(InputMap map, KeyStroke key) { if (map == null) return; map.remove(key); removeUIBinding(map.getParent(), key); } /** * Method to automatically switch to the proper technology for a Cell. * @param cell the cell being displayed. * If technology auto-switching is on, make sure the right technology is displayed * for the Cell. */ public static void autoTechnologySwitch(Cell cell, WindowFrame wf) { if (cell.getView().isTextView()) return; Technology tech = cell.getTechnology(); if (tech != null && tech != Technology.getCurrent()) { if (User.isAutoTechnologySwitch()) { tech.setCurrent(); wf.getPaletteTab().setSelectedItem(tech.getTechName()); wf.getLayersTab().setSelectedTechnology(tech); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?