001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.workbench.ui;
034:
035: import java.awt.BorderLayout;
036: import java.awt.GridBagConstraints;
037: import java.awt.GridBagLayout;
038: import java.awt.Insets;
039: import java.awt.event.ActionListener;
040: import java.io.File;
041:
042: import javax.swing.JLabel;
043: import javax.swing.JPanel;
044:
045: public class FMEFileDriverPanel extends AbstractDriverPanel {
046: BorderLayout borderLayout1 = new BorderLayout();
047: OKCancelPanel okCancelPanel = new OKCancelPanel();
048: JPanel centrePanel = new JPanel();
049: JPanel innerCentrePanel = new JPanel();
050: JLabel whitespaceLabel = new JLabel();
051: FileNamePanel fmeFileNamePanel;
052: GridBagLayout gridBagLayout1 = new GridBagLayout();
053: GridBagLayout gridBagLayout2 = new GridBagLayout();
054:
055: public FMEFileDriverPanel(ErrorHandler errorHandler) {
056: fmeFileNamePanel = new FileNamePanel(errorHandler);
057:
058: try {
059: jbInit();
060: fmeFileNamePanel.setFileMustExist(true);
061:
062: /*FileNamePanel.addBrowseListener(
063: new ActionListener() {
064: public void actionPerformed(ActionEvent e) {
065: setTemplateFile();
066: }
067: });*/
068: } catch (Exception ex) {
069: ex.printStackTrace();
070: }
071: }
072:
073: public void setGMLFileMustExist(boolean gmlFileMustExist) {
074: fmeFileNamePanel.setFileMustExist(gmlFileMustExist);
075: }
076:
077: public void setCache(DriverPanelCache cache) {
078: super .setCache(cache);
079:
080: if (cache.get(DriverPanelCache.FILE_CACHE_KEY) != null) {
081: fmeFileNamePanel.setSelectedFile((File) cache
082: .get(DriverPanelCache.FILE_CACHE_KEY));
083: }
084: }
085:
086: public String getValidationError() {
087: if (!fmeFileNamePanel.isInputValid()) {
088: return fmeFileNamePanel.getValidationError();
089: }
090:
091: return null;
092: }
093:
094: public File getFMEFile() {
095: return fmeFileNamePanel.getSelectedFile();
096: }
097:
098: public DriverPanelCache getCache() {
099: DriverPanelCache cache = super .getCache();
100: cache.put(DriverPanelCache.FILE_CACHE_KEY, fmeFileNamePanel
101: .getSelectedFile());
102:
103: //cache.put(TEMPLATE_FILE_CACHE_KEY, templateFileNamePanel.getSelectedFile());
104: return cache;
105: }
106:
107: public void addActionListener(ActionListener l) {
108: okCancelPanel.addActionListener(l);
109: }
110:
111: public void removeActionListener(ActionListener l) {
112: okCancelPanel.removeActionListener(l);
113: }
114:
115: public boolean wasOKPressed() {
116: return okCancelPanel.wasOKPressed();
117: }
118:
119: void jbInit() throws Exception {
120: this .setLayout(borderLayout1);
121: innerCentrePanel.setLayout(gridBagLayout1);
122: whitespaceLabel.setText(" ");
123: fmeFileNamePanel.setUpperDescription("FME File");
124: centrePanel.setLayout(gridBagLayout2);
125: this .add(okCancelPanel, BorderLayout.SOUTH);
126: this .add(centrePanel, BorderLayout.CENTER);
127: centrePanel.add(innerCentrePanel, new GridBagConstraints(0, 0,
128: 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
129: GridBagConstraints.BOTH, new Insets(10, 10, 10, 10), 0,
130: 0));
131: innerCentrePanel.add(fmeFileNamePanel, new GridBagConstraints(
132: 0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
133: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
134: innerCentrePanel.add(whitespaceLabel, new GridBagConstraints(1,
135: 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
136: GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
137: }
138: }
|