This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 47498
Collapse All | Expand All

(-)nbproject/project.xml (+8 lines)
Lines 93-98 Link Here
93
                        <release-version>1</release-version>
93
                        <release-version>1</release-version>
94
                    </run-dependency>
94
                    </run-dependency>
95
                </dependency>
95
                </dependency>
96
                <dependency>
97
                    <code-name-base>org.netbeans.modules.project.libraries</code-name-base>
98
                    <build-prerequisite/>
99
                    <compile-dependency/>
100
                    <run-dependency>
101
                        <release-version>1</release-version>
102
                    </run-dependency>
103
                </dependency>
96
            </module-dependencies>
104
            </module-dependencies>
97
            <public-packages>
105
            <public-packages>
98
                <package>org.netbeans.modules.java.freeform.spi</package>
106
                <package>org.netbeans.modules.java.freeform.spi</package>
(-)src/org/netbeans/modules/java/freeform/ui/Bundle.properties (-1 / +16 lines)
Lines 6-12 Link Here
6
# http://www.sun.com/
6
# http://www.sun.com/
7
# 
7
# 
8
# The Original Code is NetBeans. The Initial Developer of the Original
8
# The Original Code is NetBeans. The Initial Developer of the Original
9
# Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
9
# Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
10
# Microsystems, Inc. All Rights Reserved.
10
# Microsystems, Inc. All Rights Reserved.
11
11
12
# OutputPanel
12
# OutputPanel
Lines 75-77 Link Here
75
LBL_ProjectCustomizer_Category_Sources=Sources
75
LBL_ProjectCustomizer_Category_Sources=Sources
76
LBL_ProjectCustomizer_Category_Classpath=Classpath
76
LBL_ProjectCustomizer_Category_Classpath=Classpath
77
LBL_ProjectCustomizer_Category_Output=Output
77
LBL_ProjectCustomizer_Category_Output=Output
78
79
TXT_Edit=Edit...
80
TXT_EditLibraryTitle=Edit Library
81
TXT_SourceFolder=Source Folder\:
82
TXT_BrowseJavadoc=Browse...
83
TXT_Browse_Sources=Browse...
84
TXT_JavaDocFolder=Javadoc Folder\:
85
TXT_OpenJavadoc=Open Javadoc
86
TXT_Javadoc=Javadoc
87
CTL_SelectJD=Open Javadoc
88
MNE_SelectJD=O
89
TXT_OpenSources=Open Sources
90
TXT_Sources=Sources
91
CTL_SelectSources=Open Sources
92
MNE_SelectSources=O
(-)src/org/netbeans/modules/java/freeform/ui/ClasspathPanel.form (-3 / +24 lines)
Lines 6-11 Link Here
6
      <Dimension value="[275, 202]"/>
6
      <Dimension value="[275, 202]"/>
7
    </Property>
7
    </Property>
8
  </Properties>
8
  </Properties>
9
  <AuxValues>
10
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
11
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
12
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
13
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
14
  </AuxValues>
9
15
10
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
16
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
11
  <SubComponents>
17
  <SubComponents>
Lines 104-110 Link Here
104
    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
110
    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
105
      <Constraints>
111
      <Constraints>
106
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
112
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
107
          <GridBagConstraints gridX="0" gridY="4" gridWidth="2" gridHeight="4" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="10" weightX="1.0" weightY="1.0"/>
113
          <GridBagConstraints gridX="0" gridY="4" gridWidth="2" gridHeight="5" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="10" weightX="1.0" weightY="1.0"/>
108
        </Constraint>
114
        </Constraint>
109
      </Constraints>
115
      </Constraints>
110
116
Lines 154-160 Link Here
154
      </Events>
160
      </Events>
155
      <Constraints>
161
      <Constraints>
156
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
162
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
157
          <GridBagConstraints gridX="2" gridY="6" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
163
          <GridBagConstraints gridX="2" gridY="7" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
158
        </Constraint>
164
        </Constraint>
159
      </Constraints>
165
      </Constraints>
160
    </Component>
166
    </Component>
Lines 169-175 Link Here
169
      </Events>
175
      </Events>
170
      <Constraints>
176
      <Constraints>
171
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
177
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
172
          <GridBagConstraints gridX="2" gridY="7" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
178
          <GridBagConstraints gridX="2" gridY="8" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
173
        </Constraint>
179
        </Constraint>
174
      </Constraints>
180
      </Constraints>
175
    </Component>
181
    </Component>
