001: /*
002: * ExportXMLPanel_4.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.executequery.gui.importexport;
023:
024: import java.awt.Dimension;
025: import java.awt.Color;
026: import java.awt.Font;
027: import java.awt.GridBagConstraints;
028: import java.awt.GridBagLayout;
029: import java.awt.Insets;
030: import java.awt.event.ActionEvent;
031: import java.awt.event.ActionListener;
032: import javax.swing.ButtonGroup;
033: import javax.swing.JLabel;
034: import javax.swing.JPanel;
035: import javax.swing.JRadioButton;
036: import javax.swing.JScrollPane;
037: import javax.swing.JTextArea;
038: import org.underworldlabs.swing.MultiLineLabel;
039:
040: import org.executequery.gui.importexport.ImportExportXMLPanel;
041:
042: /* ----------------------------------------------------------
043: * CVS NOTE: Changes to the CVS repository prior to the
044: * release of version 3.0.0beta1 has meant a
045: * resetting of CVS revision numbers.
046: * ----------------------------------------------------------
047: */
048:
049: /**
050: *
051: * @author Takis Diakoumis
052: * @version $Revision: 1.5 $
053: * @date $Date: 2006/05/29 14:47:16 $
054: */
055: public class ExportXMLPanel_4 extends JPanel {
056:
057: private ImportExportXMLPanel parent;
058:
059: private JTextArea sampleArea;
060:
061: private JRadioButton schemaRadio;
062: private JRadioButton tableRadio;
063:
064: private String schemaSample;
065: private String tableSample;
066:
067: public ExportXMLPanel_4(ImportExportXMLPanel parent) {
068: super (new GridBagLayout());
069: this .parent = parent;
070: try {
071: jbInit();
072: } catch (Exception e) {
073: e.printStackTrace();
074: }
075: }
076:
077: private void jbInit() throws Exception {
078: sampleArea = new JTextArea();
079: JScrollPane scroller = new JScrollPane(sampleArea);
080: scroller.setPreferredSize(new Dimension(475, 120));
081: sampleArea.setSelectionColor(Color.WHITE);
082:
083: sampleArea.setEditable(false);
084: sampleArea.setFont(new Font("monospaced", 0, 12));
085:
086: schemaRadio = new JRadioButton(
087: "Schema details (includes connection information"
088: + " as attributes)");
089: tableRadio = new JRadioButton("Table name only");
090:
091: ButtonGroup bg = new ButtonGroup();
092: bg.add(schemaRadio);
093: bg.add(tableRadio);
094:
095: schemaRadio.setSelected(true);
096:
097: ActionListener radioListener = new ActionListener() {
098: public void actionPerformed(ActionEvent e) {
099: setSampleArea();
100: }
101: };
102:
103: schemaRadio.addActionListener(radioListener);
104: tableRadio.addActionListener(radioListener);
105:
106: String line_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
107: String line_2 = "\n<schema name=\"schema_name\" jdbcurl=\"jdbc:oracle:thin:@"
108: + "[server]:[port]:[source]\" user=\"username\">";
109: String line_3 = "\n <table name=\"table_name\">\n";
110: String line_4 = " <row rownum=\"1\">\n <column_name>3000</column_name>"
111: + "\n ...";
112:
113: schemaSample = line_1 + line_2 + line_3 + line_4;
114: tableSample = line_1 + line_3 + line_4;
115:
116: StringBuffer sb = new StringBuffer();
117: sb
118: .append("Selecting schema includes table nodes and is the only ");
119: sb
120: .append("available option for a multiple table export using a single XML file.");
121:
122: GridBagConstraints gbc = new GridBagConstraints();
123: gbc.gridy++;
124: gbc.insets = new Insets(5, 5, 5, 5);
125: gbc.anchor = GridBagConstraints.NORTHWEST;
126: gbc.fill = GridBagConstraints.HORIZONTAL;
127: add(new JLabel("Select the XML root element."), gbc);
128: gbc.insets.top = 0;
129: gbc.insets.bottom = 0;
130: gbc.gridy++;
131: add(new MultiLineLabel(sb.toString()), gbc);
132: gbc.gridy++;
133: gbc.insets.top = 5;
134: gbc.insets.left = 20;
135: add(schemaRadio, gbc);
136: gbc.insets.top = 7;
137: gbc.gridy++;
138: add(tableRadio, gbc);
139: gbc.gridy++;
140: gbc.insets.left = 10;
141: add(new JLabel("Sample:"), gbc);
142: gbc.gridy++;
143: gbc.insets.left = 20;
144: gbc.insets.right = 20;
145: gbc.insets.bottom = 20;
146: gbc.weightx = 1.0;
147: gbc.weighty = 1.0;
148: gbc.fill = GridBagConstraints.BOTH;
149: add(scroller, gbc);
150:
151: setPreferredSize(parent.getChildDimension());
152:
153: setSelectedRadios();
154: setSampleArea();
155: }
156:
157: public void setSelectedRadios() {
158: if (parent.getTableTransferType() == ImportExportProcess.MULTIPLE_TABLE) {
159: schemaRadio.setSelected(true);
160:
161: if (parent.getMutlipleTableTransferType() == ImportExportProcess.SINGLE_FILE)
162: tableRadio.setEnabled(false);
163: else
164: tableRadio.setEnabled(true);
165:
166: } else
167: tableRadio.setEnabled(true);
168: }
169:
170: public void setSampleArea() {
171: if (schemaRadio.isSelected()) {
172: sampleArea.setText(schemaSample);
173: } else {
174: sampleArea.setText(tableSample);
175: }
176: }
177:
178: public int getSelection() {
179: if (schemaRadio.isSelected()) {
180: return ImportExportProcess.SCHEMA_ELEMENT;
181: } else {
182: return ImportExportProcess.TABLE_ELEMENT;
183: }
184: }
185:
186: }
|