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.dialogs;
025:
026: import javax.swing.ButtonGroup;
027: import javax.swing.JLabel;
028: import javax.swing.JRadioButton;
029: import javax.swing.JTextField;
030: import org.dlib.gui.FlexLayout;
031: import org.dlib.gui.TPanel;
032: import org.fao.gast.lib.Lib;
033:
034: //==============================================================================
035:
036: public class ServerPanel extends TPanel {
037: //---------------------------------------------------------------------------
038: //---
039: //--- Constructor
040: //---
041: //---------------------------------------------------------------------------
042:
043: public ServerPanel() {
044: super ("Server");
045:
046: FlexLayout fl = new FlexLayout(3, 5);
047: fl.setColProp(2, FlexLayout.EXPAND);
048: setLayout(fl);
049:
050: add("0,0,x,c,3", jrbEmbed);
051: add("0,1,x,c,3", jrbExter);
052:
053: add("1,2", new JLabel("Host"));
054: add("2,2,x", txtHost);
055:
056: add("1,3", new JLabel("Port"));
057: add("2,3,x", txtPort);
058:
059: add("1,4", new JLabel("Servlet"));
060: add("2,4,x", txtServlet);
061:
062: btgServer.add(jrbEmbed);
063: btgServer.add(jrbExter);
064: btgServer.setSelected(jrbEmbed.getModel(), true);
065: }
066:
067: //---------------------------------------------------------------------------
068: //---
069: //--- API methods
070: //---
071: //---------------------------------------------------------------------------
072:
073: public String getHost() {
074: if (jrbEmbed.isSelected()) {
075: String host = Lib.embeddedSC.getHost();
076:
077: return (host == null) ? "localhost" : host;
078: } else {
079: return txtHost.getText();
080: }
081: }
082:
083: //---------------------------------------------------------------------------
084:
085: public int getPort() throws NumberFormatException {
086: if (jrbEmbed.isSelected()) {
087: String port = Lib.embeddedSC.getPort();
088:
089: return (port == null) ? 80 : Integer.parseInt(port);
090: } else {
091: String port = txtPort.getText().trim();
092:
093: if (port.length() == 0)
094: return 80;
095:
096: return Integer.parseInt(port);
097: }
098: }
099:
100: //---------------------------------------------------------------------------
101:
102: public String getServlet() {
103: if (jrbEmbed.isSelected())
104: return Lib.embeddedSC.getServlet();
105: else
106: return txtServlet.getText();
107: }
108:
109: //---------------------------------------------------------------------------
110: //---
111: //--- Variables
112: //---
113: //---------------------------------------------------------------------------
114:
115: private ButtonGroup btgServer = new ButtonGroup();
116: private JRadioButton jrbEmbed = new JRadioButton("Embedded");
117: private JRadioButton jrbExter = new JRadioButton("External");
118: private JTextField txtHost = new JTextField(20);
119: private JTextField txtPort = new JTextField(20);
120: private JTextField txtServlet = new JTextField(20);
121: }
122:
123: //==============================================================================
|