Revision: 3288
Author: silva.josemanuel1
Date: Thu Feb 11 14:26:15 2010
Log: Added a RevisionListPanel to do reverts. Opening and comparing
revisions is still to be added.
http://code.google.com/p/power-architect/source/detail?r=3288
Added:
/trunk/src/ca/sqlpower/architect/swingui/enterprise/RevisionListPanel.java
Modified:
/trunk/regress/ca/sqlpower/architect/StubArchitectSession.java
/trunk/regress/ca/sqlpower/architect/TestingArchitectSession.java
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
/trunk/src/ca/sqlpower/architect/ArchitectSession.java
/trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java
/trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
/trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java
/trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSession.java
/trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
/trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
=======================================
--- /dev/null
+++
/trunk/src/ca/sqlpower/architect/swingui/enterprise/RevisionListPanel.java
Thu Feb 11 14:26:15 2010
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2010, 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.enterprise;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.List;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+import javax.swing.table.DefaultTableModel;
+
+import ca.sqlpower.architect.enterprise.ArchitectClientSideSession;
+import ca.sqlpower.architect.swingui.ArchitectFrame;
+import ca.sqlpower.architect.swingui.ArchitectSwingSession;
+import ca.sqlpower.enterprise.TransactionInformation;
+import ca.sqlpower.util.UserPrompter;
+import ca.sqlpower.util.UserPrompter.UserPromptOptions;
+import ca.sqlpower.util.UserPrompter.UserPromptResponse;
+import ca.sqlpower.util.UserPrompterFactory.UserPromptType;
+
+import com.jgoodies.forms.builder.DefaultFormBuilder;
+import com.jgoodies.forms.layout.CellConstraints;
+import com.jgoodies.forms.layout.FormLayout;
+
+public class RevisionListPanel {
+
+ private static final String[] headers = {"Version", "Time
Created", "Author", "Description"};
+
+ private final Component dialogOwner;
+ private final ArchitectClientSideSession session;
+ private final ArchitectSwingSession swingSession;
+ private final UserPrompter revertPrompt;
+ private final Action closeAction;
+
+ private List<TransactionInformation> transactions;
+
+ private final JTable revisionsTable;
+ private final JPanel panel;
+
+ private final Action refreshAction = new AbstractAction("Refresh...") {
+ public void actionPerformed(ActionEvent e) {
+ refreshRevisionsList();
+ }
+ };
+
+ private final Action revertAction = new AbstractAction("Revert...") {
+ public void actionPerformed(ActionEvent e) {
+ int revisionNo = Integer.parseInt((String)
revisionsTable.getValueAt(revisionsTable.getSelectedRow(), 0));
+ int response = JOptionPane.showConfirmDialog(dialogOwner,
+ "Are you sure you would like to revert to version " +
revisionNo,
+ "Revert...", JOptionPane.OK_CANCEL_OPTION);
+ if (response == JOptionPane.OK_OPTION) {
+ try {
+ session.revertServerWorkspace(revisionNo);
+ refreshRevisionsList();
+ } catch (Throwable t) {
+ throw new RuntimeException("Error requesting server
revert", t);
+ }
+ }
+ }
+ };
+
+ private final Action openAction = new AbstractAction("Open...") {
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(dialogOwner, "This feature is
not yet supported. Try again soon!");
+ }
+ };
+
+ private final Action compareAction = new AbstractAction("Compare...") {
+ public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(dialogOwner, "This feature is
not yet supported. Try again soon!");
+ }
+ };
+
+ private void refreshRevisionsList() {
+
+ try {
+ transactions = session.getTransactionList();
+ } catch (Throwable e) {
+ throw new RuntimeException("Error getting revision list from
server: " + e);
+ }
+
+ String[][] data = new String[transactions.size()][4];
+
+ for (int i = 0; i < transactions.size(); i++) {
+ TransactionInformation transaction = transactions.get(i);
+ data[i][0] = String.valueOf(transaction.getVersionNumber());
+ data[i][1] = transaction.getTimeCreated().toString();
+ data[i][2] = transaction.getVersionAuthor();
+ data[i][3] = transaction.getVersionDescription();
+ }
+
+ revisionsTable.setModel(new DefaultTableModel(data, headers) {
+ public boolean isCellEditable(int x, int y) {
+ return false;
+ }
+ });
+
+ }
+
+ public RevisionListPanel(ArchitectSwingSession swingSession,
ArchitectFrame architectFrame, Action closeAction) {
+
+ this.dialogOwner = architectFrame;
+ this.swingSession = swingSession;
+ this.session = swingSession.getEnterpriseSession();
+ this.closeAction = closeAction;
+
+ DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout(
+ "pref:grow, 5dlu, pref:grow, 5dlu, pref",
+ "pref, pref, pref"));
+
+ revisionsTable = new JTable();
+ revisionsTable.setColumnSelectionAllowed(false);
+ revisionsTable.setShowVerticalLines(false);
+ revisionsTable.setShowHorizontalLines(false);
+
+ refreshRevisionsList();
+
+ ListSelectionModel selectionModel =
revisionsTable.getSelectionModel();
+ selectionModel.setSelectionInterval(transactions.size(),
transactions.size());
+
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
+ revisionsTable.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2 &&
SwingUtilities.isLeftMouseButton(e)) {
+ revertAction.actionPerformed(null);
+ }
+ }
+ });
+
+ JScrollPane revisionsPane = new JScrollPane(revisionsTable);
+
+ CellConstraints cc = new CellConstraints();
+ builder.add(new JLabel("Revisions:"), cc.xyw(3, 1, 2));
+ builder.nextLine();
+ builder.add(revisionsPane, cc.xywh(3, 2, 1, 2));
+
+ revertPrompt = swingSession.createUserPrompter("Are you sure you
would like the server to revert to version {0}?",
+ UserPromptType.BOOLEAN,
+ UserPromptOptions.OK_CANCEL,
+ UserPromptResponse.OK,
+ UserPromptResponse.OK,
+ "OK", "Cancel");
+
+ DefaultFormBuilder buttonBarBuilder = new DefaultFormBuilder(new
FormLayout("pref"));
+ buttonBarBuilder.append(new JButton(refreshAction));
+ buttonBarBuilder.append(new JButton(revertAction));
+ buttonBarBuilder.append(new JButton(openAction));
+ buttonBarBuilder.append(new JButton(compareAction));
+ buttonBarBuilder.append(new JButton(closeAction));
+ builder.add(buttonBarBuilder.getPanel(), cc.xy(5, 2));
+ builder.setDefaultDialogBorder();
+ panel = builder.getPanel();
+ panel.setPreferredSize(new Dimension(700, 250));
+
+ }
+
+ public JPanel getPanel() {
+ return panel;
+ }
+
+}
=======================================
--- /trunk/regress/ca/sqlpower/architect/StubArchitectSession.java Thu Feb
11 11:47:13 2010
+++ /trunk/regress/ca/sqlpower/architect/StubArchitectSession.java Thu Feb
11 14:26:15 2010
@@ -153,5 +153,10 @@
// TODO Auto-generated method stub
}
+
+ public boolean isEnterpriseSession() {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
=======================================
--- /trunk/regress/ca/sqlpower/architect/TestingArchitectSession.java Tue
Jan 26 10:49:55 2010
+++ /trunk/regress/ca/sqlpower/architect/TestingArchitectSession.java Thu
Feb 11 14:26:15 2010
@@ -189,5 +189,10 @@
// TODO Auto-generated method stub
}
+
+ public boolean isEnterpriseSession() {
+ // TODO Auto-generated method stub
+ return false;
+ }
}
=======================================
---
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
Tue Jan 26 10:49:55 2010
+++
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
Thu Feb 11 14:26:15 2010
@@ -36,6 +36,7 @@
import ca.sqlpower.architect.ProjectLoader;
import ca.sqlpower.architect.ddl.DDLGenerator;
import ca.sqlpower.architect.ddl.GenericDDLGenerator;
+import ca.sqlpower.architect.enterprise.ArchitectClientSideSession;
import ca.sqlpower.architect.etl.kettle.KettleJob;
import ca.sqlpower.architect.olap.OLAPRootObject;
import ca.sqlpower.architect.olap.OLAPSession;
@@ -426,4 +427,14 @@
// TODO Auto-generated method stub
}
-}
+
+ public boolean isEnterpriseSession() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public ArchitectClientSideSession getEnterpriseSession() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectSession.java Tue Jan 26
10:49:55 2010
+++ /trunk/src/ca/sqlpower/architect/ArchitectSession.java Thu Feb 11
14:26:15 2010
@@ -106,6 +106,8 @@
* Returns the root SQL object of the session, which is the tree that
contains Columns, Databases, etc.
*/
public SQLObjectRoot getRootObject();
+
+ public boolean isEnterpriseSession();
void addPropertyChangeListener(PropertyChangeListener l);
@@ -113,7 +115,7 @@
public void
addSessionLifecycleListener(SessionLifecycleListener<ArchitectSession> l);
- public void
removeSessionLifecycleListener(SessionLifecycleListener<ArchitectSession>
l);
+ public void
removeSessionLifecycleListener(SessionLifecycleListener<ArchitectSession>
l);
/**
* Ends this session, disposing its frame and releasing any system
=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java Thu Feb 11
14:16:30 2010
+++ /trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java Thu Feb 11
14:26:15 2010
@@ -75,6 +75,8 @@
* and load functionality, and houses the source database connections.
*/
private ProjectLoader projectLoader;
+
+ protected boolean isEnterpriseSession;
public ArchitectSessionImpl(final ArchitectSessionContext context,
String name) throws SQLObjectException {
@@ -84,7 +86,8 @@
project.init(this);
this.project.setProfileManager(new ProfileManagerImpl(this));
this.name = name;
- this.projectLoader = new ProjectLoader(this);
+ this.projectLoader = new ProjectLoader(this);
+ this.isEnterpriseSession = false;
}
@@ -228,6 +231,10 @@
public void
removeSessionLifecycleListener(SessionLifecycleListener<ArchitectSession>
l) {
lifecycleListeners.remove(l);
}
+
+ public boolean isEnterpriseSession() {
+ return isEnterpriseSession;
+ }
}
=======================================
---
/trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Thu Feb 11 10:59:09 2010
+++
/trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
Thu Feb 11 14:26:15 2010
@@ -7,6 +7,8 @@
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
+import java.text.DateFormat;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -53,6 +55,7 @@
import ca.sqlpower.dao.json.SPJSONMessageDecoder;
import ca.sqlpower.dao.json.SPJSONPersister;
import ca.sqlpower.dao.session.SessionPersisterSuperConverter;
+import ca.sqlpower.enterprise.TransactionInformation;
import ca.sqlpower.enterprise.client.SPServerInfo;
import ca.sqlpower.sql.DataSourceCollection;
import ca.sqlpower.sql.DatabaseListChangeEvent;
@@ -90,10 +93,11 @@
int currentRevision = 0;
public ArchitectClientSideSession(ArchitectSessionContext context,
- ProjectLocation projectLocation) throws
SQLObjectException {
- super(context, projectLocation.getName());
+ String name, ProjectLocation projectLocation) throws SQLObjectException
{
+ super(context, name);
this.projectLocation = projectLocation;
+ this.isEnterpriseSession = true;
outboundHttpClient =
createHttpClient(projectLocation.getServiceInfo());
@@ -268,7 +272,49 @@
}
}
- public static ProjectLocation createNewServerSession(SPServerInfo
serviceInfo) throws URISyntaxException, ClientProtocolException,
IOException, JSONException {
+ /**
+ * Requests the server for the transaction list.
+ *
+ * @return A list of TransactionInformation containing all the
information about revisions of this project.
+ * @throws IOException
+ * @throws URISyntaxException
+ * @throws JSONException
+ * @throws ParseException
+ */
+ public List<TransactionInformation> getTransactionList() throws
IOException, URISyntaxException, JSONException, ParseException {
+
+ SPServerInfo serviceInfo = projectLocation.getServiceInfo();
+ HttpClient httpClient = createHttpClient(serviceInfo);
+ List<TransactionInformation> transactions = new
ArrayList<TransactionInformation>();
+
+ try {
+
+ String responseBody = executeServerRequest(httpClient,
projectLocation.getServiceInfo(),
+ "/project/" + projectLocation.getUUID()
+ "/revision_list",
+ new JSONResponseHandler());
+ JSONArray jsonArray = new JSONArray(responseBody);
+
+ for (int i = 0; i < jsonArray.length(); i++) {
+
+ JSONObject json = jsonArray.getJSONObject(i);
+ TransactionInformation transaction = new
TransactionInformation(
+ json.getLong("number"),
+ DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.SHORT).parse(json.getString("time")),
+ json.getString("author"),
+ json.getString("description"));
+ transactions.add(transaction);
+
+ }
+
+ return transactions;
+
+ } finally {
+ httpClient.getConnectionManager().shutdown();
+ }
+
+ }
+
+ public static ProjectLocation createNewServerSession(SPServerInfo
serviceInfo) throws URISyntaxException, ClientProtocolException,
IOException, JSONException {
HttpClient httpClient = createHttpClient(serviceInfo);
try {
HttpUriRequest request = new
HttpGet(getServerURI(serviceInfo, "/jcr/projects/new"));
@@ -284,6 +330,10 @@
httpClient.getConnectionManager().shutdown();
}
}
+
+ public void revertServerWorkspace(int revisionNo) throws IOException,
URISyntaxException {
+ revertServerWorkspace(projectLocation, revisionNo);
+ }
/**
* This method reverts the server workspace specified by the given
project location
@@ -295,13 +345,13 @@
* @throws URISyntaxException
*/
public static void revertServerWorkspace(ProjectLocation projectLocation,
int revisionNo) throws IOException, URISyntaxException {
- SPServerInfo serviceInfo = projectLocation.getServiceInfo();
- HttpClient httpClient = createHttpClient(serviceInfo);
-
+ SPServerInfo serviceInfo = projectLocation.getServiceInfo();
+ HttpClient httpClient = createHttpClient(serviceInfo);
+
try {
executeServerRequest(httpClient,
projectLocation.getServiceInfo(),
- "/project/" + projectLocation.getUUID() +
- "/revert?revisionNo=" + revisionNo,
+ "/project/" + projectLocation.getUUID() + "/revert",
+ "revisionNo=" + revisionNo,
new BasicResponseHandler());
} finally {
httpClient.getConnectionManager().shutdown();
@@ -325,15 +375,24 @@
private static <T> T executeServerRequest(HttpClient httpClient,
SPServerInfo serviceInfo,
String contextRelativePath, ResponseHandler<T>
responseHandler)throws IOException, URISyntaxException {
- HttpUriRequest request = new HttpGet(getServerURI(serviceInfo,
contextRelativePath));
- return httpClient.execute(request, responseHandler);
- }
+ return executeServerRequest(httpClient, serviceInfo,
contextRelativePath, null, responseHandler);
+ }
+
+ private static <T> T executeServerRequest(HttpClient httpClient,
SPServerInfo serviceInfo,
+ String contextRelativePath, String query, ResponseHandler<T>
responseHandler) throws IOException, URISyntaxException {
+ HttpUriRequest request = new HttpGet(getServerURI(serviceInfo,
contextRelativePath, query));
+ return httpClient.execute(request, responseHandler);
+ }
private static URI getServerURI(SPServerInfo serviceInfo, String
contextRelativePath) throws URISyntaxException {
+ return getServerURI(serviceInfo, contextRelativePath, null);
+ }
+
+ private static URI getServerURI(SPServerInfo serviceInfo, String
contextRelativePath, String query) throws URISyntaxException {
logger.debug("Getting server URI for: " + serviceInfo);
String contextPath = serviceInfo.getPath();
URI serverURI = new URI("http", null,
serviceInfo.getServerAddress(), serviceInfo.getPort(),
- contextPath + contextRelativePath, null, null);
+ contextPath + contextRelativePath, query, null);
logger.debug("Created URI " + serverURI);
return serverURI;
}
@@ -351,7 +410,7 @@
public static ArchitectClientSideSession
openServerSession(ArchitectSessionContext context, ProjectLocation
projectLoc)
throws SQLObjectException {
- final ArchitectClientSideSession session = new
ArchitectClientSideSession(context, projectLoc);
+ final ArchitectClientSideSession session = new
ArchitectClientSideSession(context, projectLoc.getName(), projectLoc);
// TODO
//context.registerChildSession(session);
//session.startUpdaterThread();
@@ -477,8 +536,8 @@
URI uri = new URI("http", null,
projectLocation.getServiceInfo().getServerAddress(),
projectLocation.getServiceInfo().getPort(),
projectLocation.getServiceInfo().getPath() +
contextRelativePath, "oldRevisionNo=" + currentRevision, null);
HttpUriRequest request = new
HttpGet(uri);
-
- String message = inboundHttpClient.execute(request, new
JSONResponseHandler());
+
+ String message = inboundHttpClient.execute(request, new
JSONResponseHandler());
JSONObject json = new
JSONObject(message);
final String jsonArray =
json.getString("data");
@@ -695,7 +754,7 @@
private static class JSONResponseHandler implements
ResponseHandler<String> {
- public String handleResponse(HttpResponse response) throws
ClientProtocolException, IOException {
+ public String handleResponse(HttpResponse response) throws
ClientProtocolException, IOException {
try {
BufferedReader reader = new BufferedReader(
@@ -727,6 +786,6 @@
} catch (Exception ex) {
throw new RuntimeException(ex);
}
- }
- }
-}
+ }
+ }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java Wed Feb 10
11:19:11 2010
+++ /trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java Thu Feb 11
14:26:15 2010
@@ -115,6 +115,7 @@
import ca.sqlpower.architect.swingui.action.ZoomAction;
import ca.sqlpower.architect.swingui.action.ZoomResetAction;
import ca.sqlpower.architect.swingui.action.ZoomToFitAction;
+import ca.sqlpower.architect.swingui.enterprise.RevisionListPanel;
import ca.sqlpower.architect.swingui.enterprise.ServerProjectsManagerPanel;
import ca.sqlpower.architect.swingui.olap.action.ImportSchemaAction;
import ca.sqlpower.architect.swingui.olap.action.OLAPEditAction;
@@ -263,6 +264,28 @@
d.setLocationRelativeTo(ArchitectFrame.this);
d.setVisible(true);
}
+ };
+
+ private Action openRevisionListAction = new
AbstractAction("Revisions...") {
+ public void actionPerformed(ActionEvent e) {
+
+ final JDialog d =
SPSUtils.makeOwnedDialog(ArchitectFrame.this, "Revision List");
+ Action closeAction = new AbstractAction("Close") {
+ public void actionPerformed(ActionEvent e) {
+ d.dispose();
+ }
+ };
+
+ RevisionListPanel p = new RevisionListPanel(session,
ArchitectFrame.this, closeAction);
+ d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ d.setContentPane(p.getPanel());
+
+ SPSUtils.makeJDialogCancellable(d, null);
+ d.pack();
+ d.setLocationRelativeTo(ArchitectFrame.this);
+ d.setVisible(true);
+
+ }
};
/**
@@ -684,6 +707,8 @@
JMenu enterpriseMenu = new JMenu("Enterprise");
enterpriseMenu.add(openServerManagerAction);
enterpriseMenu.add(openProjectManagerAction);
+ openRevisionListAction.setEnabled(session.isEnterpriseSession());
+ enterpriseMenu.add(openRevisionListAction);
menuBar.add(enterpriseMenu);
JMenu toolsMenu = new
JMenu(Messages.getString("ArchitectFrame.toolsMenu")); //$NON-NLS-1$
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSession.java Tue
Jan 26 10:49:55 2010
+++ /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSession.java Thu
Feb 11 14:26:15 2010
@@ -26,6 +26,7 @@
import ca.sqlpower.architect.ArchitectSession;
import ca.sqlpower.architect.CoreUserSettings;
+import ca.sqlpower.architect.enterprise.ArchitectClientSideSession;
import ca.sqlpower.architect.etl.kettle.KettleJob;
import ca.sqlpower.architect.olap.OLAPRootObject;
import ca.sqlpower.architect.olap.OLAPSession;
@@ -310,4 +311,8 @@
public JMenu createDataSourcesMenu();
public PrintSettings getPrintSettings();
-}
+
+ public boolean isEnterpriseSession();
+
+ public ArchitectClientSideSession getEnterpriseSession();
+}
=======================================
---
/trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
Thu Feb 11 11:00:01 2010
+++
/trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java
Thu Feb 11 14:26:15 2010
@@ -270,7 +270,7 @@
public ArchitectSwingSession createNewServerSession(SPServerInfo
serverInfo, boolean initGUI) throws SQLObjectException,
ClientProtocolException, URISyntaxException, IOException, JSONException {
ProjectLocation projectLocation =
ArchitectClientSideSession.createNewServerSession(serverInfo);
- ArchitectSession clientSession = new
ArchitectClientSideSession(this, projectLocation);
+ ArchitectSession clientSession = new
ArchitectClientSideSession(this, projectLocation.getName(),
projectLocation);
ArchitectSwingSession swingSession = new
ArchitectSwingSessionImpl(this, clientSession);
@@ -283,7 +283,7 @@
public ArchitectSwingSession createServerSession(ProjectLocation
projectLocation, boolean initGUI) throws SQLObjectException {
- ArchitectClientSideSession clientSession = new
ArchitectClientSideSession(this, projectLocation);
+ ArchitectClientSideSession clientSession = new
ArchitectClientSideSession(this, projectLocation.getName(),
projectLocation);
ArchitectSwingSession swingSession = new
ArchitectSwingSessionImpl(this, clientSession);
clientSession.startUpdaterThread();
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
Tue Feb 9 12:57:13 2010
+++ /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
Thu Feb 11 14:26:15 2010
@@ -55,6 +55,7 @@
import ca.sqlpower.architect.ProjectLoader;
import ca.sqlpower.architect.UserSettings;
import ca.sqlpower.architect.ddl.DDLGenerator;
+import ca.sqlpower.architect.enterprise.ArchitectClientSideSession;
import ca.sqlpower.architect.etl.kettle.KettleJob;
import ca.sqlpower.architect.olap.OLAPRootObject;
import ca.sqlpower.architect.olap.OLAPSession;
@@ -137,7 +138,7 @@
private boolean savingEntireSource;
- private boolean isNew;
+ private boolean isNew;
private DBTree sourceDatabases;
@@ -205,78 +206,8 @@
* @throws SQLObjectException
*/
ArchitectSwingSessionImpl(final ArchitectSwingSessionContext context,
String name)
- throws SQLObjectException {
-
- swinguiUserPrompterFactory = new SwingUIUserPrompterFactory(frame);
- this.isNew = true;
- this.context = context;
- this.delegateSession = new ArchitectSessionImpl(context, name);
- this.olapRootObject = new OLAPRootObject(delegateSession);
- ((ArchitectSessionImpl)delegateSession).setProfileManager(new
ProfileManagerImpl(this));
-
((ArchitectSessionImpl)delegateSession).setUserPrompterFactory(this);
- this.recent = new RecentMenu(this.getClass()) {
- @Override
- public void loadFile(String fileName) throws IOException {
- File f = new File(fileName);
- try {
-
OpenProjectAction.openAsynchronously(getContext().createSession(false), f,
ArchitectSwingSessionImpl.this);
- } catch (SQLObjectException ex) {
-
SPSUtils.showExceptionDialogNoReport(getArchitectFrame(),
Messages.getString("ArchitectSwingSessionImpl.openProjectFileFailed"), ex);
//$NON-NLS-1$
- }
- }
- };
-
- // Make sure we can load the pl.ini file so we can handle
exceptions
- // XXX this is probably redundant now, since the context owns the
pl.ini
- getContext().getPlDotIni();
-
- setProjectLoader(new SwingUIProjectLoader(this));
-
- compareDMSettings = new CompareDMSettings();
-
- kettleJob = new KettleJob(this);
-
- olapSchemaManager = new OLAPSchemaManager(this);
-
- delegateSession.getRootObject().addChild(getTargetDatabase());
- this.sourceDatabases = new DBTree(this);
-
- playPen = RelationalPlayPenFactory.createPlayPen(this,
sourceDatabases);
- UserSettings sprefs = getUserSettings().getSwingSettings();
- if (sprefs != null) {
-
playPen.setRenderingAntialiased(sprefs.getBoolean(ArchitectSwingUserSettings.PLAYPEN_RENDER_ANTIALIASED,
false));
- }
- projectModificationWatcher = new
ProjectModificationWatcher(playPen);
-
- getRootObject().addSPListener(new AbstractSPListener() {
- @Override
- public void propertyChangeImpl(PropertyChangeEvent e) {
- isNew = false;
- }
- @Override
- public void childRemovedImpl(SPChildEvent e) {
- isNew = false;
- }
- @Override
- public void childAddedImpl(SPChildEvent e) {
- isNew = false;
- }
- });
- undoManager = new ArchitectUndoManager(playPen);
-
playPen.getPlayPenContentPane().addPropertyChangeListener("location",
undoManager.getEventAdapter()); //$NON-NLS-1$
-
playPen.getPlayPenContentPane().addPropertyChangeListener("connectionPoints",
undoManager.getEventAdapter()); //$NON-NLS-1$
-
playPen.getPlayPenContentPane().addPropertyChangeListener("backgroundColor",
undoManager.getEventAdapter()); //$NON-NLS-1$
-
playPen.getPlayPenContentPane().addPropertyChangeListener("foregroundColor",
undoManager.getEventAdapter()); //$NON-NLS-1$
-
playPen.getPlayPenContentPane().addPropertyChangeListener("dashed",
undoManager.getEventAdapter()); //$NON-NLS-1$
-
playPen.getPlayPenContentPane().addPropertyChangeListener("rounded",
undoManager.getEventAdapter()); //$NON-NLS-1$
-
- lifecycleListeners = new
ArrayList<SessionLifecycleListener<ArchitectSession>>();
-
- swingWorkers = new HashSet<SPSwingWorker>();
-
- olapEditSessions = new ArrayList<OLAPEditSession>();
-
- printSettings = new PrintSettings();
+ throws SQLObjectException {
+ this(context, new ArchitectSessionImpl(context, name));
}
ArchitectSwingSessionImpl(final ArchitectSwingSessionContext context,
ArchitectSession delegateSession)
@@ -1134,4 +1065,16 @@
public void removePropertyChangeListener(PropertyChangeListener l) {
delegateSession.removePropertyChangeListener(l);
}
-}
+
+ public boolean isEnterpriseSession() {
+ return delegateSession.isEnterpriseSession();
+ }
+
+ public ArchitectClientSideSession getEnterpriseSession() {
+ if (isEnterpriseSession()) {
+ return (ArchitectClientSideSession) delegateSession;
+ } else {
+ throw new RuntimeException("This swing session is not an
enterprise session");
+ }
+ }
+}