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.dbms;
025:
026: import javax.swing.JLabel;
027: import javax.swing.JTextField;
028: import org.dlib.gui.FlexLayout;
029: import org.fao.gast.lib.Lib;
030:
031: //==============================================================================
032:
033: public class GenericPanel extends DbmsPanel {
034: //---------------------------------------------------------------------------
035: //---
036: //--- Constructor
037: //---
038: //---------------------------------------------------------------------------
039:
040: public GenericPanel() {
041: FlexLayout fl = new FlexLayout(3, 4);
042: fl.setColProp(1, FlexLayout.EXPAND);
043: setLayout(fl);
044:
045: add("0,0", new JLabel("JDBC Driver"));
046: add("0,1", new JLabel("URL"));
047: add("0,2", new JLabel("Username"));
048: add("0,3", new JLabel("Password"));
049:
050: add("1,0,x", txtDriver);
051: add("1,1,x", txtURL);
052: add("1,2", txtUser);
053: add("1,3", txtPass);
054:
055: add("2,0", new JLabel("<html><font color='red'>(REQ)</font>"));
056: add("2,1", new JLabel("<html><font color='red'>(REQ)</font>"));
057: }
058:
059: //---------------------------------------------------------------------------
060: //---
061: //--- DbmsPanel methods
062: //---
063: //---------------------------------------------------------------------------
064:
065: public String getLabel() {
066: return "Generic JDBC connection";
067: }
068:
069: //---------------------------------------------------------------------------
070:
071: public boolean matches(String url) {
072: return true;
073: }
074:
075: //---------------------------------------------------------------------------
076:
077: public void retrieve() {
078: txtDriver.setText(Lib.config.getDbmsDriver());
079: txtURL.setText(Lib.config.getDbmsURL());
080: txtUser.setText(Lib.config.getDbmsUser());
081: txtPass.setText(Lib.config.getDbmsPassword());
082: }
083:
084: //---------------------------------------------------------------------------
085:
086: public void save() throws Exception {
087: Lib.config.setDbmsDriver(txtDriver.getText());
088: Lib.config.setDbmsURL(txtURL.getText());
089: Lib.config.setDbmsUser(txtUser.getText());
090: Lib.config.setDbmsPassword(txtPass.getText());
091: Lib.config.removeActivator();
092: Lib.config.save();
093: }
094:
095: //---------------------------------------------------------------------------
096: //---
097: //--- Variables
098: //---
099: //---------------------------------------------------------------------------
100:
101: private JTextField txtDriver = new JTextField();
102: private JTextField txtURL = new JTextField();
103: private JTextField txtUser = new JTextField(12);
104: private JTextField txtPass = new JTextField(12);
105: }
106:
107: //==============================================================================
|