[hg] main-silver: #146983: Add possibility to choose MySQL insta...

  • From: Jaroslav Havlin < >
  • To:
  • Subject: [hg] main-silver: #146983: Add possibility to choose MySQL insta...
  • Date: Fri, 15 Feb 2013 06:39:37 -0800

changeset b16240d5b8f9 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/b16240d5b8f9
description:
        #146983: Add possibility to choose MySQL installation

diffstat:

 db.mysql/src/org/netbeans/modules/db/mysql/impl/InstallationManager.java     
                    |   67 +++-
 db.mysql/src/org/netbeans/modules/db/mysql/impl/MultiInstallation.java       
                    |   67 +++
 db.mysql/src/org/netbeans/modules/db/mysql/impl/ServerNodeProvider.java      
                    |    4 +
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/BundledInstallation.java
                |    4 +
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxStandaloneInstallation.java
        |    5 +
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxXAMPPInstallation.java
             |    5 +
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/MAMPInstallation.java
                   |    5 +
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/SXDEWebStackInstallation.java
           |    5 +
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone51Installation.java
    |   65 ---
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone50Installation.java
    |   25 +-
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandaloneMultiInstallation.java
 |   99 +++++
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.form
         |   57 +++
 
db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.java
         |  184 ++++++++++
 db.mysql/src/org/netbeans/modules/db/mysql/layer.xml                         
                    |   10 +-
 14 files changed, 506 insertions(+), 96 deletions(-)

diffs (757 lines):

diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/impl/InstallationManager.java 
b/db.mysql/src/org/netbeans/modules/db/mysql/impl/InstallationManager.java
--- a/db.mysql/src/org/netbeans/modules/db/mysql/impl/InstallationManager.java
+++ b/db.mysql/src/org/netbeans/modules/db/mysql/impl/InstallationManager.java
@@ -44,6 +44,8 @@
 
 package org.netbeans.modules.db.mysql.impl;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
@@ -52,6 +54,10 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import org.netbeans.modules.db.mysql.installations.BundledInstallation;
+import 
org.netbeans.modules.db.mysql.installations.ui.SelectInstallationPanel;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.util.ImageUtilities;
+import org.openide.util.NbBundle;
 import org.openide.util.lookup.Lookups;
 
 /**
@@ -67,7 +73,8 @@
     
     private static final String INSTALLATION_PROVIDER_PATH = 
             "Databases/MySQL/Installations"; // NOI18N
-
+    private static final String ICON_BASE =
+            "org/netbeans/modules/db/mysql/resources/database.gif";     
//NOI18N
 
     public static synchronized List<Installation> 
getInstallations(Collection loadedInstallations) {
         if ( INSTALLATIONS == null ) {
@@ -105,17 +112,22 @@
     }
     
     /**
-     * See if we can detect the paths to the various admin tools
-     * 
-     * @return a valid installation if detected, null otherwise.  Returns the
-     *      first installation found, so if there are multiple installations
-     *      the other ones available will not be detected.
+     * Get all valid installations of MySQL in this system.
      */
