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.database.sample;
025:
026: import java.awt.Frame;
027: import java.awt.event.ActionEvent;
028: import javax.swing.JComboBox;
029: import javax.swing.JComponent;
030: import javax.swing.JLabel;
031: import javax.swing.JPanel;
032: import jeeves.utils.Util;
033: import org.dlib.gui.FlexLayout;
034: import org.dlib.gui.GuiUtil;
035: import org.dlib.gui.ProgressDialog;
036: import org.fao.gast.gui.panels.FormPanel;
037:
038: //==============================================================================
039:
040: public class MainPanel extends FormPanel {
041: //---------------------------------------------------------------------------
042: //---
043: //--- Constructor
044: //---
045: //---------------------------------------------------------------------------
046:
047: public MainPanel() {
048: }
049:
050: //---------------------------------------------------------------------------
051: //---
052: //--- ActionListener
053: //---
054: //---------------------------------------------------------------------------
055:
056: public void actionPerformed(ActionEvent e) {
057: String cmd = e.getActionCommand();
058:
059: if (cmd.equals("import"))
060: doImport();
061: }
062:
063: //---------------------------------------------------------------------------
064:
065: private void doImport() {
066: Frame owner = GuiUtil.getFrame(this );
067: ProgressDialog dialog = new ProgressDialog(owner,
068: "Importing data");
069: Worker worker = new Worker(dialog);
070:
071: String runs = cmbRuns.getSelectedItem().toString();
072: runs = Util.replaceString(runs, ".", "");
073:
074: worker.setRuns(Integer.parseInt(runs));
075:
076: dialog.run(worker);
077: }
078:
079: //---------------------------------------------------------------------------
080: //---
081: //--- Protected methods
082: //---
083: //---------------------------------------------------------------------------
084:
085: protected JComponent buildInnerPanel() {
086: JPanel p = new JPanel();
087:
088: FlexLayout fl = new FlexLayout(2, 1);
089: fl.setColProp(1, FlexLayout.EXPAND);
090: p.setLayout(fl);
091:
092: p.add("0,0", new JLabel("Runs"));
093: p.add("1,0", cmbRuns);
094:
095: cmbRuns.addItem("1");
096: cmbRuns.addItem("10");
097: cmbRuns.addItem("100");
098: cmbRuns.addItem("1.000");
099: cmbRuns.addItem("10.000");
100: cmbRuns.addItem("100.000");
101: cmbRuns.addItem("1.000.000");
102:
103: return p;
104: }
105:
106: //---------------------------------------------------------------------------
107: //---
108: //--- Variables
109: //---
110: //---------------------------------------------------------------------------
111:
112: private JComboBox cmbRuns = new JComboBox();
113: }
114:
115: //==============================================================================
|