001: /*
002: * Copyright 2006-2007 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007: *
008: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
010: * the license for the specific language governing your rights and limitations.
011: *
012: * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013: */
014: package org.pentaho.reportdesigner.crm.report.wizard.reportgeneratewizard;
015:
016: import org.jetbrains.annotations.NotNull;
017: import org.jetbrains.annotations.Nullable;
018: import org.pentaho.reportdesigner.crm.report.IconLoader;
019: import org.pentaho.reportdesigner.crm.report.connection.ColumnInfo;
020: import org.pentaho.reportdesigner.crm.report.datasetplugin.jdbc.JDBCConnectionConfigurationPanel;
021: import org.pentaho.reportdesigner.crm.report.wizard.AbstractWizardPage;
022: import org.pentaho.reportdesigner.crm.report.wizard.WizardData;
023: import org.pentaho.reportdesigner.lib.client.i18n.TranslationManager;
024:
025: import javax.swing.*;
026: import java.awt.*;
027: import java.beans.PropertyChangeEvent;
028: import java.beans.PropertyChangeListener;
029: import java.util.ArrayList;
030: import java.util.HashMap;
031:
032: /**
033: * User: Martin
034: * Date: 20.01.2006
035: * Time: 09:48:17
036: */
037: public class WizardPageConnectionSettings extends AbstractWizardPage {
038: @Nullable
039: private JPanel centerPanel;
040:
041: @NotNull
042: private JDBCConnectionConfigurationPanel jdbcConnectionConfigurationPanel;
043:
044: private boolean connectionTestSuccessful;
045:
046: public WizardPageConnectionSettings() {
047: connectionTestSuccessful = false;
048: }
049:
050: @NotNull
051: public JComponent getCenterPanel() {
052: JPanel centerPanel = this .centerPanel;
053: if (centerPanel == null) {
054: jdbcConnectionConfigurationPanel = new JDBCConnectionConfigurationPanel(
055: getWizardDialog(), getWizardDialog()
056: .getReportDialog().getWorkspaceSettings());
057: jdbcConnectionConfigurationPanel
058: .addPropertyChangeListener2(
059: JDBCConnectionConfigurationPanel.CONNECTION_TEST,
060: new PropertyChangeListener() {
061: public void propertyChange(@NotNull
062: PropertyChangeEvent evt) {
063: connectionTestSuccessful = ((Boolean) evt
064: .getNewValue())
065: .booleanValue();
066: fireWizardPageStateChanged();
067: }
068: });
069:
070: centerPanel = new JPanel(new BorderLayout());
071: centerPanel.add(jdbcConnectionConfigurationPanel,
072: BorderLayout.CENTER);
073: this .centerPanel = centerPanel;
074: }
075: return centerPanel;
076: }
077:
078: public boolean canNext() {
079: return connectionTestSuccessful;
080: }
081:
082: public boolean canPrevious() {
083: return true;
084: }
085:
086: public boolean canCancel() {
087: return true;
088: }
089:
090: public boolean canFinish() {
091: return connectionTestSuccessful;
092: }
093:
094: @NotNull
095: public String getTitle() {
096: return TranslationManager.getInstance().getTranslation("R",
097: "WizardPageConnectionSettings.Title");
098: }
099:
100: @Nullable
101: public ImageIcon getIcon() {
102: return IconLoader.getInstance()
103: .getWizardPageConnectionSettingsIcon();
104: }
105:
106: @NotNull
107: public String getDescription() {
108: return TranslationManager.getInstance().getTranslation("R",
109: "WizardPageConnectionSettings.Description");
110: }
111:
112: @NotNull
113: public WizardData[] getWizardDatas() {
114: jdbcConnectionConfigurationPanel.storeSettings();
115:
116: @Nullable
117: WizardData groupData = getWizardDialog().getWizardDatas().get(
118: WizardData.COLUMN_GROUPS);
119: if (groupData != null) {
120: //noinspection unchecked
121: ArrayList<ColumnInfo> columnGroups = (ArrayList<ColumnInfo>) groupData
122: .getValue();
123: if (columnGroups != null) {
124: columnGroups.clear();
125: }
126: }
127:
128: @Nullable
129: WizardData columnExpressionsData = getWizardDialog()
130: .getWizardDatas().get(WizardData.COLUMN_EXPRESSIONS);
131: if (columnExpressionsData != null) {
132: //noinspection unchecked
133: HashMap<ColumnInfo, Class<?>> columnGroups = (HashMap<ColumnInfo, Class<?>>) columnExpressionsData
134: .getValue();
135: if (columnGroups != null) {
136: columnGroups.keySet().clear();
137: }
138: }
139:
140: return new WizardData[] {
141: new WizardData(WizardData.JARS,
142: jdbcConnectionConfigurationPanel.getJars()),
143: new WizardData(WizardData.DRIVER_CLASS,
144: jdbcConnectionConfigurationPanel
145: .getDriverClass()),
146: new WizardData(WizardData.CONNECTION_STRING,
147: jdbcConnectionConfigurationPanel
148: .getConnectionString()),
149: new WizardData(WizardData.USERNAME,
150: jdbcConnectionConfigurationPanel.getUsername()),
151: new WizardData(WizardData.PASSWORD,
152: jdbcConnectionConfigurationPanel.getPassword()), };
153:
154: }
155:
156: public void dispose() {
157: }
158: }
|