-    public static Installation detectInstallation() {
+    public static List<Installation> detectAllInstallations() {
         List<Installation> installationCopy = new 
CopyOnWriteArrayList<Installation>();
-        Collection loadedInstallations = 
Lookups.forPath(INSTALLATION_PROVIDER_PATH).lookupAll(Installation.class);
+        Collection<Installation> loadedInstallations = new 
ArrayList<Installation>(3);
+        
loadedInstallations.addAll(Lookups.forPath(INSTALLATION_PROVIDER_PATH)
+                .lookupAll(Installation.class));
+        Collection<? extends MultiInstallation> multiInstallations =
+                Lookups.forPath(INSTALLATION_PROVIDER_PATH).lookupAll(
+                MultiInstallation.class);
+        for (MultiInstallation mi : multiInstallations) {
+            loadedInstallations.addAll(mi.getInstallations());
+        }
         
installationCopy.addAll(InstallationManager.getInstallations(loadedInstallations));
-        
+        List<Installation> validInstallations =
+                new ArrayList<Installation>(3);
         for ( Iterator it = installationCopy.iterator() ; it.hasNext() ; ) {
             Installation installation = (Installation)it.next();
             
@@ -125,10 +137,45 @@
             
             if ( installation.isInstalled() ) {
                 LOGGER.log(Level.FINE, "Installation is installed");
-                return installation;
+                validInstallations.add(installation);
             }
         }
+        return validInstallations;
+    }
         
+    /**
+     * See if we can detect the paths to the various admin tools
+     *
+     * @return a valid installation if detected, null otherwise.  Returns the
+     *      first installation found, so if there are multiple installations
+     *      the other ones available will not be detected.
+     */
+    public static Installation detectInstallation() {
+        List<Installation> allInstallations = detectAllInstallations();
+        if (allInstallations.isEmpty()) {
         return null;
+        } else {
+            if (allInstallations.size() > 1) {
+                notifyAboutMultipleInstallations();
     }        
+            return allInstallations.get(0);
 }
+    }
+
+    @NbBundle.Messages({
+        "NotifyMultipleInstallations.title=Multiple MySQL installations 
found",
+        "NotifyMultipleInstallations.text=Select the installation to use"
+    })
+    private static void notifyAboutMultipleInstallations() {
+        NotificationDisplayer.getDefault().notify(
+                Bundle.NotifyMultipleInstallations_title(),
+                ImageUtilities.loadImageIcon(ICON_BASE, false),
+                Bundle.NotifyMultipleInstallations_text(),
+                new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                SelectInstallationPanel.showSelectInstallationDialog();
+            }
+        });
+    }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/impl/MultiInstallation.java 
b/db.mysql/src/org/netbeans/modules/db/mysql/impl/MultiInstallation.java
new file mode 100644
--- /dev/null
+++ b/db.mysql/src/org/netbeans/modules/db/mysql/impl/MultiInstallation.java
@@ -0,0 +1,67 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.db.mysql.impl;
+
+import java.util.Collection;
+
+/**
+ * This interface defines an abstraction of an installation of MySQL which 
can
+ * have several versions in the same system. For example, on Windows, there 
can
+ * be several versions of MySQL installed in C:\Program Files\.
+ *
+ * @author jhavlin
+ */
+public interface MultiInstallation {
+
+    /**
+     * Get collection of existing or theoretically possible installations in 
the
+     * local system.
+     */
+    public Collection<Installation> getInstallations();
+
+    /**
+     * Result of last invocation of {@link #getInstallations()} can be 
cached.
+     * This method forces this object to return fresh results the next time 
the
+     * method is invoked.
+     */
+    public void refresh();
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/impl/ServerNodeProvider.java 
b/db.mysql/src/org/netbeans/modules/db/mysql/impl/ServerNodeProvider.java
--- a/db.mysql/src/org/netbeans/modules/db/mysql/impl/ServerNodeProvider.java
+++ b/db.mysql/src/org/netbeans/modules/db/mysql/impl/ServerNodeProvider.java
@@ -154,6 +154,10 @@
 
     private void findAndRegisterInstallation() {
         Installation installation = InstallationManager.detectInstallation();
+        registerInstallation(installation);
+    }
+
+    public void registerInstallation(Installation installation) {
         if ( installation == null ) {
             return;
         }
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/BundledInstallation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/BundledInstallation.java
--- 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/BundledInstallation.java
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/BundledInstallation.java
@@ -102,4 +102,8 @@
         return port;
     }
 
+    @Override
+    public String toString() {
+        return "Bundled Installation";                                  
//NOI18N
 }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxStandaloneInstallation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxStandaloneInstallation.java
--- 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxStandaloneInstallation.java
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxStandaloneInstallation.java
@@ -91,4 +91,9 @@
     public String getDefaultPort() {
         return "3306"; // NOI18N
     }
+
+    @Override
+    public String toString() {
+        return "Linux Standalone Installation - " + SVC_EXE;            
//NOI18N
 }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxXAMPPInstallation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxXAMPPInstallation.java
--- 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxXAMPPInstallation.java
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/LinuxXAMPPInstallation.java
@@ -93,4 +93,9 @@
     public String getDefaultPort() {
         return DEFAULT_PORT;
     }
+
+    @Override
+    public String toString() {
+        return "Linux XAMPP Installation - " + LAMPP;                   
//NOI18N
 }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/MAMPInstallation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/MAMPInstallation.java
--- 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/MAMPInstallation.java
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/MAMPInstallation.java
@@ -101,4 +101,9 @@
     public String getDefaultPort() {
         return DEFAULT_PORT;
     }
+
+    @Override
+    public String toString() {
+        return "MAMP Installation - " + START_PATH;                     
//NOI18N
 }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/SXDEWebStackInstallation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/SXDEWebStackInstallation.java
--- 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/SXDEWebStackInstallation.java
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/SXDEWebStackInstallation.java
@@ -94,4 +94,9 @@
     public String getDefaultPort() {
         return "3306"; // NOI18N
     }
+
+    @Override
+    public String toString() {
+        return "SXDE WebStack Installation - " + SVC_EXE;               
//NOI18N
 }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone51Installation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone51Installation.java
deleted file mode 100644
--- 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone51Installation.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
- *
- * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
- *
- * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
- * Other names may be trademarks of their respective owners.
- *
- * The contents of this file are subject to the terms of either the GNU
- * General Public License Version 2 only ("GPL") or the Common
- * Development and Distribution License("CDDL") (collectively, the
- * "License"). You may not use this file except in compliance with the
- * License. You can obtain a copy of the License at
- * http://www.netbeans.org/cddl-gplv2.html
- * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
- * specific language governing permissions and limitations under the
- * License.  When distributing the software, include this License Header
- * Notice in each file and include the License file at
- * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the GPL Version 2 section of the License file that
- * accompanied this code. If applicable, add the following below the
- * License Header, with the fields enclosed by brackets [] replaced by
- * your own identifying information:
- * "Portions Copyrighted [year] [name of copyright owner]"
- * 
- * If you wish your version of this file to be governed by only the CDDL
- * or only the GPL Version 2, indicate your decision by adding
- * "[Contributor] elects to include this software in this distribution
- * under the [CDDL or GPL Version 2] license." If you do not indicate a
- * single choice of license, a recipient has the option to distribute
- * your version of this file under either the CDDL, the GPL Version 2 or
- * to extend the choice of license to its licensees as provided above.
- * However, if you add GPL Version 2 code and therefore, elected the GPL
- * Version 2 license, then the option applies only if the new code is
- * made subject to such option by the copyright holder.
- * 
- * Contributor(s):
- * 
- * Portions Copyrighted 2008 Sun Microsystems, Inc.
- */
-
-package org.netbeans.modules.db.mysql.installations;
-
-/**
- * Standalone version 5.1 on Windows
- * 
- * @author David Van Couvering
- */
-public class WindowsStandalone51Installation 
-        extends WindowsStandalone50Installation {
-    private static final String DEFAULT_BASE_PATH = 
-            "C:/Program Files/MySQL/MySQL Server 5.1";
-    
-    private static final WindowsStandalone51Installation DEFAULT = new
-            WindowsStandalone51Installation(DEFAULT_BASE_PATH);
-    
-    public static WindowsStandalone51Installation getDefault() {
-        return DEFAULT;
-    }
-    
-    private WindowsStandalone51Installation(String basePath) {
-        super(basePath);
-    }
-}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone50Installation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandaloneInstallation.java
rename from 
db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone50Installation.java
rename to 
db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandaloneInstallation.java
--- 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandalone50Installation.java
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandaloneInstallation.java
@@ -47,29 +47,22 @@
 import org.openide.util.Utilities;
 
 /**
- * Standalone version 5.0 on Windows, not installed as a server
+ * Standalone version on Windows, not installed as a server
  * 
  * @author David Van Couvering
  */
-public class WindowsStandalone50Installation implements Installation {
-    private static final String DEFAULT_BASE_PATH = 
-            "C:/Program Files/MySQL/MySQL Server 5.0";
-    
-    private static final WindowsStandalone50Installation DEFAULT = new
-            WindowsStandalone50Installation(DEFAULT_BASE_PATH);
+public class WindowsStandaloneInstallation implements Installation {
+    static final String DEFAULT_BASE_PATH = "C:/Program Files/MySQL/";  
//NOI18N
+    static final String FOLDER_NAME_PREFIX = "MySQL Server ";           
//NOI18N
     
     private final String basePath;
         
-    public static WindowsStandalone50Installation getDefault() {
-        return DEFAULT;
-    }
-
-    protected WindowsStandalone50Installation(String basePath) {
-        this.basePath = basePath;
+    protected WindowsStandaloneInstallation(String folderName) {
+        this.basePath = DEFAULT_BASE_PATH + folderName;
     }
     
     public String[] getStartCommand() {
-        return new String[] { basePath + "/bin/mysqld-nt.exe", "--console"}; 
// NOI18N
+        return new String[] { basePath + "/bin/mysqld.exe", "--console"}; // 
NOI18N
     }
 
     public String[] getStopCommand() {
@@ -97,4 +90,8 @@
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
+    @Override
+    public String toString() {
+        return "Windows Installation - " + basePath;                    
//NOI18N
 }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandaloneMultiInstallation.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandaloneMultiInstallation.java
new file mode 100644
--- /dev/null
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/WindowsStandaloneMultiInstallation.java
@@ -0,0 +1,99 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.db.mysql.installations;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.modules.db.mysql.impl.Installation;
+import org.netbeans.modules.db.mysql.impl.MultiInstallation;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+/**
+ * Class for detection of installed versions of MySQL on Windows OS.
+ *
+ * @author jhavlin
+ */
+public class WindowsStandaloneMultiInstallation implements MultiInstallation 
{
+
+    private static final WindowsStandaloneMultiInstallation DEFAULT =
+            new WindowsStandaloneMultiInstallation();
+    private Collection<Installation> installations = null;
+
+    @Override
+    public Collection<Installation> getInstallations() {
+        if (installations != null) {
+            return installations;
+        }
+        FileObject fo = FileUtil.toFileObject(
+                new File(WindowsStandaloneInstallation.DEFAULT_BASE_PATH));
+
+        if (fo != null) {
+            List<Installation> found = new ArrayList<Installation>(3);
+            for (FileObject child : fo.getChildren()) {
+                if (child.getNameExt().startsWith(
+                        WindowsStandaloneInstallation.FOLDER_NAME_PREFIX)
+                        && child.isFolder()) {
+                    found.add(
+                            new WindowsStandaloneInstallation(
+                            child.getNameExt()));
+                }
+            }
+            installations = found;
+        } else {
+            installations = Collections.emptyList();
+        }
+        return installations;
+    }
+
+    @Override
+    public void refresh() {
+        installations = null;
+    }
+
+    public static WindowsStandaloneMultiInstallation getDefault() {
+        return DEFAULT;
+    }
+}
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.form
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.form
new file mode 100644
--- /dev/null
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.form
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.5" maxVersion="1.8" 
type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" 
value="1"/>
+    <AuxValue name="FormSettings_autoSetComponentName" 
type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" 
value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" 
type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" 
value="true"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" 
value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" 
type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" 
value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" 
value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="scrollPane" pref="532" max="32767" 
attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="scrollPane" pref="103" max="32767" 
attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JScrollPane" name="scrollPane">
+
+      <Layout 
class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JList" name="installationList">
+          <Properties>
+            <Property name="model" type="javax.swing.ListModel" 
editor="org.netbeans.modules.form.editors2.ListModelEditor">
+              <StringArray count="5">
+                <StringItem index="0" value="Item 1"/>
+                <StringItem index="1" value="Item 2"/>
+                <StringItem index="2" value="Item 3"/>
+                <StringItem index="3" value="Item 4"/>
+                <StringItem index="4" value="Item 5"/>
+              </StringArray>
+            </Property>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+  </SubComponents>
+</Form>
diff --git 
a/db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.java
 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.java
new file mode 100644
--- /dev/null
+++ 
b/db.mysql/src/org/netbeans/modules/db/mysql/installations/ui/SelectInstallationPanel.java
@@ -0,0 +1,184 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.db.mysql.installations.ui;
+
+import java.awt.EventQueue;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+import javax.swing.ListSelectionModel;
+import org.netbeans.modules.db.mysql.impl.Installation;
+import org.netbeans.modules.db.mysql.impl.InstallationManager;
+import org.netbeans.modules.db.mysql.impl.ServerNodeProvider;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.util.NbBundle;
+import org.openide.util.RequestProcessor;
+
+/**
+ *
+ * @author jhavlin
+ */
+public class SelectInstallationPanel extends javax.swing.JPanel {
+
+    private DialogDescriptor dialogDescriptor = null;
+
+    /**
+     * Creates new form SelectInstallationPanel
+     */
+    private SelectInstallationPanel() {
+        initComponents();
+    }
+
+    @NbBundle.Messages({
+        "MSG_Detecting_Wait=Detecting installations, please wait..."
+    })
+    private void initList() {
+        installationList.setListData(new Object[]{
+            Bundle.MSG_Detecting_Wait()
+        });
+        
installationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        installationList.setEnabled(false);
+
+        RequestProcessor.getDefault().post(new Runnable() {
+            @Override
+            public void run() {
+                final List<Installation> installations =
+                        InstallationManager.detectAllInstallations();
+                EventQueue.invokeLater(new Runnable() {
+                    @Override
+                    public void run() {
+                        updateListForDetectedInstallations(installations);
+                    }
+                });
+            }
+        });
+    }
+
+    @NbBundle.Messages({
+        "MSG_NoInstallationFound=Sorry, no installation was detected"
+    })
+    private void updateListForDetectedInstallations(List<Installation> 
insts) {
+        if (insts.isEmpty()) {
+            installationList.setListData(new Object[]{
+                Bundle.MSG_NoInstallationFound()});
+        } else {
+            installationList.setListData(insts.toArray());
+            installationList.setEnabled(true);
+            dialogDescriptor.setValid(true);
+        }
+    }
+
+    private void setDialogDescriptor(DialogDescriptor dialogDescriptor) {
+        if (this.dialogDescriptor != null) {
+            throw new IllegalStateException(
+                    "DialogDescriptor has been already set."); //NOI18N
+        }
+        this.dialogDescriptor = dialogDescriptor;
+        dialogDescriptor.setValid(false);
+        initList();
+    }
+
+    @NbBundle.Messages({
+        "selectInstalllation_title=Select MySQL Installation"
+    })
+    public static void showSelectInstallationDialog() {
+        final SelectInstallationPanel sip = new SelectInstallationPanel();
+        final DialogDescriptor dd = new DialogDescriptor(
+                sip,
+                Bundle.selectInstalllation_title(),
+                true,
+                DialogDescriptor.OK_CANCEL_OPTION,
+                DialogDescriptor.OK_OPTION,
+                null);
+        sip.setDialogDescriptor(dd);
+        DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
+        if (DialogDescriptor.OK_OPTION.equals(dd.getValue())) {
+            Object val = sip.installationList.getSelectedValue();
+            if (val instanceof Installation) {
+                ServerNodeProvider.getDefault().registerInstallation(
+                        (Installation) val);
+            }
+        }
+    }
+
+    /**
+     * This method is called from within the constructor to initialize the 
form.
+     * WARNING: Do NOT modify this code. The content of this method is always
+     * regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated 
Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        scrollPane = new javax.swing.JScrollPane();
+        installationList = new javax.swing.JList();
+
+        installationList.setModel(new javax.swing.AbstractListModel() {
+            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", 
"Item 5" };
+            public int getSize() { return strings.length; }
+            public Object getElementAt(int i) { return strings[i]; }
+        });
+        scrollPane.setViewportView(installationList);
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+        this.setLayout(layout);
+        layout.setHorizontalGroup(
+            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(scrollPane, 
javax.swing.GroupLayout.DEFAULT_SIZE, 532, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addContainerGap()
+                .addComponent(scrollPane, 
javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
+                .addContainerGap())
+        );
+    }// </editor-fold>//GEN-END:initComponents
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JList installationList;
+    private javax.swing.JScrollPane scrollPane;
+    // End of variables declaration//GEN-END:variables
+}
diff --git a/db.mysql/src/org/netbeans/modules/db/mysql/layer.xml 
b/db.mysql/src/org/netbeans/modules/db/mysql/layer.xml
--- a/db.mysql/src/org/netbeans/modules/db/mysql/layer.xml
+++ b/db.mysql/src/org/netbeans/modules/db/mysql/layer.xml
@@ -103,13 +103,9 @@
                     <attr name="instanceOf" 
stringvalue="org.netbeans.modules.db.mysql.impl.Installation"/>
                 </file>
                 -->
-                <file name="WindowsStandalone50Installation.instance">
-                    <attr name="instanceCreate" 
methodvalue="org.netbeans.modules.db.mysql.installations.WindowsStandalone50Installation.getDefault"/>
-                    <attr name="instanceOf" 
stringvalue="org.netbeans.modules.db.mysql.impl.Installation"/>
-                </file>
-                <file name="WindowsStandalone51Installation.instance">
-                    <attr name="instanceCreate" 
methodvalue="org.netbeans.modules.db.mysql.installations.WindowsStandalone51Installation.getDefault"/>
-                    <attr name="instanceOf" 
stringvalue="org.netbeans.modules.db.mysql.impl.Installation"/>
+                <file name="WindowsStandaloneMultiInstallation.instance">
+                    <attr name="instanceCreate" 
methodvalue="org.netbeans.modules.db.mysql.installations.WindowsStandaloneMultiInstallation.getDefault"/>
+                    <attr name="instanceOf" 
stringvalue="org.netbeans.modules.db.mysql.impl.MultiInstallation"/>
                 </file>
             </folder>
         </folder>

[hg] main-silver: #146983: Add possibility to choose MySQL insta...

Jaroslav Havlin 02/15/2013

Project Features

About this Project

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