001: package net.sourceforge.squirrel_sql.plugins.dataimport.gui;
002:
003: /*
004: * Copyright (C) 2007 Thorsten Mürell
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: import java.awt.Component;
022:
023: import javax.swing.JCheckBox;
024: import javax.swing.JPanel;
025:
026: import net.sourceforge.squirrel_sql.fw.util.StringManager;
027: import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
028: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
029: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
030: import net.sourceforge.squirrel_sql.plugins.dataimport.prefs.DataImportPreferenceBean;
031: import net.sourceforge.squirrel_sql.plugins.dataimport.prefs.PreferencesManager;
032:
033: import com.jgoodies.forms.builder.PanelBuilder;
034: import com.jgoodies.forms.layout.CellConstraints;
035: import com.jgoodies.forms.layout.FormLayout;
036:
037: /**
038: * This is the preferences panel for the dataimport plugin.
039: *
040: * @author Thorsten Mürell
041: */
042: public class PreferencesPanel extends JPanel {
043: private static final long serialVersionUID = 7648092437088098470L;
044:
045: DataImportPreferenceBean prefs = null;
046:
047: JCheckBox truncateCheckBox = null;
048:
049: /** Logger for this class. */
050: private final static ILogger log = LoggerController
051: .createLogger(PreferencesPanel.class);
052:
053: /** Internationalized strings for this class. */
054: private static final StringManager stringMgr = StringManagerFactory
055: .getStringManager(PreferencesPanel.class);
056:
057: /**
058: * Standard constructor.
059: *
060: * @param prefs The preferences container bean
061: */
062: public PreferencesPanel(DataImportPreferenceBean prefs) {
063: super ();
064: this .prefs = prefs;
065: createGUI();
066: loadData();
067: }
068:
069: private void createGUI() {
070: final FormLayout layout = new FormLayout(
071: // Columns
072: "left:pref:grow",
073: // Rows
074: "12dlu");
075:
076: PanelBuilder builder = new PanelBuilder(layout);
077: CellConstraints cc = new CellConstraints();
078: builder.setDefaultDialogBorder();
079:
080: //i18n[PreferencesPanel.truncateTable=Truncate table before inserting data]
081: truncateCheckBox = new JCheckBox(stringMgr
082: .getString("PreferencesPanel.truncateTable"));
083:
084: int y = 1;
085: builder.add(truncateCheckBox, cc.xy(1, y));
086:
087: add(builder.getPanel());
088: }
089:
090: private void loadData() {
091: truncateCheckBox.setSelected(prefs.isUseTruncate());
092: }
093:
094: private void save() {
095: prefs.setUseTruncate(truncateCheckBox.isSelected());
096:
097: PreferencesManager.savePrefs();
098: }
099:
100: /**
101: * Applies the changes
102: */
103: public void applyChanges() {
104: save();
105: }
106:
107: /**
108: * Returns the panel component, i.e. this.
109: *
110: * @return The preferences panel component
111: */
112: public Component getPanelComponent() {
113: return this;
114: }
115:
116: }
|