1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 package org.dbforms.devgui;
30
31 import java.awt.*;
32 import java.awt.event.*;
33
34 import java.io.*;
35
36 import javax.swing.*;
37
38
39
40 /***
41 * DOCUMENT ME!
42 *
43 * @author Administrator
44 * @version
45 */
46 public class WebAppPanel extends AbstractPropertyPanel implements ActionListener {
47 private JButton b_browseApp;
48 private JButton b_chooseRoot;
49
50
51 private JLabel jLabel1;
52
53
54 private JLabel jLabel2;
55 private JTextField tf_webAppRoot;
56 private JTextField tf_webAppURL;
57
58 /***
59 * Creates new form WebAppPanel
60 *
61 * @param parent DOCUMENT ME!
62 */
63 public WebAppPanel(DevGui parent) {
64 super(parent.getProjectData());
65 initComponents();
66 doLayout();
67 }
68
69 /***
70 * DOCUMENT ME!
71 *
72 * @param projectData DOCUMENT ME!
73 */
74 public void setNewProjectData(ProjectData projectData) {
75 this.projectData = projectData;
76
77 tf_webAppRoot.setText(projectData.getProperty("webAppRoot"));
78 tf_webAppURL.setText(projectData.getProperty("webAppURL"));
79 }
80
81
82 /***
83 * DOCUMENT ME!
84 *
85 * @param ev DOCUMENT ME!
86 */
87 public void actionPerformed(ActionEvent ev) {
88 if (ev.getSource() == b_chooseRoot) {
89 File dlgFile = new File(projectData.getProperty("webAppRoot"));
90
91 if (!dlgFile.exists()) {
92 dlgFile = null;
93 }
94
95 JFileChooser dlg_fileChooser = new JFileChooser(dlgFile);
96 dlg_fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
97
98 dlg_fileChooser.setVisible(true);
99
100 int returnVal = dlg_fileChooser.showOpenDialog(this);
101
102 if (returnVal == JFileChooser.APPROVE_OPTION) {
103 tf_webAppRoot.setText(dlg_fileChooser.getSelectedFile().getAbsolutePath());
104 tf_webAppRoot.grabFocus();
105 }
106 } else if (ev.getSource() == b_browseApp) {
107 System.out.println("##");
108
109 String webAppURL = projectData.getProperty("webAppURL");
110
111 try {
112 BrowserTool.openURL(webAppURL);
113 } catch (IOException ioe) {
114 showExceptionDialog(ioe);
115 }
116 }
117 }
118
119
120 /***
121 * This method is called from within the constructor to initialize the form.
122 * WARNING: Do NOT modify this code. The content of this method is always
123 * regenerated by the FormEditor.
124 */
125 private void initComponents() {
126 setLayout(new BorderLayout());
127
128 JPanel panel_top = new JPanel();
129 panel_top.setLayout(new GridLayout(2, 3));
130 add(BorderLayout.NORTH, panel_top);
131
132 jLabel1 = new javax.swing.JLabel();
133 jLabel1.setText("Location of Webapp");
134 jLabel1.setToolTipText("the location of root directory of your web app");
135 panel_top.add(jLabel1);
136
137 tf_webAppRoot = new JTextField();
138 addAFocusListener(tf_webAppRoot, "webAppRoot");
139 panel_top.add(tf_webAppRoot);
140
141 b_chooseRoot = new JButton("change dir...");
142 b_chooseRoot.addActionListener(this);
143 b_chooseRoot.setToolTipText("Choose the local root directory of your web application.");
144 panel_top.add(b_chooseRoot);
145
146 jLabel2 = new javax.swing.JLabel();
147 jLabel2.setText("Web-URL of Webapp");
148 panel_top.add(jLabel2);
149
150 tf_webAppURL = new JTextField("http://127.0.0.1:8080/yourApp");
151 addAFocusListener(tf_webAppURL, "webAppURL");
152 panel_top.add(tf_webAppURL);
153
154 b_browseApp = new JButton("view in browser...");
155 b_chooseRoot.setToolTipText("Test the application. Web server must be running!");
156 b_browseApp.addActionListener(this);
157 panel_top.add(b_browseApp);
158 }
159 }