[dna-commits] DNA SVN: r1064 - in branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt: actions and 1 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Wed Jun 24 18:14:12 EDT 2009


Author: elvisisking
Date: 2009-06-24 18:14:12 -0400 (Wed, 24 Jun 2009)
New Revision: 1064

Added:
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java
Modified:
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/PublishAction.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/UnpublishAction.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java
Log:
More UI implementation.

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java	2009-06-24 18:31:40 UTC (rev 1063)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java	2009-06-24 22:14:12 UTC (rev 1064)
@@ -45,6 +45,13 @@
     public static String EditServerActionText;
     public static String EditServerActionToolTip;
     
+    public static String ErrorDialogTitle;
+
+    public static String PublishOperationPublishTaskName;
+    public static String PublishOperationPublishTitle;
+    public static String PublishOperationUnpublishTaskName;
+    public static String PublishOperationUnpublishTitle;
+    
     public static String PublishPagePublishTitle;
     public static String PublishPageLocationGroupTitle;
     public static String PublishPageMissingRepositoryStatusMsg;
@@ -67,8 +74,10 @@
     public static String PublishPageWorkspacePublishToolTip;
     public static String PublishPageWorkspaceUnpublishToolTip;
 
+    public static String PublishWizardPublishErrorMsg;
     public static String PublishWizardPublishTitle;
     public static String PublishWizardUnpublishTitle;
