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

📄 projectmanagementtab.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: ProjectManagementTab.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.dialogs.options;import com.sun.electric.tool.project.Project;import com.sun.electric.tool.project.Users;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.OpenFile;import java.awt.Frame;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.util.Iterator;import javax.swing.DefaultListModel;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;import javax.swing.ListSelectionModel;/** * Class to handle the "Project Management" tab of the Preferences dialog. */public class ProjectManagementTab extends PreferencePanel{	private String initialRepository;	private String initialUserName;	private JList userList;	private DefaultListModel userModel;	private boolean authorized;	/** Creates new form ProjectManagement Options */	public ProjectManagementTab(Frame parent, boolean modal)	{		super(parent, modal);		initComponents();		if (Users.LOWSECURITY)		{	        projectManagement.remove(usersPanelMidSecurity);	        repositoryPanel.remove(midWarning);		} else		{	        projectManagement.remove(usersPanelLowSecurity);			deleteButton.setEnabled(false);			addButton.setEnabled(false);		}		pack();	}	/** return the panel to use for this preferences tab. */	public JPanel getPanel() { return projectManagement; }	/** return the name of this preferences tab. */	public String getName() { return "Project Management"; }	/**	 * Method called at the start of the dialog.	 * Caches current values and displays them in the Project Management tab.	 */	public void init()	{		initialRepository = Project.getRepositoryLocation();		repositoryTextArea.setText(initialRepository);		initialUserName = Project.getCurrentUserName();		if (Users.LOWSECURITY)		{			if (initialUserName.length() == 0) initialUserName = System.getProperty("user.name");			userName.setText(initialUserName);		} else		{			if (initialUserName.length() == 0) initialUserName = "NOBODY LOGGED IN";			currentUserLabel.setText("Logged-in user: " + initialUserName);			userModel = new DefaultListModel();			userList = new JList(userModel);			userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);			userListPane.setViewportView(userList);			userList.clearSelection();			userModel.clear();			for(Iterator<String> it = Users.getUsers(); it.hasNext(); )			{				String user = it.next();				userModel.addElement(user);			}			userList.setSelectedIndex(0);		}	}	/**	 * Method called when the "OK" panel is hit.	 * Updates any changed fields in the General tab.	 */	public void term()	{		String currRepository = repositoryTextArea.getText();		if (!currRepository.equals(initialRepository))			Project.setRepositoryLocation(currRepository);		if (Users.LOWSECURITY)		{			String uName = userName.getText();			if (!uName.equals(initialUserName))				Project.setCurrentUserName(uName);		}	}	/**	 * Method called when the factory reset is requested.	 */	public void reset()	{		if (!Project.getFactoryRepositoryLocation().equals(Project.getRepositoryLocation()))			Project.setRepositoryLocation(Project.getFactoryRepositoryLocation());		if (!Project.getFactoryCurrentUserName().equals(Project.getCurrentUserName()))			Project.setCurrentUserName(Project.getFactoryCurrentUserName());	}	/**	 * This class displays a dialog for password-related operations.	 */	private static class PasswordDialog extends EDialog	{		private static final int NEWUSER        = 1;		private static final int CHANGEPASSWORD = 2;		private static final int LOGINUSER      = 3;		private static final int DELETEUSER     = 4;		private static final int AUTHORIZE      = 5;		private static final int RENAMEAUTHPASS = 6;		private int operation;		private String userName;		private JTextField userNameField;		private JPasswordField password, confirm, oldPassword;		private boolean didCancel;		/** Creates new form for password-related inquiries */		private PasswordDialog(int operation, String userName)		{			super(null, true);			this.operation = operation;			this.userName = userName;			initComponents();			setVisible(true);		}		public boolean cancelled() { return didCancel; }		public String getUserName() { return userNameField.getText(); }		public String getPassword() { return new String(password.getPassword()); }		protected void escapePressed() { exit(false); }		private void exit(boolean goodButton)		{			didCancel = !goodButton;			if (goodButton)			{				switch (operation)				{					case NEWUSER:						// validate the dialog						String name = userNameField.getText().trim();						if (name.length() == 0)						{							JOptionPane.showMessageDialog(this, "You must type a user name", "Blank User Name", JOptionPane.ERROR_MESSAGE);							userNameField.selectAll();							return;						}						if (Users.isExistingUser(name))						{							JOptionPane.showMessageDialog(this, "User " + name + " already exists.  Choose another name",								"User Name Exists", JOptionPane.ERROR_MESSAGE);							userNameField.selectAll();							return;						}						String pass = new String(password.getPassword());						String conf = new String(confirm.getPassword());						if (!pass.equals(conf))						{							JOptionPane.showMessageDialog(this, "Confirmed password does not match original password",								"Confirmation Error", JOptionPane.ERROR_MESSAGE);							confirm.selectAll();							return;						}						break;					case CHANGEPASSWORD:						// validate the dialog						String givenPassword = new String(oldPassword.getPassword()).trim();						String encryptedPassword = Users.getEncryptedPassword(userName);						String encryptedGivenPassword = Users.encryptPassword(givenPassword);						if (!encryptedGivenPassword.equals(encryptedPassword))						{							JOptionPane.showMessageDialog(this, "Incorrect password given for user " + userName,								"Invalid Password", JOptionPane.ERROR_MESSAGE);							oldPassword.selectAll();							return;						}						pass = new String(password.getPassword());						conf = new String(confirm.getPassword());						if (!pass.equals(conf))						{							JOptionPane.showMessageDialog(this, "Confirmed password does not match new password",								"Confirmation Error", JOptionPane.ERROR_MESSAGE);							confirm.selectAll();							return;						}						break;					case LOGINUSER:						// validate the dialog						givenPassword = new String(password.getPassword()).trim();						encryptedPassword = Users.getEncryptedPassword(userName);						encryptedGivenPassword = Users.encryptPassword(givenPassword);						if (!encryptedGivenPassword.equals(encryptedPassword))						{							JOptionPane.showMessageDialog(this, "Incorrect password given for user " + userName,								"Invalid Password", JOptionPane.ERROR_MESSAGE);							password.selectAll();							return;						}						break;					case AUTHORIZE:						// validate the dialog						givenPassword = new String(password.getPassword()).trim();						encryptedPassword = Project.getAuthorizationPassword();						if (!givenPassword.equals(encryptedPassword))						{							JOptionPane.showMessageDialog(this, "Incorrect administrator password",								"Invalid Password", JOptionPane.ERROR_MESSAGE);							password.selectAll();							return;						}						break;					case RENAMEAUTHPASS:						// validate the dialog						givenPassword = new String(oldPassword.getPassword()).trim();						encryptedPassword = Project.getAuthorizationPassword();						if (!givenPassword.equals(encryptedPassword))						{							JOptionPane.showMessageDialog(this, "Incorrect administrator password",								"Invalid Password", JOptionPane.ERROR_MESSAGE);							oldPassword.selectAll();							return;						}						pass = new String(password.getPassword());						conf = new String(confirm.getPassword());						if (!pass.equals(conf))						{							JOptionPane.showMessageDialog(this, "Confirmed password does not match new password",								"Confirmation Error", JOptionPane.ERROR_MESSAGE);							confirm.selectAll();							return;						}						break;				}			}			setVisible(false);			dispose();		}		private void initComponents()		{			getContentPane().setLayout(new GridBagLayout());			setName("");			addWindowListener(new WindowAdapter()			{				public void windowClosing(WindowEvent evt) { exit(false); }			});			switch (operation)			{				case NEWUSER:					setTitle("Create New User");					JLabel lab1 = new JLabel("User name:");					GridBagConstraints gbc = new GridBagConstraints();					gbc.gridx = 0;   gbc.gridy = 0;					gbc.anchor = GridBagConstraints.WEST;					gbc.insets = new java.awt.Insets(4, 4, 4, 4);					getContentPane().add(lab1, gbc);					userNameField = new JTextField("");					userNameField.setColumns(20);					gbc = new GridBagConstraints();					gbc.gridx = 1;   gbc.gridy = 0;					gbc.anchor = GridBagConstraints.CENTER;					gbc.fill = GridBagConstraints.HORIZONTAL;					gbc.weightx = 1;					gbc.insets = new Insets(4, 4, 4, 4);					getContentPane().add(userNameField, gbc);					JLabel lab2 = new JLabel("Password:");					gbc = new GridBagConstraints();					gbc.gridx = 0;   gbc.gridy = 1;					gbc.anchor = GridBagConstraints.WEST;					gbc.insets = new java.awt.Insets(4, 4, 4, 4);					getContentPane().add(lab2, gbc);					password = new JPasswordField("");					gbc = new GridBagConstraints();

⌨️ 快捷键说明

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