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.websvc.core.wseditor.support;
043:
044: import java.awt.Component;
045: import java.util.Comparator;
046: import java.util.Set;
047: import java.util.TreeMap;
048: import org.netbeans.modules.websvc.api.jaxws.project.config.JaxWsModel;
049: import org.netbeans.modules.websvc.core.wseditor.spi.WSEditor;
050: import org.openide.nodes.Node;
051: import org.openide.util.NbBundle;
052:
053: /**
054: *
055: * @author Roderico Cruz
056: */
057: public class EditWSAttributesPanel extends javax.swing.JPanel {
058:
059: private static final long serialVersionUID = 1L;
060: private StringBuffer description;
061: private TreeMap<String, WSEditor> treeMap;
062:
063: /** Creates new form EditWSAttributesPanel */
064: public EditWSAttributesPanel() {
065: initComponents();
066: initComponents();
067: treeMap = new TreeMap<String, WSEditor>(
068: new AlphabeticalComparator());
069: description = new StringBuffer("");
070: descLabel.setText(NbBundle.getMessage(
071: EditWSAttributesPanel.class, "MSG_NO_EDITORS"));
072: }
073:
074: public void addTabs(Set<WSEditor> editors, Node node,
075: JaxWsModel jaxWsModel) {
076: jTabbedPane1.removeAll();
077: treeMap.clear();
078:
079: //Display tabs in alphabetical order
080: for (WSEditor editor : editors) {
081: treeMap.put(editor.getTitle(), editor);
082: }
083:
084: Set<String> titles = treeMap.keySet();
085: for (String title : titles) {
086: WSEditor editor = treeMap.get(title);
087: Component c = editor.createWSEditorComponent(node,
088: jaxWsModel);
089: jTabbedPane1.addTab(title, c);
090: String desc = editor.getDescription();
091: if (desc != null && !desc.trim().equals("")) {
092: c.getAccessibleContext().setAccessibleDescription(desc);
093: description.append(" ");
094: description.append(desc);
095: }
096: }
097: String descText = description.toString();
098: String helpText = NbBundle.getMessage(
099: EditWSAttributesPanel.class, "MSG_PRESS_F1");
100: if (!descText.equals("")) {
101: descText = "<html>" + descText + " " + helpText
102: + " </html>";
103: descLabel.setText(descText);
104: }
105: }
106:
107: class AlphabeticalComparator implements Comparator {
108: public int compare(Object obj1, Object obj2) {
109: String str1 = (String) obj1;
110: String str2 = (String) obj2;
111: return str1.toLowerCase().compareTo(str2.toLowerCase());
112: }
113: }
114:
115: /** This method is called from within the constructor to
116: * initialize the form.
117: * WARNING: Do NOT modify this code. The content of this method is
118: * always regenerated by the Form Editor.
119: */
120: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
121: private void initComponents() {
122:
123: jPanel1 = new javax.swing.JPanel();
124: descLabel = new javax.swing.JLabel();
125: jTabbedPane1 = new javax.swing.JTabbedPane();
126:
127: descLabel.setText(org.openide.util.NbBundle.getMessage(
128: EditWSAttributesPanel.class, "jLabel1.text")); // NOI18N
129: descLabel.setPreferredSize(new java.awt.Dimension(261, 16));
130:
131: org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
132: jPanel1);
133: jPanel1.setLayout(jPanel1Layout);
134: jPanel1Layout
135: .setHorizontalGroup(jPanel1Layout
136: .createParallelGroup(
137: org.jdesktop.layout.GroupLayout.LEADING)
138: .add(
139: jPanel1Layout
140: .createSequentialGroup()
141: .addContainerGap()
142: .add(
143: descLabel,
144: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
145: 597, Short.MAX_VALUE)));
146: jPanel1Layout
147: .setVerticalGroup(jPanel1Layout
148: .createParallelGroup(
149: org.jdesktop.layout.GroupLayout.LEADING)
150: .add(
151: jPanel1Layout
152: .createSequentialGroup()
153: .addContainerGap()
154: .add(
155: descLabel,
156: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
157: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
158: Short.MAX_VALUE)
159: .addContainerGap(22,
160: Short.MAX_VALUE)));
161:
162: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
163: this );
164: this .setLayout(layout);
165: layout
166: .setHorizontalGroup(layout
167: .createParallelGroup(
168: org.jdesktop.layout.GroupLayout.LEADING)
169: .add(
170: layout
171: .createSequentialGroup()
172: .add(
173: jPanel1,
174: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
175: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
176: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
177: .addContainerGap(
178: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
179: Short.MAX_VALUE))
180: .add(
181: jTabbedPane1,
182: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
183: 621, Short.MAX_VALUE));
184: layout
185: .setVerticalGroup(layout
186: .createParallelGroup(
187: org.jdesktop.layout.GroupLayout.LEADING)
188: .add(
189: layout
190: .createSequentialGroup()
191: .add(
192: jPanel1,
193: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
194: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
195: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
196: .addPreferredGap(
197: org.jdesktop.layout.LayoutStyle.RELATED)
198: .add(
199: jTabbedPane1,
200: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
201: 481, Short.MAX_VALUE)));
202: }// </editor-fold>//GEN-END:initComponents
203:
204: // Variables declaration - do not modify//GEN-BEGIN:variables
205: private javax.swing.JLabel descLabel;
206: private javax.swing.JPanel jPanel1;
207: private javax.swing.JTabbedPane jTabbedPane1;
208: // End of variables declaration//GEN-END:variables
209:
210: }
|