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.geonet.csw.client;
025:
026: import java.util.StringTokenizer;
027: import javax.swing.JCheckBox;
028: import javax.swing.JLabel;
029: import javax.swing.JTextField;
030: import org.dlib.gui.FlexLayout;
031: import org.dlib.gui.TPanel;
032: import org.fao.geonet.csw.common.Csw;
033: import org.fao.geonet.csw.common.Csw.Section;
034: import org.fao.geonet.csw.common.requests.CatalogRequest;
035: import org.fao.geonet.csw.common.requests.GetCapabilitiesRequest;
036:
037: //=============================================================================
038:
039: public class GetCapabilitiesPanel extends TPanel {
040: private JTextField txtUpdateSeq = new JTextField();
041: private JTextField txtAccFormats = new JTextField("application/xml");
042: private JTextField txtAccVersions = new JTextField(Csw.CSW_VERSION);
043:
044: private JCheckBox chbServIdent = new JCheckBox(
045: "Service identification");
046: private JCheckBox chbServProvid = new JCheckBox("Service provider");
047: private JCheckBox chbOperMeta = new JCheckBox("Operations metadata");
048: private JCheckBox chbFiltCapab = new JCheckBox(
049: "Filter capabilities");
050:
051: //---------------------------------------------------------------------------
052: //---
053: //--- Constructor
054: //---
055: //---------------------------------------------------------------------------
056:
057: public GetCapabilitiesPanel() {
058: super ("GetCapabilities Parameters");
059:
060: FlexLayout fl = new FlexLayout(2, 7);
061: fl.setColProp(1, FlexLayout.EXPAND);
062: setLayout(fl);
063:
064: add("0,0", new JLabel("Update sequence"));
065: add("0,1", new JLabel("Accept format(s)"));
066: add("0,2", new JLabel("Accept version(s)"));
067:
068: add("1,0,x", txtUpdateSeq);
069: add("1,1,x", txtAccFormats);
070: add("1,2,x", txtAccVersions);
071:
072: add("0,3,x,c,2", chbServIdent);
073: add("0,4,x,c,2", chbServProvid);
074: add("0,5,x,c,2", chbOperMeta);
075: add("0,6,x,c,2", chbFiltCapab);
076: }
077:
078: //---------------------------------------------------------------------------
079: //---
080: //--- API method
081: //---
082: //---------------------------------------------------------------------------
083:
084: public CatalogRequest createRequest() {
085: GetCapabilitiesRequest request = new GetCapabilitiesRequest();
086:
087: String updateSequence = txtUpdateSeq.getText();
088: String acceptFormats = txtAccFormats.getText();
089: String acceptVersions = txtAccVersions.getText();
090:
091: if (!updateSequence.equals(""))
092: request.setUpdateSequence(updateSequence);
093:
094: //--- 'AcceptFormats' parameter
095:
096: if (!acceptFormats.equals("")) {
097: StringTokenizer st = new StringTokenizer(acceptFormats, ",");
098:
099: while (st.hasMoreTokens())
100: request.addOutputFormat(st.nextToken());
101: }
102:
103: //--- 'AcceptVersions' parameter
104:
105: if (!acceptVersions.equals("")) {
106: StringTokenizer st = new StringTokenizer(acceptVersions,
107: ",");
108:
109: while (st.hasMoreTokens())
110: request.addVersion(st.nextToken());
111: }
112:
113: //--- 'Sections' parameter
114:
115: if (chbServIdent.isSelected())
116: request.addSection(Section.ServiceIdentification);
117:
118: if (chbServProvid.isSelected())
119: request.addSection(Section.ServiceProvider);
120:
121: if (chbOperMeta.isSelected())
122: request.addSection(Section.OperationsMetadata);
123:
124: if (chbFiltCapab.isSelected())
125: request.addSection(Section.Filter_Capabilities);
126:
127: return request;
128: }
129: }
130:
131: //=============================================================================
|