Revision: 3809
Author: [email protected]
Date: Thu Jul 29 14:36:01 2010
Log: The enterprise project will now generate html reports using its own save format. Also rebranded the html reports.
http://code.google.com/p/power-architect/source/detail?r=3809

Modified:
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSession.java /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java /trunk/src/main/java/ca/sqlpower/architect/swingui/SwingUIProjectLoader.java /trunk/src/main/java/ca/sqlpower/architect/transformation/XsltTransformation.java
 /trunk/src/main/resources/xsltStylesheets/architect2html.xslt

=======================================
--- /trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java Wed Jul 28 09:52:56 2010 +++ /trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java Thu Jul 29 14:36:01 2010
@@ -530,4 +530,16 @@
     public ArchitectStatusBar getStatusInformation() {
         return null;
     }
-}
+
+    @Override
+    public void setSaveBehaviour(Saver saveBehaviour) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public Saver getSaveBehaviour() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java Wed Jul 28 14:53:29 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java Thu Jul 29 14:36:01 2010
@@ -177,10 +177,6 @@

     public static final double ZOOM_STEP = 0.25;

-    public static interface Saver {
- public boolean save(ArchitectSwingSession session, boolean showChooser);
-    }
-
     private ArchitectSwingSessionContext context;
     private ArchitectSwingSession currentSession = null;
private List<ArchitectSwingSession> sessions = new ArrayList<ArchitectSwingSession>();
@@ -269,12 +265,6 @@

private List<SelectionListener> selectionListeners = new ArrayList<SelectionListener>();

-    private Saver saveBehaviour = new Saver() {
- public boolean save(ArchitectSwingSession session, boolean showChooser) {
-            return session.saveOrSaveAs(showChooser, true);
-        }
-    };
-
private final EditCriticSettingsAction showCriticsManagerAction = new EditCriticSettingsAction(this);

     /**
@@ -668,7 +658,7 @@
Messages.getString("ArchitectFrame.saveProjectActionIconDescription"), //$NON-NLS-1$ sprefs.getInt(ArchitectSwingUserSettings.ICON_SIZE, ArchitectSwingSessionContext.ICON_SIZE))) {
             public void actionPerformed(ActionEvent e) {
-                saveBehaviour.save(currentSession, false);
+                currentSession.saveOrSaveAs(false, true);
stackedTabPane.setTitleAt(stackedTabPane.getSelectedIndex(), currentSession.getName()); setTitle(Messages.getString("ArchitectSwingSessionImpl.mainFrameTitle", currentSession.getName())); //$NON-NLS-1$
             }
@@ -682,7 +672,7 @@
Messages.getString("ArchitectFrame.saveProjectAsActionIconDescription"), //$NON-NLS-1$ sprefs.getInt(ArchitectSwingUserSettings.ICON_SIZE, ArchitectSwingSessionContext.ICON_SIZE))) {
             public void actionPerformed(ActionEvent e) {
-                saveBehaviour.save(currentSession, true);
+                currentSession.saveOrSaveAs(true, true);
stackedTabPane.setTitleAt(stackedTabPane.getSelectedIndex(), currentSession.getName()); setTitle(Messages.getString("ArchitectSwingSessionImpl.mainFrameTitle", currentSession.getName())); //$NON-NLS-1$
             }
@@ -695,7 +685,7 @@
sprefs.getInt(ArchitectSwingUserSettings.ICON_SIZE, ArchitectSwingSessionContext.ICON_SIZE))) {
             public void actionPerformed(ActionEvent e) {
                 for (ArchitectSwingSession session : sessions) {
-                    saveBehaviour.save(session, false);
+                    session.saveOrSaveAs(false, true);
stackedTabPane.setTitleAt(stackedTabPane.indexOfTab(sessionTabs.get(session)), session.getName());
                 }
setTitle(Messages.getString("ArchitectSwingSessionImpl.mainFrameTitle", currentSession.getName())); //$NON-NLS-1$
@@ -1428,10 +1418,6 @@
         this.newWindowAction = newWindowAction;
         newWindowMenu.setAction(newWindowAction);
     }
-
-    public void setSaveBehaviour(Saver saveBehaviour) {
-        this.saveBehaviour = saveBehaviour;
-    }

     public ZoomToFitAction getZoomToFitAction() {
         return zoomToFitAction;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSession.java Wed Jul 28 09:52:56 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSession.java Thu Jul 29 14:36:01 2010
@@ -19,6 +19,8 @@
 package ca.sqlpower.architect.swingui;

 import java.awt.Window;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.util.List;
 import java.util.concurrent.Executor;

@@ -50,6 +52,11 @@
  */
