[hg] main-silver: #215173 disable finish when no platforms in co...

  • From: Milos Kleint < >
  • To: , ,
  • Subject: [hg] main-silver: #215173 disable finish when no platforms in co...
  • Date: Sat, 01 Dec 2012 13:36:53 -0800

changeset a15027b4ebb3 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/a15027b4ebb3
description:
        #215173 disable finish when no platforms in combobox are loaded or 
when the searching... value is selected.

diffstat:

 maven.apisupport/manifest.mf                                                 
          |   2 +-
 maven.apisupport/nbproject/project.xml                                       
          |   2 +-
 
maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
      |  13 +-
 
maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanel.java
         |  10 ++-
 
maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
   |  36 ++++++++-
 swing.validation/manifest.mf                                                 
          |   2 +-
 
swing.validation/src/org/netbeans/api/validation/adapters/WizardDescriptorAdapter.java
 |  33 +++++++++
 7 files changed, 80 insertions(+), 18 deletions(-)

diffs (263 lines):

diff --git a/maven.apisupport/manifest.mf b/maven.apisupport/manifest.mf
--- a/maven.apisupport/manifest.mf
+++ b/maven.apisupport/manifest.mf
@@ -2,5 +2,5 @@
 OpenIDE-Module: org.netbeans.modules.maven.apisupport/1
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/maven/apisupport/Bundle.properties
 AutoUpdate-Show-In-Client: false
-OpenIDE-Module-Specification-Version: 1.36
+OpenIDE-Module-Specification-Version: 1.37
 
diff --git a/maven.apisupport/nbproject/project.xml 
b/maven.apisupport/nbproject/project.xml
--- a/maven.apisupport/nbproject/project.xml
+++ b/maven.apisupport/nbproject/project.xml
@@ -199,7 +199,7 @@
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>2</release-version>
-                        <specification-version>1.16</specification-version>
+                        <specification-version>1.22</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
diff --git 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
--- 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
+++ 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardIterator.java
@@ -121,10 +121,10 @@
     }
 
     @SuppressWarnings({"unchecked", "rawtypes"}) // XXX until rewrite panel 
storage
-    private WizardDescriptor.Panel<WizardDescriptor>[] 
createPanels(ValidationGroup vg) {
+    private WizardDescriptor.Panel<WizardDescriptor>[] 
createPanels(ValidationGroup enabledVG, ValidationGroup errorMsgVG) {
             return new WizardDescriptor.Panel[] {
-                ArchetypeWizards.basicWizardPanel(vg, false, archetype),
-                new NbmWizardPanel(vg, archetype)
+                ArchetypeWizards.basicWizardPanel(errorMsgVG, false, 
archetype),
+                new NbmWizardPanel(enabledVG, errorMsgVG, archetype)
             };
     }
     
@@ -183,9 +183,10 @@
     @Override
     public void initialize(WizardDescriptor wiz) {
         index = 0;
-        ValidationGroup vg = ValidationGroup.create(new 
WizardDescriptorAdapter(wiz));
-
-        panels = createPanels(vg);
+        ValidationGroup enabledVG = ValidationGroup.create(new 
WizardDescriptorAdapter(wiz, WizardDescriptorAdapter.Type.VALID));
+        ValidationGroup errorMsgVG = ValidationGroup.create(new 
WizardDescriptorAdapter(wiz, WizardDescriptorAdapter.Type.MESSAGE));
+        enabledVG.addItem(errorMsgVG, false);
+        panels = createPanels(enabledVG, errorMsgVG);
         this.wiz = wiz;
         wiz.putProperty ("NewProjectWizard_Title", title); // NOI18N
         // Make sure list of steps is accurate.
diff --git 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanel.java
 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanel.java
--- 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanel.java
+++ 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanel.java
@@ -62,18 +62,24 @@
 
     private final Archetype archetype;
     private final ValidationGroup validationGroup;
+    private final ValidationGroup justEnabledStateValidationGroup;
     
 
 
-    public NbmWizardPanel(ValidationGroup vg, Archetype arch) {
-        validationGroup = vg;
+    public NbmWizardPanel(ValidationGroup enabledVG, ValidationGroup 
errorMsgVG, Archetype arch) {
+        validationGroup = errorMsgVG;
         archetype = arch;
+        justEnabledStateValidationGroup = enabledVG;
     }
 
     ValidationGroup getValidationGroup() {
         return validationGroup;
     }
     
+    ValidationGroup getEnabledStateValidationGroup() {
+        return justEnabledStateValidationGroup;
+    }
+    
     @Override
     @Messages("LBL_CreateProjectStepNbm=Module Options")
     public Component getComponent() {
diff --git 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
--- 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
+++ 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
@@ -56,6 +56,9 @@
 import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
 import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
 import org.netbeans.modules.maven.indexer.api.RepositoryQueries.Result;
+import org.netbeans.validation.api.Problems;
+import org.netbeans.validation.api.Severity;
+import org.netbeans.validation.api.Validator;
 import org.netbeans.validation.api.ValidatorUtils;
 import org.netbeans.validation.api.builtin.stringvalidation.StringValidators;
 import org.netbeans.validation.api.ui.ValidationGroup;
@@ -77,7 +80,9 @@
     private static final String SEARCHING = NbmWizardPanelVisual_wait();
     private final NbmWizardPanel panel;
     private ValidationGroup vg = ValidationGroup.create();
+    private ValidationGroup vgEnabled = ValidationGroup.create();
     boolean isApp = false;
+    private boolean isLoaded = false;
 
     @SuppressWarnings("unchecked") // SIMPLEVALIDATION-48
     @Messages("ADD_Module_Name=NetBeans Module ArtifactId")
@@ -91,13 +96,31 @@
                     StringValidators.REQUIRE_VALID_FILENAME
                     ));
             SwingValidationGroup.setComponentName(txtAddModule, 
ADD_Module_Name());
+            vgEnabled.add(versionCombo, new Validator<String>() {
+
+                @Override
+                public void validate(Problems prblms, String name, String 
value) {
+                    if (SEARCHING.equals(value) || !isLoaded) {
+                        prblms.add("still searching", Severity.FATAL);
+                    }
+                }
+
+                @Override
+                public Class modelType() {
+                    return String.class;
+                }
+            });
         } else {
             cbAddModule.setVisible(false);
             txtAddModule.setVisible(false);
         }
         RP.post(new Runnable() {
             public @Override void run() {
-
+                EventQueue.invokeLater(new Runnable()  {
+                        public @Override void run() {
+                            versionCombo.setModel(new 
DefaultComboBoxModel(new Object[] {SEARCHING}));
+                        }
+                    });
                 RepositoryInfo info = MavenNbModuleImpl.netbeansRepo();
                 final Object key = this;
                 if (info == null) {
@@ -109,12 +132,6 @@
                     }
                 }
                 if (info != null) {
-                    EventQueue.invokeLater(new Runnable()  {
-                        public @Override void run() {
-                            versionCombo.setModel(new 
DefaultComboBoxModel(new Object[] {SEARCHING}));
-                        }
-                    });
-
                     final List<String> versions = new ArrayList<String>();
                     final Result<NBVersionInfo> result = 
RepositoryQueries.getVersionsResult("org.netbeans.cluster", "platform", 
Collections.singletonList(info));
                     for (NBVersionInfo version : result.getResults()) { // 
NOI18N
@@ -146,6 +163,7 @@
                     } else {
                         
RepositoryPreferences.getInstance().removeTransientRepositories(key);
                     }
+                    isLoaded = true;
                     EventQueue.invokeLater(new Runnable()  {
                                             public @Override void run() {
                                                 versionCombo.setModel(new 
DefaultComboBoxModel(versions.toArray()));
@@ -257,6 +275,7 @@
             cbOsgiDeps.setEnabled(false);
             cbOsgiDeps.setSelected(false);
         }
+        vgEnabled.performValidation();
     }//GEN-LAST:event_versionComboActionPerformed
 
 
@@ -287,6 +306,7 @@
                 @Override
                 public void run() {
                     panel.getValidationGroup().remove(vg);
+                    panel.getEnabledStateValidationGroup().remove(vgEnabled);
                 }
             });
          }
@@ -310,6 +330,8 @@
                 @Override
                 public void run() {
                     panel.getValidationGroup().addItem(vg, true);
+                    
panel.getEnabledStateValidationGroup().addItem(vgEnabled, true);
+                    vgEnabled.performValidation();
                 }
             });
         }