+    public static String PublishWizardUnpublishErrorMsg;
     
     public static String ServerPageAuthenticationGroupTitle;
     public static String ServerPageInvalidServerProperties;

Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java	                        (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java	2009-06-24 22:14:12 UTC (rev 1064)
@@ -0,0 +1,140 @@
+/*
+ * 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.publish.ui.swt.actions;
+
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.dna.publish.ui.swt.Activator;
+import org.jboss.dna.publish.ui.swt.wizards.PublishWizard;
+import org.jboss.dna.publish.ui.swt.wizards.PublishOperation.Type;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public abstract class BasePublishingAction implements IObjectActionDelegate {
+
+    // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    /**
+     * The current workspace selection.
+     * 
+     * @since 0.6
+     */
+    private IStructuredSelection selection;
+
+    /**
+     * The active part's Shell.
+     * 
+     * @since 0.6
+     */
+    private Shell shell;
+    
+    /**
+     * Indicates if this is a publishing or unpublishing action.
+     * 
+     * @since 0.6
+     */
+    private final Type type;
+
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
+
+    /**
+     * @param type indicates the type of action
+     * @since 0.6
+     */
+    public BasePublishingAction(Type type) {
+        this.type = type;
+    }
+    
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     * @since 0.6
+     */
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public void run( IAction action ) {
+        assert (this.selection != null);
+        assert (!this.selection.isEmpty());
+
+        List<IResource> resources;
+
+        if (this.selection.size() == 1) {
+            resources = Collections.singletonList((IResource)this.selection.getFirstElement());
+        } else {
+            resources = this.selection.toList();
+        }
+
+        // run wizard
+        new WizardDialog(shell, new PublishWizard(this.type, resources, Activator.getDefault().getServerManager()));
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
+     *      org.eclipse.jface.viewers.ISelection)
+     * @since 0.6
+     */
+    @Override
+    public void selectionChanged( IAction action,
+                                  ISelection selection ) {
+        if (selection instanceof IStructuredSelection) {
+            this.selection = (IStructuredSelection)selection;
+        } else {
+            this.selection = null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
+     * @since 0.6
+     */
+    @Override
+    public void setActivePart( IAction action,
+                               IWorkbenchPart targetPart ) {
+        this.shell = targetPart.getSite().getShell();
+    }
+
+}


Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/PublishAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/PublishAction.java	2009-06-24 18:31:40 UTC (rev 1063)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/PublishAction.java	2009-06-24 22:14:12 UTC (rev 1064)
@@ -23,20 +23,7 @@
  */
 package org.jboss.dna.publish.ui.swt.actions;
 
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.jboss.dna.publish.ui.swt.Activator;
-import org.jboss.dna.publish.ui.swt.wizards.PublishWizard;
-import org.jboss.dna.publish.ui.swt.wizards.PublishWizard.Type;
+import org.jboss.dna.publish.ui.swt.wizards.PublishOperation.Type;
 
 /**
  * The PublishAction controls the publishing of one or more {@link org.eclipse.core.resources.IResource}s to a DNA repository.
@@ -44,80 +31,17 @@
  * @author Dan Florian
  * @since 0.6
  */
-public final class PublishAction implements IObjectActionDelegate {
+public final class PublishAction extends BasePublishingAction {
 
     // ===========================================================================================================================
-    // Fields
+    // Constructors
     // ===========================================================================================================================
 
-    private IStructuredSelection selection;
-
     /**
-     * The active part's Shell.
-     * 
      * @since 0.6
      */
-    private Shell shell;
-
-    // ===========================================================================================================================
-    // Constants
-    // ===========================================================================================================================
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
-     * @since 0.6
-     */
-    @Override
-    @SuppressWarnings( "unchecked" )
-    public void run( IAction action ) {
-        assert (this.selection != null);
-        assert (!this.selection.isEmpty());
-
-        List<IResource> resources;
-
-        if (this.selection.size() == 1) {
-            resources = Collections.singletonList((IResource)this.selection.getFirstElement());
-        } else {
-            resources = this.selection.toList();
-        }
-
-        WizardDialog dialog = new WizardDialog(shell, new PublishWizard(Type.PUBLISH, resources,
-                                                                        Activator.getDefault().getServerManager()));
-
-        if (dialog.getReturnCode() == Window.OK) {
-            // TODO implement run publish
-        }
+    public PublishAction() {
+        super(Type.PUBLISH);
     }
 
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
-     *      org.eclipse.jface.viewers.ISelection)
-     * @since 0.6
-     */
-    @Override
-    public void selectionChanged( IAction action,
-                                  ISelection selection ) {
-        if (selection instanceof IStructuredSelection) {
-            this.selection = (IStructuredSelection)selection;
-        } else {
-            this.selection = null;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
-     * @since 0.6
-     */
-    @Override
-    public void setActivePart( IAction action,
-                               IWorkbenchPart targetPart ) {
-        this.shell = targetPart.getSite().getShell();
-    }
-
 }

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/UnpublishAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/UnpublishAction.java	2009-06-24 18:31:40 UTC (rev 1063)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/UnpublishAction.java	2009-06-24 22:14:12 UTC (rev 1064)
@@ -23,10 +23,7 @@
  */
 package org.jboss.dna.publish.ui.swt.actions;
 
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.dna.publish.ui.swt.wizards.PublishOperation.Type;
 
 /**
  * The UnpublishAction controls the unpublishing of on or more {@link org.eclipse.core.resources.IResource}s from a DNA
@@ -35,45 +32,17 @@
  * @author Dan Florian
  * @since 0.6
  */
-public final class UnpublishAction implements IObjectActionDelegate {
+public final class UnpublishAction extends BasePublishingAction {
 
-    /**
-     * The active part's Shell.
-     * 
-     * @since 0.6
-     */
-//    private Shell shell;
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
 
     /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
      * @since 0.6
      */
-    public void run( IAction action ) {
-        // TODO implement
+    public UnpublishAction() {
+        super(Type.UNPUBLISH);
     }
 
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
-     *      org.eclipse.jface.viewers.ISelection)
-     * @since 0.6
-     */
-    public void selectionChanged( IAction action,
-                                  ISelection selection ) {
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
-     * @since 0.6
-     */
-    public void setActivePart( IAction action,
-                               IWorkbenchPart targetPart ) {
-//        this.shell = targetPart.getSite().getShell();
-    }
-
 }

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties	2009-06-24 18:31:40 UTC (rev 1063)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties	2009-06-24 22:14:12 UTC (rev 1064)
@@ -10,9 +10,16 @@
 EditServerActionText = Edit Server
 EditServerActionToolTip = Edit Server
 
+ErrorDialogTitle = Error
+
 NewServerActionText = New Server
 NewServerActionToolTip = New Server
 
+PublishOperationPublishTaskName = Publishing resources
+PublishOperationPublishTitle = Publish
+PublishOperationUnpublishTaskName = Unpublishing resources
+PublishOperationUnpublishTitle = Unpublish
+
 PublishPagePublishTitle = Publish the selected resources
 PublishPageLocationGroupTitle = Location
 PublishPageMissingRepositoryStatusMsg = A repository must be selected
@@ -35,7 +42,9 @@
 PublishPageWorkspacePublishToolTip = The workspace where the resources are being published
 PublishPageWorkspaceUnpublishToolTip = The workspace where the resources are being unpublished
 
+PublishWizardPublishErrorMsg = Error Publishing
 PublishWizardPublishTitle = Publish
+PublishWizardUnpublishErrorMsg = Error Unpublishing
 PublishWizardUnpublishTitle = Unpublish
 
 ServerPageAuthenticationGroupTitle = Authentication

Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java	                        (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java	2009-06-24 22:14:12 UTC (rev 1064)
@@ -0,0 +1,168 @@
+/*
+ * 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.publish.ui.swt.wizards;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.jboss.dna.publish.domain.Workspace;
+import org.jboss.dna.publish.ui.swt.I18n;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public class PublishOperation implements IRunnableWithProgress {
+
+    // ===========================================================================================================================
+    // Constants
+    // ===========================================================================================================================
+
+    /**
+     * The wizard type.
+     * 
+     * @since 0.6
+     */
+    public enum Type {
+        /**
+         * Indicates the wizard will be used to publish.
+         * 
+         * @since 0.6
+         */
+        PUBLISH,
+
+        /**
+         * Indicates the wizard will be used to unpublish.
+         * 
+         * @since 0.6
+         */
+        UNPUBLISH
+    }
+
+    // ===========================================================================================================================
+    // Fields
+    // ===========================================================================================================================
+
+    /**
+     * The resources being published or unpublished.
+     * 
+     * @since 0.6
+     */
+    private final Collection<IResource> resources;
+
+    /**
+     * The operation type.
+     * 
+     * @since 0.6
+     */
+    private final Type type;
+
+    /**
+     * The workspace to use when publishing or unpublishing.
+     * 
+     * @since 0.6
+     */
+    private Workspace workspace;
+
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
+
+    /**
+     * @param type the operation type
+     * @param resources the resources being published or unpublished
+     */
+    public PublishOperation( Type type,
+                             Collection<IResource> resources ) {
+        this.type = type;
+        this.resources = resources;
+    }
+
+    // ===========================================================================================================================
+    // Methods
+    // ===========================================================================================================================
+
+    /**
+     * @return the operation title
+     * @since 0.6
+     */
+    public String getTitle() {
+        return ((this.type == Type.PUBLISH) ? I18n.PublishOperationPublishTitle : I18n.PublishOperationUnpublishTitle);
+    }
+
+    /**
+     * @return <code>true</code> if a publishing operation
+     * @since 0.6
+     */
+    public boolean isPublishing() {
+        return (this.type == Type.PUBLISH);
+    }
+
+    /**
+     * @return <code>true</code> if an unpublishing operation
+     * @since 0.6
+     */
+    public boolean isUnpublishing() {
+        return this.type == Type.UNPUBLISH;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
+     * @since 0.6
+     */
+    @Override
+    public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
+        assert (this.workspace != null);
+        
+        try {
+            // TODO
+            String name = (isPublishing() ? I18n.PublishOperationPublishTaskName : I18n.PublishOperationUnpublishTaskName);
+            monitor.beginTask(name, this.resources.size());
+            
+            for (IResource resource : this.resources) {
+                // TODO call publisher here
+                monitor.worked(1);
+            }
+        } catch (Exception e) {
+            throw new InvocationTargetException(e);
+        } finally {
+            monitor.done();
+        }
+    }
+
+    /**
+     * The workspace must be set prior to executing the operation.
+     * 
+     * @param workspace the workspace used when publishing or unpublishing (never <code>null</code>)
+     * @since 0.6
+     */
+    protected void setWorkspace( Workspace workspace ) {
+        this.workspace = workspace;
+    }
+
+}


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

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java	2009-06-24 18:31:40 UTC (rev 1063)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java	2009-06-24 22:14:12 UTC (rev 1064)
@@ -45,7 +45,7 @@
 import org.jboss.dna.publish.domain.Server;
 import org.jboss.dna.publish.domain.Workspace;
 import org.jboss.dna.publish.ui.swt.I18n;
-import org.jboss.dna.publish.ui.swt.wizards.PublishWizard.Type;
+import org.jboss.dna.publish.ui.swt.wizards.PublishOperation.Type;
 
 /**
  * @author Dan Florian
@@ -79,19 +79,31 @@
     private Combo cbxWorkspace;
 
     /**
-     * Indicates if the resources are being published or unpublished.
+     * Indicates if publishing or unpublishing is being done.
      * 
      * @since 0.6
      */
     private final Type type;
 
     /**
+     * The collection of resources being published/unpublished.
+     * 
+     * @since 0.6
+     */
+    private final List<IResource> resources;
+
+    /**
      * The repository where the workspace is located.
      * 
      * @since 0.6
      */
     private Repository repository;
 
+    /**
+     * A collection of repositories for the selected server (never <code>null</code>).
+     * 
+     * @since 0.6
+     */
     private List<Repository> repositories;
 
     /**
@@ -101,37 +113,40 @@
      */
     private Server server;
 
+    /**
+     * A collection of servers from the server registry (never <code>null</code>).
+     * 
+     * @since 0.6
+     */
     private List<Server> servers;
 
     /**
-     * The workspace where the resources are being published/unpublished.
+     * The current validation status.
      * 
      * @since 0.6
      */
-    private Workspace workspace;
+    private Status status;
 
-    private List<Workspace> workspaces;
-
     /**
-     * The collection of resources being published/unpublished.
+     * The workspace where the resources are being published/unpublished (may be <code>null</code>).
      * 
      * @since 0.6
      */
-    private final List<IResource> resources;
+    private Workspace workspace;
 
     /**
-     * The current validation status.
+     * A collection of workspaces for the selected server repository (never <code>null</code>).
      * 
      * @since 0.6
      */
-    private Status status;
+    private List<Workspace> workspaces;
 
     // ===========================================================================================================================
     // Constructors
     // ===========================================================================================================================
 
     /**
-     * @param type the publish or unpublish indicator
+     * @param type indicates if publishing or unpublishing is being done
      * @param resources the resources being published or unpublished (never <code>null</code>)
      * @since 0.6
      */

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java	2009-06-24 18:31:40 UTC (rev 1063)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java	2009-06-24 22:14:12 UTC (rev 1064)
@@ -23,14 +23,21 @@
  */
 package org.jboss.dna.publish.ui.swt.wizards;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.wizard.Wizard;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.jboss.dna.publish.ServerManager;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.Status.Severity;
+import org.jboss.dna.publish.domain.Workspace;
+import org.jboss.dna.publish.ui.swt.Activator;
 import org.jboss.dna.publish.ui.swt.I18n;
+import org.jboss.dna.publish.ui.swt.wizards.PublishOperation.Type;
 
 /**
  * @author Dan Florian
@@ -39,34 +46,16 @@
 public final class PublishWizard extends Wizard {
 
     // ===========================================================================================================================
-    // Constants
+    // Fields
     // ===========================================================================================================================
 
     /**
-     * The wizard type.
+     * The publishing or unpublishing operation.
      * 
      * @since 0.6
      */
-    public enum Type {
-        /**
-         * Indicates the wizard will be used to publish.
-         * 
-         * @since 0.6
-         */
-        PUBLISH,
-
-        /**
-         * Indicates the wizard will be used to unpublish.
-         * 
-         * @since 0.6
-         */
-        UNPUBLISH
-    }
-
-    // ===========================================================================================================================
-    // Fields
-    // ===========================================================================================================================
-
+    private final PublishOperation operation;
+    
     /**
      * The wizard page containing all the controls that allow publishing/unpublishing of resources.
      * 
@@ -94,9 +83,11 @@
     public PublishWizard( Type type,
                           List<IResource> resources,
                           ServerManager serverManager ) {
+        this.operation = new PublishOperation(type, resources);
         this.page = new PublishPage(type, resources);
         this.serverManager = serverManager;
-        setWindowTitle((type == Type.PUBLISH) ? I18n.PublishWizardPublishTitle : I18n.PublishWizardUnpublishTitle);
+
+        setWindowTitle(this.operation.isPublishing() ? I18n.PublishWizardPublishTitle : I18n.PublishWizardUnpublishTitle);
     }
 
     // ===========================================================================================================================
@@ -130,8 +121,20 @@
      */
     @Override
     public boolean performFinish() {
-        // TODO implement performFinish()
-        // Status status = null;
+        Workspace workspace = this.page.getWorkspace();
+        this.operation.setWorkspace(workspace);
+        
+        try {
+            getContainer().run(true, true, this.operation);
+        } catch (InterruptedException e) {
+            return false;
+        } catch (InvocationTargetException e) {
+            String message = (this.operation.isPublishing() ? I18n.PublishWizardPublishErrorMsg : I18n.PublishWizardUnpublishErrorMsg);
+            Activator.getDefault().log(getClass(), new Status(Severity.ERROR, message, e.getTargetException()));
+            MessageDialog.openError(getContainer().getShell(), I18n.ErrorDialogTitle, message);
+            return false;
+        }
+        
         return true; //!status.isError();
     }
 




More information about the dna-commits mailing list