public interface ArchitectSwingSession extends ArchitectSession, SwingWorkerRegistry {

+    public static interface Saver {
+ public boolean save(ArchitectSwingSession session, boolean showChooser, boolean separateThread); + public void saveToStream(ArchitectSwingSession session, OutputStream out) throws IOException;
+    }
+
     /**
      * Returns the context that created this session.
      */
@@ -346,4 +353,8 @@
     public Executor getSaveExecutor();

     ArchitectStatusBar getStatusInformation();
-}
+
+    void setSaveBehaviour(Saver saveBehaviour);
+
+    public Saver getSaveBehaviour();
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java Fri Jul 16 08:41:08 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java Thu Jul 29 14:36:01 2010
@@ -229,7 +229,7 @@
public ArchitectSwingSession createServerSession(ProjectLocation projectLocation, boolean autoStartUpdater) throws SQLObjectException {

final ArchitectClientSideSession clientSession = new ArchitectClientSideSession(this, projectLocation.getName(), projectLocation); - final ArchitectSwingSessionImpl swingSession = new ArchitectSwingSessionImpl(this, clientSession); + final ArchitectSwingSession swingSession = new ArchitectSwingSessionImpl(this, clientSession); clientSession.getUpdater().setUserPrompterFactory(new NonModalSwingUIUserPrompterFactory(swingSession.getArchitectFrame()));

clientSession.getUpdater().addListener(new NetworkConflictResolver.UpdateListener() {
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Wed Jul 28 09:52:56 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Thu Jul 29 14:36:01 2010
@@ -27,6 +27,7 @@
 import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
@@ -115,7 +116,7 @@
private static final Logger logger = Logger.getLogger(ArchitectSwingSessionImpl.class);

private static final Executor saveExecutor = new ScheduledThreadPoolExecutor(1);
-
+
     private final ArchitectSwingSessionContext context;

     /**
@@ -135,6 +136,62 @@

     private JScrollPane playPenScrollPane;

+    private Saver saveBehaviour = new Saver() {
+ public boolean save(ArchitectSwingSession session, boolean showChooser, boolean separateThread) {
+            final boolean finalSeparateThread = separateThread;
+            final ProgressMonitor pm = new ProgressMonitor
+ (frame, Messages.getString("ArchitectSwingSessionImpl.saveProgressDialogTitle"), "", 0, 100); //$NON-NLS-1$ //$NON-NLS-2$
+
+            class SaverTask implements Runnable {
+                boolean success;
+
+                public void run() {
+                    SwingUIProjectLoader project = getProjectLoader();
+                    try {
+                        success = false;
+                        if (finalSeparateThread) {
+                            SwingUtilities.invokeAndWait(new Runnable() {
+                                public void run() {
+ getArchitectFrame().setEnableSaveOption(false);
+                                }
+                            });
+                        }
+                        project.setSaveInProgress(true);
+                        project.save(finalSeparateThread ? pm : null);
+                        success = true;
+                    } catch (Exception ex) {
+                        success = false;
+                        ASUtils.showExceptionDialog(
+                                ArchitectSwingSessionImpl.this,
+ Messages.getString("ArchitectSwingSessionImpl.cannotSaveProject")+ex.getMessage(), ex); //$NON-NLS-1$
+                    } finally {
+                        project.setSaveInProgress(false);
+                        if (finalSeparateThread) {
+                            SwingUtilities.invokeLater(new Runnable() {
+                                public void run() {
+ getArchitectFrame().setEnableSaveOption(true);
+                                }
+                            });
+                        }
+                    }
+                }
+            }
+            SaverTask saveTask = new SaverTask();
+            if (separateThread) {
+                saveExecutor.execute(saveTask);
+                return true; // this is an optimistic lie
+            } else {
+                saveTask.run();
+                return saveTask.success;
+            }
+        }
+
+        @Override
+ public void saveToStream(ArchitectSwingSession session, OutputStream out) throws IOException {
+            session.getProjectLoader().save(out, "utf-8");
+        }
+    };
+
     /**
      * The menu of recently-opened project files on this system.
      */
@@ -574,52 +631,7 @@
                 setName(projName);
             }
         }
-        final boolean finalSeparateThread = separateThread;
-        final ProgressMonitor pm = new ProgressMonitor
- (frame, Messages.getString("ArchitectSwingSessionImpl.saveProgressDialogTitle"), "", 0, 100); //$NON-NLS-1$ //$NON-NLS-2$
-
-        class SaverTask implements Runnable {
-            boolean success;
-
-            public void run() {
-                SwingUIProjectLoader project = getProjectLoader();
-                try {
-                    success = false;
-                    if (finalSeparateThread) {
-                        SwingUtilities.invokeAndWait(new Runnable() {
-                            public void run() {
- getArchitectFrame().setEnableSaveOption(false);
-                            }
-                        });
-                    }
-                    project.setSaveInProgress(true);
-                    project.save(finalSeparateThread ? pm : null);
-                    success = true;
-                } catch (Exception ex) {
-                    success = false;
-                    ASUtils.showExceptionDialog(
-                            ArchitectSwingSessionImpl.this,
- Messages.getString("ArchitectSwingSessionImpl.cannotSaveProject")+ex.getMessage(), ex); //$NON-NLS-1$
-                } finally {
-                    project.setSaveInProgress(false);
-                    if (finalSeparateThread) {
-                        SwingUtilities.invokeLater(new Runnable() {
-                            public void run() {
- getArchitectFrame().setEnableSaveOption(true);
-                            }
-                        });
-                    }
-                }
-            }
-        }
-        SaverTask saveTask = new SaverTask();
-        if (separateThread) {
-            saveExecutor.execute(saveTask);
-            return true; // this is an optimistic lie
-        } else {
-            saveTask.run();
-            return saveTask.success;
-        }
+        return saveBehaviour.save(this, showChooser, separateThread);
     }

     public Executor getSaveExecutor() {
@@ -850,6 +862,14 @@
         }
         return profileDialog;
     }
