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

📄 preferencesframe.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		JButton resetAll = new JButton("Reset All");		resetAll.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { resetAllActionPerformed(); }		});		gbc = new GridBagConstraints();		gbc.gridx = 1;   gbc.gridy = 2;		gbc.insets = new Insets(4, 4, 4, 4);		leftPanel.add(resetAll, gbc);		JButton help = new JButton("Help");		help.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { helpActionPerformed(); }		});		gbc = new GridBagConstraints();		gbc.gridx = 0;   gbc.gridy = 3;		gbc.insets = new Insets(4, 4, 4, 4);		leftPanel.add(help, gbc);		JButton apply = new JButton("Apply");		apply.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { applyActionPerformed(); }		});		gbc = new GridBagConstraints();		gbc.gridx = 1;   gbc.gridy = 3;		gbc.insets = new Insets(4, 4, 4, 4);		leftPanel.add(apply, gbc);		cancel = new JButton("Cancel");		cancel.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { cancelActionPerformed(); }		});		gbc = new GridBagConstraints();		gbc.gridx = 0;   gbc.gridy = 4;		gbc.insets = new Insets(4, 4, 4, 4);		leftPanel.add(cancel, gbc);		ok = new JButton("OK");		ok.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { okActionPerformed(); }		});		gbc = new GridBagConstraints();		gbc.gridx = 1;   gbc.gridy = 4;		gbc.insets = new Insets(4, 4, 4, 4);		leftPanel.add(ok, gbc);		getRootPane().setDefaultButton(ok);		getRootPane().setDefaultButton(ok);		// build preferences framework		splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);		loadOptionPanel();		splitPane.setLeftComponent(leftPanel);		recursivelyHighlight(optionTree, rootNode, initialDMTN, optionTree.getPathForRow(0));		gbc = new GridBagConstraints();		gbc.gridx = 0;   gbc.gridy = 0;		gbc.gridwidth = 1;		gbc.fill = GridBagConstraints.BOTH;		gbc.weightx = 1.0;   gbc.weighty = 1.0;		getContentPane().add(splitPane, gbc);		pack();		finishInitialization();	}	private void addTreeNode(PreferencePanel panel, DefaultMutableTreeNode theSet)	{		optionPanes.add(panel);		String sectionName = (String)theSet.getUserObject();		String name = panel.getName();		DefaultMutableTreeNode dmtn = new DefaultMutableTreeNode(name);		theSet.add(dmtn);		if (sectionName.equals(currentSectionName) && name.equals(currentTabName))			initialDMTN = dmtn;	}	private boolean openSelectedPath(DefaultMutableTreeNode rootNode)	{		for (int i = 0; i < rootNode.getChildCount(); i++)		{			DefaultMutableTreeNode node = (DefaultMutableTreeNode)rootNode.getChildAt(i);			Object o = node.getUserObject();			if (o.toString().equals(currentTabName))			{				optionTree.scrollPathToVisible(new TreePath(node.getPath()));				return true;			}			if (openSelectedPath(node)) return true;		}		return false;	}	private void cancelActionPerformed()	{		closeDialog(null);	}	private void okActionPerformed()	{		new OKUpdate(this, true);	}	private void applyActionPerformed()	{		new OKUpdate(this, false);	}	private void resetActionPerformed()	{		for(PreferencePanel ti : optionPanes)		{			if (ti.getName().equals(currentTabName))			{				boolean response = Job.getUserInterface().confirmMessage(					"Do you really want to reset the " + ti.getName() + " Preferences to their 'factory' state?");				if (response)				{					Pref.delayPrefFlushing();					boolean inPlace = ti.resetThis();					Pref.resumePrefFlushing();					if (inPlace)					{						// panel was reset in place without redisplay					} else					{						// panel unable to reset itself: do hard reset and quit dialog						ti.reset();						closeDialog(null);				        WindowFrame.repaintAllWindows();					}					return;				}				break;			}		}	}	private void resetAllActionPerformed()	{		boolean response = Job.getUserInterface().confirmMessage(			"Do you really want to reset all Preferences to their 'factory' state?");		if (response)		{			Pref.delayPrefFlushing();			for(PreferencePanel ti : optionPanes)				ti.reset();			Pref.resumePrefFlushing();			closeDialog(null);            WindowFrame.repaintAllWindows();		}	}	private void helpActionPerformed()	{		ManualViewer.showPreferenceHelp(currentSectionName.trim() + "/" + currentTabName);		closeDialog(null);	}	private void exportActionPerformed()	{		Job.getUserInterface().exportPrefs();	}	private void importActionPerformed()	{		Job.getUserInterface().importPrefs();		TopLevel top = TopLevel.getCurrentJFrame();		top.getEMenuBar().restoreSavedBindings(false); // trying to cache again		// recache all layers and their graphics		Technology.cacheTransparentLayerColors();		// close dialog now because all values are cached badly		closeDialog(null);		// redraw everything		EditWindow.repaintAllContents();		for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); )		{			WindowFrame wf = it.next();			wf.loadComponentMenuForTechnology();		}	}	private void loadOptionPanel()	{		for(PreferencePanel ti : optionPanes)		{			if (ti.getName().equals(currentTabName))			{				if (!ti.isInited())				{					ti.init();					ti.setInited();				}				splitPane.setRightComponent(ti.getPanel());				return;			}		}	}	protected void escapePressed() { cancelActionPerformed(); }	/**	 * Class to update primitive node information.	 */	private static class OKUpdate extends Job	{		private transient PreferencesFrame dialog;		private Pref.PrefChangeBatch changeBatch;		private transient boolean andDone;		private OKUpdate(PreferencesFrame dialog, boolean andDone)		{			super("Update Preferences", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.dialog = dialog;			this.andDone = andDone;			// gather preference changes on the client			Pref.gatherPrefChanges();			for(PreferencePanel ti : dialog.optionPanes)			{				if (ti.isInited())					ti.term();			}			changeBatch = Pref.getPrefChanges();			startJob();		}		public boolean doIt() throws JobException		{			Pref.implementPrefChanges(changeBatch);			return true;		}		public void terminateOK()		{			if (andDone) dialog.closeDialog(null);		}	}	private static class TreeHandler implements MouseListener, TreeExpansionListener	{		private PreferencesFrame dialog;		TreeHandler(PreferencesFrame dialog) { this.dialog = dialog; }		public void mouseClicked(MouseEvent e) {}		public void mouseEntered(MouseEvent e) {}		public void mouseExited(MouseEvent e) {}		public void mouseReleased(MouseEvent e) {}		public void mousePressed(MouseEvent e)		{			TreePath currentPath = dialog.optionTree.getPathForLocation(e.getX(), e.getY());			if (currentPath == null) return;			dialog.optionTree.setSelectionPath(currentPath);			DefaultMutableTreeNode node = (DefaultMutableTreeNode)currentPath.getLastPathComponent();			currentTabName = (String)node.getUserObject();			dialog.optionTree.expandPath(currentPath);			if (currentTabName.endsWith(" "))			{				currentSectionName = currentTabName;			} else			{				dialog.loadOptionPanel();			}			dialog.pack();		}		public void treeCollapsed(TreeExpansionEvent e)		{			dialog.pack();		}		public void treeExpanded(TreeExpansionEvent e)		{			TreePath tp = e.getPath();			if (tp.getPathCount() == 2)			{				// opened a path down to the bottom: close all others				TreePath topPath = dialog.optionTree.getPathForRow(0);				DefaultMutableTreeNode node = (DefaultMutableTreeNode)topPath.getLastPathComponent();				int numChildren = node.getChildCount();				for(int i=0; i<numChildren; i++)				{					DefaultMutableTreeNode child = (DefaultMutableTreeNode)node.getChildAt(i);					TreePath descentPath = topPath.pathByAddingChild(child);					if (descentPath.getLastPathComponent().equals(tp.getLastPathComponent()))					{						DefaultMutableTreeNode subNode = (DefaultMutableTreeNode)descentPath.getLastPathComponent();						currentSectionName = (String)subNode.getUserObject();					} else					{						dialog.optionTree.collapsePath(descentPath);					}				}			}			dialog.pack();		}	}	/** Closes the dialog */	private void closeDialog(java.awt.event.WindowEvent evt)	{		setVisible(false);		dispose();	}}

⌨️ 快捷键说明

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