summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/ug/CMSBaseUGTab.java
blob: 8e7fb34dd4e133ad2861a8471b92e922ce9644b4 (plain)
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
143
144
145
146
147
148
149
150
151
152
153
// --- BEGIN COPYRIGHT BLOCK ---
// This program 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; version 2 of the License.
//
// This program 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 this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.admin.certsrv.ug;

import com.netscape.admin.certsrv.*;
import java.util.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;

/**
 * Base class for the tabs in the User and group tabbed pane.
 *
 * @author Jack Pan-Chen
 * @version $Revision$, $Date$
 */
public abstract class CMSBaseUGTab  extends CMSBasePanel
    implements MouseListener, IRefreshTab
{

    /*==========================================================
     * variables
     *==========================================================*/
    protected CMSBaseResourceModel mModel; //resource model

    private String mTitle;                  // panel title actually shows
    protected boolean mInit = false;        // true if this panel is initialized
    protected JPanel mListPanel, mActionPanel;  //panels
    protected String mHelpToken;

	/*==========================================================
     * constructors
     *==========================================================*/
    public CMSBaseUGTab(String panelName, CMSBaseResourceModel model) {
        super(panelName);
        mModel = model;
        try {
            String title = mResource.getString(mPanelName+"_TITLE");
            mTitle = title;
        } catch (MissingResourceException e) {
            mTitle = "Missing Title";
        }
    }

    /*==========================================================
	 * public methods
     *==========================================================*/

    /**
     * Initialization of the panel. Subcalss must provide
     * the proper implementation.
     */
    public void init() {
        setLayout(new BorderLayout());

        //======== list panel ========================
		mListPanel = createListPanel();
		mListPanel.setBorder(new EmptyBorder(DIFFERENT_COMPONENT_SPACE,
		        DIFFERENT_COMPONENT_SPACE,
		        DIFFERENT_COMPONENT_SPACE - COMPONENT_SPACE,
		        DIFFERENT_COMPONENT_SPACE));
		add("Center",mListPanel);

		//====== action panel ===========================
		mActionPanel = createActionPanel();
		add("South",mActionPanel);
    }

    /**
     * Called by the Tab parent to initialize the panel
     */
    public void initialize() {
        if (!mInit) {
            init();
            mInit = true;
        }
    }


    /**
     * Returns the title of the tab
     * @return string representation of the title
     */
    public String getTitle() {
		return mTitle;
	}

	/**
     * set the title of the tab
     */
    public void setTitle(String title) {
		mTitle = title;
	}

    public void helpCallback() {
        CMSAdminUtil.help(mHelpToken);
    }

    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}

    /*==========================================================
	 * protected methods
     *==========================================================*/
    protected abstract JPanel createActionPanel();
    protected abstract JPanel createListPanel();

    //=== OVERWRITE DIALOG MESSAGE =====================

    protected void showMessageDialog(String keyword, int messageType ) {
        CMSAdminUtil.showMessageDialog(mModel.getFrame(), mResource, mPanelName, keyword, messageType);
    }

    protected void showMessageDialog(String keyword) {
        showMessageDialog(keyword, ERROR_MESSAGE);
    }

    protected int showConfirmDialog(String keyword, int messageType ) {
        return CMSAdminUtil.showConfirmDialog(mModel.getFrame(), mResource, mPanelName, keyword, messageType);
    }

    protected int showConfirmDialog(String keyword) {
        return showConfirmDialog(keyword, WARNING_MESSAGE);
    }

    protected int showConfirmDialog(String keyword, String[] params) {
        return showConfirmDialog(keyword, params, WARNING_MESSAGE);
    }

    protected void showErrorDialog(String message) {
        CMSAdminUtil.showErrorDialog(mModel.getFrame(), mResource, message, ERROR_MESSAGE);
    }

    public abstract void refresh();
}