[dna-commits] DNA SVN: r1141 - in branches/eclipse/org.jboss.dna.publish.ui.swt: icons/objects and 6 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Fri Jul 31 12:52:11 EDT 2009


Author: elvisisking
Date: 2009-07-31 12:52:11 -0400 (Fri, 31 Jul 2009)
New Revision: 1141

Added:
   branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/checkmark.gif
   branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete_server.gif
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
Removed:
   branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/checkbox.gif
Modified:
   branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath
   branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/repository.gif
   branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
   branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/new_server.gif
   branches/eclipse/org.jboss.dna.publish.ui.swt/icons/wizards/dna_wizard_banner.png
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java
Log:
Some new icons. Finished up the publishing results dialog.Fixed a bug in ServerPage that wouldn't allow update to server if the password was changed.

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/.classpath	2009-07-31 16:52:11 UTC (rev 1141)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry exported="true" kind="lib" path="dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar"/>
+	<classpathentry exported="true" kind="lib" path="dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar" sourcepath="dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="src" path="src"/>

Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/checkmark.gif
===================================================================
(Binary files differ)


Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/checkmark.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/repository.gif
===================================================================
(Binary files differ)

Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/checkbox.gif
===================================================================
(Binary files differ)

Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete_server.gif
===================================================================
(Binary files differ)


Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete_server.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif	2009-07-31 16:52:11 UTC (rev 1141)
@@ -1,3 +1,2 @@
-GIF89a
-*ü7
\ No newline at end of file
+GIF89a
+6‰¤F]xQ‚„V­²P…l‹qpa%ˆÕJd^Đ' ›¬¼8+Ú,+Ï:å,hq– Dô¬*¥shC
\ No newline at end of file

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/new_server.gif
===================================================================
(Binary files differ)

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/wizards/dna_wizard_banner.png
===================================================================
(Binary files differ)

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/I18n.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -56,9 +56,12 @@
     public static String NewServerActionText;
     public static String NewServerActionToolTip;
 
-    public static String PublishOperationPublishNotAttemptedMsg;
+    public static String PublishingResultsPublishNotAttemptedMsg;
+    public static String PublishingResultsTooManyResultsMsg;
+    public static String PublishingResultsUnknownSeverityMsg;
+    public static String PublishingResultsUnpublishNotAttemptedMsg;
+
     public static String PublishOperationPublishTaskName;
-    public static String PublishOperationUnpublishNotAttemptedMsg;
     public static String PublishOperationUnpublishTaskName;
     
     public static String PublishPagePublishTitle;

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -44,6 +44,8 @@
 
     String OBJECT_ICONS_FOLDER = ICON_PATH + "objects/"; //$NON-NLS-1$
 
+    String CHECKMARK_IMAGE_PATH = OBJECT_ICONS_FOLDER + "checkmark.gif"; //$NON-NLS-1$
+
     String REPOSITORY_IMAGE_PATH = OBJECT_ICONS_FOLDER + "repository.gif"; //$NON-NLS-1$
 
     String SERVER_IMAGE_PATH = OBJECT_ICONS_FOLDER + "server.gif"; //$NON-NLS-1$
@@ -56,10 +58,10 @@
 
     String VIEWS_ICON_FOLDER = ICON_PATH + "views/"; //$NON-NLS-1$
 
-    String CHECKBOX_IMAGE_PATH = VIEWS_ICON_FOLDER + "checkbox.gif"; //$NON-NLS-1$
-
     String COLLAPSE_ALL_IMAGE_PATH = VIEWS_ICON_FOLDER + "collapse_all.gif"; //$NON-NLS-1$
 
