summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/config/CMSCertSettingPanel.java
blob: 975ba97da533ece4cebb199bcc696b2760045920 (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
// --- 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.config;

import com.netscape.admin.certsrv.*;
import com.netscape.management.client.util.*;
import com.netscape.admin.certsrv.connection.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/**
 * CA Certificate Setting
 *
 * @author Christine Ho
 * @author Jack Pan-Chen
 * @version $Revision$, $Date$
 */
public abstract class CMSCertSettingPanel extends CMSBaseTab {

    /*==========================================================
     * variables
     *==========================================================*/
    protected JLabel _mapper, _publisher;
    protected CMSBaseResourceModel _model;
    protected AdminConnection _admin;
    protected JButton mMapper, mPublisher;

	/*==========================================================
     * constructors
     *==========================================================*/
     
    public CMSCertSettingPanel(String panelName, CMSTabPanel parent) {
        super(panelName, parent);
        _model = parent.getResourceModel();
    }

    /*==========================================================
	 * public methods
     *==========================================================*/
     
    /**
     * Actual UI construction
     */
    public void init() {
        _admin = _model.getServerInfo().getAdmin();
        GridBagLayout gb = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();
        CMSAdminUtil.resetGBC(gbc);
        mCenterPanel.setLayout(gb);
        
        JPanel mapPanel = new JPanel();
        GridBagLayout gb2 = new GridBagLayout();
        mapPanel.setLayout(gb2);
        mapPanel.setBorder(makeTitledBorder("MAPPER"));
        CMSAdminUtil.resetGBC(gbc);
        gbc.anchor = gbc.NORTH;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.weightx = 1.0;
        gb.setConstraints(mapPanel, gbc);
        mCenterPanel.add(mapPanel);
        
        CMSAdminUtil.resetGBC(gbc);
        JLabel mapperLabel = makeJLabel("MAPPER");
        _mapper = new JLabel("");
        mMapper = makeJButton("MAPPER");
        addEntryField(mapPanel, mapperLabel, _mapper, mMapper , gbc);
        
        JPanel  certSetting = new JPanel();
        GridBagLayout gb1 = new GridBagLayout();
        certSetting.setLayout(gb1);
        certSetting.setBorder(makeTitledBorder("PUBLISHER"));
        CMSAdminUtil.resetGBC(gbc);
        gbc.anchor = gbc.NORTH;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.gridheight = gbc.REMAINDER;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gb.setConstraints(certSetting, gbc);
        mCenterPanel.add(certSetting);

        CMSAdminUtil.resetGBC(gbc);
        JLabel publisherLabel = makeJLabel("PUBLISHER");
        _publisher = new JLabel("");
        mPublisher = makeJButton("PUBLISHER");
        addEntryField(certSetting, publisherLabel, _publisher, mPublisher, gbc);
    }
    
    /*==========================================================
	 * protected methods
     *==========================================================*/
     
    protected int getIndex(String value, String[] source) {
        for (int i=0; i<source.length; i++) {
            if (value.equals(source[i]))
                return i;
        }
        return -1;
    }
    
    /**
     * Add 3 components in the same row to a panel, assumed to be using
     * GridBagLayout. Customized for the LDAP certificate mappings/publishing
     * UI.
     */
    protected void addEntryField(JPanel panel, JComponent field1, 
      JComponent field2, JComponent field3, GridBagConstraints gbc) {
        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.gridx = 0;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(COMPONENT_SPACE,DIFFERENT_COMPONENT_SPACE,0,0);
        panel.add( field1, gbc );

        gbc.gridx++;
        gbc.anchor = gbc.EAST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = 1;
        gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE,0,0);
        panel.add(field2, gbc);

        gbc.gridx++;
        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.insets = new Insets(COMPONENT_SPACE,COMPONENT_SPACE,
      		                            0,DIFFERENT_COMPONENT_SPACE);
        panel.add( field3, gbc );
    }
    
}