001: /*
002: * GeneralExportOptionsPanel.java
003: *
004: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005: *
006: * Copyright 2002-2008, Thomas Kellerer
007: * No part of this code maybe reused without the permission of the author
008: *
009: * To contact the author please send an email to: support@sql-workbench.net
010: *
011: */
012: package workbench.gui.dialogs.export;
013:
014: import java.awt.event.ActionListener;
015: import workbench.resource.ResourceMgr;
016: import workbench.resource.Settings;
017:
018: /**
019: *
020: * @author support@sql-workbench.net
021: */
022: public class GeneralExportOptionsPanel extends javax.swing.JPanel
023: implements ExportOptions {
024:
025: /** Creates new form GeneralExportOptionsPanel */
026: public GeneralExportOptionsPanel() {
027: initComponents();
028: }
029:
030: public void saveSettings() {
031: Settings s = Settings.getInstance();
032: s.setProperty("workbench.export.general.dateformat", this
033: .getDateFormat());
034: s.setProperty("workbench.export.general.timestampformat", this
035: .getTimestampFormat());
036: s.setProperty("workbench.export.general.encoding", this
037: .getEncoding());
038: }
039:
040: public void restoreSettings() {
041: Settings s = Settings.getInstance();
042: this .setDateFormat(s.getProperty(
043: "workbench.export.general.dateformat", ""));
044: this .setTimestampFormat(s.getProperty(
045: "workbench.export.general.timestampformat", ""));
046: this .setEncoding(s.getProperty(
047: "workbench.export.general.encoding", s
048: .getDefaultDataEncoding()));
049: }
050:
051: public String getDateFormat() {
052: return this .dateFormat.getText();
053: }
054:
055: public String getEncoding() {
056: return encodingPanel.getEncoding();
057: }
058:
059: public String getTimestampFormat() {
060: return this .timestampFormat.getText();
061: }
062:
063: public void setDateFormat(String format) {
064: dateFormat.setText(format);
065: }
066:
067: public void setEncoding(String enc) {
068: encodingPanel.setEncoding(enc);
069: }
070:
071: public void setTimestampFormat(String format) {
072: timestampFormat.setText(format);
073: }
074:
075: public void showRetrieveColumnsLabel() {
076: selectColumnsButton.setText(ResourceMgr
077: .getString("LblRetrieveColumns"));
078: }
079:
080: public void showSelectColumnsLabel() {
081: selectColumnsButton.setText(ResourceMgr
082: .getString("LblSelectColumns"));
083: }
084:
085: public void allowSelectColumns(boolean flag) {
086: this .selectColumnsButton.setEnabled(flag);
087: }
088:
089: public Object addColumnSelectListener(ActionListener l) {
090: this .selectColumnsButton.addActionListener(l);
091: return this .selectColumnsButton;
092: }
093:
094: /** This method is called from within the constructor to
095: * initialize the form.
096: * WARNING: Do NOT modify this code. The content of this method is
097: * always regenerated by the Form Editor.
098: */
099: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
100: private void initComponents() {
101: java.awt.GridBagConstraints gridBagConstraints;
102:
103: encodingPanel = new workbench.gui.components.EncodingPanel();
104: dateFormatLabel = new javax.swing.JLabel();
105: dateFormat = new javax.swing.JTextField();
106: timestampFormatLabel = new javax.swing.JLabel();
107: timestampFormat = new javax.swing.JTextField();
108: jPanel1 = new javax.swing.JPanel();
109: selectColumnsButton = new javax.swing.JButton();
110:
111: setLayout(new java.awt.GridBagLayout());
112: gridBagConstraints = new java.awt.GridBagConstraints();
113: gridBagConstraints.gridx = 0;
114: gridBagConstraints.gridy = 0;
115: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
116: gridBagConstraints.weightx = 1.0;
117: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
118: add(encodingPanel, gridBagConstraints);
119:
120: dateFormatLabel.setText(ResourceMgr.getString("LblDateFormat"));
121: gridBagConstraints = new java.awt.GridBagConstraints();
122: gridBagConstraints.gridx = 0;
123: gridBagConstraints.gridy = 1;
124: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
125: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
126: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
127: add(dateFormatLabel, gridBagConstraints);
128: gridBagConstraints = new java.awt.GridBagConstraints();
129: gridBagConstraints.gridx = 0;
130: gridBagConstraints.gridy = 2;
131: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
132: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
133: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
134: add(dateFormat, gridBagConstraints);
135:
136: timestampFormatLabel.setText(ResourceMgr
137: .getString("LblTimestampFormat"));
138: gridBagConstraints = new java.awt.GridBagConstraints();
139: gridBagConstraints.gridx = 0;
140: gridBagConstraints.gridy = 3;
141: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
142: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
143: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
144: add(timestampFormatLabel, gridBagConstraints);
145: gridBagConstraints = new java.awt.GridBagConstraints();
146: gridBagConstraints.gridx = 0;
147: gridBagConstraints.gridy = 4;
148: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
149: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
150: gridBagConstraints.insets = new java.awt.Insets(0, 4, 0, 4);
151: add(timestampFormat, gridBagConstraints);
152: gridBagConstraints = new java.awt.GridBagConstraints();
153: gridBagConstraints.gridx = 0;
154: gridBagConstraints.gridy = 6;
155: gridBagConstraints.weightx = 1.0;
156: gridBagConstraints.weighty = 1.0;
157: add(jPanel1, gridBagConstraints);
158:
159: selectColumnsButton.setText(ResourceMgr
160: .getString("LblSelectColumns"));
161: gridBagConstraints = new java.awt.GridBagConstraints();
162: gridBagConstraints.gridx = 0;
163: gridBagConstraints.gridy = 5;
164: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
165: gridBagConstraints.insets = new java.awt.Insets(4, 4, 0, 4);
166: add(selectColumnsButton, gridBagConstraints);
167: }// </editor-fold>//GEN-END:initComponents
168:
169: // Variables declaration - do not modify//GEN-BEGIN:variables
170: private javax.swing.JTextField dateFormat;
171: private javax.swing.JLabel dateFormatLabel;
172: private workbench.gui.components.EncodingPanel encodingPanel;
173: private javax.swing.JPanel jPanel1;
174: private javax.swing.JButton selectColumnsButton;
175: private javax.swing.JTextField timestampFormat;
176: private javax.swing.JLabel timestampFormatLabel;
177: // End of variables declaration//GEN-END:variables
178:
179: }
|