diff options
author | Tomas O'Connor <toconnor@openoffice.org> | 2003-02-20 10:54:46 +0000 |
---|---|---|
committer | Tomas O'Connor <toconnor@openoffice.org> | 2003-02-20 10:54:46 +0000 |
commit | fd672cc757f6666d342241ac2bef4861c216e1d8 (patch) | |
tree | cb99575d65925f6120de17e3336fa5e5f671067e /scripting | |
parent | e9e8dd25712e0ec6a4c9535d34d708da087f914a (diff) |
IssueZilla 10661 - Add dialog for configuring the path to OpenOffice.org install.
Diffstat (limited to 'scripting')
8 files changed, 600 insertions, 3 deletions
diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties index 5095829d9245..0e4f2bd100c7 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/Bundle.properties @@ -7,7 +7,7 @@ LBL_component_name=<name of component> # WizardDescriptor # Dialog title: -TITLE_wizard=My Wizard +TITLE_wizard=Select Path to OpenOffice.org Installation # WizardDescriptor.Iterator # Label the sequence #. Appears at top of pane: @@ -19,7 +19,8 @@ TITLE_x_of_y={0} of {1} # WizardDescriptor.Panel # Will appear in dialog title; see above -TITLE_WizardPanel=Panel Name +TITLE_ParcelPropertiesVisualPanel=Parcel Recipe Properties +TITLE_SelectPathVisualPanel=Path to OpenOffice.org # CallableSystemAction LBL_Action=Run Action diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java new file mode 100644 index 000000000000..f7c057cf48b3 --- /dev/null +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathDescriptor.java @@ -0,0 +1,72 @@ +/* + * InstallationPathDescriptor.java + * + * Created on February 12, 2003 + */ + +package org.openoffice.netbeans.modules.office.wizard; + +import java.awt.Dimension; +import java.awt.Toolkit; +import java.net.URL; +import java.net.MalformedURLException; + +import org.openide.TopManager; +import org.openide.WizardDescriptor; +import org.openide.util.NbBundle; + +/** A wizard descriptor. + * + * @author tomaso + */ +public class InstallationPathDescriptor extends WizardDescriptor { + + private final InstallationPathIterator iterator; + public static final String PROP_INSTALLPATH = "INSTALLPATH"; + + /** Make a descriptor suited to use InstallationPathIterator. + * Sets up various wizard properties to follow recommended + * style guidelines. + */ + public InstallationPathDescriptor() { + this(new InstallationPathIterator()); + } + private InstallationPathDescriptor(InstallationPathIterator iterator) { + super(iterator); + this.iterator = iterator; + // Set title for the dialog: + setTitle(NbBundle.getMessage(InstallationPathDescriptor.class, "TITLE_wizard")); + // Make the left pane appear: + putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); // NOI18N + // Make the left pane show list of steps etc.: + putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); // NOI18N + // Number the steps. + // putProperty("WizardPanel_contentNumbered", Boolean.TRUE); // NOI18N + /* + // Optional: make nonmodal. + setModal(false); + // (If you make the wizard nonmodal, you will call it differently; + // see InstallationPathAction for instructions.) + // Optional: show a help tab with special info about the pane: + putProperty("WizardPanel_helpDisplayed", Boolean.TRUE); // NOI18N + // Optional: set the size of the left pane explicitly: + putProperty("WizardPanel_leftDimension", new Dimension(100, 400)); // NOI18N + // Optional: if you want a special background image for the left pane: + try { + putProperty("WizardPanel_image", // NOI18N + Toolkit.getDefaultToolkit().getImage + (new URL("nbresloc:/org/openoffice/netbeans/modules/office/wizard/InstallationPathImage.gif"))); // NOI18N + } catch (MalformedURLException mfue) { + throw new IllegalStateException(mfue.toString()); + } + */ + } + + // Called when user moves forward or backward etc.: + protected void updateState() { + super.updateState(); + putProperty("WizardPanel_contentData", iterator.getSteps()); // NOI18N + putProperty("WizardPanel_contentSelectedIndex", new Integer(iterator.getIndex())); // NOI18N + } + +} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java new file mode 100644 index 000000000000..323175d4c5b8 --- /dev/null +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/InstallationPathIterator.java @@ -0,0 +1,136 @@ +/* + * InstallationPathIterator.java + * + * Created on February 12, 2003 + */ + +package org.openoffice.netbeans.modules.office.wizard; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.HashSet; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Set; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import org.openide.WizardDescriptor; +import org.openide.util.NbBundle; + +/** A wizard iterator (sequence of panels). + * Used to create a wizard. Create one or more + * panels from template as needed too. + * + * @author tomaso + */ +public class InstallationPathIterator implements WizardDescriptor.Iterator { + + // You should define what panels you want to use here: + + protected WizardDescriptor.Panel[] createPanels() { + return new WizardDescriptor.Panel[] { + new SelectPathPanel() + }; + } + + // And the list of step names: + + protected String[] createSteps() { + return new String[] { + "Select OpenOffice.org Installation" + }; + } + + // --- The rest probably does not need to be touched. --- + + // Keep track of the panels and selected panel: + + private transient int index = 0; + // Also package-accessible to descriptor: + protected final int getIndex() { + return index; + } + private transient WizardDescriptor.Panel[] panels = null; + protected final WizardDescriptor.Panel[] getPanels() { + if (panels == null) { + panels = createPanels(); + } + return panels; + } + + // Also the list of steps in the left pane: + + private transient String[] steps = null; + // Also package-accessible to descriptor: + protected final String[] getSteps() { + if (steps == null) { + steps = createSteps(); + } + return steps; + } + + // --- WizardDescriptor.Iterator METHODS: --- + // Note that this is very similar to WizardDescriptor.Iterator, but with a + // few more options for customization. If you e.g. want to make panels appear + // or disappear dynamically, go ahead. + + public String name() { + return NbBundle.getMessage(InstallationPathIterator.class, "TITLE_x_of_y", + new Integer(index + 1), new Integer(getPanels().length)); + } + + public boolean hasNext() { + return index < getPanels().length - 1; + } + public boolean hasPrevious() { + return index > 0; + } + public void nextPanel() { + if (!hasNext()) throw new NoSuchElementException(); + index++; + } + public void previousPanel() { + if (!hasPrevious()) throw new NoSuchElementException(); + index--; + } + public WizardDescriptor.Panel current() { + return getPanels()[index]; + } + + // If nothing unusual changes in the middle of the wizard, simply: + public final void addChangeListener(ChangeListener l) {} + public final void removeChangeListener(ChangeListener l) {} + // If something changes dynamically (besides moving between panels), + // e.g. the number of panels changes in response to user input, then + // uncomment the following and call when needed: + // fireChangeEvent(); + /* + private transient Set listeners = new HashSet(1); // Set<ChangeListener> + public final void addChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } + } + public final void removeChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } + } + protected final void fireChangeEvent() { + Iterator it; + synchronized (listeners) { + it = new HashSet(listeners).iterator(); + } + ChangeEvent ev = new ChangeEvent(this); + while (it.hasNext()) { + ((ChangeListener)it.next()).stateChanged(ev); + } + } + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + listeners = new HashSet(1); + } + */ + +} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form index 48ee7b800446..0bfb183f5047 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.form @@ -1,6 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 300]"/> + </Property> + </Properties> <AuxValues> <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,75,0,0,1,-112"/> </AuxValues> @@ -47,8 +52,8 @@ <AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value=""/> <AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value=""/> <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value=""/> - <AuxValue name="JavaCodeGenerator_CodeGeneration" type="java.lang.Integer" value="0"/> <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value=""/> + <AuxValue name="JavaCodeGenerator_CodeGeneration" type="java.lang.Integer" value="0"/> </AuxValues> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java index dbfd4edfd328..e9af2c1360df 100644 --- a/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/ParcelPropertiesVisualPanel.java @@ -59,6 +59,7 @@ public class ParcelPropertiesVisualPanel extends javax.swing.JPanel { setLayout(new java.awt.GridBagLayout()); + setPreferredSize(new java.awt.Dimension(500, 300)); jLabel1.setText("Parcel Recipe Name"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java new file mode 100644 index 000000000000..500189fdc9cf --- /dev/null +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathPanel.java @@ -0,0 +1,110 @@ +/* + * SelectPathPanel.java + * + * Created on February 12, 2003 + */ + +package org.openoffice.netbeans.modules.office.wizard; + +import java.awt.Component; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import org.openide.WizardDescriptor; +import org.openide.util.HelpCtx; +import org.openide.util.NbBundle; + +import org.openoffice.idesupport.OfficeInstallation; + +/** A single panel descriptor for a wizard. + * You probably want to make a wizard iterator to hold it. + * + * @author tomaso + */ +public class SelectPathPanel implements WizardDescriptor.Panel /* .FinishPanel */ { + + /** The visual component that displays this panel. + * If you need to access the component from this class, + * just use getComponent(). + */ + private SelectPathVisualPanel component; + + /** Create the wizard panel descriptor. */ + public SelectPathPanel() { + } + + // Get the visual component for the panel. In this template, the component + // is kept separate. This can be more efficient: if the wizard is created + // but never displayed, or not all panels are displayed, it is better to + // create only those which really need to be visible. + public Component getComponent() { + if (component == null) { + component = new SelectPathVisualPanel(this); + } + return component; + } + + public HelpCtx getHelp() { + // Show no Help button for this panel: + return HelpCtx.DEFAULT_HELP; + // If you have context help: + // return new HelpCtx(SelectPathPanel.class); + } + + public boolean isValid() { + // If it is always OK to press Next or Finish, then: + return true; + // If it depends on some condition (form filled out...), then: + // return someCondition(); + // and when this condition changes (last form field filled in...) then: + // fireChangeEvent(); + // and uncomment the complicated stuff below. + } + + public final void addChangeListener(ChangeListener l) {} + public final void removeChangeListener(ChangeListener l) {} + /* + private final Set listeners = new HashSet(1); // Set<ChangeListener> + public final void addChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.add(l); + } + } + public final void removeChangeListener(ChangeListener l) { + synchronized (listeners) { + listeners.remove(l); + } + } + protected final void fireChangeEvent() { + Iterator it; + synchronized (listeners) { + it = new HashSet(listeners).iterator(); + } + ChangeEvent ev = new ChangeEvent(this); + while (it.hasNext()) { + ((ChangeListener)it.next()).stateChanged(ev); + } + } + */ + + private OfficeInstallation office; + + public void setSelectedPath(OfficeInstallation oi) { + this.office = oi; + } + + // You can use a settings object to keep track of state. + // Normally the settings object will be the WizardDescriptor, + // so you can use WizardDescriptor.getProperty & putProperty + // to store information entered by the user. + public void readSettings(Object settings) { + } + + public void storeSettings(Object settings) { + WizardDescriptor wiz = (WizardDescriptor)settings; + wiz.putProperty(InstallationPathDescriptor.PROP_INSTALLPATH, office); + } +} diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.form b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.form new file mode 100644 index 000000000000..088e5db8b08c --- /dev/null +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.form @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[600, 300]"/> + </Property> + </Properties> + <AuxValues> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,27,0,0,2,1"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" value="Installations Detected"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="11" insetsRight="2" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="installPath"> + <Properties> + <Property name="editable" type="boolean" value="false"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="10" weightX="1.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="text" type="java.lang.String" value="Installation Directory"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="11" insetsRight="12" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JComboBox" name="installationsComboBox"> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="installationsComboBoxActionPerformed"/> + </Events> + <AuxValues> + <AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value=""/> + <AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value=""/> + <AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value=""/> + <AuxValue name="JavaCodeGenerator_CodeGeneration" type="java.lang.Integer" value="0"/> + <AuxValue name="JavaCodeGenerator_CreateCodePost" type="java.lang.String" value=""/> + </AuxValues> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="0" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="11" insetsLeft="0" insetsBottom="11" insetsRight="11" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="2" gridWidth="1" gridHeight="1" fill="3" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="1.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + </Container> + <Component class="javax.swing.JButton" name="browseButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Browse..."/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="2" gridY="1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> +</Form> diff --git a/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java new file mode 100644 index 000000000000..c8cebccac45b --- /dev/null +++ b/scripting/java/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualPanel.java @@ -0,0 +1,187 @@ +/* + * SelectPathVisualPanel.java + * + * Created on February 12, 2003 + */ + +package org.openoffice.netbeans.modules.office.wizard; + +import java.util.Hashtable; +import java.util.Enumeration; +import java.io.File; +import java.io.IOException; +import javax.swing.JFileChooser; + +import org.openide.util.NbBundle; +import org.openoffice.idesupport.SVersionRCFile; +import org.openoffice.idesupport.OfficeInstallation; + +/** A single panel for a wizard - the GUI portion. + * + * @author tomaso + */ +public class SelectPathVisualPanel extends javax.swing.JPanel { + + /** The wizard panel descriptor associated with this GUI panel. + * If you need to fire state changes or something similar, you can + * use this handle to do so. + */ + private final SelectPathPanel panel; + + /** Create the wizard panel and set up some basic properties. */ + public SelectPathVisualPanel(SelectPathPanel panel) { + this.panel = panel; + initComponents(); + + try { + Enumeration enum = SVersionRCFile.createInstance().getVersions(); + + while (enum.hasMoreElements()) { + OfficeInstallation oi = (OfficeInstallation)enum.nextElement(); + installationsComboBox.addItem(oi); + } + } + catch (IOException ioe) { + installationsComboBox.addItem("<empty>"); + } + + // Provide a name in the title bar. + setName(NbBundle.getMessage(SelectPathVisualPanel.class, "TITLE_WizardPanel")); + /* + // Optional: provide a special description for this pane. + // You must have turned on WizardDescriptor.WizardPanel_helpDisplayed + // (see descriptor in standard iterator template for an example of this). + try { + putClientProperty("WizardPanel_helpURL", // NOI18N + new URL("nbresloc:/org/openoffice/netbeans/modules/office/wizard/SelectPathVisualHelp.html")); // NOI18N + } catch (MalformedURLException mfue) { + throw new IllegalStateException(mfue.toString()); + } + */ + } + + /** 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. + */ + private void initComponents() {//GEN-BEGIN:initComponents + java.awt.GridBagConstraints gridBagConstraints; + + jLabel1 = new javax.swing.JLabel(); + installPath = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + installationsComboBox = new javax.swing.JComboBox(); + jPanel1 = new javax.swing.JPanel(); + browseButton = new javax.swing.JButton(); + + setLayout(new java.awt.GridBagLayout()); + + setPreferredSize(new java.awt.Dimension(600, 300)); + jLabel1.setText("Installations Detected"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 2); + add(jLabel1, gridBagConstraints); + + installPath.setEditable(false); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.weightx = 1.0; + gridBagConstraints.insets = new java.awt.Insets(12, 0, 11, 11); + add(installPath, gridBagConstraints); + + jLabel2.setText("Installation Directory"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.insets = new java.awt.Insets(12, 12, 11, 12); + add(jLabel2, gridBagConstraints); + + installationsComboBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + installationsComboBoxActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(11, 0, 11, 11); + add(installationsComboBox, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.weighty = 1.0; + add(jPanel1, gridBagConstraints); + + browseButton.setText("Browse..."); + browseButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + browseButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 2; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + add(browseButton, gridBagConstraints); + + }//GEN-END:initComponents + + private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed + // Add your handling code here: + File target = null; + + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int result = chooser.showDialog(null, null); + + if (result == JFileChooser.APPROVE_OPTION) { + target = chooser.getSelectedFile(); + + String path; + try { + path = target.getCanonicalPath(); + } + catch (IOException ioe) { + path = target.getAbsolutePath(); + } + + OfficeInstallation oi = new OfficeInstallation(path, path); + + if (oi.supportsFramework()) { + installPath.setText(path); + panel.setSelectedPath(oi); + } + } + + }//GEN-LAST:event_browseButtonActionPerformed + + private void installationsComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_installationsComboBoxActionPerformed + // Add your handling code here: + OfficeInstallation oi = + (OfficeInstallation)installationsComboBox.getSelectedItem(); + + installPath.setText(oi.getPath()); + panel.setSelectedPath(oi); + }//GEN-LAST:event_installationsComboBoxActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField installPath; + private javax.swing.JButton browseButton; + private javax.swing.JComboBox installationsComboBox; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel1; + // End of variables declaration//GEN-END:variables + +} |