+
+    public void setSaveBehaviour(Saver saveBehaviour) {
+        this.saveBehaviour = saveBehaviour;
+    }
+
+    public Saver getSaveBehaviour() {
+        return saveBehaviour;
+    }

     /**
      * See {...@link #savingEntireSource}.
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/SwingUIProjectLoader.java Tue Jul 20 13:12:40 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/SwingUIProjectLoader.java Thu Jul 29 14:36:01 2010
@@ -829,7 +829,7 @@
      * @throws IOException
      * @throws SQLObjectException
      */
- public void save(PrintWriter out, String encoding) throws IOException, SQLObjectException {
+    public void save(PrintWriter out, String encoding) throws IOException {
         sqlObjectSaveIdMap = new IdentityHashMap<SQLObject, String>();
         olapObjectSaveIdMap = new IdentityHashMap<OLAPObject, String>();
         dbcsSaveIdMap = new HashMap<SPDataSource, String>();
@@ -866,9 +866,6 @@
         } catch (IOException e) {
ioo.println(out, new ExceptionReport(e, "", ArchitectVersion.APP_FULL_VERSION.toString(), "Architect").toXML());
             throw e;
-        } catch (SQLObjectException e) {
- ioo.println(out, new ExceptionReport(e, "", ArchitectVersion.APP_FULL_VERSION.toString(), "Architect").toXML());
-            throw e;
         } catch (RuntimeException e) {
ioo.println(out, new ExceptionReport(e, "", ArchitectVersion.APP_FULL_VERSION.toString(), "Architect").toXML());
             throw e;
@@ -877,7 +874,7 @@
         }
     }

- public void save(OutputStream out, String encoding) throws IOException, SQLObjectException { + public void save(OutputStream out, String encoding) throws IOException { save(new PrintWriter(new OutputStreamWriter(out, encoding)), encoding);
     }

@@ -931,7 +928,7 @@
         ioo.indent--;
     }