Lines 215-220 Link Here
215
      <Constraints>
221
      <Constraints>
216
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
222
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
217
          <GridBagConstraints gridX="0" gridY="1" gridWidth="3" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="11" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
223
          <GridBagConstraints gridX="0" gridY="1" gridWidth="3" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="11" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/>
224
        </Constraint>
225
      </Constraints>
226
    </Component>
227
    <Component class="javax.swing.JButton" name="jButton1">
228
      <Properties>
229
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
230
          <ResourceString bundle="org/netbeans/modules/java/freeform/ui/Bundle.properties" key="TXT_Edit" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
231
        </Property>
232
      </Properties>
233
      <Events>
234
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="editLibrary"/>
235
      </Events>
236
      <Constraints>
237
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
238
          <GridBagConstraints gridX="2" gridY="6" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="6" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
218
        </Constraint>
239
        </Constraint>
219
      </Constraints>
240
      </Constraints>
220
    </Component>
241
    </Component>
(-)src/org/netbeans/modules/java/freeform/ui/ClasspathPanel.java (-4 / +100 lines)
Lines 7-13 Link Here
7
 * http://www.sun.com/
7
 * http://www.sun.com/
8
 *
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
12
 */
13
13
Lines 15-32 Link Here
15
15
16
import java.awt.event.ItemEvent;
16
import java.awt.event.ItemEvent;
17
import java.io.File;
17
import java.io.File;
18
import java.io.IOException;
19
import java.net.MalformedURLException;
20
import java.net.URL;
18
import java.util.ArrayList;
21
import java.util.ArrayList;
22
import java.util.Collections;
19
import java.util.Iterator;
23
import java.util.Iterator;
20
import java.util.List;
24
import java.util.List;
21
import javax.swing.DefaultListModel;
25
import javax.swing.DefaultListModel;
22
import javax.swing.JComponent;
26
import javax.swing.JComponent;
23
import javax.swing.JFileChooser;
27
import javax.swing.JFileChooser;
28
import org.netbeans.api.project.libraries.Library;
29
import org.netbeans.api.project.libraries.LibraryManager;
24
import org.netbeans.modules.ant.freeform.spi.ProjectPropertiesPanel;
30
import org.netbeans.modules.ant.freeform.spi.ProjectPropertiesPanel;
25
import org.netbeans.modules.ant.freeform.spi.support.Util;
31
import org.netbeans.modules.ant.freeform.spi.support.Util;
26
import org.netbeans.modules.java.freeform.JavaProjectGenerator;
32
import org.netbeans.modules.java.freeform.JavaProjectGenerator;
33
import org.netbeans.spi.project.libraries.LibraryFactory;
34
import org.netbeans.spi.project.libraries.LibraryImplementation;
35
import org.netbeans.spi.project.libraries.LibraryTypeProvider;
36
import org.netbeans.spi.project.libraries.support.LibrariesSupport;
27
import org.netbeans.spi.project.support.ant.AntProjectHelper;
37
import org.netbeans.spi.project.support.ant.AntProjectHelper;
28
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
38
import org.netbeans.spi.project.support.ant.PropertyEvaluator;
29
import org.netbeans.spi.project.support.ant.PropertyUtils;
39
import org.netbeans.spi.project.support.ant.PropertyUtils;
40
import org.openide.DialogDescriptor;
41
import org.openide.DialogDisplayer;
42
import org.openide.ErrorManager;
30
import org.openide.filesystems.FileUtil;
43
import org.openide.filesystems.FileUtil;
31
import org.openide.util.HelpCtx;
44
import org.openide.util.HelpCtx;
32
import org.openide.util.NbBundle;
45
import org.openide.util.NbBundle;
Lines 153-158 Link Here
153
        moveDown = new javax.swing.JButton();
166
        moveDown = new javax.swing.JButton();
154
        jTextArea1 = new javax.swing.JTextArea();
167
        jTextArea1 = new javax.swing.JTextArea();
155
        separateClasspath = new javax.swing.JCheckBox();
168
        separateClasspath = new javax.swing.JCheckBox();
169
        jButton1 = new javax.swing.JButton();
156
170
157
        setLayout(new java.awt.GridBagLayout());
171
        setLayout(new java.awt.GridBagLayout());
158
172
Lines 222-228 Link Here
222
        gridBagConstraints.gridx = 0;
236
        gridBagConstraints.gridx = 0;
223
        gridBagConstraints.gridy = 4;