diff --git a/swing.validation/manifest.mf b/swing.validation/manifest.mf
--- a/swing.validation/manifest.mf
+++ b/swing.validation/manifest.mf
@@ -1,5 +1,5 @@
 Manifest-Version: 1.0
 OpenIDE-Module: org.netbeans.modules.swing.validation/2
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/swing/validation/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.21
+OpenIDE-Module-Specification-Version: 1.22
 
diff --git 
a/swing.validation/src/org/netbeans/api/validation/adapters/WizardDescriptorAdapter.java
 
b/swing.validation/src/org/netbeans/api/validation/adapters/WizardDescriptorAdapter.java
--- 
a/swing.validation/src/org/netbeans/api/validation/adapters/WizardDescriptorAdapter.java
+++ 
b/swing.validation/src/org/netbeans/api/validation/adapters/WizardDescriptorAdapter.java
@@ -53,31 +53,64 @@
  */
 public class WizardDescriptorAdapter implements ValidationUI {
     private final WizardDescriptor wiz;
+    private final Type type;
 
+    /**
+     * 
+     * @since 1.22
+     */
+    public enum Type {
+        VALID, MESSAGE, VALID_AND_MESSAGE
+    }
     public WizardDescriptorAdapter(WizardDescriptor d) {
+        this(d, Type.VALID_AND_MESSAGE);
+    }
+    
+    /**
+     * allow to decide what ui elements should be affected, button 
enablement or error message or both.
+     * @since 1.22
+     */ 
+    public WizardDescriptorAdapter(WizardDescriptor d, Type type) {
         this.wiz = d;
+        this.type = type;
     }
 
     @Override
     public void clearProblem() {
+        if (type != Type.VALID) {
         wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, null);
+        }
+        if (type != Type.MESSAGE) {
         wiz.setValid(true);
     }
+    }
 
     @Override
     public void showProblem(Problem p) {
         switch (p.severity()) {
             case INFO :
+                if (type != Type.VALID) {
                 wiz.putProperty(WizardDescriptor.PROP_INFO_MESSAGE, 
p.getMessage());
+                }
+                if (type != Type.MESSAGE) {
                 wiz.setValid(true);
+                }
                 break;
             case WARNING :
+                if (type != Type.VALID) {
                 wiz.putProperty(WizardDescriptor.PROP_WARNING_MESSAGE, 
p.getMessage());
+                }
+                if (type != Type.MESSAGE) {
                 wiz.setValid(true);
+                }
                 break;
             case FATAL :
+                if (type != Type.VALID) {
                 wiz.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, 
p.getMessage());
+                }
+                if (type != Type.MESSAGE) {
                 wiz.setValid(false);
+                }
                 break;
         }
     }

[hg] main-silver: #215173 disable finish when no platforms in co...

Milos Kleint 12/01/2012

Project Features

About this Project

APIsupport was started in November 2009, is owned by Antonin Nebuzelsky, and has 43 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close