1.1 --- a/python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java Sat Jun 27 22:22:42 2015 +0200
1.2 +++ b/python.core/src/org/netbeans/modules/python/api/PythonPlatformManager.java Wed Jul 08 18:26:38 2015 +0200
1.3 @@ -296,6 +296,9 @@
1.4 }
1.5
1.6 public PythonPlatform getPlatform(String name){
1.7 + if (name == null) {
1.8 + return null;
1.9 + }
1.10 return platforms.get(name);
1.11 }
1.12
2.1 --- a/python.project2/src/org/netbeans/modules/python/project2/PythonProject2.java Sat Jun 27 22:22:42 2015 +0200
2.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/PythonProject2.java Wed Jul 08 18:26:38 2015 +0200
2.3 @@ -129,9 +129,7 @@
2.4 public PythonPlatform getActivePlatform() {
2.5 String pid = getProp(ProjectUtils.getAuxiliaryConfiguration(this), PythonProject2.APPLICATION_ARGS);
2.6 final PythonPlatformManager manager = PythonPlatformManager.getInstance();
2.7 - if (pid == null) {
2.8 - pid = manager.getDefaultPlatform();
2.9 - }
2.10 +
2.11 return manager.getPlatform(pid);
2.12 }
2.13
3.1 --- a/python.project2/src/org/netbeans/modules/python/project2/ui/Bundle.properties Sat Jun 27 22:22:42 2015 +0200
3.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/ui/Bundle.properties Wed Jul 08 18:26:38 2015 +0200
3.3 @@ -2,4 +2,5 @@
3.4 # To change this template file, choose Tools | Templates
3.5 # and open the template in the editor.
3.6
3.7 -MainModuleChooser.jLabel1.text=&Main Modules:
3.8 \ No newline at end of file
3.9 +MainModuleChooser.jLabel1.text=&Main Modules:
3.10 +PythonPlatformChooser.jLabel1.text=&Available Python Platforms:
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/ui/PythonPlatformChooser.form Wed Jul 08 18:26:38 2015 +0200
4.3 @@ -0,0 +1,57 @@
4.4 +<?xml version="1.0" encoding="UTF-8" ?>
4.5 +
4.6 +<Form version="1.5" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4.7 + <Properties>
4.8 + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
4.9 + <Dimension value="[300, 300]"/>
4.10 + </Property>
4.11 + </Properties>
4.12 + <AuxValues>
4.13 + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
4.14 + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
4.15 + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
4.16 + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
4.17 + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
4.18 + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
4.19 + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
4.20 + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
4.21 + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
4.22 + </AuxValues>
4.23 +
4.24 + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
4.25 + <SubComponents>
4.26 + <Component class="javax.swing.JLabel" name="jLabel1">
4.27 + <Properties>
4.28 + <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
4.29 + <ResourceString bundle="org/netbeans/modules/python/project2/ui/Bundle.properties" key="PythonPlatformChooser.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
4.30 + </Property>
4.31 + </Properties>
4.32 + <AuxValues>
4.33 + <AuxValue name="generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
4.34 + </AuxValues>
4.35 + <Constraints>
4.36 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.37 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="0" insetsRight="12" anchor="18" weightX="1.0" weightY="0.0"/>
4.38 + </Constraint>
4.39 + </Constraints>
4.40 + </Component>
4.41 + <Container class="javax.swing.JScrollPane" name="jScrollPane1">
4.42 + <Constraints>
4.43 + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
4.44 + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="12" insetsRight="12" anchor="10" weightX="1.0" weightY="1.0"/>
4.45 + </Constraint>
4.46 + </Constraints>
4.47 +
4.48 + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
4.49 + <SubComponents>
4.50 + <Component class="javax.swing.JList" name="pythonPlatforms">
4.51 + <Properties>
4.52 + <Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
4.53 + <Connection code="new DefaultListModel()" type="code"/>
4.54 + </Property>
4.55 + </Properties>
4.56 + </Component>
4.57 + </SubComponents>
4.58 + </Container>
4.59 + </SubComponents>
4.60 +</Form>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/ui/PythonPlatformChooser.java Wed Jul 08 18:26:38 2015 +0200
5.3 @@ -0,0 +1,112 @@
5.4 +/*
5.5 + * MainClassChooser.java
5.6 + *
5.7 + * Created on July 01, 2015 18:23
5.8 + */
5.9 +
5.10 +package org.netbeans.modules.python.project2.ui;
5.11 +
5.12 +import java.util.LinkedList;
5.13 +import java.util.List;
5.14 +import javax.swing.DefaultListModel;
5.15 +import javax.swing.JButton;
5.16 +import javax.swing.SwingUtilities;
5.17 +import org.netbeans.modules.python.api.PythonPlatformManager;
5.18 +import org.netbeans.modules.python.project2.PythonProject2;
5.19 +import org.openide.util.NbBundle;
5.20 +import org.openide.util.RequestProcessor;
5.21 +
5.22 +/**
5.23 + *
5.24 + * @author Julien Enselme
5.25 + */
5.26 +@NbBundle.Messages({"PPC_TXT_PleaseWait=Please Wait..."})
5.27 +final class PythonPlatformChooser extends javax.swing.JPanel {
5.28 +
5.29 + private final PythonProject2 project;
5.30 + private final JButton okButton;
5.31 + private final static RequestProcessor RP = new RequestProcessor("PythonPlatformChooser"); //NOI18N
5.32 +
5.33 + PythonPlatformChooser (final PythonProject2 project, final JButton okButton) {
5.34 + assert project != null;
5.35 + assert okButton != null;
5.36 + initComponents();
5.37 + this.project = project;
5.38 + this.okButton = okButton;
5.39 + this.okButton.setEnabled(false);
5.40 + ((DefaultListModel)this.pythonPlatforms.getModel()).addElement(NbBundle.getMessage(PythonPlatformChooser.class, "PPC_TXT_PleaseWait"));
5.41 + RP.post(new Runnable() {
5.42 + @Override
5.43 + public void run() {
5.44 + initData();
5.45 + }
5.46 + });
5.47 + }
5.48 +
5.49 + public String getPythonPlatform () {
5.50 + return (String) pythonPlatforms.getSelectedValue();
5.51 + }
5.52 +
5.53 +
5.54 + private void initData () {
5.55 + final List<String> data = new LinkedList<>(PythonPlatformManager.getInstance().getPlatformList());
5.56 + SwingUtilities.invokeLater(new Runnable() {
5.57 + @Override
5.58 + public void run() {
5.59 + DefaultListModel lm = (DefaultListModel)pythonPlatforms.getModel();
5.60 + lm.clear();
5.61 + for (String s : data) {
5.62 + lm.addElement(s);
5.63 + }
5.64 + okButton.setEnabled(true);
5.65 + }
5.66 + });
5.67 + }
5.68 +
5.69 + /** This method is called from within the constructor to
5.70 + * initialize the form.
5.71 + * WARNING: Do NOT modify this code. The content of this method is
5.72 + * always regenerated by the Form Editor.
5.73 + */
5.74 + @SuppressWarnings("unchecked")
5.75 + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
5.76 + private void initComponents() {
5.77 + java.awt.GridBagConstraints gridBagConstraints;
5.78 +
5.79 + jLabel1 = new javax.swing.JLabel();
5.80 + jScrollPane1 = new javax.swing.JScrollPane();
5.81 + pythonPlatforms = new javax.swing.JList();
5.82 +
5.83 + setPreferredSize(new java.awt.Dimension(300, 300));
5.84 + setLayout(new java.awt.GridBagLayout());
5.85 +
5.86 + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PythonPlatformChooser.class, "PythonPlatformChooser.jLabel1.text")); // NOI18N
5.87 + gridBagConstraints = new java.awt.GridBagConstraints();
5.88 + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
5.89 + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
5.90 + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
5.91 + gridBagConstraints.weightx = 1.0;
5.92 + gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
5.93 + add(jLabel1, gridBagConstraints);
5.94 +
5.95 + pythonPlatforms.setModel(new DefaultListModel());
5.96 + jScrollPane1.setViewportView(pythonPlatforms);
5.97 +
5.98 + gridBagConstraints = new java.awt.GridBagConstraints();
5.99 + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
5.100 + gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
5.101 + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
5.102 + gridBagConstraints.weightx = 1.0;
5.103 + gridBagConstraints.weighty = 1.0;
5.104 + gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
5.105 + add(jScrollPane1, gridBagConstraints);
5.106 + }// </editor-fold>//GEN-END:initComponents
5.107 +
5.108 +
5.109 + // Variables declaration - do not modify//GEN-BEGIN:variables
5.110 + private javax.swing.JLabel jLabel1;
5.111 + private javax.swing.JScrollPane jScrollPane1;
5.112 + private javax.swing.JList pythonPlatforms;
5.113 + // End of variables declaration//GEN-END:variables
5.114 +
5.115 +}
6.1 --- a/python.project2/src/org/netbeans/modules/python/project2/ui/Utils.java Sat Jun 27 22:22:42 2015 +0200
6.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/ui/Utils.java Wed Jul 08 18:26:38 2015 +0200
6.3 @@ -47,6 +47,21 @@
6.4 return null;
6.5 }
6.6
6.7 + @NbBundle.Messages({"LBL_SelectPythonPlatform=Select Python Platform", "LBL_BrowsePythonPlatforms=Browse Python Platforms"})
6.8 + public static String choosePythonPlatform(PythonProject2 project) {
6.9 + final JButton okButton = new JButton (NbBundle.getMessage(Utils.class, "LBL_SelectPythonPlatform"));
6.10 + final PythonPlatformChooser ppc = new PythonPlatformChooser(project, okButton);
6.11 + final Object[] options = new Object[] {okButton, DialogDescriptor.CANCEL_OPTION};
6.12 + final DialogDescriptor dd = new DialogDescriptor(ppc, NbBundle.getMessage(Utils.class, "LBL_BrowsePythonPlatforms"), true, options,
6.13 + okButton,DialogDescriptor.RIGHT_ALIGN, HelpCtx.DEFAULT_HELP, null);
6.14 + dd.setClosingOptions(options);
6.15 + if (DialogDisplayer.getDefault().notify(dd) == okButton) {
6.16 + return ppc.getPythonPlatform();
6.17 + }
6.18 +
6.19 + return null;
6.20 + }
6.21 +
6.22 public static interface SourceRootsMediator {
6.23 public void setRelatedEditMediator(SourceRootsMediator rem);
6.24 }
7.1 --- a/python.project2/src/org/netbeans/modules/python/project2/ui/actions/RunCommand.java Sat Jun 27 22:22:42 2015 +0200
7.2 +++ b/python.project2/src/org/netbeans/modules/python/project2/ui/actions/RunCommand.java Wed Jul 08 18:26:38 2015 +0200
7.3 @@ -6,6 +6,7 @@
7.4 import org.netbeans.api.project.ProjectUtils;
7.5 import org.netbeans.api.project.SourceGroup;
7.6 import org.netbeans.api.project.Sources;
7.7 +import org.netbeans.modules.python.api.PythonPlatformManager;
7.8 import org.netbeans.modules.python.project2.ui.Utils;
7.9 import org.netbeans.spi.project.ActionProvider;
7.10 import org.openide.filesystems.FileObject;
7.11 @@ -50,9 +51,18 @@
7.12 // }
7.13
7.14 final PythonProject2 pyProject = getProject();
7.15 - final PythonPlatform platform = checkProjectPythonPlatform(pyProject);
7.16 + PythonPlatform platform = checkProjectPythonPlatform(pyProject);
7.17 if (platform == null) {
7.18 - return; // invalid platform user has been warn in check so safe to return
7.19 + String platformName = Utils.choosePythonPlatform(pyProject);
7.20 + PythonPlatformManager ppm = PythonPlatformManager.getInstance();
7.21 + if (platformName == null) {
7.22 + platformName = ppm.getDefaultPlatform();
7.23 + }
7.24 + platform = ppm.getPlatform(platformName);
7.25 + if (platform == null) {
7.26 + return;
7.27 + }
7.28 + pyProject.setActivePlatform(platform);
7.29 }
7.30
7.31 String main = pyProject.getMainModule();