237
        gridBagConstraints.gridy = 4;
224
        gridBagConstraints.gridwidth = 2;
238
        gridBagConstraints.gridwidth = 2;
225
        gridBagConstraints.gridheight = 4;
239
        gridBagConstraints.gridheight = 5;
226
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
240
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
227
        gridBagConstraints.weightx = 1.0;
241
        gridBagConstraints.weightx = 1.0;
228
        gridBagConstraints.weighty = 1.0;
242
        gridBagConstraints.weighty = 1.0;
Lines 261-267 Link Here
261
275
262
        gridBagConstraints = new java.awt.GridBagConstraints();
276
        gridBagConstraints = new java.awt.GridBagConstraints();
263
        gridBagConstraints.gridx = 2;
277
        gridBagConstraints.gridx = 2;
264
        gridBagConstraints.gridy = 6;
278
        gridBagConstraints.gridy = 7;
265
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
279
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
266
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
280
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
267
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
281
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
Lines 276-282 Link Here
276
290
277
        gridBagConstraints = new java.awt.GridBagConstraints();
291
        gridBagConstraints = new java.awt.GridBagConstraints();
278
        gridBagConstraints.gridx = 2;
292
        gridBagConstraints.gridx = 2;
279
        gridBagConstraints.gridy = 7;
293
        gridBagConstraints.gridy = 8;
280
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
294
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
281
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
295
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
282
        add(moveDown, gridBagConstraints);
296
        add(moveDown, gridBagConstraints);
Lines 310-317 Link Here
310
        gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 0);
324
        gridBagConstraints.insets = new java.awt.Insets(11, 0, 0, 0);
311
        add(separateClasspath, gridBagConstraints);
325
        add(separateClasspath, gridBagConstraints);
312
326
327
        jButton1.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("TXT_Edit"));
328
        jButton1.addActionListener(new java.awt.event.ActionListener() {
329
            public void actionPerformed(java.awt.event.ActionEvent evt) {
330
                editLibrary(evt);
331
            }
332
        });
333
334
        gridBagConstraints = new java.awt.GridBagConstraints();
335
        gridBagConstraints.gridx = 2;
336
        gridBagConstraints.gridy = 6;
337
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
338
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
339
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
340
        add(jButton1, gridBagConstraints);
341
313
    }//GEN-END:initComponents
342
    }//GEN-END:initComponents
314
343
344
    private void editLibrary(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editLibrary
345
        String selectedEntry = (String) classpath.getSelectedValue();
346
        assert selectedEntry != null;
347
        File f = FileUtil.normalizeFile (new File (selectedEntry));        
348
        URL rootURL = null;
349
        try {
350
             rootURL = f.toURI().toURL();
351
            if (FileUtil.isArchiveFile(rootURL)) {
352
                rootURL = FileUtil.getArchiveRoot(rootURL);
353
            }
354
        } catch (MalformedURLException mue) {
355
            ErrorManager.getDefault().notify(mue);
356
            return;
357
        }
358
        Library oldLibrary = LibraryManager.getDefault().getLibrary(selectedEntry);
359
        LibraryEditor editor = new LibraryEditor ();
360
        if (oldLibrary != null) {
361
            List classpath = oldLibrary.getContent("classpath");    //NOI18N
362
            List sources = oldLibrary.getContent("src");            //NOI18N            
363
            List javadoc = oldLibrary.getContent("javadoc");        //NOI18N            
364
            //If library exists allow to change only Library created by this support
365
            if (classpath.size() == 1 && rootURL.equals(classpath.get(0)) &&
366
                sources.size() <= 1 && javadoc.size() <= 1) {
367
                editor.setSourceFolder ((URL)sources.get(0));
368
                editor.setJavadocFolder((URL)javadoc.get(0));
369
            }
370
            else {
371
                return;
372
            }
373
        }
374
        
375
        DialogDescriptor dd = new DialogDescriptor (editor,NbBundle.getMessage(ClasspathPanel.class,"TXT_EditLibraryTitle"),true,
376
                DialogDescriptor.OK_CANCEL_OPTION,DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, 
377
                new HelpCtx (LibraryEditor.class),null);
378
        if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
379
            try {
380
                if (oldLibrary != null) {
381
                    LibraryManager.getDefault().removeLibrary(oldLibrary);
382
                }
383
                URL sources = editor.getSourceFoler();
384
                URL javadoc = editor.getJavadocFolder();            
385
                LibraryTypeProvider provider = LibrariesSupport.getLibraryTypeProvider("j2se");    //NOI18N
386
                assert provider != null : "No J2SE LibraryTypeProvider";    //NOI18N
387
                LibraryImplementation impl = provider.createLibrary();
388
                impl.setName (PropertyUtils.getUsablePropertyName(selectedEntry));                
389
                impl.setContent ("classpath",Collections.singletonList(rootURL)); //NOI18N
390
                if (sources != null) {
391
                    if (FileUtil.isArchiveFile(sources)) {
392
                        sources = FileUtil.getArchiveRoot (sources);
393
                    }
394
                    impl.setContent ("src",Collections.singletonList(sources)); //NOI18N
395
                }
396
                if (javadoc != null) {
397
                    if (FileUtil.isArchiveFile(javadoc)) {
398
                        javadoc = FileUtil.getArchiveRoot (javadoc);
399
                    }
400
                    impl.setContent ("javadoc",Collections.singletonList(javadoc)); //NOI18N
401
                }
402
                Library newLibrary = LibraryFactory.createLibrary(impl);
403
                LibraryManager.getDefault().addLibrary(newLibrary);
404
            } catch (IOException ioe) {
405
                ErrorManager.getDefault().notify(ioe);
406
            }            
407
        }
