001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.apisupport.project.ui.platform;
043:
044: import java.awt.EventQueue;
045: import javax.swing.DefaultListModel;
046: import javax.swing.JPanel;
047: import javax.swing.ListModel;
048: import org.netbeans.modules.apisupport.project.universe.ModuleEntry;
049: import org.netbeans.modules.apisupport.project.universe.NbPlatform;
050: import org.openide.util.NbBundle;
051: import org.openide.util.RequestProcessor;
052:
053: /**
054: * Represents <em>Modules</em> tab in the NetBeans platforms customizer.
055: *
056: * @author Martin Krauskopf
057: */
058: final class NbPlatformCustomizerModules extends JPanel {
059:
060: /** Creates new form NbPlatformCustomizerModules */
061: NbPlatformCustomizerModules() {
062: initComponents();
063: initAccessibility();
064: }
065:
066: void setPlatform(final NbPlatform plaf) {
067: moduleList.setModel(createWaitModel());
068: RequestProcessor.getDefault().post(new Runnable() {
069: public void run() {
070: final ModuleEntry[] modules = plaf.getModules();
071: EventQueue.invokeLater(new Runnable() {
072: public void run() {
073: moduleList
074: .setModel(new PlatformComponentFactory.ModuleEntryListModel(
075: modules));
076: }
077: });
078: }
079: });
080: }
081:
082: void reset() {
083: moduleList.setModel(new DefaultListModel());
084: }
085:
086: /** This method is called from within the constructor to
087: * initialize the form.
088: * WARNING: Do NOT modify this code. The content of this method is
089: * always regenerated by the Form Editor.
090: */
091: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
092: private void initComponents() {
093: java.awt.GridBagConstraints gridBagConstraints;
094:
095: moduleLabel = new javax.swing.JLabel();
096: moduleSP = new javax.swing.JScrollPane();
097: moduleList = new javax.swing.JList();
098:
099: setLayout(new java.awt.GridBagLayout());
100:
101: setBorder(new javax.swing.border.EmptyBorder(
102: new java.awt.Insets(12, 12, 12, 12)));
103: moduleLabel.setLabelFor(moduleList);
104: org.openide.awt.Mnemonics.setLocalizedText(moduleLabel,
105: org.openide.util.NbBundle.getMessage(
106: NbPlatformCustomizerModules.class,
107: "LBL_PlatformModules"));
108: gridBagConstraints = new java.awt.GridBagConstraints();
109: gridBagConstraints.gridx = 0;
110: gridBagConstraints.gridy = 0;
111: gridBagConstraints.gridwidth = 2;
112: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
113: add(moduleLabel, gridBagConstraints);
114:
115: moduleList
116: .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
117: moduleSP.setViewportView(moduleList);
118:
119: gridBagConstraints = new java.awt.GridBagConstraints();
120: gridBagConstraints.gridx = 0;
121: gridBagConstraints.gridy = 1;
122: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
123: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
124: gridBagConstraints.weightx = 1.0;
125: gridBagConstraints.weighty = 1.0;
126: add(moduleSP, gridBagConstraints);
127:
128: }
129:
130: // </editor-fold>//GEN-END:initComponents
131:
132: // Variables declaration - do not modify//GEN-BEGIN:variables
133: private javax.swing.JLabel moduleLabel;
134: private javax.swing.JList moduleList;
135: private javax.swing.JScrollPane moduleSP;
136:
137: // End of variables declaration//GEN-END:variables
138:
139: private void initAccessibility() {
140: moduleList.getAccessibleContext().setAccessibleDescription(
141: getMessage("ACS_CTL_moduleList"));
142: }
143:
144: private String getMessage(String key) {
145: return NbBundle.getMessage(NbPlatformCustomizerJavadoc.class,
146: key);
147: }
148:
149: private ListModel createWaitModel() {
150: DefaultListModel waitModel = new DefaultListModel();
151: waitModel.addElement(NbBundle.getMessage(
152: NbPlatformCustomizerModules.class, "LBL_PleaseWait")); // NOI18N
153: return waitModel;
154: }
155:
156: }
|