~ubuntu-branches/debian/stretch/389-admin-console/stretch

« back to all changes in this revision

Viewing changes to src/com/netscape/management/admserv/AdminResourceModel.java

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2011-10-12 11:05:09 UTC
  • Revision ID: package-import@ubuntu.com-20111012110509-ybd1jr5xeat2ug1i
Tags: upstream-1.1.8
ImportĀ upstreamĀ versionĀ 1.1.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** BEGIN COPYRIGHT BLOCK
 
2
 * Copyright (C) 2001 Sun Microsystems, Inc.  Used by permission.
 
3
 * Copyright (C) 2005 Red Hat, Inc.
 
4
 * All rights reserved.
 
5
 * 
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; version 2
 
9
 * of the License.
 
10
 * 
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 * 
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
 * 
 
20
 * END COPYRIGHT BLOCK **/
 
21
package com.netscape.management.admserv;
 
22
 
 
23
import java.util.*;
 
24
import java.awt.*;
 
25
import java.awt.event.*;
 
26
import javax.swing.*;
 
27
import com.netscape.management.admserv.panel.*;
 
28
import com.netscape.management.client.*;
 
29
import com.netscape.management.client.console.*;
 
30
import com.netscape.management.client.util.*;
 
31
import com.netscape.management.client.logging.*;
 
32
import com.netscape.management.admserv.config.*;
 
33
import com.netscape.management.admserv.logging.*;
 
34
import netscape.ldap.*;
 
35
 
 
36
import com.netscape.management.client.security.CertificateDialog;
 
37
import com.netscape.management.client.security.PKCSConfigDialog;
 
38
import com.netscape.management.client.security.CertMigrateWizard;
 
39
 
 
40
public class AdminResourceModel extends ResourceModel implements IMenuInfo {
 
41
    static String iconSource = "com/netscape/management/client/images/";
 
42
    static ResourceSet _resource = new ResourceSet("com.netscape.management.admserv.admserv");
 
43
    IResourceObject[]_selection;
 
44
 
 
45
    static public String MENU_CERT_DIALOG   = "CERTIFICATE SETUP WIZARD";
 
46
    static public String MENU_PKCS11_CONFIG = "CERTIFICATE MANAGEMENT";
 
47
    static public String MENU_IMPORT_CERT   = "IMPORT CERTIFICATE";
 
48
    
 
49
    ConsoleInfo _consoleInfo;
 
50
 
 
51
    /**
 
52
      * Returns supported menu categories
 
53
      */
 
54
    public String[] getMenuCategoryIDs() {
 
55
        return new String[]{ Framework.MENU_FILE//,
 
56
            //ResourcePage.MENU_CONTEXT
 
57
        };
 
58
    }
 
59
 
 
60
 
 
61
    /**
 
62
      * constrcutor and initialize all the internal variables
 
63
      */
 
64
    public AdminResourceModel(ConsoleInfo ci, String[] taskList) {
 
65
 
 
66
 
 
67
        _consoleInfo = ci;
 
68
 
 
69
        ResourceObject root = new AdminServerNode(ci, taskList);
 
70
 
 
71
        root.add(new LoggingNode(ci, taskList));
 
72
 
 
73
        setRoot(root);
 
74
    }
 
75
 
 
76
 
 
77
    public IMenuItem[] getMenuItems(String categoryID) {
 
78
 
 
79
        ResourceSet _resource = new ResourceSet("com.netscape.management.client.default");
 
80
        if (AdminFrameworkInitializer.canAccessSecurity && categoryID.equals(Framework.MENU_FILE)) {
 
81
            MenuItemCategory category = new MenuItemCategory("security", _resource.getString("menu", "FileSecurity"));
 
82
            category.add(new MenuItemText(MENU_CERT_DIALOG, 
 
83
                              _resource.getString("menu", "FileManageCert"), 
 
84
                              "TODO:description", 
 
85
                              new SecurityAction(MENU_CERT_DIALOG)));
 
86
            category.add(new MenuItemText(MENU_PKCS11_CONFIG, 
 
87
                              _resource.getString("menu", "FilePKCS11Config"), 
 
88
                              "TODO:description", 
 
89
                              new SecurityAction(MENU_PKCS11_CONFIG)));
 
90
            category.add(new MenuItemText(MENU_IMPORT_CERT, 
 
91
                             _resource.getString("menu", "FileImportCert"),  
 
92
                             "TODO:description", 
 
93
                             new SecurityAction(MENU_IMPORT_CERT)));
 
94
            return new IMenuItem[]{
 
95
                category,
 
96
                new MenuItemSeparator()
 
97
            };
 
98
        }
 
99
        return null;
 
100
    }
 
101
 
 
102
    class SecurityAction implements ActionListener {
 
103
        String _id;
 
104
        public SecurityAction(String id) {
 
105
            _id = id;
 
106
        }
 
107
        public void actionPerformed(ActionEvent e) {
 
108
            if (_id.equals(MENU_CERT_DIALOG)) {
 
109
                JFrame f = UtilConsoleGlobals.getActivatedFrame();
 
110
                try {
 
111
                    if (f != null && f instanceof Framework){
 
112
                        ((Framework)f).setBusyCursor(true);
 
113
                    }
 
114
                    CertificateDialog certDialog = new CertificateDialog(f, _consoleInfo, (String)_consoleInfo.get("SIE"));
 
115
                    certDialog.setVisible(true);
 
116
                }
 
117
                finally {
 
118
                    if (f != null && f instanceof Framework){
 
119
                        ((Framework)f).setBusyCursor(false);
 
120
                    }
 
121
                }
 
122
            } else if (_id.equals(MENU_PKCS11_CONFIG)) {
 
123
                JFrame f = UtilConsoleGlobals.getActivatedFrame();
 
124
                try {
 
125
                    if (f != null && f instanceof Framework){
 
126
                        ((Framework)f).setBusyCursor(true);
 
127
                    }
 
128
                    PKCSConfigDialog pkcsConfig = new PKCSConfigDialog(f, _consoleInfo, (String)_consoleInfo.get("SIE"));
 
129
                    pkcsConfig.setVisible(true);
 
130
                }
 
131
                finally {
 
132
                    if (f != null && f instanceof Framework){
 
133
                        ((Framework)f).setBusyCursor(false);
 
134
                    }
 
135
                }
 
136
            } else if (_id.equals(MENU_IMPORT_CERT)) {
 
137
                CertMigrateWizard certMigrate = new CertMigrateWizard(null, _consoleInfo, (String)_consoleInfo.get("SIE"));
 
138
                certMigrate.setVisible(true);
 
139
            }
 
140
        }
 
141
    }
 
142
 
 
143
    public void actionObjectSelected(IPage viewInstance,
 
144
            IResourceObject[] selection,
 
145
            IResourceObject[] previousSelection) {
 
146
        super.actionObjectSelected(viewInstance, selection,
 
147
                previousSelection);
 
148
        _selection = selection;
 
149
    }
 
150
 
 
151
    /**
 
152
     * Notification that a menu item has been selected.
 
153
     */
 
154
    public void actionMenuSelected(IPage viewInstance, IMenuItem item) {
 
155
    }
 
156
 
 
157
}