summaryrefslogtreecommitdiffstats
path: root/base/console/src/com/netscape/admin/certsrv/config/ProfileEditDialog.java
blob: 1d87b60fd851c6118cd3db33420b4cf977df76b5 (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
// --- 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.admin.certsrv.connection.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;

import com.netscape.management.client.util.*;
import com.netscape.certsrv.common.*;

/**
 * Policy Parameter Configuration Dialog
 *
 * @author Jack Pan-Chen
 * @version $Revision$, $Date$
 * @see com.netscape.admin.certsrv.config
 */
public class ProfileEditDialog extends CMSBaseConfigDialog
    implements ActionListener, ChangeListener
{
    protected JButton mRefresh, mOrder, mHelp;
    protected JTextField mAuthField=null,mNameField=null, mDescField=null, mConfigField=null;
    protected JLabel mVisibleLabel=null,mAuthLabel=null,mNameLabel=null, mDescLabel = null, mConfigLabel =null;
    protected JComboBox mVisibleField = null;
    protected JTable mPolicyTable=null, mInputTable=null, mOutputTable=null,
      mAuthTable=null;

    protected String mDefSetId = null;
	protected String mName = null;
    protected JTabbedPane mTabbedPane = null;
    protected JButton mPolicyEdit, mPolicyAdd, mPolicyDelete;
    protected JButton mInputEdit, mInputAdd, mInputDelete;
    protected JButton mOutputEdit, mOutputAdd, mOutputDelete;

    /*==========================================================
     * constructors
     *==========================================================*/
    public ProfileEditDialog(NameValuePairs nvp,
				JFrame parent,
				AdminConnection conn,
				String dest) {

        super(parent, dest);

		PREFIX = "PROFILEEDITDIALOG";
        mHelpToken = "configuration-certificateprofiles";
		mImplName_token = Constants.PR_POLICY_IMPL_NAME;
		mImplType   = Constants.PR_EXT_PLUGIN_IMPLTYPE_POLICY;

		init(nvp,parent,conn,dest);
        setSize(540, 440);
    }


    protected JPanel makeContentPane() {
        JPanel mListPanel = new JPanel();
        GridBagLayout gb = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();
        mListPanel.setLayout(gb);

    // 'Policy Rule ID' here
        CMSAdminUtil.resetGBC(gbc);
        mRulenameCaption = CMSAdminUtil.makeJLabel(mResource, PREFIX,
            "RULENAME", null);
        mRulenameCaption.addMouseListener(this);
        mPluginLabel = new JLabel();
        mPluginLabel.setVisible(false);
        mPluginName = new JTextField();

        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,0,0);
        mListPanel.add(mRulenameCaption, gbc);

        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,
                                 0,CMSAdminUtil.COMPONENT_SPACE);
        mListPanel.add( mPluginName, gbc );
        mListPanel.add( mPluginLabel, gbc );

        // name
        CMSAdminUtil.resetGBC(gbc);
        mNameLabel = CMSAdminUtil.makeJLabel(mResource, PREFIX,
         "NAMENAME", null);
        mNameLabel.addMouseListener(this);

        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,0,0);
        mListPanel.add( mNameLabel, gbc );

        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = gbc.REMAINDER;
        mNameField = new JTextField();
        mListPanel.add( mNameField, gbc );

        // desc
        CMSAdminUtil.resetGBC(gbc);
        mDescLabel = CMSAdminUtil.makeJLabel(mResource, PREFIX,
         "DESCNAME", null);
        mDescLabel.addMouseListener(this);

        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,0,0);
        mListPanel.add( mDescLabel, gbc );

        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = gbc.REMAINDER;
        mDescField = new JTextField();
        mListPanel.add( mDescField, gbc );

	// visible
        CMSAdminUtil.resetGBC(gbc);
        mVisibleLabel = CMSAdminUtil.makeJLabel(mResource, PREFIX,
         "VISIBLENAME", null);
        mVisibleLabel.addMouseListener(this);

        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,0,0);
        mListPanel.add( mVisibleLabel, gbc );

        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = gbc.REMAINDER;
        String[] item = {"true", "false"};
        mVisibleField = new JComboBox(item);
        mListPanel.add( mVisibleField, gbc );

	// auth
        CMSAdminUtil.resetGBC(gbc);
        mAuthLabel = CMSAdminUtil.makeJLabel(mResource, PREFIX,
         "AUTHNAME", null);
        mAuthLabel.addMouseListener(this);

        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,0,0);
        mListPanel.add( mAuthLabel, gbc );

        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = gbc.REMAINDER;
        mAuthField = new JTextField();
        mListPanel.add( mAuthField, gbc );

        // config file
