001: package tide.export;
002:
003: import java.awt.BorderLayout;
004: import javax.swing.border.EmptyBorder;
005: import tide.editor.*;
006: import tide.project.*;
007: import javax.swing.*;
008: import snow.utils.gui.*;
009:
010: /** User interface to enter some JNLP parameters.
011: */
012: public final class JNLPPanel extends JPanel {
013: public static final String codebaseDefault = "http://www.myhomepage/javaapplications/";
014:
015: private final JTextField codebase = new JTextField(codebaseDefault,
016: 30);
017: private final JTextField homepage = new JTextField("index.html", 20);
018: private final JTextField vendor = new JTextField("Vendor", 20);
019: private final JTextField title = new JTextField("Title", 20);
020: private final JTextField description = new JTextField(
021: "Description", 20);
022: private final JTextField javaVersion = new JTextField("1.6+", 20);
023:
024: public JNLPPanel() {
025: super (new BorderLayout(0, 0));
026:
027: JTextArea descr = new JTextArea(
028: "If the application is signed, full permissions are automatically set."
029: + "\nExternal jars are automatically loaded."
030: + "\nXmx options are taken from project settings.");
031: descr.setEditable(false);
032: descr.setBorder(new EmptyBorder(5, 5, 5, 5));
033: descr.setBackground(this .getBackground());
034: add(descr, BorderLayout.NORTH);
035:
036: JPanel cp = new JPanel();
037: add(cp, BorderLayout.CENTER);
038: GridLayout3 gl = new GridLayout3(2, cp);
039:
040: setOpaque(false);
041: setBorder(BorderFactory.createRaisedBevelBorder());
042:
043: gl.addTitleSeparator("Spec");
044:
045: gl.add("Codebase");
046: gl.add(codebase);
047:
048: gl.addTitleSeparator("Information");
049:
050: gl.add("HomePage (relative to codebase)");
051: gl.add(homepage);
052: gl.add("Vendor");
053: gl.add(vendor);
054: gl.add("Title");
055: gl.add(title);
056: gl.add("Description");
057: gl.add(description);
058:
059: gl.addTitleSeparator("Resources");
060:
061: gl.add("Java J2SE version");
062: gl.add(javaVersion, false);
063:
064: readValuesFromIniFile();
065: }
066:
067: public String getCodeBase() {
068: return codebase.getText().trim();
069: }
070:
071: public String getTitle() {
072: return title.getText().trim();
073: }
074:
075: public String getHomePage() {
076: return homepage.getText().trim();
077: }
078:
079: public String getVendor() {
080: return vendor.getText().trim();
081: }
082:
083: public String getDescription() {
084: return description.getText().trim();
085: }
086:
087: public String getJavaVersion() {
088: return javaVersion.getText().trim();
089: }
090:
091: /** Must be called at the end.
092: */
093: public void saveSettingsInInifile() {
094: if (MainEditorFrame.instance == null)
095: return;
096: ProjectSettings actualProject = MainEditorFrame.instance
097: .getActualProject();
098:
099: actualProject.setProperty("JNLP_codebase", codebase.getText());
100: actualProject.setProperty("JNLP_homepage", homepage.getText());
101: actualProject.setProperty("JNLP_vendor", vendor.getText());
102: actualProject.setProperty("JNLP_description", description
103: .getText());
104: actualProject.setProperty("JNLP_title", title.getText());
105: actualProject.setProperty("JNLP_javaversion", javaVersion
106: .getText());
107: }
108:
109: private void readValuesFromIniFile() {
110: if (MainEditorFrame.instance == null)
111: return;
112: ProjectSettings actualProject = MainEditorFrame.instance
113: .getActualProject();
114:
115: codebase.setText(actualProject.getProperty("JNLP_codebase",
116: codebaseDefault));
117: homepage.setText(actualProject.getProperty("JNLP_homepage",
118: "index.html"));
119: vendor.setText(actualProject.getProperty("JNLP_vendor",
120: "Vendor"));
121: description.setText(actualProject.getProperty(
122: "JNLP_description", actualProject.getProjectName()
123: + " is a wonderful application"));
124: title.setText(actualProject.getProperty("JNLP_title",
125: actualProject.getProjectName()));
126: javaVersion.setText(actualProject.getProperty(
127: "JNLP_javaversion", System.getProperty(
128: "java.specification.version", "1.6")
129: + "+")); // default from system
130: }
131:
132: /*test
133: public static void main(String[] arguments)
134: {
135:
136: JFrame f = new JFrame("JNLP parameters");
137: f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
138: f.setContentPane(new JNLPPanel());
139: f.pack();
140: f.setLocationRelativeTo(null);
141: f.setVisible(true);
142: }*/
143: }
|