- private void saveDataSources(PrintWriter out) throws IOException, SQLObjectException {
+    private void saveDataSources(PrintWriter out) throws IOException {
// FIXME this needs work. It should include everything we need in order to build // the referenced parent type from scratch (except the jdbc driver path) // and the code that loads a project should check if the referenced parent
@@ -1088,7 +1085,7 @@
      * or more &lt;database&gt; elements.
      * @param out2
      */
- private void saveSourceDatabases(PrintWriter out) throws IOException, SQLObjectException {
+    private void saveSourceDatabases(PrintWriter out) throws IOException {
         ioo.println(out, "<source-databases>"); //$NON-NLS-1$
         ioo.indent++;
SQLObject dbTreeRoot = (SQLObject) getSession().getDBTree().getModel().getRoot();
@@ -1107,7 +1104,7 @@
      * Recursively walks through the children of db, writing to the
      * output file all SQLRelationship objects encountered.
      */
- private void saveRelationships(PrintWriter out, SQLDatabase db) throws SQLObjectException, IOException { + private void saveRelationships(PrintWriter out, SQLDatabase db) throws IOException {
         ioo.println(out, "<relationships>"); //$NON-NLS-1$
         ioo.indent++;
         Iterator<? extends SQLObject> it = db.getChildren().iterator();
@@ -1121,7 +1118,7 @@
     /**
      * The recursive subroutine of saveRelationships.
      */
- private void saveRelationshipsRecurse(PrintWriter out, SQLObject o) throws SQLObjectException, IOException { + private void saveRelationshipsRecurse(PrintWriter out, SQLObject o) throws IOException { if ( (!getSession().isSavingEntireSource()) && (!o.isPopulated()) ) {
             return;
         } else if (o instanceof SQLRelationship) {
@@ -1134,7 +1131,7 @@
         }
     }

- private void saveTargetDatabase(PrintWriter out) throws IOException, SQLObjectException {
+    private void saveTargetDatabase(PrintWriter out) throws IOException {
         SQLDatabase db = (SQLDatabase) getSession().getTargetDatabase();
ioo.println(out, "<target-database id=\"ppdb\" dbcs-ref="+ //$NON-NLS-1$ quote(dbcsSaveIdMap.get(db.getDataSource()))+ ">"); //$NON-NLS-1$
@@ -1396,7 +1393,7 @@
      * is responsible for deferencing the attribute and setting the
      * property manually.
      */
- private void saveSQLObject(PrintWriter out, SQLObject o) throws IOException, SQLObjectException { + private void saveSQLObject(PrintWriter out, SQLObject o) throws IOException {
         if (o instanceof SQLRelationship.SQLImportedKey) {
// ImportedKeys only store the fkTable for a SQLRelationship, which
             // is saved with the relationship for forward compatability.
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/transformation/XsltTransformation.java Thu Jul 22 08:25:22 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/transformation/XsltTransformation.java Thu Jul 29 14:36:01 2010
@@ -96,14 +96,8 @@
         */
public void transform(InputStream xsltStylesheet, File output, ArchitectSwingSession session)
          throws Exception {
-
-               File project = session.getProjectLoader().getFile();
-               if (project != null) {
-                   projectDir = project.getParentFile();
-               }
-
                ByteArrayOutputStream sessionAsStream = new 
ByteArrayOutputStream();
-               session.getProjectLoader().save(sessionAsStream, "utf-8");
+               session.getSaveBehaviour().saveToStream(session, 
sessionAsStream);

Source xmlSource = new StreamSource(new ByteArrayInputStream(sessionAsStream.toByteArray()));
                Source xsltSource = new StreamSource(xsltStylesheet);
=======================================
--- /trunk/src/main/resources/xsltStylesheets/architect2html.xslt Sun Feb 21 15:30:06 2010 +++ /trunk/src/main/resources/xsltStylesheets/architect2html.xslt Thu Jul 29 14:36:01 2010
@@ -118,7 +118,7 @@
       <xsl:value-of select="$title"/>
     </xsl:when>
     <xsl:otherwise>
-      <xsl:value-of select="'Power*Architect Datamodel'"/>
+      <xsl:value-of select="'SQL Power Architect Datamodel'"/>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>

Reply via email to