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; |