/*
        CMSAdminUtil.resetGBC(gbc);
        mConfigLabel = CMSAdminUtil.makeJLabel(mResource, PREFIX,
         "CONFIGNAME", null);
        mConfigLabel.addMouseListener(this);

        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,0,0);
   //     mListPanel.add( mConfigLabel, gbc );

        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = gbc.REMAINDER;
        mConfigField = new JTextField();
    //    mListPanel.add( mConfigField, gbc );

*/

    // 'Policy Plugin ID' here
        CMSAdminUtil.resetGBC(gbc);
        mImplnameCaption = CMSAdminUtil.makeJLabel(mResource, PREFIX,
         "IMPLNAME", null);
        mImplnameCaption.addMouseListener(this);

        gbc.fill = gbc.NONE;
        gbc.weightx = 0.0;
        gbc.gridwidth = 1;
        gbc.anchor = gbc.EAST;
        gbc.insets = new Insets(CMSAdminUtil.COMPONENT_SPACE,
                                 CMSAdminUtil.COMPONENT_SPACE,0,0);
        mListPanel.add( mImplnameCaption, gbc );

        gbc.anchor = gbc.WEST;
        gbc.fill = gbc.HORIZONTAL;
        gbc.weightx = 1.0;
        gbc.gridwidth = gbc.REMAINDER;
        mImplName = new JLabel();
        mListPanel.add( mImplName, gbc );

        /* Tab */
        mTabbedPane = new JTabbedPane();
        Vector policyColNames = new Vector();
        policyColNames.addElement("Set Id");
        policyColNames.addElement("Id");
        policyColNames.addElement("Defaults");
        policyColNames.addElement("Constraints");
        Vector policyData = new Vector();
        Vector policyRow = new Vector();
        policyRow.addElement("p1");
        policyRow.addElement("p1");
        policyRow.addElement("NoDefault");
        policyRow.addElement("NoConstraint");
        policyData.addElement(policyRow);
        ProfileEditDataModel model = new ProfileEditDataModel();
        model.setInfo(policyData, policyColNames);
        mPolicyTable = new JTable(model);
        mPolicyEdit = CMSAdminUtil.makeJButton(mResource, PREFIX, "EDIT", null, this);
        mPolicyAdd = CMSAdminUtil.makeJButton(mResource, PREFIX, "ADD", null, this);
        mPolicyDelete = CMSAdminUtil.makeJButton(mResource, PREFIX, "DELETE", null, this);
        JPanel buttonPanel = createUserButtonPanel(mPolicyAdd,
          mPolicyDelete, mPolicyEdit);
        JPanel lpanel = createListPanel(mPolicyTable, buttonPanel,
          policyColNames, policyData);

        Vector inputColNames = new Vector();
        inputColNames.addElement("Id");
        inputColNames.addElement("Inputs");
        Vector inputData = new Vector();
        Vector inputRow = new Vector();
        inputRow.addElement("i1");
        inputRow.addElement("NoInput");
        inputData.addElement(inputRow);
        ProfileEditDataModel model1 = new ProfileEditDataModel();
        model1.setInfo(inputData, inputColNames);
        mInputTable = new JTable(model1);
        mInputEdit = CMSAdminUtil.makeJButton(mResource, PREFIX, "EDIT", null, this);
        mInputAdd = CMSAdminUtil.makeJButton(mResource, PREFIX, "ADD", null, this);
        mInputDelete = CMSAdminUtil.makeJButton(mResource, PREFIX, "DELETE", null, this);
        JPanel buttonPanel1 = createUserButtonPanel(mInputAdd,
          mInputDelete, mInputEdit);
        JPanel lpanel1 = createListPanel(mInputTable, buttonPanel1,
          inputColNames, inputData);

        Vector outputColNames = new Vector();
        outputColNames.addElement("Id");
        outputColNames.addElement("Outputs");
        Vector outputData = new Vector();
        Vector outputRow = new Vector();
        outputRow.addElement("i1");
        outputRow.addElement("NoOutput");
        outputData.addElement(outputRow);
        ProfileEditDataModel model2 = new ProfileEditDataModel();
        model2.setInfo(outputData, outputColNames);
        mOutputTable = new JTable(model2);
        mOutputEdit = CMSAdminUtil.makeJButton(mResource, PREFIX, "EDIT", null, this);
        mOutputAdd = CMSAdminUtil.makeJButton(mResource, PREFIX, "ADD", null, this);
        mOutputDelete = CMSAdminUtil.makeJButton(mResource, PREFIX, "DELETE",
          null , this);
        JPanel buttonPanel2 = createUserButtonPanel(mOutputAdd,
          mOutputDelete, mOutputEdit);
        JPanel lpanel2 = createListPanel(mOutputTable, buttonPanel2,
          outputColNames, outputData);

