Revision: 3129
Author: mike892
Date: Thu Jul 23 08:37:48 2009
Log: Updated the dialogs which prompt a user to replace their datasource.
They will now be almost identical to the Database Connection Manager with
the added options to select a datasource, skip the datasource or cancel the
loading. In order to do this a Database connection manager is made and then
its panel is stolen and placed on a dialog. Furthermore fixed these dialogs
because they were broken before and refactored some code so it was not in
multiple places.
http://code.google.com/p/power-architect/source/detail?r=3129
Deleted:
/trunk/src/ca/sqlpower/architect/swingui/SwingUIUserPrompterFactory.java
Modified:
/trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
=======================================
---
/trunk/src/ca/sqlpower/architect/swingui/SwingUIUserPrompterFactory.java
Tue Jul 7 14:52:55 2009
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2009, SQL Power Group Inc.
- *
- * This file is part of Power*Architect.
- *
- * Power*Architect is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * Power*Architect is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package ca.sqlpower.architect.swingui;
-
-import javax.swing.JFrame;
-
-import ca.sqlpower.sql.DataSourceCollection;
-import ca.sqlpower.sql.SPDataSource;
-import ca.sqlpower.swingui.DataSourceUserPrompter;
-import ca.sqlpower.swingui.ModalDialogUserPrompter;
-import ca.sqlpower.util.UserPrompter;
-import ca.sqlpower.util.UserPrompterFactory;
-import ca.sqlpower.util.UserPrompter.UserPromptOptions;
-import ca.sqlpower.util.UserPrompter.UserPromptResponse;
-
-public class SwingUIUserPrompterFactory implements UserPrompterFactory {
-
- private JFrame owner;
- private final DataSourceCollection dsCollection;
-
- public SwingUIUserPrompterFactory(JFrame owner, DataSourceCollection
dsCollection) {
- this.owner = owner;
- this.dsCollection = dsCollection;
- }
-
- public UserPrompter createUserPrompter(String question, UserPromptType
responseType, UserPromptOptions optionType, UserPromptResponse
defaultResponseType,
- Object defaultResponse, String ... buttonNames) {
- switch (responseType) {
- case BOOLEAN :
- return new ModalDialogUserPrompter(optionType,
defaultResponseType, owner, question, buttonNames);
- case JDBC_DATA_SOURCE:
- return new DataSourceUserPrompter(responseType,
optionType, defaultResponseType, (SPDataSource) defaultResponse, owner,
question, dsCollection, buttonNames);
- default :
- throw new UnsupportedOperationException("User prompt
type " + responseType + " is unknown.");
- }
- }
-
- public void setParentFrame(JFrame frame) {
- owner = frame;
- }
-
-}
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
Fri May 29 07:57:16 2009
+++ /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
Thu Jul 23 08:37:48 2009
@@ -67,6 +67,7 @@
import ca.sqlpower.architect.swingui.olap.OLAPEditSession;
import ca.sqlpower.architect.swingui.olap.OLAPSchemaManager;
import ca.sqlpower.architect.undo.ArchitectUndoManager;
+import ca.sqlpower.sql.DataSourceCollection;
import ca.sqlpower.sql.JDBCDataSource;
import ca.sqlpower.sql.SPDataSource;
import ca.sqlpower.sqlobject.SQLDatabase;
@@ -80,6 +81,7 @@
import ca.sqlpower.swingui.RecentMenu;
import ca.sqlpower.swingui.SPSUtils;
import ca.sqlpower.swingui.SPSwingWorker;
+import ca.sqlpower.swingui.SwingUIUserPrompterFactory;
import ca.sqlpower.swingui.event.SessionLifecycleEvent;
import ca.sqlpower.swingui.event.SessionLifecycleListener;
import ca.sqlpower.util.UserPrompter;
@@ -202,7 +204,8 @@
*/
ArchitectSwingSessionImpl(final ArchitectSwingSessionContext context,
String name)
throws SQLObjectException {
- swinguiUserPrompterFactory = new SwingUIUserPrompterFactory(null,
context.getPlDotIni());
+ DataSourceCollection<SPDataSource> connections =
(DataSourceCollection<SPDataSource>) context.getPlDotIni().getConnections();
+ swinguiUserPrompterFactory = new SwingUIUserPrompterFactory(frame,
connections);
this.isNew = true;
this.context = context;
this.delegateSession = new ArchitectSessionImpl(context, name);