001: /*
002: * This file is part of the GeOxygene project source files.
003: *
004: * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for
005: * the development and deployment of geographic (GIS) applications. It is a open source
006: * contribution of the COGIT laboratory at the Institut Géographique National (the French
007: * National Mapping Agency).
008: *
009: * See: http://oxygene-project.sourceforge.net
010: *
011: * Copyright (C) 2005 Institut Géographique National
012: *
013: * This library is free software; you can redistribute it and/or modify it under the terms
014: * of the GNU Lesser General Public License as published by the Free Software Foundation;
015: * either version 2.1 of the License, or any later version.
016: *
017: * This library is distributed in the hope that it will be useful, but WITHOUT ANY
018: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
019: * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020: *
021: * You should have received a copy of the GNU Lesser General Public License along with
022: * this library (see file LICENSE if present); if not, write to the Free Software
023: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024: *
025: */
026:
027: package fr.ign.cogit.geoxygene.util.loader.gui;
028:
029: import java.awt.Container;
030: import java.awt.FlowLayout;
031: import java.awt.Frame;
032: import java.awt.GridLayout;
033: import java.awt.event.ActionEvent;
034: import java.awt.event.ActionListener;
035:
036: import javax.swing.JButton;
037: import javax.swing.JCheckBox;
038: import javax.swing.JComboBox;
039: import javax.swing.JDialog;
040: import javax.swing.JFrame;
041: import javax.swing.JPanel;
042:
043: /**
044: * On demande a l'utilisateur ce qu'il veut faire.
045: *
046: * @author Thierry Badard & Arnaud Braun
047: * @version 1.0
048: *
049: */
050:
051: /* L'idee est d'avoir differents types de generation des IDs possible :
052: * simple, unicite sur toutes les tables geographiques de la base,
053: * recopie d'une colonne, un jour calcul d'empreinte numerique ...
054: * La parametrisation se fait par passage d'un tableau de bbolean.
055: *
056: *
057: */
058:
059: public class GUIManageData extends JFrame {
060:
061: private static final String FRAME_TITLE = "GeOxygene Gestion des donnees ";
062:
063: private boolean genereIds = false;
064: private boolean genereSimple = false;
065: private boolean genereUnique = false;
066: private boolean homogeneise = false;
067: private boolean spatialIndex = false;
068: private boolean emprise = false;
069:
070: private String genereIdsText = "Generation des COGITID";
071: private String homogeneiseText = "Homogeneise les geometries";
072: private String spatialIndexText = "Calcul des index spatiaux";
073: private String empriseText = "Calcul des emprises (pour ORACLE)";
074:
075: private String genereSimpleText = "Generation simple";
076: private String genereUniqueText = "Generation avec unicite sur toute la base";
077:
078: private boolean[] selectedValues = new boolean[6];
079:
080: public GUIManageData() {
081:
082: }
083:
084: public boolean[] showDialog() {
085: final JDialog dialog = createDialog(this );
086: dialog.setSize(600, 300);
087: dialog.show();
088: dialog.dispose();
089: return selectedValues;
090: }
091:
092: private void getSelectedValues() {
093: selectedValues[0] = genereIds;
094: selectedValues[1] = homogeneise;
095: selectedValues[2] = spatialIndex;
096: selectedValues[3] = emprise;
097: selectedValues[4] = genereSimple;
098: selectedValues[5] = genereUnique;
099: }
100:
101: private JDialog createDialog(Frame parent) {
102:
103: String title = FRAME_TITLE;
104: final JDialog dialog = new JDialog(parent, title, true);
105:
106: Container contentPane = dialog.getContentPane();
107: contentPane.setLayout(new GridLayout(6, 1));
108:
109: final JCheckBox genereIdsCheckBox = new JCheckBox(genereIdsText);
110: contentPane.add(genereIdsCheckBox);
111: genereIdsCheckBox.setSelected(false);
112:
113: final JComboBox typeGenere = new JComboBox(new String[] {
114: genereSimpleText, genereUniqueText });
115: typeGenere.setEnabled(false);
116: JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 100,
117: 10));
118: panel.add(typeGenere);
119: contentPane.add(panel);
120:
121: genereIdsCheckBox.addActionListener(new ActionListener() {
122: public void actionPerformed(ActionEvent e) {
123: if (genereIdsCheckBox.isSelected())
124: typeGenere.setEnabled(true);
125: else
126: typeGenere.setEnabled(false);
127: }
128: });
129:
130: final JCheckBox homogeneiseCheckBox = new JCheckBox(
131: homogeneiseText);
132: contentPane.add(homogeneiseCheckBox);
133: homogeneiseCheckBox.setSelected(false);
134:
135: final JCheckBox empriseCheckBox = new JCheckBox(empriseText);
136: contentPane.add(empriseCheckBox);
137: empriseCheckBox.setSelected(false);
138:
139: final JCheckBox spatialIndexCheckBox = new JCheckBox(
140: spatialIndexText);
141: contentPane.add(spatialIndexCheckBox);
142: spatialIndexCheckBox.setSelected(false);
143:
144: JPanel controlPanel = new JPanel(new FlowLayout(
145: FlowLayout.CENTER, 20, 10));
146:
147: JButton okButton = new JButton("Ok");
148: okButton.setActionCommand("Ok");
149: okButton.addActionListener(new ActionListener() {
150: public void actionPerformed(ActionEvent e) {
151: genereIds = genereIdsCheckBox.isSelected();
152: homogeneise = homogeneiseCheckBox.isSelected();
153: spatialIndex = spatialIndexCheckBox.isSelected();
154: emprise = empriseCheckBox.isSelected();
155: if (typeGenere.getSelectedIndex() == 0) {
156: genereSimple = true;
157: genereUnique = false;
158: } else if (typeGenere.getSelectedIndex() == 1) {
159: genereSimple = false;
160: genereUnique = true;
161: } else {
162: genereSimple = false;
163: genereUnique = false;
164: }
165: getSelectedValues();
166: dialog.dispose();
167: }
168: });
169:
170: JButton cancelButton = new JButton("Cancel");
171: cancelButton.addActionListener(new ActionListener() {
172: public void actionPerformed(ActionEvent e) {
173: genereIds = false;
174: genereSimple = false;
175: genereUnique = false;
176: homogeneise = false;
177: spatialIndex = false;
178: emprise = false;
179: getSelectedValues();
180: dialog.dispose();
181: }
182: });
183:
184: controlPanel.add(okButton);
185: controlPanel.add(cancelButton);
186: contentPane.add(controlPanel);
187:
188: dialog.pack();
189: dialog.setLocationRelativeTo(parent);
190:
191: return dialog;
192: }
193:
194: }
|