408
    }//GEN-LAST:event_editLibrary
409
315
    private void classpathValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_classpathValueChanged
410
    private void classpathValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_classpathValueChanged
316
        updateButtons();
411
        updateButtons();
317
    }//GEN-LAST:event_classpathValueChanged
412
    }//GEN-LAST:event_classpathValueChanged
Lines 565-570 Link Here
565
    // Variables declaration - do not modify//GEN-BEGIN:variables
660
    // Variables declaration - do not modify//GEN-BEGIN:variables
566
    private javax.swing.JButton addClasspath;
661
    private javax.swing.JButton addClasspath;
567
    private javax.swing.JList classpath;
662
    private javax.swing.JList classpath;
663
    private javax.swing.JButton jButton1;
568
    private javax.swing.JLabel jLabel2;
664
    private javax.swing.JLabel jLabel2;
569
    private javax.swing.JLabel jLabel3;
665
    private javax.swing.JLabel jLabel3;
570
    private javax.swing.JPanel jPanel1;
666
    private javax.swing.JPanel jPanel1;
(-)src/org/netbeans/modules/java/freeform/ui/LibraryEditor.form (+100 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
2
3
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <AuxValues>
5
    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
6
    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
7
    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
8
    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
9
  </AuxValues>
10
11
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
12
  <SubComponents>
13
    <Component class="javax.swing.JLabel" name="jLabel1">
14
      <Properties>
15
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
16
          <ComponentRef name="sources"/>
17
        </Property>
18
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
19
          <ResourceString bundle="org/netbeans/modules/java/freeform/ui/Bundle.properties" key="TXT_SourceFolder" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
20
        </Property>
21
      </Properties>
22
      <Constraints>
23
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
24
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="0" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
25
        </Constraint>
26
      </Constraints>
27
    </Component>
28
    <Component class="javax.swing.JTextField" name="sources">
29
      <Properties>
30
        <Property name="columns" type="int" value="30"/>
31
      </Properties>
32
      <Constraints>
33
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
34
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="18" weightX="1.0" weightY="0.0"/>
35
        </Constraint>
36
      </Constraints>
37
    </Component>
38
    <Component class="javax.swing.JButton" name="jButton1">
39
      <Properties>
40
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
41
          <ResourceString bundle="org/netbeans/modules/java/freeform/ui/Bundle.properties" key="TXT_Browse_Sources" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
42
        </Property>
43
      </Properties>
44
      <Events>
45
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseSources"/>
46
      </Events>
47
      <Constraints>
48
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
49
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="0" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
50
        </Constraint>
51
      </Constraints>
52
    </Component>
53
    <Component class="javax.swing.JLabel" name="jLabel2">
54
      <Properties>
55
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
56
          <ResourceString bundle="org/netbeans/modules/java/freeform/ui/Bundle.properties" key="TXT_JavaDocFolder" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
57
        </Property>
58
      </Properties>
59
      <Constraints>
60
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
61
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="12" insetsBottom="12" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
62
        </Constraint>
63
      </Constraints>
64
    </Component>
65
    <Component class="javax.swing.JTextField" name="javadoc">
66
      <Properties>
67
        <Property name="columns" type="int" value="30"/>
68
      </Properties>
69
      <Constraints>
70
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
71
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="12" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
72
        </Constraint>
73
      </Constraints>
74
    </Component>
75
    <Component class="javax.swing.JButton" name="jButton2">
76
      <Properties>
77
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
78
          <ResourceString bundle="org/netbeans/modules/java/freeform/ui/Bundle.properties" key="TXT_BrowseJavadoc" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
79
        </Property>
80
      </Properties>
81
      <Events>
82
        <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="browseJavadoc"/>
83
      </Events>
84
      <Constraints>
85
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
86
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="12" insetsLeft="0" insetsBottom="12" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
87
        </Constraint>
88
      </Constraints>
89
    </Component>
90
    <Container class="javax.swing.JPanel" name="jPanel1">
91
      <Constraints>
92
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
93
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="0" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="1.0"/>
94
        </Constraint>
95
      </Constraints>
96
97
      <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
98
    </Container>
99
  </SubComponents>
100
</Form>
(-)src/org/netbeans/modules/java/freeform/ui/LibraryEditor.java (+215 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.modules.java.freeform.ui;
15
16
17
import java.io.File;
18
import java.net.MalformedURLException;
19
import java.net.URI;
20
import java.net.URL;
21
import javax.swing.JFileChooser;
22
import javax.swing.filechooser.FileFilter;
23
import org.openide.ErrorManager;
24
import org.openide.filesystems.FileUtil;
25
import org.openide.util.NbBundle;
26
27
/**
28
 *
29
 * @author  tom
30
 */
31
public class LibraryEditor extends javax.swing.JPanel {
32
    
33
    /** Creates new form LibraryEditor */
34
    public LibraryEditor() {
35
        initComponents();
36
    }
37
    
38
    
39
    public final URL getSourceFoler () {
40
        File f = FileUtil.normalizeFile(new File (this.sources.getText()));
41
        try {
42
            return f.toURI().toURL();        
43
        } catch (MalformedURLException mfu) {
44
            ErrorManager.getDefault().notify (mfu);
45
            return null;
46
        }
47
    }
48
    
49
    public final void setSourceFolder (URL folder) {
50
        File f = new File (URI.create (folder.toExternalForm()));        
51
        this.sources.setText (f.getAbsolutePath());
52
    }
53
    
54
    public final URL getJavadocFolder () {
55
        try {
56
            File f = FileUtil.normalizeFile(new File (this.javadoc.getText()));
57
            return f.toURI().toURL();        
58
        } catch (MalformedURLException mfu) {
59
            ErrorManager.getDefault().notify(mfu);
60
            return null;
61
        }
62
    }
63
    
64
    public final void setJavadocFolder (URL folder) {
65
        File f = new File (URI.create (folder.toExternalForm()));
66
        this.javadoc.setText(f.getAbsolutePath());
67
    }
68
    
69
    /** This method is called from within the constructor to
70
     * initialize the form.
71
     * WARNING: Do NOT modify this code. The content of this method is
72
     * always regenerated by the Form Editor.
73
     */
74
    private void initComponents() {//GEN-BEGIN:initComponents
75
        java.awt.GridBagConstraints gridBagConstraints;
76
77
        jLabel1 = new javax.swing.JLabel();
78
        sources = new javax.swing.JTextField();
79
        jButton1 = new javax.swing.JButton();
80
        jLabel2 = new javax.swing.JLabel();
81
        javadoc = new javax.swing.JTextField();
82
        jButton2 = new javax.swing.JButton();
83
        jPanel1 = new javax.swing.JPanel();
84
85
        setLayout(new java.awt.GridBagLayout());
86
87
        jLabel1.setLabelFor(sources);
88
        jLabel1.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("TXT_SourceFolder"));
89
        gridBagConstraints = new java.awt.GridBagConstraints();
90
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
91
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 0, 12);
92
        add(jLabel1, gridBagConstraints);
93
94
        sources.setColumns(30);
95
        gridBagConstraints = new java.awt.GridBagConstraints();
96
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
97
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
98
        gridBagConstraints.weightx = 1.0;
99
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 12);
100
        add(sources, gridBagConstraints);
101
102
        jButton1.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("TXT_Browse_Sources"));
