KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > catalog > ModuleEnableDisablePanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.autoupdate.catalog;
21
22 import java.awt.BorderLayout JavaDoc;
23 import java.awt.Component JavaDoc;
24 import java.awt.Font JavaDoc;
25 import java.util.HashSet JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Set JavaDoc;
29 import java.util.SortedSet JavaDoc;
30 import java.util.TreeSet JavaDoc;
31 import javax.swing.*;
32
33 import org.netbeans.Module;
34 import org.netbeans.ModuleManager;
35 import org.openide.util.NbBundle;
36
37 /** XXX
38  * @author Jiri Rechtacek
39  * @see "#20323"
40  */

41 class ModuleEnableDisablePanel extends JPanel {
42     Set JavaDoc/*<Module>*/ explicit;
43     Set JavaDoc/*<Module>*/ modules;
44     private boolean toEnable;
45     
46     public ModuleEnableDisablePanel (boolean enable, Set JavaDoc/*Module*/ explicit, Set JavaDoc/*Module*/ implied) {
47         this.explicit = explicit;
48         this.modules = implied;
49         this.toEnable = enable;
50         initComponents ();
51         postInitComponents ();
52     }
53     
54     private void initComponents() {//GEN-BEGIN:initComponents
55
jPanel1 = new javax.swing.JPanel JavaDoc();
56         enableDisableConfirmation = new javax.swing.JLabel JavaDoc();
57
58         setLayout(new java.awt.BorderLayout JavaDoc(0, 2));
59
60         add(jPanel1, java.awt.BorderLayout.CENTER);
61
62         enableDisableConfirmation.setText(org.openide.util.NbBundle.getMessage(ModuleEnableDisablePanel.class, "LBL_ModuleEnableDisablePanel_EnableConfirmation", new Object JavaDoc[] {}));
63         add(enableDisableConfirmation, java.awt.BorderLayout.SOUTH);
64
65     }//GEN-END:initComponents
66

67     
68     // Variables declaration - do not modify//GEN-BEGIN:variables
69
private javax.swing.JLabel JavaDoc enableDisableConfirmation;
70     private javax.swing.JPanel JavaDoc jPanel1;
71     // End of variables declaration//GEN-END:variables
72

73     private String JavaDoc getModuleNames () {
74         return explicit.size () == 1 ? ((Module) explicit.iterator ().next ()).getDisplayName () :
75                     NbBundle.getMessage (ModuleUninstallPanel.class, "CTL_ModuleNodeActions_UninstallAction_many"); // NOI18N
76
}
77     
78     private void postInitComponents () {
79         
80     String JavaDoc enableDisableText;
81         
82         if (toEnable) {
83             enableDisableText = NbBundle.getMessage(ModuleEnableDisablePanel.class, "LBL_ModuleEnableDisablePanel_EnableLabel", new Object JavaDoc[] {getModuleNames ()});
84             enableDisableConfirmation.setText(org.openide.util.NbBundle.getMessage(ModuleEnableDisablePanel.class, "LBL_ModuleEnableDisablePanel_EnableConfirmation", new Object JavaDoc[] {}));
85         } else {
86             enableDisableText = NbBundle.getMessage(ModuleEnableDisablePanel.class, "LBL_ModuleEnableDisablePanel_DisableLabel", new Object JavaDoc[] {getModuleNames ()});
87             enableDisableConfirmation.setText(org.openide.util.NbBundle.getMessage(ModuleEnableDisablePanel.class, "LBL_ModuleEnableDisablePanel_DisableConfirmation", new Object JavaDoc[] {}));
88         }
89         
90         Component JavaDoc c = new ModulesAndDescription ((Module []) modules.toArray (new Module [modules.size ()]), enableDisableText);
91         add (c, BorderLayout.CENTER);
92     }
93     
94 }
95
Popular Tags