Merge the two combo boxes together into a single tree-style combo box.
1.1 --- a/j2ee.blueprints/src/org/netbeans/modules/j2ee/blueprints/ui/BluePrintsPanel.form Fri Dec 03 20:01:38 2004 +0000
1.2 +++ b/j2ee.blueprints/src/org/netbeans/modules/j2ee/blueprints/ui/BluePrintsPanel.form Fri Dec 03 20:54:18 2004 +0000
1.3 @@ -124,9 +124,7 @@
1.4 </Constraint>
1.5 </Constraints>
1.6
1.7 - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
1.8 - <Property name="alignment" type="int" value="0"/>
1.9 - </Layout>
1.10 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
1.11 <SubComponents>
1.12 <Component class="javax.swing.JButton" name="backBtn">
1.13 <Properties>
1.14 @@ -140,6 +138,11 @@
1.15 <ResourceString bundle="org/netbeans/modules/j2ee/blueprints/ui/Bundle.properties" key="backBtn" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
1.16 </Property>
1.17 </Properties>
1.18 + <Constraints>
1.19 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
1.20 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="5" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
1.21 + </Constraint>
1.22 + </Constraints>
1.23 </Component>
1.24 <Component class="javax.swing.JButton" name="forwardBtn">
1.25 <Properties>
1.26 @@ -153,29 +156,27 @@
1.27 <ResourceString bundle="org/netbeans/modules/j2ee/blueprints/ui/Bundle.properties" key="forwardBtn" replaceFormat="java.util.ResourceBundle.getBundle("{bundleNameSlashes}").getString("{key}")"/>
1.28 </Property>
1.29 </Properties>
1.30 + <Constraints>
1.31 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
1.32 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="5" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
1.33 + </Constraint>
1.34 + </Constraints>
1.35 </Component>
1.36 - <Component class="javax.swing.JComboBox" name="categoryCbx">
1.37 + <Component class="javax.swing.JComboBox" name="entryCbx">
1.38 <Properties>
1.39 <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
1.40 <Font name="Dialog" size="12" style="0"/>
1.41 </Property>
1.42 - <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
1.43 - <StringArray count="0"/>
1.44 - </Property>
1.45 + <Property name="maximumRowCount" type="int" value="16"/>
1.46 </Properties>
1.47 <Events>
1.48 - <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="categoryCbxItemStateChanged"/>
1.49 + <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="entryCbxItemStateChanged"/>
1.50 </Events>
1.51 - </Component>
1.52 - <Component class="javax.swing.JComboBox" name="articleCbx">
1.53 - <Properties>
1.54 - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
1.55 - <Font name="Dialog" size="12" style="0"/>
1.56 - </Property>
1.57 - </Properties>
1.58 - <Events>
1.59 - <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="articleCbxItemStateChanged"/>
1.60 - </Events>
1.61 + <Constraints>
1.62 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
1.63 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="5" insetsBottom="0" insetsRight="5" anchor="17" weightX="1.0" weightY="0.0"/>
1.64 + </Constraint>
1.65 + </Constraints>
1.66 </Component>
1.67 </SubComponents>
1.68 </Container>
2.1 --- a/j2ee.blueprints/src/org/netbeans/modules/j2ee/blueprints/ui/BluePrintsPanel.java Fri Dec 03 20:01:38 2004 +0000
2.2 +++ b/j2ee.blueprints/src/org/netbeans/modules/j2ee/blueprints/ui/BluePrintsPanel.java Fri Dec 03 20:54:18 2004 +0000
2.3 @@ -27,6 +27,7 @@
2.4 import java.io.IOException;
2.5 import java.io.InputStream;
2.6 import java.net.URL;
2.7 +import java.util.ArrayList;
2.8 import java.util.Hashtable;
2.9 import java.util.ResourceBundle;
2.10 import javax.swing.ComboBoxModel;
2.11 @@ -38,6 +39,7 @@
2.12 import javax.swing.JOptionPane;
2.13 import javax.swing.JScrollPane;
2.14 import javax.swing.SwingUtilities;
2.15 +import javax.swing.border.EmptyBorder;
2.16 import javax.swing.text.BadLocationException;
2.17 import javax.swing.text.html.HTMLEditorKit;
2.18 import org.netbeans.modules.j2ee.blueprints.catalog.SolutionsCatalog;
2.19 @@ -61,10 +63,10 @@
2.20 * The user can browse categories and articles, design documents and
2.21 * launch a wizard to create new projects from a template.
2.22 *
2.23 + * @author Mark Roth
2.24 + * @author Yutaka Yoshida
2.25 + * @author Ludo
2.26 * @author Richard Gregor
2.27 - * @author Ludo
2.28 - * @author Yutaka Yoshida
2.29 - * @author Mark Roth
2.30 */
2.31 public class BluePrintsPanel extends javax.swing.JPanel {
2.32 private static final String UI_RESOURCES_URL =
2.33 @@ -89,7 +91,7 @@
2.34 public BluePrintsPanel() {
2.35 initComponents();
2.36 tabbedPnl.removeAll();
2.37 - initComboBoxes();
2.38 + initComboBox();
2.39 }
2.40
2.41 /** This method is called from within the constructor to
2.42 @@ -109,8 +111,7 @@
2.43 toolbarPanel = new javax.swing.JPanel();
2.44 backBtn = new javax.swing.JButton();
2.45 forwardBtn = new javax.swing.JButton();
2.46 - categoryCbx = new javax.swing.JComboBox();
2.47 - articleCbx = new javax.swing.JComboBox();
2.48 + entryCbx = new javax.swing.JComboBox();
2.49 tabbedPnl = new javax.swing.JTabbedPane();
2.50 categoryScroll = new javax.swing.JScrollPane();
2.51 categoryText = new javax.swing.JTextPane();
2.52 @@ -171,36 +172,39 @@
2.53 gridBagConstraints.insets = new java.awt.Insets(12, 12, 7, 12);
2.54 add(titlePanel, gridBagConstraints);
2.55
2.56 - toolbarPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
2.57 + toolbarPanel.setLayout(new java.awt.GridBagLayout());
2.58
2.59 toolbarPanel.setOpaque(false);
2.60 backBtn.setFont(new java.awt.Font("Dialog", 0, 12));
2.61 backBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/j2ee/blueprints/ui/resources/back.gif")));
2.62 backBtn.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/blueprints/ui/Bundle").getString("backBtn"));
2.63 - toolbarPanel.add(backBtn);
2.64 + gridBagConstraints = new java.awt.GridBagConstraints();
2.65 + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
2.66 + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
2.67 + toolbarPanel.add(backBtn, gridBagConstraints);
2.68
2.69 forwardBtn.setFont(new java.awt.Font("Dialog", 0, 12));
2.70 forwardBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/j2ee/blueprints/ui/resources/forward.gif")));
2.71 forwardBtn.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/blueprints/ui/Bundle").getString("forwardBtn"));
2.72 - toolbarPanel.add(forwardBtn);
2.73 + gridBagConstraints = new java.awt.GridBagConstraints();
2.74 + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
2.75 + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 0);
2.76 + toolbarPanel.add(forwardBtn, gridBagConstraints);
2.77
2.78 - categoryCbx.setFont(new java.awt.Font("Dialog", 0, 12));
2.79 - categoryCbx.addItemListener(new java.awt.event.ItemListener() {
2.80 + entryCbx.setFont(new java.awt.Font("Dialog", 0, 12));
2.81 + entryCbx.setMaximumRowCount(16);
2.82 + entryCbx.addItemListener(new java.awt.event.ItemListener() {
2.83 public void itemStateChanged(java.awt.event.ItemEvent evt) {
2.84 - categoryCbxItemStateChanged(evt);
2.85 + entryCbxItemStateChanged(evt);
2.86 }
2.87 });
2.88
2.89 - toolbarPanel.add(categoryCbx);
2.90 -
2.91 - articleCbx.setFont(new java.awt.Font("Dialog", 0, 12));
2.92 - articleCbx.addItemListener(new java.awt.event.ItemListener() {
2.93 - public void itemStateChanged(java.awt.event.ItemEvent evt) {
2.94 - articleCbxItemStateChanged(evt);
2.95 - }
2.96 - });
2.97 -
2.98 - toolbarPanel.add(articleCbx);
2.99 + gridBagConstraints = new java.awt.GridBagConstraints();
2.100 + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
2.101 + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
2.102 + gridBagConstraints.weightx = 1.0;
2.103 + gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
2.104 + toolbarPanel.add(entryCbx, gridBagConstraints);
2.105
2.106 gridBagConstraints = new java.awt.GridBagConstraints();
2.107 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
2.108 @@ -260,26 +264,21 @@
2.109
2.110 }//GEN-END:initComponents
2.111
2.112 + private void entryCbxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_entryCbxItemStateChanged
2.113 + selectNewEntry();
2.114 + }//GEN-LAST:event_entryCbxItemStateChanged
2.115 +
2.116 private void installBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installBtnActionPerformed
2.117 installExample();
2.118 }//GEN-LAST:event_installBtnActionPerformed
2.119 -
2.120 - private void articleCbxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_articleCbxItemStateChanged
2.121 - selectNewArticle();
2.122 - }//GEN-LAST:event_articleCbxItemStateChanged
2.123 -
2.124 - private void categoryCbxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_categoryCbxItemStateChanged
2.125 - selectNewCategory();
2.126 - }//GEN-LAST:event_categoryCbxItemStateChanged
2.127
2.128
2.129 // Variables declaration - do not modify//GEN-BEGIN:variables
2.130 - private javax.swing.JComboBox articleCbx;
2.131 private javax.swing.JButton backBtn;
2.132 - private javax.swing.JComboBox categoryCbx;
2.133 private javax.swing.JScrollPane categoryScroll;
2.134 private javax.swing.JTextPane categoryText;
2.135 private javax.swing.JPanel designBrowser;
2.136 + private javax.swing.JComboBox entryCbx;
2.137 private javax.swing.JPanel examplePnl;
2.138 private javax.swing.JButton forwardBtn;
2.139 private javax.swing.JButton installBtn;
2.140 @@ -296,30 +295,32 @@
2.141 // End of variables declaration//GEN-END:variables
2.142
2.143 public Category getSelectedCategory() {
2.144 - return (Category)categoryCbx.getSelectedItem();
2.145 + Object entry = entryCbx.getSelectedItem();
2.146 + if(!(entry instanceof Category)) {
2.147 + // Scan up the list until we hit a category
2.148 + int index = entryCbx.getSelectedIndex();
2.149 + do {
2.150 + index--;
2.151 + entry = entryCbx.getItemAt(index);
2.152 + } while((index > 0) && !(entry instanceof Category));
2.153 + }
2.154 + return (Category)entry;
2.155 }
2.156
2.157 public Example getSelectedArticle() {
2.158 - return (Example)articleCbx.getSelectedItem();
2.159 + Object entry = entryCbx.getSelectedItem();
2.160 + return (entry instanceof Example) ? (Example)entry : null;
2.161 }
2.162
2.163 - private void initComboBoxes() {
2.164 + private void initComboBox() {
2.165 // Set up combo boxes:
2.166 - categoryCbx.setRenderer(new CategoryListCellRenderer());
2.167 - articleCbx.setRenderer(new ArticleListCellRenderer());
2.168 - categoryCbx.setModel(new CategoryComboBoxModel());
2.169 - categoryCbx.setSelectedIndex(0);
2.170 + entryCbx.setRenderer(new EntryListCellRenderer());
2.171 + entryCbx.setModel(new EntryComboBoxModel());
2.172 + entryCbx.setSelectedIndex(0);
2.173 updateTabs();
2.174 }
2.175
2.176 - private void selectNewCategory() {
2.177 - Category category = getSelectedCategory();
2.178 - articleCbx.setModel(new ArticleComboBoxModel(category));
2.179 - articleCbx.setSelectedIndex(-1);
2.180 - updateTabs();
2.181 - }
2.182 -
2.183 - private void selectNewArticle() {
2.184 + private void selectNewEntry() {
2.185 updateTabs();
2.186 }
2.187
2.188 @@ -478,40 +479,57 @@
2.189 }
2.190
2.191 /**
2.192 - * Backing model for the category drop-down.
2.193 + * Backing model for the entry drop-down.
2.194 * Gets its data from demo.xml.
2.195 */
2.196 - private class CategoryComboBoxModel
2.197 + private class EntryComboBoxModel
2.198 extends DefaultComboBoxModel
2.199 {
2.200 private Demo demo;
2.201 + private ArrayList entries = new ArrayList();
2.202
2.203 - public CategoryComboBoxModel() {
2.204 + public EntryComboBoxModel() {
2.205 this.demo = solutionsCatalog.getDemoXml();
2.206 + Category[] categories = demo.getCategory();
2.207 + for(int categoryNum = 0; categoryNum < categories.length;
2.208 + categoryNum++)
2.209 + {
2.210 + entries.add(categories[categoryNum]);
2.211 + Example[] examples = categories[categoryNum].getExample();
2.212 + for(int exampleNum = 0; exampleNum < examples.length;
2.213 + exampleNum++)
2.214 + {
2.215 + entries.add(examples[exampleNum]);
2.216 + }
2.217 + }
2.218 }
2.219
2.220 public int getSize() {
2.221 - return demo.getCategory().length;
2.222 + return entries.size();
2.223 }
2.224
2.225 public Object getElementAt(int index) {
2.226 - return demo.getCategory(index);
2.227 + return entries.get(index);
2.228 }
2.229 }
2.230
2.231 /**
2.232 - * Cell renderer for the category drop-down
2.233 + * Cell renderer for the entry drop-down
2.234 *
2.235 * Adds an icon and changes the text of the cell to match the name of
2.236 - * the category.
2.237 + * the category or article.
2.238 */
2.239 - private static class CategoryListCellRenderer
2.240 + private static class EntryListCellRenderer
2.241 extends DefaultListCellRenderer
2.242 {
2.243 - private ImageIcon icon;
2.244 + private ImageIcon categoryIcon;
2.245 + private ImageIcon articleIcon;
2.246
2.247 - public CategoryListCellRenderer() {
2.248 - this.icon = new ImageIcon(getClass().getResource(ICON_CATEGORY));
2.249 + public EntryListCellRenderer() {
2.250 + this.categoryIcon = new ImageIcon(getClass().getResource(
2.251 + ICON_CATEGORY));
2.252 + this.articleIcon = new ImageIcon(getClass().getResource(
2.253 + ICON_ARTICLE));
2.254 }
2.255
2.256 public Component getListCellRendererComponent(JList list,
2.257 @@ -520,89 +538,21 @@
2.258 Component result = super.getListCellRendererComponent(list, value,
2.259 index, isSelected, cellHasFocus);
2.260 JLabel label = (JLabel)result;
2.261 - label.setIcon(icon);
2.262 - Category category = (Category)value;
2.263 - if(category != null) {
2.264 + if(value instanceof Category) {
2.265 + Category category = (Category)value;
2.266 + label.setIcon(categoryIcon);
2.267 label.setText(category.getName(0));
2.268 }
2.269 - else {
2.270 - label.setText(bundle.getString("chooseCategory")); // NOI18N
2.271 + else if(value instanceof Example) {
2.272 + Example example = (Example)value;
2.273 + label.setIcon(articleIcon);
2.274 + label.setText(example.getName(0));
2.275 + // Tab the articles so they look like they're in the category
2.276 + label.setBorder(new EmptyBorder(0, 19, 0, 0));
2.277 }
2.278 return result;
2.279 }
2.280 }
2.281 -
2.282 - /**
2.283 - * Backing model for the article drop-down.
2.284 - * Gets its data from demo.xml.
2.285 - */
2.286 - private class ArticleComboBoxModel
2.287 - extends DefaultComboBoxModel
2.288 - {
2.289 - private Category category;
2.290 -
2.291 - public ArticleComboBoxModel(Category category) {
2.292 - this.category = category;
2.293 - }
2.294 -
2.295 - public int getSize() {
2.296 - return category.getExample().length;
2.297 - }
2.298 -
2.299 - public Object getElementAt(int index) {
2.300 - return category.getExample(index);
2.301 - }
2.302 - }
2.303 -
2.304 - /**
2.305 - * Cell renderer for the article drop-down
2.306 - *
2.307 - * Adds an icon and changes the text of the cell to match the name of
2.308 - * the article.
2.309 - */
2.310 - private static class ArticleListCellRenderer
2.311 - extends DefaultListCellRenderer
2.312 - {
2.313 - private ImageIcon icon;
2.314 -
2.315 - public ArticleListCellRenderer() {
2.316 - this.icon = new ImageIcon(getClass().getResource(ICON_ARTICLE));
2.317 - }
2.318 -
2.319 - public Component getListCellRendererComponent(JList list,
2.320 - Object value, int index, boolean isSelected, boolean cellHasFocus)
2.321 - {
2.322 - Component result = super.getListCellRendererComponent(list, value,
2.323 - index, isSelected, cellHasFocus);
2.324 - JLabel label = (JLabel)result;
2.325 - label.setIcon(icon);
2.326 - Example example = (Example)value;
2.327 - if(example != null) {
2.328 - label.setText(example.getName(0));
2.329 - }
2.330 - else {
2.331 - label.setText(bundle.getString("chooseArticle")); // NOI18N
2.332 - }
2.333 - return result;
2.334 - }
2.335 - }
2.336 -
2.337 - class GlobalListener implements ActionListener {
2.338 - public void actionPerformed(ActionEvent e){
2.339 - Object obj = e.getSource();
2.340 -// if(obj == debuggingBtn){
2.341 -// showURL("DEBUGGING_PAGE");
2.342 -// URL u = getUrlFromFile(NbBundle.getMessage(getClass(),"DEBUGGING_PAGE"));
2.343 -// displayer.showURL(u);
2.344 -// return;
2.345 -// }
2.346 - //if(obj == usingBtn){
2.347 - // showURL("J2EE_PAGE");
2.348 - // return;
2.349 - //}
2.350 - }
2.351 - }
2.352 -
2.353 }
2.354
2.355
3.1 --- a/j2ee.blueprints/src/org/netbeans/modules/j2ee/blueprints/ui/Bundle.properties Fri Dec 03 20:01:38 2004 +0000
3.2 +++ b/j2ee.blueprints/src/org/netbeans/modules/j2ee/blueprints/ui/Bundle.properties Fri Dec 03 20:54:18 2004 +0000
3.3 @@ -39,10 +39,6 @@
3.4
3.5 examplePnl=Example
3.6
3.7 -chooseCategory=Choose Category
3.8 -chooseArticle=Choose Article
3.9 -
3.10 -
3.11 categoryPnl=Category
3.12
3.13 NB_subtitle=Early Access