01: package tide.project;
02:
03: import java.awt.BorderLayout;
04: import javax.swing.border.EmptyBorder;
05: import snow.utils.gui.*;
06: import java.io.File;
07: import tide.editor.MainEditorFrame;
08: import java.util.*;
09: import snow.utils.storage.FileUtils;
10: import javax.swing.*;
11:
12: // offer automated JDK download ??
13:
14: /** Wizard to select the JDK.
15: * Modal dialog.
16: */
17: public final class SelectJDKDialog extends JDialog {
18: final private FileField javaHomeField;
19: final private CloseControlPanel ccp;
20:
21: public SelectJDKDialog(final JFrame parent, final String expl) {
22: super (parent, "JDK selection", true);
23:
24: final ProjectSettings projDef = MainEditorFrame.instance
25: .getActualProject();
26:
27: List<File> allKnownJDKPaths = FileUtils.getFilesFromList(
28: MainEditorFrame.instance.globalProperties.getProperty(
29: "JDK_paths", ""), true);
30:
31: ccp = new CloseControlPanel(this , true, true, "Ok");
32: add(ccp, BorderLayout.SOUTH);
33:
34: JPanel cpPanel = new JPanel();
35: add(cpPanel, BorderLayout.CENTER);
36: GridLayout3 gl3 = new GridLayout3(2, cpPanel);
37: cpPanel.setBorder(new EmptyBorder(5, 2, 2, 2));
38:
39: gl3.addExplanationArea(expl);
40:
41: gl3.addSeparator();
42: gl3.add("JDK home");
43:
44: String dh = projDef.getJava_Home().getAbsolutePath();
45: if (allKnownJDKPaths.size() > 0) {
46: // take the "latest" ?
47: dh = "" + allKnownJDKPaths.get(allKnownJDKPaths.size() - 1);
48: }
49:
50: javaHomeField = new FileField(
51: dh,
52: false,
53: "Select the java development kit home directory (where /bin is)",
54: JFileChooser.DIRECTORIES_ONLY);
55:
56: javaHomeField.setAlternatePaths(allKnownJDKPaths);
57:
58: javaHomeField.getTextField().setColumns(30);
59: gl3.add(javaHomeField);
60: javaHomeField.setAutoColorized();
61: String oldJDKHome = javaHomeField.getPath().getAbsolutePath();
62:
63: pack();
64: setLocationRelativeTo(null);
65: setVisible(true);
66: }
67:
68: public File getSelectedJDKHomeOrNull() {
69: if (ccp.getWasCancelled())
70: return null;
71: return javaHomeField.getPath();
72: }
73:
74: }
|