+    String DELETE_SERVER_IMAGE_PATH = VIEWS_ICON_FOLDER + "delete_server.gif"; //$NON-NLS-1$
+
     String DNA_WINDOW_IMAGE_PATH = VIEWS_ICON_FOLDER + "dna_window.png"; //$NON-NLS-1$
 
     String EDIT_SERVER_IMAGE_PATH = VIEWS_ICON_FOLDER + "edit_server.gif"; //$NON-NLS-1$

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/DeleteServerAction.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -23,6 +23,7 @@
  */
 package org.jboss.dna.web.jcr.rest.client.swt.actions;
 
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DELETE_SERVER_IMAGE_PATH;
 import java.util.ArrayList;
 import java.util.List;
 import org.eclipse.jface.dialogs.Dialog;
@@ -30,7 +31,6 @@
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.window.Window;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
 import org.eclipse.ui.actions.BaseSelectionListenerAction;
 import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
@@ -85,8 +85,7 @@
                                ServerManager serverManager ) {
         super(I18n.DeleteServerActionText);
         setToolTipText(I18n.DeleteServerActionToolTip);
-        setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
-        setDisabledImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
+        setImageDescriptor(Activator.getDefault().getImageDescriptor(DELETE_SERVER_IMAGE_PATH));
         setEnabled(false);
 
         this.serversToDelete = new ArrayList<Server>(5);

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -23,7 +23,7 @@
  */
 package org.jboss.dna.web.jcr.rest.client.swt.dialogs;
 
-import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.CHECKBOX_IMAGE_PATH;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.CHECKMARK_IMAGE_PATH;
 import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_WINDOW_IMAGE_PATH;
 import java.util.List;
 import org.eclipse.core.resources.IFile;
@@ -49,6 +49,7 @@
 import org.jboss.dna.web.jcr.rest.client.swt.I18n;
 import org.jboss.dna.web.jcr.rest.client.swt.Utils;
 import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishingResults;
 
 /**
  * The <code>DeleteServerDialog</code> class provides a UI for deleting a {@link Server server}.
@@ -62,10 +63,25 @@
     // Constants
     // ===========================================================================================================================
 
+    /**
+     * The table column index of the column where the file name is displayed.
+     * 
+     * @since 0.6
+     */
     private static final int FILE_COL = 0;
 
+    /**
+     * The table column index of the column where the status severity is displayed.
+     * 
+     * @since 0.6
+     */
     private static final int SEVERITY_COL = 1;
 
+    /**
+     * The table column index of the column where the error message is displayed.
+     * 
+     * @since 0.6
+     */
     private static final int MESSAGE_COL = 2;
 
     // ===========================================================================================================================
@@ -80,46 +96,26 @@
     private Throwable error;
 
     /**
-     * The list of files that were published or unpublished.
+     * The results of the publishing operation.
      * 
      * @since 0.6
      */
-    private final List<IFile> files;
+    private final PublishingResults results;
 
-    /**
-     * The status of the publish or unpublish operation for each file.
-     * 
-     * @since 0.6
-     */
-    private final List<Status> statuses;
-
-    /**
-     * The operation type.
-     * 
-     * @since 0.6
-     */
-    private final PublishOperation.Type type;
-
     // ===========================================================================================================================
     // Constructors
     // ===========================================================================================================================
 
     /**
      * @param parentShell the dialog parent
-     * @param type the operation type (publish or unpublish)
-     * @param files the files used in the operation
-     * @param statuses the operation status of each file
+     * @param results the results being displayed (never <code>null</code>)
      * @since 0.6
      */
     public PublishingResultsDialog( Shell parentShell,
-                                    PublishOperation.Type type,
-                                    List<IFile> files,
-                                    List<Status> statuses ) {
+                                    PublishingResults results ) {
         super(parentShell, I18n.PublishResultsDialogTitle, Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH), null,
               MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0);
-        this.files = files;
-        this.statuses = statuses;
-        this.type = type;
+        this.results = results;
 
         // make sure dialog is resizable
         setShellStyle(getShellStyle() | SWT.RESIZE);
@@ -127,22 +123,16 @@
 
     /**
      * @param parentShell the dialog parent
-     * @param type the operation type (publish or unpublish)
-     * @param files the files used in the operation
-     * @param statuses the operation status of each file
+     * @param results the results being displayed (never <code>null</code>)
      * @param error an unexpected error caught during the publish operation
      * @since 0.6
      */
     public PublishingResultsDialog( Shell parentShell,
-                                    PublishOperation.Type type,
-                                    List<IFile> files,
-                                    List<Status> statuses,
+                                    PublishingResults results,
                                     Throwable error ) {
         super(parentShell, I18n.PublishResultsDialogTitle, Activator.getDefault().getImage(DNA_WINDOW_IMAGE_PATH), null,
               MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0);
-        this.files = files;
-        this.statuses = statuses;
-        this.type = type;
+        this.results = results;
         this.error = error;
 
         // make sure dialog is resizable
@@ -164,12 +154,15 @@
         super.configureShell(shell);
 
         // now set message
-        if (this.type == PublishOperation.Type.PUBLISH) {
-            this.message = ((this.error == null) ? I18n.PublishResultsDialogPublishMsg : I18n.bind(I18n.PublishResultsDialogErrorPublishingMsg,
-                                                                                                   this.error.getLocalizedMessage()));
+        Object[] counts = new Object[] {this.results.getOksCount(), this.results.getErrorCount(), this.results.getInfoCount(),
+            this.results.getWarningsCount()};
+
+        if (this.results.getType() == PublishOperation.Type.PUBLISH) {
+            this.message = ((this.error == null) ? I18n.bind(I18n.PublishResultsDialogPublishMsg, counts) : I18n.bind(I18n.PublishResultsDialogErrorPublishingMsg,
+                                                                                                                      this.error.getLocalizedMessage()));
         } else {
-            this.message = ((this.error == null) ? I18n.PublishResultsDialogUnpublishMsg : I18n.bind(I18n.PublishResultsDialogErrorUnpublishingMsg,
-                                                                                                     this.error.getLocalizedMessage()));
+            this.message = ((this.error == null) ? I18n.bind(I18n.PublishResultsDialogUnpublishMsg, counts) : I18n.bind(I18n.PublishResultsDialogErrorUnpublishingMsg,
+                                                                                                                        this.error.getLocalizedMessage()));
         }
     }
 
@@ -195,7 +188,7 @@
     protected Control createCustomArea( Composite parent ) {
         Composite pnl = new Composite(parent, SWT.NONE);
         pnl.setLayout(new GridLayout());
-        GridData gd = new GridData(SWT.LEFT, SWT.CENTER, true, true);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
         pnl.setLayoutData(gd);
 
         TableViewer viewer = new TableViewer(pnl, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
@@ -205,14 +198,14 @@
 
         Table table = viewer.getTable();
         table.setLayout(new GridLayout());
-        table.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true));
+        table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
         table.setHeaderVisible(true);
         table.setLinesVisible(true);
 
         TableColumn col = new TableColumn(table, SWT.LEFT);
         col.setText(I18n.PublishResultsDialogFileHeader);
 
-        col = new TableColumn(table, SWT.LEFT);
+        col = new TableColumn(table, SWT.CENTER);
         col.setResizable(false);
 
         col = new TableColumn(table, SWT.LEFT);
@@ -235,16 +228,16 @@
      * @since 0.6
      */
     List<IFile> getFiles() {
-        return this.files;
+        return this.results.getFiles();
     }
 
     /**
-     * @param index the index of the status being requested
-     * @return the status
+     * @param file the file whose status is being requested
+     * @return the status or <code>null</code> if not found
      * @since 0.6
      */
-    Status getStatus( int index ) {
-        return this.statuses.get(index);
+    Status getStatus( IFile file ) {
+        return this.results.getStatus(file);
     }
 
     // ===========================================================================================================================
@@ -270,10 +263,10 @@
         public Image getColumnImage( Object element,
                                      int columnIndex ) {
             if (columnIndex == SEVERITY_COL) {
-                Status status = getStatus(getFiles().indexOf(element));
+                Status status = getStatus((IFile)element);
 
                 if (status.isOk()) {
-                    return Activator.getDefault().getImage(CHECKBOX_IMAGE_PATH);
+                    return Activator.getDefault().getImage(CHECKMARK_IMAGE_PATH);
                 }
 
                 return Utils.getImage(status);
@@ -296,7 +289,7 @@
             }
 
             if (columnIndex == MESSAGE_COL) {
-                Status status = getStatus(getFiles().indexOf(element));
+                Status status = getStatus((IFile)element);
 
                 if (!status.isOk()) {
                     return status.getMessage();

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/i18n.properties	2009-07-31 16:52:11 UTC (rev 1141)
@@ -34,7 +34,7 @@
 DeleteServerDialogOneServerMsg = Are you sure you want to delete the "{0}" server?
 DeleteServerDialogTitle = Confirm Delete Server
 
-EditServerActionText = Edit Server
+EditServerActionText = Server Properties
 EditServerActionToolTip = Edit server properties
 
 ErrorDialogTitle = Error
@@ -42,12 +42,14 @@
 MissingImage = The following image cannot be found "{0}"
 
 NewServerActionText = New Server
-NewServerActionToolTip = Create and register a new server
+NewServerActionToolTip = Create a new server
 
-PublishOperationPublishNotAttemptedMsg = Publishing not attempted
-PublishOperationUnpublishNotAttemptedMsg = Unpublishing not attempted
+PublishingResultsPublishNotAttemptedMsg = Publishing not attempted
+PublishingResultsTooManyResultsMsg = Adding a status to the results failed since there is not enough files involved in the publishing operation.
+PublishingResultsUnknownSeverityMsg = "{0}" is an unknown status severity
+PublishingResultsUnpublishNotAttemptedMsg = Unpublishing not attempted
+
 PublishOperationPublishTaskName = Publishing resources
-PublishOperationUnpublishNotAttemptedMsg = Unpublishing not attempted
 PublishOperationUnpublishTaskName = Unpublishing resources
 
 PublishPagePublishTitle = Publish the selected resources
@@ -81,9 +83,9 @@
 PublishResultsDialogErrorUnpublishingMsg = There was a problem publishing some or all of the files. See results below and the log for more details. Error message: "{0}."
 PublishResultsDialogFileHeader = File
 PublishResultsDialogMessageHeader = Message
-PublishResultsDialogPublishMsg = Here are the results of the publishing request.
+PublishResultsDialogPublishMsg = The operation completed with {0} file(s) being published. There were {1} error(s), {2} info(s), and {3} warning(s).
 PublishResultsDialogTitle = Results
-PublishResultsDialogUnpublishMsg = Here are the results of the unpublishing request.
+PublishResultsDialogUnpublishMsg = The operation completed with {0} file(s) being unpublished. There were {1} error(s), {2} info(s), and {3} warning(s).
 
 PublishWizardPublishErrorMsg = Error Publishing
 PublishWizardPublishTitle = Publish

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -25,12 +25,11 @@
 
 import java.io.File;
 import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
 import java.util.List;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
 import org.jboss.dna.web.jcr.rest.client.swt.Activator;
 import org.jboss.dna.web.jcr.rest.client.swt.I18n;
@@ -66,22 +65,6 @@
         UNPUBLISH
     }
 
-    /**
-     * Status indicating the file was not attempted to be published.
-     * 
-     * @since 0.6
-     */
-    private static final Status PUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
-                                                                          I18n.PublishOperationPublishNotAttemptedMsg, null);
-
-    /**
-     * Status indicating the file was not attempted to be published.
-     * 
-     * @since 0.6
-     */
-    private static final Status UNPUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
-                                                                            I18n.PublishOperationUnpublishNotAttemptedMsg, null);
-
     // ===========================================================================================================================
     // Fields
     // ===========================================================================================================================
@@ -101,11 +84,11 @@
     private final Type type;
 
     /**
-     * The operation status for each file.
+     * The results of the publishing operation.
      * 
      * @since 0.6
      */
-    private List<Status> statuses;
+    private PublishingResults results;
 
     /**
      * The workspace to use when publishing or unpublishing.
@@ -127,6 +110,10 @@
     public PublishOperation( Type type,
                              List<IFile> files,
                              Workspace workspace ) {
+        Utils.nullArgumentCheck("type", type); //$NON-NLS-1$
+        Utils.nullArgumentCheck("files", files); //$NON-NLS-1$
+        Utils.nullArgumentCheck("workspace", workspace); //$NON-NLS-1$
+
         this.type = type;
         this.files = files;
         this.workspace = workspace;
@@ -137,11 +124,11 @@
     // ===========================================================================================================================
 
     /**
-     * @return the operation status of each file (never <code>null</code> and always one status for each file)
+     * @return the results of the publishing operation or <code>null</code> if operation has not been executed
      * @since 0.6
      */
-    public List<Status> getStatus() {
-        return this.statuses;
+    public PublishingResults getResults() {
+        return this.results;
     }
 
     /**
@@ -169,30 +156,34 @@
     public void execute( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
         assert (this.workspace != null);
 
-        this.statuses = new ArrayList<Status>(this.files.size());
+        this.results = new PublishingResults(this.type, this.files);
 
         try {
             String name = (isPublishing() ? I18n.PublishOperationPublishTaskName : I18n.PublishOperationUnpublishTaskName);
             monitor.beginTask(name, this.files.size());
             monitor.setTaskName(name);
 
-            for (IFile eclipseFile : this.files) {                    
+            for (IFile eclipseFile : this.files) {
 
                 if (monitor.isCanceled()) {
                     throw new InterruptedException();
                 }
 
                 File file = eclipseFile.getLocation().toFile();
+                Status status = null;
+
                 // TODO call publisher here (timeout?)
                 if (isPublishing()) {
-                    this.statuses.add(Activator.getDefault().getServerManager().publish(this.workspace,
-                                                                                        eclipseFile.getFullPath().toString(),
-                                                                                        file));
+                    status = Activator.getDefault().getServerManager().publish(this.workspace,
+                                                                               eclipseFile.getFullPath().toString(),
+                                                                               file);
                 } else {
-                    this.statuses.add(Activator.getDefault().getServerManager().unpublish(this.workspace,
-                                                                                          eclipseFile.getFullPath().toString(),
-                                                                                          file));
+                    status = Activator.getDefault().getServerManager().unpublish(this.workspace,
+                                                                                 eclipseFile.getFullPath().toString(),
+                                                                                 file);
                 }
+
+                results.addStatus(status);
                 monitor.worked(1);
             }
         } catch (InterruptedException e) {
@@ -200,15 +191,7 @@
         } catch (Exception e) {
             throw new InvocationTargetException(e);
         } finally {
-            // ensure there is a status for each file
-            if (this.files.size() != this.statuses.size()) {
-                Status status = (isPublishing() ? PUBLISH_NOT_ATTEMPTED_STATUS : UNPUBLISH_NOT_ATTEMPTED_STATUS);
-
-                for (int count = this.files.size() - this.statuses.size(), i = 0; i < count; ++i) {
-                    this.statuses.add(status);
-                }
-            }
-
+            results.closeOut();
             monitor.done();
         }
     }

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -36,6 +36,7 @@
 import org.eclipse.jface.wizard.Wizard;
 import org.jboss.dna.web.jcr.rest.client.ServerManager;
 import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Utils;
 import org.jboss.dna.web.jcr.rest.client.Status.Severity;
 import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
 import org.jboss.dna.web.jcr.rest.client.swt.Activator;
@@ -79,7 +80,7 @@
     // ===========================================================================================================================
 
     /**
-     * @param type the publishing or unpublishing indicator
+     * @param type the publishing or unpublishing indicator (never <code>null</code>)
      * @param resources the resources being published or unpublished (never <code>null</code>)
      * @param serverManager the server manager in charge of the server registry (never <code>null</code>)
      * @throws CoreException if there is a problem processing the resources
@@ -88,6 +89,10 @@
     public PublishWizard( Type type,
                           List<IResource> resources,
                           ServerManager serverManager ) throws CoreException {
+        Utils.nullArgumentCheck("type", type); //$NON-NLS-1$
+        Utils.nullArgumentCheck("resources", resources); //$NON-NLS-1$
+        Utils.nullArgumentCheck("serverManager", serverManager); //$NON-NLS-1$
+
         this.type = type;
         this.page = new PublishPage(type, resources);
         this.serverManager = serverManager;
@@ -186,9 +191,9 @@
             PublishingResultsDialog resultsDialog = null;
 
             if (error == null) {
-                resultsDialog = new PublishingResultsDialog(getShell(), this.type, files, operation.getStatus());
+                resultsDialog = new PublishingResultsDialog(getShell(), operation.getResults());
             } else {
-                resultsDialog = new PublishingResultsDialog(getShell(), this.type, files, operation.getStatus(), error);
+                resultsDialog = new PublishingResultsDialog(getShell(), operation.getResults(), error);
             }
 
             resultsDialog.open();

Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java	                        (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -0,0 +1,260 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.web.jcr.rest.client.swt.wizards;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.Utils;
+import org.jboss.dna.web.jcr.rest.client.Status.Severity;
+import org.jboss.dna.web.jcr.rest.client.swt.I18n;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class PublishingResults {
+
+    // ===========================================================================================================================
+    // Constants
+    // ===========================================================================================================================
+
+    /**
+     * Status indicating the file was not attempted to be published.
+     * 
+     * @since 0.6
+     */
+    private static final Status PUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
+                                                                          I18n.PublishingResultsPublishNotAttemptedMsg, null);
+
+    /**
+     * Status indicating the file was not attempted to be published.
+     * 
+     * @since 0.6
+     */
+    private static final Status UNPUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
+                                                                            I18n.PublishingResultsUnpublishNotAttemptedMsg, null);
+
+    // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    /**
+     * Indicates if a status for each file has been added.
+     * 
+     * @since 0.6
+     */
+    private boolean complete;
+
+    /**
+     * The files involved in the publishing operation.
+     * 
+     * @since 0.6
+     */
+    private final List<IFile> files;
+
+    /**
+     * The number of {@link Status status} objects that have an {@link Severity#ERROR error} severity.
+     * 
+     * @since 0.6
+     */
+    private int numErrors;
+
+    /**
+     * The number of {@link Status status} objects that have an {@link Severity#INFO info} severity.
+     * 
+     * @since 0.6
+     */
+    private int numInfos;
+
+    /**
+     * The number of {@link Status status} objects that have an {@link Severity#OK OK} severity.
+     * 
+     * @since 0.6
+     */
+    private int numOks;
+
+    /**
+     * The number of {@link Status status} objects that have a {@link Severity#WARNING warning} severity.
+     * 
+     * @since 0.6
+     */
+    private int numWarnings;
+
+    /**
+     * When complete there will be one status for each file.
+     * 
+     * @since 0.6
+     */
+    private final List<Status> statuses;
+
+    /**
+     * The type of publishing operation these results pertain to.
+     * 
+     * @since 0.6
+     */
+    private final Type type;
+
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
+
+    /**
+     * @param type the type of publishing operation
+     * @param files the files involved in the publishing operation (never <code>null</code>)
+     * @since 0.6
+     */
+    public PublishingResults( Type type,
+                              List<IFile> files ) {
+        Utils.nullArgumentCheck("type", type); //$NON-NLS-1$
+        Utils.nullArgumentCheck("files", files); //$NON-NLS-1$
+
+        this.type = type;
+        this.files = files;
+        this.statuses = new ArrayList<Status>(this.files.size());
+    }
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    /**
+     * @param status the status being added
+     * @throws RuntimeException if the number of status objects is greater than the number of files
+     * @since 0.6
+     */
+    public void addStatus( Status status ) {
+        if (this.files.size() < (this.statuses.size() + 1)) {
+            throw new RuntimeException(I18n.PublishingResultsTooManyResultsMsg);
+        }
+
+        this.statuses.add(status);
+
+        if (status.isError()) ++this.numErrors;
+        else if (status.isInfo()) ++this.numInfos;
+        else if (status.isOk()) ++this.numOks;
+        else if (status.isWarning()) ++this.numWarnings;
+        else throw new RuntimeException(I18n.bind(I18n.PublishingResultsUnknownSeverityMsg, status.getSeverity()));
+
+        this.complete = (this.files.size() == this.statuses.size());
+    }
+
+    /**
+     * Finalizes the results by making sure there is one status object for each file. No need to call if all files have a status.
+     * 
+     * @since 0.6
+     */
+    public void closeOut() {
+        if (this.files.size() != this.statuses.size()) {
+            Status status = ((Type.PUBLISH == this.type) ? PUBLISH_NOT_ATTEMPTED_STATUS : UNPUBLISH_NOT_ATTEMPTED_STATUS);
+
+            for (int count = this.files.size() - this.statuses.size(), i = 0; i < count; ++i) {
+                addStatus(status);
+            }
+        }
+    }
+
+    /**
+     * @return the number of errors in the result
+     * @since 0.6
+     */
+    public int getErrorCount() {
+        return this.numErrors;
+    }
+
+    /**
+     * @return the files involved in the publishing operation
+     * @since 0.6
+     */
+    public List<IFile> getFiles() {
+        return this.files;
+    }
+
+    /**
+     * @return the number of infos in the result
+     * @since 0.6
+     */
+    public int getInfoCount() {
+        return this.numInfos;
+    }
+
+    /**
+     * @return the number of OKs in the result
+     * @since 0.6
+     */
+    public int getOksCount() {
+        return this.numOks;
+    }
+
+    /**
+     * @param file the file whose status is being requested (never <code>null</code>)
+     * @return the status or <code>null</code> if there is no status for the specified file
+     * @since 0.6
+     */
+    public Status getStatus( IFile file ) {
+        Utils.nullArgumentCheck("file", file); //$NON-NLS-1$
+        int index = this.files.indexOf(file);
+
+        if (index == -1) {
+            return null;
+        }
+
+        return this.statuses.get(index);
+    }
+
+    /**
+     * @return the status of each file involved in the publishing operation
+     * @since 0.6
+     */
+    public List<Status> getStatuses() {
+        return this.statuses;
+    }
+
+    /**
+     * @return the publishing operation type
+     * @since 0.6
+     */
+    public Type getType() {
+        return this.type;
+    }
+
+    /**
+     * @return the number of warnings in the result
+     * @since 0.6
+     */
+    public int getWarningsCount() {
+        return this.numWarnings;
+    }
+
+    /**
+     * @return <code>true</code> if there is one status object for each file
+     * @since 0.6
+     */
+    public boolean isComplete() {
+        return this.complete;
+    }
+
+}


Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java	2009-07-29 23:01:57 UTC (rev 1140)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java	2009-07-31 16:52:11 UTC (rev 1141)
@@ -407,7 +407,7 @@
             this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword);
 
             // if server is valid and is different from what we started with validate and check the registry
-            if (this.status.isOk() && !this.server.equals(getServer())) {
+            if (this.status.isOk() && !this.server.hasSameKey(getServer())) {
                 this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword, getServerManager());
             }
         }



More information about the dna-commits mailing list