103
        jButton1.addActionListener(new java.awt.event.ActionListener() {
104
            public void actionPerformed(java.awt.event.ActionEvent evt) {
105
                browseSources(evt);
106
            }
107
        });
108
109
        gridBagConstraints = new java.awt.GridBagConstraints();
110
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
111
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
112
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 12);
113
        add(jButton1, gridBagConstraints);
114
115
        jLabel2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("TXT_JavaDocFolder"));
116
        gridBagConstraints = new java.awt.GridBagConstraints();
117
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
118
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
119
        add(jLabel2, gridBagConstraints);
120
121
        javadoc.setColumns(30);
122
        gridBagConstraints = new java.awt.GridBagConstraints();
123
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
124
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
125
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 12);
126
        add(javadoc, gridBagConstraints);
127
128
        jButton2.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/freeform/ui/Bundle").getString("TXT_BrowseJavadoc"));
129
        jButton2.addActionListener(new java.awt.event.ActionListener() {
130
            public void actionPerformed(java.awt.event.ActionEvent evt) {
131
                browseJavadoc(evt);
132
            }
133
        });
134
135
        gridBagConstraints = new java.awt.GridBagConstraints();
136
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
137
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
138
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 12);
139
        add(jButton2, gridBagConstraints);
140
141
        gridBagConstraints = new java.awt.GridBagConstraints();
