KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > devgui > WebAppPanel


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/devgui/WebAppPanel.java,v 1.7 2004/08/18 12:25:57 hkollmann Exp $
3  * $Revision: 1.7 $
4  * $Date: 2004/08/18 12:25:57 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 /*
25  * WebAppPanel.java
26  *
27  * Created on 26. April 2001, 15:42
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 PropertyPanel implements ActionListener {
47    private JButton b_browseApp;
48    private JButton b_chooseRoot;
49
50    // GUI Variables declaration
51
private JLabel jLabel1;
52
53    // GUI Variables declaration
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 JavaDoc 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() { //GEN-BEGIN: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 JavaDoc();
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 JavaDoc();
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 }
160
Popular Tags