//        JPanel lpanel2 = createOutputPanel();
//        JPanel lpanel3 = createAuthPanel();
        CMSAdminUtil.resetGBC(gbc);
        gbc.fill = gbc.BOTH;
        gbc.anchor = gbc.WEST;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        mTabbedPane.addTab(mResource.getString(PREFIX+"_POLICIES_TAB"), lpanel);
        mTabbedPane.addTab(mResource.getString(PREFIX+"_INPUTS_TAB"), lpanel1);
        mTabbedPane.addTab(mResource.getString(PREFIX+"_OUTPUTS_TAB"), lpanel2);

        //mTabbedPane.addTab(mResource.getString(PREFIX+"_OUTPUTS_TAB"), lpanel2);
        //mTabbedPane.addTab(mResource.getString(PREFIX+"_AUTHS_TAB"), lpanel3);
        gb.setConstraints(mTabbedPane, gbc);
        mListPanel.add(mTabbedPane);

    /* Panel for list of plugin's parameters */
        mParamPanel = new JPanel();
/*
        mScrollPane = new JScrollPane(mParamPanel);
        mScrollPane.setBorder(CMSAdminUtil.makeEtchedBorder());
        CMSAdminUtil.resetGBC(gbc);
        gbc.fill = gbc.BOTH;
        gbc.anchor = gbc.WEST;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gb.setConstraints(mScrollPane, gbc);
        mListPanel.add(mScrollPane);
*/

    /* Panel in which to put plugin's help text */
        mHelpPanel = new JPanel();
        mHelpPanel.setBorder(CMSAdminUtil.makeEtchedBorder());
        mHelpLabel = new JTextArea(3,0);
        mHelpLabel.setLineWrap(true);
        mHelpLabel.setWrapStyleWord(true);
        mHelpLabel.setBackground(mHelpPanel.getBackground());
        mHelpLabel.setEditable(false);
        GridBagLayout gb2 = new GridBagLayout();
        GridBagConstraints gbc2 = new GridBagConstraints();

        CMSAdminUtil.resetGBC(gbc2);
        gbc2.fill = gbc.BOTH;
        gbc2.anchor = gbc.WEST;
        gbc2.gridwidth = gbc.REMAINDER;
        gbc2.weightx = 1.0;
        gbc2.weighty = 1.0;
        gb2.setConstraints(mHelpLabel, gbc2);
        mHelpPanel.setLayout(gb2);
        mHelpPanel.add(mHelpLabel);

        CMSAdminUtil.resetGBC(gbc);
        gbc.anchor = gbc.SOUTH;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.gridheight = gbc.REMAINDER;
        gbc.weightx = 1.0;
        gbc.weighty = 0.0;
        gb.setConstraints(mHelpPanel, gbc);
        mListPanel.add(mHelpPanel);
        mTabbedPane.addChangeListener(this);

        return mListPanel;
    }

    private JTable getTable() {
        int i = mTabbedPane.getSelectedIndex();
        if (i == 0) {
            return mPolicyTable;
        } else if (i == 1) {
            return mInputTable;
        } else if (i == 2) {
            return mOutputTable;
        }
        return null;
    }

    public JPanel createListPanel(JTable table, JPanel buttonPanel,
      Vector column, Vector datav)
    {
        Vector colNames = column;
        Vector data = datav;

        JPanel listPanel = new JPanel();
        GridBagLayout gb = new GridBagLayout();
        GridBagConstraints gbc = new GridBagConstraints();
        listPanel.setLayout(gb);

        //center table
        JScrollPane mScrollPane = JTable.createScrollPaneForTable(table);
        mScrollPane.setHorizontalScrollBarPolicy(mScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
        mScrollPane.setVerticalScrollBarPolicy(mScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        table.setAutoscrolls(true);
        table.sizeColumnsToFit(true);
        table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        // table.getSelectionModel().addListSelectionListener(this);
        mScrollPane.setBackground(Color.white);
        table.addMouseListener(this);

        CMSAdminUtil.resetGBC(gbc);
        gbc.anchor = gbc.NORTH;
        gbc.fill = gbc.BOTH;
        gbc.gridwidth = 1;
        gbc.weightx = 1.0;
        gbc.insets = CMSAdminUtil.DEFAULT_EMPTY_INSETS;
        gb.setConstraints(mScrollPane, gbc);
        listPanel.add(mScrollPane);

        CMSAdminUtil.resetGBC(gbc);
        gbc.anchor = gbc.NORTH;
        gbc.gridwidth = gbc.REMAINDER;
        gbc.gridheight = gbc.REMAINDER;
        gbc.weightx = 0.0;
        gbc.weighty = 1.0;
        gbc.insets = CMSAdminUtil.DEFAULT_EMPTY_INSETS;
        gb.setConstraints(buttonPanel, gbc);
        listPanel.add(buttonPanel);

        return listPanel;
    }

    protected JPanel createUserButtonPanel(JButton add, JButton delete,
      JButton edit) {
        Debug.println("CMSPluginInstanceTab::createUserButtonPanel()");
        //edit, add, delete, help buttons required
        //actionlister to this object
        JButton[] buttons = {add, delete, edit};
        JButtonFactory.resize( buttons );
        return CMSAdminUtil.makeJButtonVPanel( buttons );
    }

    public void refresh()
    {
        showDialog(null, mName);
    }

    public void stateChanged(ChangeEvent evt) {
        setProfileOtherInfo(mName);
    }

    public void actionPerformed(ActionEvent evt) {

        if (evt.getSource().equals(mHelp)) {
            CMSAdminUtil.help(mHelpToken);
        }

        if (evt.getSource().equals(mPolicyAdd)) {
            String profileId = mPluginName.getText();
            Debug.println("Add Policy");
            ProfilePolicySelectionDialog dialog =
              new ProfilePolicySelectionDialog(mDefSetId, profileId,
                "PROFILEPOLICYSELDIALOG",
                mModel.getFrame(),
                mAdminConnection,
               DestDef.DEST_REGISTRY_ADMIN, mDest);

            dialog.setModel(mModel);
            dialog.setDisplay();
            dialog.showDialog();
            refresh();
        }

        if (evt.getSource().equals(mInputAdd)) {
            String profileId = mPluginName.getText();
            Debug.println("Add Input");
            ProfileNonPolicySelDialog dialog =
              new ProfileNonPolicySelDialog(profileId,
              "PROFILEINPUTSELDIALOG", mModel.getFrame(),
              mAdminConnection, DestDef.DEST_REGISTRY_ADMIN, mDest,
              ScopeDef.SC_PROFILE_INPUT);
            dialog.setModel(mModel);
            dialog.setDisplay();
            dialog.showDialog();
            refresh();
        }

        if (evt.getSource().equals(mOutputAdd)) {
            String profileId = mPluginName.getText();
            Debug.println("Add Output");
            ProfileNonPolicySelDialog dialog =
              new ProfileNonPolicySelDialog(profileId,
              "PROFILEOUTPUTSELDIALOG", mModel.getFrame(),
              mAdminConnection, DestDef.DEST_REGISTRY_ADMIN, mDest,
              ScopeDef.SC_PROFILE_OUTPUT);
            dialog.setModel(mModel);
            dialog.setDisplay();
            dialog.showDialog();
            refresh();
        }

        if (evt.getSource().equals(mPolicyDelete)) {
            JTable table = getTable();
            if (table.getSelectedRowCount() <= 0) {
                String msg = mResource.getString(
                  PREFIX+"_DIALOG_NOPOLICY_MESSAGE");
                    CMSAdminUtil.showErrorDialog(mModel.getFrame(),
                      mResource, msg, CMSAdminUtil.ERROR_MESSAGE);
                return;
            }
            int i = CMSAdminUtil.showConfirmDialog(mParentFrame,
              mResource, PREFIX, "DELETE", CMSAdminUtil.WARNING_MESSAGE);
            if (i == JOptionPane.YES_OPTION) {
		        String policyId = (String)
                  table.getValueAt(table.getSelectedRow(), 0) + ":" +
                  table.getValueAt(table.getSelectedRow(), 1);
                try {
                    deletePolicy(mPluginName.getText().trim(),policyId);

                    ProfileEditDataModel model =
                      (ProfileEditDataModel)table.getModel();
                    model.removeRow(table.getSelectedRow());
                    table.invalidate();
                    table.validate();
                    table.repaint(1);
                } catch (EAdminException e) {
                    CMSAdminUtil.showErrorDialog(mParentFrame,
                      mResource, e.toString(), CMSAdminUtil.ERROR_MESSAGE);
                    return;
                }
                Debug.println("Deleted");
            }
        }

        if (evt.getSource().equals(mInputDelete)) {
            JTable table = getTable();
            if (table.getSelectedRowCount() <= 0) {
                String msg = mResource.getString(
                  PREFIX+"_DIALOG_NOPOLICY_MESSAGE");
                    CMSAdminUtil.showErrorDialog(mModel.getFrame(),
                      mResource, msg, CMSAdminUtil.ERROR_MESSAGE);
                return;
            }
            int i = CMSAdminUtil.showConfirmDialog(mParentFrame,
              mResource, PREFIX, "DELETE", CMSAdminUtil.WARNING_MESSAGE);
            if (i == JOptionPane.YES_OPTION) {
                String inputId = (String)
                  table.getValueAt(table.getSelectedRow(), 0);
                try {
                    deleteInput(mPluginName.getText().trim(),inputId);

                    ProfileEditDataModel model =
                      (ProfileEditDataModel)table.getModel();
                    model.removeRow(table.getSelectedRow());
                    table.invalidate();
                    table.validate();
                    table.repaint(1);
                } catch (EAdminException e) {
                    CMSAdminUtil.showErrorDialog(mParentFrame,
                      mResource, e.toString(), CMSAdminUtil.ERROR_MESSAGE);
                    return;
                }
                Debug.println("Deleted");
            }
        }

        if (evt.getSource().equals(mOutputDelete)) {
            JTable table = getTable();
            if (table.getSelectedRowCount() <= 0) {
                String msg = mResource.getString(
                  PREFIX+"_DIALOG_NOPOLICY_MESSAGE");
                    CMSAdminUtil.showErrorDialog(mModel.getFrame(),
                      mResource, msg, CMSAdminUtil.ERROR_MESSAGE);
                return;
            }
            int i = CMSAdminUtil.showConfirmDialog(mParentFrame,
              mResource, PREFIX, "DELETE", CMSAdminUtil.WARNING_MESSAGE);
            if (i == JOptionPane.YES_OPTION) {
                String outputId = (String)
                  table.getValueAt(table.getSelectedRow(), 0);
                try {
                    deleteOutput(mPluginName.getText().trim(),outputId);

                    ProfileEditDataModel model =
                      (ProfileEditDataModel)table.getModel();
                    model.removeRow(table.getSelectedRow());
                    table.invalidate();
                    table.validate();
                    table.repaint(1);
                } catch (EAdminException e) {
                    CMSAdminUtil.showErrorDialog(mParentFrame,
                      mResource, e.toString(), CMSAdminUtil.ERROR_MESSAGE);
                    return;
                }
                Debug.println("Deleted");
            }
        }

        if (evt.getSource().equals(mPolicyEdit)) {
            JTable table = getTable();
            // pick selected entry
            if (table.getSelectedRowCount() <= 0) {
                CMSAdminUtil.showErrorDialog(mModel.getFrame(),
                  mResource,
                  "You must select a policy first",
                  CMSAdminUtil.ERROR_MESSAGE);
			    return;
            }
            String policyId = (String)
              table.getValueAt(table.getSelectedRow(), 0) + ":" +
              table.getValueAt(table.getSelectedRow(), 1);

            Debug.println("Edit");
            NameValuePairs nvp = new NameValuePairs();
            ProfilePolicyEditDialog dialog =
              new ProfilePolicyEditDialog(nvp,
              mModel.getFrame(),
              mAdminConnection,
            //  DestDef.DEST_CA_PROFILE_ADMIN);
              mDest);
            dialog.setModel(mModel);

            String name = mPluginName.getText() + ";" + policyId;
	        Debug.println(" XXXX name=" + name);
            dialog.showDialog(null, name);
        }

        if (evt.getSource().equals(mInputEdit)) {
            JTable table = getTable();
            // pick selected entry
            if (table.getSelectedRowCount() <= 0) {
                CMSAdminUtil.showErrorDialog(mModel.getFrame(),
                  mResource,
                  "You must select an input first",
                  CMSAdminUtil.ERROR_MESSAGE);
                            return;
            }
            String inputId = (String)
              table.getValueAt(table.getSelectedRow(), 0);

            Debug.println("Edit input");
            NameValuePairs nvp = new NameValuePairs();
            ProfileNonPolicyNewDialog dialog =
              new ProfileNonPolicyNewDialog(nvp,
              mModel.getFrame(),
              mAdminConnection,
              //DestDef.DEST_CA_PROFILE_ADMIN,
              mDest,
              ScopeDef.SC_PROFILE_INPUT_CONFIG, false);
            dialog.setModel(mModel);

            String name = mPluginName.getText() + ";" + inputId;
                Debug.println(" XXXX name=" + name);
            dialog.showDialog(null, mPluginName.getText().trim(), inputId);
        }

        if (evt.getSource().equals(mOutputEdit)) {
            JTable table = getTable();
            // pick selected entry
            if (table.getSelectedRowCount() <= 0) {
                CMSAdminUtil.showErrorDialog(mModel.getFrame(),
                  mResource,
                  "You must select an output first",
                  CMSAdminUtil.ERROR_MESSAGE);
                            return;
            }
            String outputId = (String)
              table.getValueAt(table.getSelectedRow(), 0);

            Debug.println("Edit output");
            NameValuePairs nvp = new NameValuePairs();
            ProfileNonPolicyNewDialog dialog =
              new ProfileNonPolicyNewDialog(nvp,
              mModel.getFrame(),
              mAdminConnection,
             // DestDef.DEST_CA_PROFILE_ADMIN,
              mDest,
              ScopeDef.SC_PROFILE_OUTPUT_CONFIG, false);
            dialog.setModel(mModel);

            String name = mPluginName.getText() + ";" + outputId;
                Debug.println(" XXXX name=" + name);
            dialog.showDialog(null, mPluginName.getText().trim(), outputId);
        }

        if (evt.getSource().equals(mOK)) {

            NameValuePairs nvp = new NameValuePairs();
            try {
                if (mModel != null)
                    mModel.progressStart();

                String instanceName = mPluginName.getText();
                nvp.put("impl", mImplName.getText());
                nvp.put("name", mNameField.getText());
                nvp.put("desc", mDescField.getText());
                nvp.put("visible", (String) (mVisibleField.getSelectedItem()));
                nvp.put("auth", mAuthField.getText());
        //      nvp.add("config", mConfigField.getText());

/*
         //       mAdminConnection.add(DestDef.DEST_CA_PROFILE_ADMIN,
                  ScopeDef.SC_PROFILE_RULES, instanceName, nvp);
*/
                //DestDef.DEST_CA_PROFILE_ADMIN,
                mAdminConnection.modify(mDest,
                  ScopeDef.SC_PROFILE_RULES, instanceName, nvp);

                mIsOK = true;
                if (mModel != null)
                    mModel.progressStop();
                this.dispose();
            } catch (EAdminException ex) {
                mModel.progressStop();
                CMSAdminUtil.showErrorDialog(mParentFrame, mResource,
                        ex.toString(),CMSAdminUtil.ERROR_MESSAGE);
            }
        }

        if (evt.getSource().equals(mCancel)) {
            this.dispose();
        }

    }

    private void deletePolicy(String profileId, String policyId)
      throws EAdminException{
        NameValuePairs nvps = new NameValuePairs();
        nvps.put("POLICYID", policyId);
        //mAdminConnection.delete(DestDef.DEST_CA_PROFILE_ADMIN,
        mAdminConnection.delete(mDest,
          ScopeDef.SC_PROFILE_POLICIES, profileId, nvps);
    }

    private void deleteInput(String profileId, String inputId)
      throws EAdminException{
        NameValuePairs nvps = new NameValuePairs();
        nvps.put("INPUTID", inputId);
        //mAdminConnection.delete(DestDef.DEST_CA_PROFILE_ADMIN,
        mAdminConnection.delete(mDest,
          ScopeDef.SC_PROFILE_INPUT, profileId, nvps);
    }

    private void deleteOutput(String profileId, String outputId)
      throws EAdminException{
        NameValuePairs nvps = new NameValuePairs();
        nvps.put("OUTPUTID", outputId);
        //mAdminConnection.delete(DestDef.DEST_CA_PROFILE_ADMIN,
        mAdminConnection.delete(mDest,
          ScopeDef.SC_PROFILE_OUTPUT, profileId, nvps);
    }

    public void showDialog(NameValuePairs data, String name) {

        mName = name;
        setProfileInfo(name);
        setProfileOtherInfo(name);

        this.show();
    }

    private void setProfileInfo(String name) {
        mModel.progressStart();

        // retrieve profile information
        NameValuePairs response = null;
        NameValuePairs request = new NameValuePairs();
        try {
            //response = mAdminConnection.read(DestDef.DEST_CA_PROFILE_ADMIN,
            response = mAdminConnection.read(mDest,
                             ScopeDef.SC_PROFILE_RULES,
                             name, request);
        } catch (EAdminException e) {
//          CMSAdminUtil.showErrorDialog(mParentFrame, mResource, e.toString());
            mModel.progressStop();
        }
        mModel.progressStop();

            String enable = response.get("enable");

	    if (response != null) {
		mPluginName.setEnabled(false);
                mPluginName.setBackground(getBackground());
        	mPluginName.setText(name);
		mNameField.setText(response.get("name"));
		mDescField.setText(response.get("desc"));
		mAuthField.setText(response.get("auth"));
		mVisibleField.setSelectedItem(response.get("visible"));
		mImplName.setText(response.get("plugin"));
 //     		mConfigField.setText(response.getValue("config"));
	    }
            if (enable != null && enable.equals("true")) {
               // disable everything
        	mNameField.setEnabled(false);
      		mDescField.setEnabled(false);
      		mAuthField.setEnabled(false);
      		mVisibleField.setEnabled(false);
      		mImplName.setEnabled(false);

                mPolicyEdit.setEnabled(false);
                mPolicyAdd.setEnabled(false);
                mPolicyDelete.setEnabled(false);

                mInputEdit.setEnabled(false);
                mInputAdd.setEnabled(false);
                mInputDelete.setEnabled(false);

                mOutputEdit.setEnabled(false);
                mOutputAdd.setEnabled(false);
                mOutputDelete.setEnabled(false);
            }
    }

    private void setProfileOtherInfo(String name) {
        if (mModel != null)
            mModel.progressStart();
        JTable table = getTable();
        NameValuePairs request = new NameValuePairs();
        NameValuePairs response = null;
        if (table == mPolicyTable) {
            try {
                response = mAdminConnection.read(
                  mDest,
                  ScopeDef.SC_PROFILE_POLICIES, name, request);
            } catch (EAdminException e) {
              CMSAdminUtil.showErrorDialog(mParentFrame, mResource,
                  e.toString(), CMSAdminUtil.ERROR_MESSAGE);
                if (mModel != null)
                    mModel.progressStop();
                return;
            }

            if (mModel != null)
                mModel.progressStop();
            if (response != null) {
              populatePolicies(response, table);
            }
        } else if (table == mInputTable) {
            try {
                response = mAdminConnection.read(
                  mDest,
                  ScopeDef.SC_PROFILE_INPUT, name, request);
            } catch (EAdminException e) {
              CMSAdminUtil.showErrorDialog(mParentFrame, mResource,
                  e.toString(), CMSAdminUtil.ERROR_MESSAGE);
                if (mModel != null)
                    mModel.progressStop();
                return;
            }

            if (mModel != null)
                mModel.progressStop();
            if (response != null) {
              populateNonPolicy(response, table);
            }
        } else if (table == mOutputTable) {
            try {
                response = mAdminConnection.read(
                  mDest,
                  ScopeDef.SC_PROFILE_OUTPUT, name, request);
            } catch (EAdminException e) {
              CMSAdminUtil.showErrorDialog(mParentFrame, mResource,
                  e.toString(), CMSAdminUtil.ERROR_MESSAGE);
                if (mModel != null)
                    mModel.progressStop();
                return;
            }

            if (mModel != null)
                mModel.progressStop();
            if (response != null) {
              populateNonPolicy(response, table);
            }
        } else {
            // do nothing
        }
    }

    private void populatePolicies(NameValuePairs response, JTable table) {
        Vector<String> colNames = new Vector<String>();
        colNames.addElement("Set Id");
        colNames.addElement("Id");
        colNames.addElement("Defaults");
        colNames.addElement("Constraints");
        Vector<Vector<String>> d = new Vector<Vector<String>>();

        for (String entry : response.keySet()) {
            entry = entry.trim();
            String value = response.get(entry);
            Debug.println("populatePolicies entry= "+entry);
            Debug.println("populatePolicies value= "+value);

            StringTokenizer st = new StringTokenizer(value, ";");
            String def = st.nextToken();
            String con = st.nextToken();
            Vector<String> row = new Vector<String>();

            StringTokenizer st1 = new StringTokenizer(entry, ":");
            String setId = st1.nextToken();
            String id = st1.nextToken();

            if (mDefSetId == null) {
              mDefSetId = setId;
            }
            row.addElement(setId);
            row.addElement(id);
            row.addElement(def);
            row.addElement(con);
            d.addElement(row);
        }
        ProfileEditDataModel model = new ProfileEditDataModel();
        model.setInfo(d, colNames);
        table.setModel(model);
    }

    private void populateNonPolicy(NameValuePairs response, JTable table) {
        Vector<String> colNames = new Vector<String>();
        colNames.addElement("Id");
        if (table == mInputTable)
            colNames.addElement("Inputs");
        else if (table == mOutputTable)
            colNames.addElement("Outputs");
        Vector<Vector<String>> d = new Vector<Vector<String>>();

        for (String entry : response.keySet()) {
            entry = entry.trim();
            String value = response.get(entry);
            Debug.println("populateNonPolicy entry= " + entry);
            Debug.println("populateNonPolicy value= " + value);

            Vector<String> row = new Vector<String>();
            row.addElement(entry);
            row.addElement(value);
            d.addElement(row);
        }
        ProfileEditDataModel model = new ProfileEditDataModel();
        model.setInfo(d, colNames);
        table.setModel(model);
    }
}