wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package com.vci.client.logon.base;
 
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
 
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JToolBar;
 
import com.vci.client.LogonApplication;
import com.vci.client.framework.delegate.RightManagementClientDelegate;
import com.vci.client.framework.util.RightControlUtil;
import com.vci.client.logon.client.LogonPanel;
import com.vci.client.ui.exception.VCIException;
import com.vci.client.ui.swing.KJButton;
import com.vci.client.ui.swing.VCIOptionPane;
 
public abstract class BaseToolBar  extends JToolBar{
 
    private static final long serialVersionUID = 1L;
    public KJButton exitButton = new KJButton("" , "exit.gif");
    public KJButton changePasswordButton = new KJButton("" , "password.gif");
    public KJButton helpButton = new KJButton("" , "help.gif");
    private Frame frame = null;
    public BaseToolBar(Frame frame) {
        try {
//            jbInit();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public void setToolButtonSize(JButton jb){
        jb.setMaximumSize(new Dimension(30, 24));
        jb.setMinimumSize(new Dimension(30, 24));
        jb.setPreferredSize(new Dimension(30, 24));
        jb.setBorder(null);
    }
    
    private void jbInit() {
        this.setFloatable(false);
        this.setBorder(BorderFactory.createEmptyBorder());
        
        setToolButtonSize(changePasswordButton);
        changePasswordButton.setToolTipText("更改密码");
        
        setToolButtonSize(helpButton);
        helpButton.setToolTipText("帮助");
        
        setToolButtonSize(exitButton);
        exitButton.setToolTipText("退出");
        
        changePasswordButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                changePasswordButton_actionEvent();
            }
        });
        setMouseEnteredAndExitedEvent(changePasswordButton);
        
        helpButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                helpMenu_actionEvent(e);
            }
        });
        setMouseEnteredAndExitedEvent(helpButton);
        
        exitButton.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                exitButton_actionEvent();
            }
        });
        setMouseEnteredAndExitedEvent(exitButton);
    }
    
    protected void setMouseEnteredAndExitedEvent(final JButton button){
        button.addMouseListener(new java.awt.event.MouseAdapter() {
              public void mouseEntered(MouseEvent e) {
                  resourceTypesButton_mouseEntered(e, button);
                }
                public void mouseExited(MouseEvent e) {
                    resourceTypesButton_mouseExited(e, button);
                }
        });
        
    }
    
    private void exitButton_actionEvent() {
        int i=VCIOptionPane.showConfirmDialog(frame, "确定要退出系统吗?","退出系统",VCIOptionPane.YES_NO_OPTION);
        if(i==0){    
            if (!RightControlUtil.isAdminOrDeveloperOrRoot(LogonApplication.getUserObject().getUserName())){
                /**
                 * 保存日志
                 */
                String message = "登出";
                LogonApplication.getUserEntityObject().setModules(LogonPanel.class.getName());
                try {
                    new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).savelog(message);
                } catch (VCIException e) {
                    VCIOptionPane.showError(LogonApplication.frame,"RMIPFramework", e);
                }
            }
              
            System.exit(0);
        }
    }
    
    private void helpMenu_actionEvent(ActionEvent ae) {
        
    }
    
    private void changePasswordButton_actionEvent(){
        ChangePasswordDialog changePasswordDialog = new ChangePasswordDialog(frame, false,LogonApplication.getUserEntityObject());
        Dimension screenSize = Toolkit.getDefaultToolkit ().getScreenSize ();
        Dimension dialogSize = changePasswordDialog.getPreferredSize ();
        dialogSize.height = 300;
        dialogSize.width = 300;
        changePasswordDialog.setSize (dialogSize);
        changePasswordDialog.setResizable(false);
        changePasswordDialog.setLocation ( (screenSize.width - dialogSize.width) / 2, (screenSize.height - dialogSize.height) / 2);
        changePasswordDialog.setVisible (true);
    }
    public void resourceTypesButton_mouseEntered(MouseEvent e,JButton jb) {
        jb.setBorder(BorderFactory.createRaisedBevelBorder());
    }
 
    public void resourceTypesButton_mouseExited(MouseEvent e,JButton jb) {
        jb.setBorder(null);
    }
    
    public void loadToolBarItem(){
//        this.add(changePasswordButton);
        this.initSpecialToolBar();
//        this.add(helpButton);
//        this.add(exitButton);
    }
    
    public abstract void initSpecialToolBar();
}