📄 administrativeloginpanel.java
字号:
/* * ==================================================================== * The Class Description * Version: 1.0.0 * Date: 11/08/2005 * Author: Xing.zhou * Function: 判断用户的身份,并根据身份进入不同的界面 * * ==================================================================== * */package vocal.ui;import vocal.userEditor.AccreditEditor;import vocal.userEditor.Editor;import vocal.comm.VPPTransactionWrapper;import vocal.pw.AccessLevels;import javax.swing.*;import javax.swing.border.*;import java.applet.Applet;import java.applet.AppletContext;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.BorderLayout;import java.awt.Container;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;public class AdministrativeLoginPanel extends LoginPanel{ private JRadioButton adminAccess; private JRadioButton techAccess; public static JDialog adminDialog; private AccountPanel accountDialog; private ConfigureServers techDialog; private AccreditPanel accreditDialog; private Editor editor = null; private AccreditEditor accrediteditor = null; private VPPTransactionWrapper aconnect; public void return_login() { adminDialog.setVisible(false); } public AdministrativeLoginPanel(boolean isStandAlone, VPPTransactionWrapper con, JRootPane root) { super(isStandAlone, con, root); aconnect = con; adminDialog = new JDialog((JFrame) this.getTopLevelAncestor(), "User Configuration", true); adminAccess = new JRadioButton("Administrator"); techAccess = new JRadioButton("Technician"); ButtonGroup group = new ButtonGroup(); group.add(adminAccess); group.add(techAccess); adminAccess.setSelected(true); JPanel temp = new JPanel(); temp.setLayout(new BoxLayout(temp, BoxLayout.X_AXIS)); temp.add(Box.createHorizontalStrut(15)); temp.add(techAccess); temp.add(Box.createHorizontalGlue()); add(temp, 0); temp = new JPanel(); temp.setLayout(new BoxLayout(temp, BoxLayout.X_AXIS)); temp.add(Box.createHorizontalStrut(15)); temp.add(adminAccess); temp.add(Box.createHorizontalGlue()); add(temp, 0); temp = new JPanel(); temp.setLayout(new BoxLayout(temp, BoxLayout.X_AXIS)); temp.add(new JLabel("Access level: ")); temp.add(Box.createHorizontalGlue()); add(temp, 0); } protected void addActionListeners() { super.addActionListeners(); } //用户进入帐号管理 protected void account_dialog() {/* if (accountDialog == null) { accountDialog = new AccountPanel(this); accountDialog.setModal(true); } Container parent = AdministrativeLoginPanel.this.getTopLevelAncestor(); parent.setVisible(false); accountDialog.setVisible(true); parent.setVisible(true); if (JFrame.class.isInstance(parent)) { ((JFrame) parent).toFront(); ((JFrame) parent).setState(JFrame.NORMAL); }*/ if (editor == null) { //用户数据显示表格区 editor = new Editor(connect); // The user editor goes in the center panel of a border layout JPanel temp = new JPanel(); temp.setLayout(new BorderLayout()); temp.add(editor, BorderLayout.CENTER); // add another panel at the bottom which has the back button JPanel temp2 = new JPanel(); temp2.setLayout(new BoxLayout(temp2, BoxLayout.X_AXIS));/* JButton back = new JButton("Back"); back.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { return_login(); //adminDialog.setVisible(false); } }); temp2.add(back);*/ JButton acc_manage = new JButton("帐号管理"); acc_manage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); temp2.add(acc_manage); JButton tech_manage = new JButton("技术管理"); tech_manage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { adminDialog.setVisible(false); tech_dialog(); } }); //只有系统管理员和技术管理员才可以进入技术管理 if((1==super.userlevel)||(3==super.userlevel)) { temp2.add(tech_manage); } JButton accredit = new JButton("帐号授权中心"); accredit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { adminDialog.setVisible(false); accredit_dialog(); } }); temp2.add(accredit); JButton video = new JButton("实时监控"); video.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //adminDialog.setVisible(false); //AdministrativeLogin temp = null; /* try { temp.getAppletContext().showDocument(new URL("http://www.sohu.com")); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } */ try { Process p=Runtime.getRuntime().exec("explorer http://192.168.1.39/vocal/monitor/enter.htm"); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); temp2.add(video); temp2.add(Box.createHorizontalGlue()); temp2.setBorder(new EmptyBorder(5, 5, 5, 5)); temp.add(temp2, BorderLayout.NORTH); adminDialog.getContentPane().add(temp); adminDialog.pack(); adminDialog.setSize(700, 500); temp2 = new JPanel(); temp2.setLayout(new BoxLayout(temp2, BoxLayout.X_AXIS)); temp2.setBorder(new EmptyBorder(2, 4, 2, 4)); temp2.add(vocal.util.Logger.getLogLabel()); temp.add(temp2, BorderLayout.SOUTH); temp2 = new JPanel(); temp2.setLayout(new BoxLayout(temp2, BoxLayout.X_AXIS)); /* JButton back = new JButton("Back"); back.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { return_login(); //adminDialog.setVisible(false); } }); temp2.add(back); JButton help = new JButton("help"); help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(AdministrativeLoginPanel.this.getTopLevelAncestor(), "Extend Multimedia Server\n\n" + "帐号管理可以用于用户帐号添加、编辑、删除\n" + "并且可以查询用户", "Login Help", JOptionPane.INFORMATION_MESSAGE); //adminDialog.setVisible(false); } }); temp2.add(help); */ temp2.add(Box.createHorizontalGlue()); temp2.setBorder(new EmptyBorder(5, 5, 5, 5)); temp.add(temp2, BorderLayout.SOUTH); } Container parent = AdministrativeLoginPanel.this.getTopLevelAncestor(); editor.init(); parent.setVisible(false); editor.loadUserNames(); adminDialog.setVisible(true); // modal parent.setVisible(true); if (JFrame.class.isInstance(parent)) { ((JFrame) parent).toFront(); ((JFrame) parent).setState(JFrame.NORMAL); } } // protected void account_dialog_repair() { if (adminDialog == null) { adminDialog = new AccountPanel(this); adminDialog.setModal(true); } Container parent = AdministrativeLoginPanel.this.getTopLevelAncestor(); parent.setVisible(false); adminDialog.setVisible(true); parent.setVisible(true); if (JFrame.class.isInstance(parent)) { ((JFrame) parent).toFront(); ((JFrame) parent).setState(JFrame.NORMAL); } } //用户进入技术管理 protected void tech_dialog() { if (techDialog == null) { techDialog = new ConfigureServers(this); techDialog.setModal(true); } Container parent = AdministrativeLoginPanel.this.getTopLevelAncestor(); parent.setVisible(false); techDialog.setVisible(true); parent.setVisible(true); if (JFrame.class.isInstance(parent)) { ((JFrame) parent).toFront(); ((JFrame) parent).setState(JFrame.NORMAL); } } //用户进入帐号授权中心 protected void accredit_dialog() { if (accreditDialog == null) { accreditDialog = new AccreditPanel(this,aconnect); accreditDialog.setModal(true); } Container parent = AdministrativeLoginPanel.this.getTopLevelAncestor(); //accrediteditor.init(); //editor.loadUserNames(); parent.setVisible(false); accreditDialog.setVisible(true); parent.setVisible(true); if (JFrame.class.isInstance(parent)) { ((JFrame) parent).toFront(); ((JFrame) parent).setState(JFrame.NORMAL); } } //处理用户登录后进入的管理界面 protected void doLogin() { if (adminAccess.isSelected()) { //当界面上选择的身份和系统数据库中的身份相同时则进入帐号管理 if((super.userlevel==2)||(super.userlevel==1)) { account_dialog(); } else { JOptionPane.showMessageDialog(AdministrativeLoginPanel.this.getTopLevelAncestor(), "Extend Multimedia Server\n\n" + "您不是帐号管理员,\n" + "请向系统管理员申请后再进入!", "Login Help", JOptionPane.INFORMATION_MESSAGE); } } else if (techAccess.isSelected()) { //当界面上选择的身份和系统数据库中的身份相同时则进入技术管理 if((super.userlevel==3)||(super.userlevel==1)) { tech_dialog(); } else { JOptionPane.showMessageDialog(AdministrativeLoginPanel.this.getTopLevelAncestor(), "Extend Multimedia Server\n\n" + "您不是技术管理员,\n" + "请向系统管理员申请后再进入!", "Login Help", JOptionPane.INFORMATION_MESSAGE); } } } protected int getAccessLevel() { if (techAccess.isSelected()) { return AccessLevels.TECHNICIAN; } return AccessLevels.ADMINISTRATOR; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -