001: //==============================================================================
002: //=== Copyright (C) 2001-2007 Food and Agriculture Organization of the
003: //=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
004: //=== and United Nations Environment Programme (UNEP)
005: //===
006: //=== This program is free software; you can redistribute it and/or modify
007: //=== it under the terms of the GNU General Public License as published by
008: //=== the Free Software Foundation; either version 2 of the License, or (at
009: //=== your option) any later version.
010: //===
011: //=== This program is distributed in the hope that it will be useful, but
012: //=== WITHOUT ANY WARRANTY; without even the implied warranty of
013: //=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: //=== General Public License for more details.
015: //===
016: //=== You should have received a copy of the GNU General Public License
017: //=== along with this program; if not, write to the Free Software
018: //=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
019: //===
020: //=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
021: //=== Rome - Italy. email: geonetwork@osgeo.org
022: //==============================================================================
023:
024: package org.fao.gast.gui.panels.config.jetty;
025:
026: import java.awt.event.ActionEvent;
027: import java.io.IOException;
028: import javax.swing.JComponent;
029: import javax.swing.JLabel;
030: import javax.swing.JPanel;
031: import javax.swing.JTextField;
032: import org.dlib.gui.FlexLayout;
033: import org.fao.gast.gui.panels.FormPanel;
034: import org.fao.gast.lib.Lib;
035:
036: //==============================================================================
037:
038: public class MainPanel extends FormPanel {
039: //---------------------------------------------------------------------------
040: //---
041: //--- Constructor
042: //---
043: //---------------------------------------------------------------------------
044:
045: public MainPanel() {
046: txtServlet.setText(Lib.embeddedSC.getServlet());
047: txtPort.setText(Lib.embeddedSC.getPort());
048: }
049:
050: //---------------------------------------------------------------------------
051: //---
052: //--- ActionListener
053: //---
054: //---------------------------------------------------------------------------
055:
056: public void actionPerformed(ActionEvent e) {
057: save();
058: }
059:
060: //---------------------------------------------------------------------------
061:
062: private void save() {
063: if (!Lib.type.isInteger(txtPort.getText()))
064: Lib.gui.showError(this , "The port must be an integer");
065: else {
066: Lib.embeddedSC.setServlet(txtServlet.getText());
067: Lib.embeddedSC.setPort(txtPort.getText());
068:
069: try {
070: Lib.embeddedSC.save();
071: Lib.gui.showInfo(this , "Configuration saved");
072: } catch (IOException e) {
073: Lib.gui.showError(this , e);
074: }
075: }
076: }
077:
078: //---------------------------------------------------------------------------
079: //---
080: //--- Protected methods
081: //---
082: //---------------------------------------------------------------------------
083:
084: protected JComponent buildInnerPanel() {
085: JPanel p = new JPanel();
086:
087: FlexLayout fl = new FlexLayout(2, 2);
088: fl.setColProp(1, FlexLayout.EXPAND);
089: p.setLayout(fl);
090:
091: p.add("0,0", new JLabel("Servlet"));
092: p.add("0,1", new JLabel("Port"));
093: p.add("1,0,x", txtServlet);
094: p.add("1,1,x", txtPort);
095:
096: return p;
097: }
098:
099: //---------------------------------------------------------------------------
100: //---
101: //--- Variables
102: //---
103: //---------------------------------------------------------------------------
104:
105: private JTextField txtServlet = new JTextField(20);
106: private JTextField txtPort = new JTextField(20);
107: }
108:
109: //==============================================================================
|