142
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
143
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
144
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
145
        gridBagConstraints.weightx = 1.0;
146
        gridBagConstraints.weighty = 1.0;
147
        add(jPanel1, gridBagConstraints);
148
149
    }//GEN-END:initComponents
150
151
    private void browseJavadoc(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseJavadoc
152
        JFileChooser chooser = new JFileChooser();
153
        FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
154
        chooser.setAcceptAllFileFilterUsed(false);
155
        chooser.setDialogTitle(NbBundle.getMessage(LibraryEditor.class,"TXT_OpenJavadoc"));
156
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
157
        chooser.setFileFilter (new SimpleFileFilter(NbBundle.getMessage(LibraryEditor.class,"TXT_Javadoc")));     //NOI18N
158
        chooser.setApproveButtonText(NbBundle.getMessage(LibraryEditor.class,"CTL_SelectJD"));
159
        chooser.setApproveButtonMnemonic(NbBundle.getMessage(LibraryEditor.class,"MNE_SelectJD").charAt(0));
160
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
161
            this.javadoc.setText(chooser.getSelectedFile().getAbsolutePath());
162
        }            
163
    }//GEN-LAST:event_browseJavadoc
164
165
    private void browseSources(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseSources
166
        JFileChooser chooser = new JFileChooser();
167
        FileUtil.preventFileChooserSymlinkTraversal(chooser, null);
168
        chooser.setAcceptAllFileFilterUsed(false);
169
        chooser.setDialogTitle(NbBundle.getMessage(LibraryEditor.class,"TXT_OpenSources"));
170
        chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
171
        chooser.setFileFilter (new SimpleFileFilter(NbBundle.getMessage(LibraryEditor.class,"TXT_Sources")));     //NOI18N
172
        chooser.setApproveButtonText(NbBundle.getMessage(LibraryEditor.class,"CTL_SelectSources"));
173
        chooser.setApproveButtonMnemonic(NbBundle.getMessage(LibraryEditor.class,"MNE_SelectSources").charAt(0));
174
        if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
175
            this.sources.setText(chooser.getSelectedFile().getAbsolutePath());
176
        }
177
    }//GEN-LAST:event_browseSources
178
    
179
    
180
    private static class SimpleFileFilter extends FileFilter {
181
        
182
        private String description;
183
        
184
        
185
        public SimpleFileFilter(String description) {
186
            this.description = description;
187
        }
188
        
189
        public boolean accept(File f) {
190
            if (f.isDirectory())
191
                return true;
192
            try {
193
                return FileUtil.isArchiveFile(FileUtil.normalizeFile(f).toURI().toURL());
194
            } catch (MalformedURLException mfu) {
195
                ErrorManager.getDefault().notify(mfu);
196
                return false;
197
            }
198
        }
199
        
200
        public String getDescription() {
201
            return this.description;
202
        }
203
    }
204
    
205
    // Variables declaration - do not modify//GEN-BEGIN:variables
206
    private javax.swing.JButton jButton1;
207
    private javax.swing.JButton jButton2;
208
    private javax.swing.JLabel jLabel1;
209
    private javax.swing.JLabel jLabel2;
210
    private javax.swing.JPanel jPanel1;
211
    private javax.swing.JTextField javadoc;
212
    private javax.swing.JTextField sources;
213
    // End of variables declaration//GEN-END:variables
214
    
215
}

Return to bug 47498