[dna-commits] DNA SVN: r1069 - in branches/eclipse: org.jboss.dna.publish/META-INF and 5 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Jul 2 16:30:08 EDT 2009


Author: elvisisking
Date: 2009-07-02 16:30:08 -0400 (Thu, 02 Jul 2009)
New Revision: 1069

Modified:
   branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
   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.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/ServerPage.java
   branches/eclipse/org.jboss.dna.publish/.classpath
   branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF
   branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java
   branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java
   branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java
   branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java
Log:
Added JCIP immutable, threadsafe annotations. Made ServerManager thread safe. Got recurse flag saving and restoring on PublishPage.

Modified: branches/eclipse/org.jboss.dna.publish/.classpath
===================================================================
--- branches/eclipse/org.jboss.dna.publish/.classpath	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/.classpath	2009-07-02 20:30:08 UTC (rev 1069)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry exported="true" kind="lib" path="jcip-annotations.jar"/>
 	<classpathentry exported="true" kind="lib" path="slf4j-api-1.5.8.jar"/>
 	<classpathentry exported="true" kind="lib" path="jettison-1.1.jar"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>

Modified: branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF
===================================================================
--- branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF	2009-07-02 20:30:08 UTC (rev 1069)
@@ -9,7 +9,8 @@
 Bundle-Localization: plugin
 Bundle-ClassPath: dnaPublish.jar,
  jettison-1.1.jar,
- slf4j-api-1.5.8.jar
+ slf4j-api-1.5.8.jar,
+ jcip-annotations.jar
 Export-Package: org.jboss.dna.publish,
  org.jboss.dna.publish.domain,
  org.jboss.dna.publish.domain.validation

Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java	2009-07-02 20:30:08 UTC (rev 1069)
@@ -31,6 +31,9 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.transform.OutputKeys;
@@ -38,6 +41,8 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
+import net.jcip.annotations.GuardedBy;
+import net.jcip.annotations.ThreadSafe;
 import org.jboss.dna.publish.Status.Severity;
 import org.jboss.dna.publish.domain.Repository;
 import org.jboss.dna.publish.domain.Server;
@@ -54,6 +59,7 @@
  * @author Dan Florian
  * @since 0.6
  */
+ at ThreadSafe
 public final class ServerManager implements IConstants {
 
     // ===========================================================================================================================
@@ -111,18 +117,30 @@
      * 
      * @since 0.6
      */
-    private final Collection<IServerRegistryListener> listeners;
+    private final CopyOnWriteArrayList<IServerRegistryListener> listeners;
 
     /**
+     * The path where the server registry is persisted or <code>null</code> if not persisted.
+     * 
      * @since 0.6
      */
     private final String stateLocationPath;
 
     /**
+     * The server registry.
+     * 
      * @since 0.6
      */
+    @GuardedBy( "serverLock" )
     private final List<Server> servers;
 
+    /**
+     * Lock used for when accessing the server registry.
+     * 
+     * @since 0.6
+     */
+    private final ReadWriteLock serverLock = new ReentrantReadWriteLock();
+
     // ===========================================================================================================================
     // Constructors
     // ===========================================================================================================================
@@ -133,9 +151,9 @@
      * @since 0.6
      */
     public ServerManager( String stateLocationPath ) {
-        this.servers = Collections.synchronizedList(new ArrayList<Server>());
+        this.servers = new ArrayList<Server>();
         this.stateLocationPath = stateLocationPath;
-        this.listeners = new ArrayList<IServerRegistryListener>();
+        this.listeners = new CopyOnWriteArrayList<IServerRegistryListener>();
     }
 
     // ===========================================================================================================================
@@ -150,11 +168,7 @@
      * @since 0.6
      */
     public boolean addRegistryListener( IServerRegistryListener listener ) {
-        if (!this.listeners.contains(listener)) {
-            return this.listeners.add(listener);
-        }
-
-        return false;
+        return this.listeners.addIfAbsent(listener);
     }
 
     /**
@@ -173,7 +187,12 @@
      * @since 0.6
      */
     public Collection<Server> getServers() {
-        return Collections.unmodifiableCollection(this.servers);
+        try {
+            this.serverLock.readLock().lock();
+            return Collections.unmodifiableCollection(new ArrayList<Server>(this.servers));
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
     }
 
     /**
@@ -196,8 +215,13 @@
      * @since 0.6
      */
     public Collection<Repository> getRepositories( Server server ) {
-        // TODO implement getRepositories()
-        return Collections.emptyList();
+        try {
+            this.serverLock.readLock().lock();
+            // TODO implement getRepositories()
+            return Collections.unmodifiableCollection(new ArrayList<Repository>(/* repositories */));
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
     }
 
     /**
@@ -206,8 +230,13 @@
      * @since 0.6
      */
     public Collection<Workspace> getWorkspaces( Repository repository ) {
-        // TODO implement getWorkspaces()
-        return Collections.emptyList();
+        try {
+            this.serverLock.readLock().lock();
+            // TODO implement getWorkspaces()
+            return Collections.unmodifiableCollection(new ArrayList<Workspace>(/* workspaces */));
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
     }
 
     /**
@@ -220,18 +249,25 @@
      */
     private Status internalAddServer( Server server,
                                       boolean notifyListeners ) {
-        if (!this.servers.contains(server)) {
-            if (this.servers.add(server)) {
-                if (notifyListeners) {
-                    Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
-                    return processRegistryListenerErrors(errors);
-                }
+        boolean added = false;
 
-                return Status.OK_STATUS;
+        try {
+            this.serverLock.writeLock().lock();
+
+            if (!this.servers.contains(server)) {
+                added = this.servers.add(server);
             }
+        } finally {
+            this.serverLock.writeLock().unlock();
+        }
 
-            // server was not added to registry for unexpected reason
-            return new Status(Severity.ERROR, ServerManagerRegistryAddUnexpectedError, null);
+        if (added) {
+            if (notifyListeners) {
+                Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
+                return processRegistryListenerErrors(errors);
+            }
+
+            return Status.OK_STATUS;
         }
 
         // server already exists
@@ -249,9 +285,18 @@
      */
     private Status internalRemoveServer( Server server,
                                          boolean notifyListeners ) {
-        if (this.servers.remove(server)) {
+        boolean removed = false;
+
+        try {
+            this.serverLock.writeLock().lock();
+            removed = this.servers.remove(server);
+        } finally {
+            this.serverLock.writeLock().unlock();
+        }
+
+        if (removed) {
             if (notifyListeners) {
-                Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(server));
+                Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
                 return processRegistryListenerErrors(errors);
             }
 
@@ -271,7 +316,12 @@
      * @since 0.6
      */
     public boolean isRegistered( Server server ) {
-        return this.servers.contains(server);
+        try {
+            this.serverLock.readLock().lock();
+            return this.servers.contains(server);
+        } finally {
+            this.serverLock.readLock().unlock();
+        }
     }
 
     /**
@@ -280,35 +330,32 @@
      * @since 0.6
      */
     private Exception[] notifyRegistryListeners( ServerRegistryEvent event ) {
-        if (!this.listeners.isEmpty()) {
-            Collection<Exception> errors = null;
-            Collection<IServerRegistryListener> registryListeners = new ArrayList<IServerRegistryListener>(this.listeners);
+        Collection<Exception> errors = null;
 
-            for (IServerRegistryListener l : registryListeners) {
-                try {
-                    Exception[] problems = l.serverRegistryChanged(event);
+        for (IServerRegistryListener l : this.listeners) {
+            try {
+                Exception[] problems = l.serverRegistryChanged(event);
 
-                    if ((problems != null) && (problems.length != 0)) {
-                        if (errors == null) {
-                            errors = new ArrayList<Exception>();
-                        }
-
-                        errors.addAll(Arrays.asList(problems));
-                    }
-                } catch (Exception e) {
+                if ((problems != null) && (problems.length != 0)) {
                     if (errors == null) {
                         errors = new ArrayList<Exception>();
                     }
 
-                    errors.add(e);
+                    errors.addAll(Arrays.asList(problems));
                 }
-            }
+            } catch (Exception e) {
+                if (errors == null) {
+                    errors = new ArrayList<Exception>();
+                }
 
-            if ((errors != null) && !errors.isEmpty()) {
-                return errors.toArray(new Exception[errors.size()]);
+                errors.add(e);
             }
         }
 
+        if ((errors != null) && !errors.isEmpty()) {
+            return errors.toArray(new Exception[errors.size()]);
+        }
+
         return null;
     }
 
@@ -482,21 +529,4 @@
         return status;
     }
 
-    // ===========================================================================================================================
-    // Methods
-    // ===========================================================================================================================
-
-    public static void main( String[] args ) {
-        ServerManager mgr = new ServerManager("/home/dan"); //$NON-NLS-1$
-
-        // populate registry
-        if (mgr.servers.isEmpty()) {
-            for (int i = 0; i < 10; ++i) {
-                mgr.addServer(new Server("http://server" + i + ".com", "user" + i, "password" + i)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-            }
-        }
-
-        mgr.saveState();
-    }
-
 }

Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java	2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,7 @@
 package org.jboss.dna.publish.domain;
 
 import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
 import org.jboss.dna.publish.IConstants;
 import org.jboss.dna.publish.Status;
 import org.jboss.dna.publish.domain.validation.RepositoryValidator;
@@ -34,6 +35,7 @@
  * @author Dan Florian
  * @since 0.6
  */
+ at Immutable
 public final class Repository implements IConstants, IDnaObject {
 
     // ===========================================================================================================================

Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java	2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,7 @@
 package org.jboss.dna.publish.domain;
 
 import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
 import org.jboss.dna.publish.IConstants;
 import org.jboss.dna.publish.Status;
 import org.jboss.dna.publish.domain.validation.RepositoryValidator;
@@ -35,6 +36,7 @@
  * @author Dan Florian
  * @since 0.6
  */
+ at Immutable
 public final class Server implements IConstants, IDnaObject {
 
     // ===========================================================================================================================

Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java	2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,7 @@
 package org.jboss.dna.publish.domain;
 
 import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
 import org.jboss.dna.publish.IConstants;
 import org.jboss.dna.publish.Status;
 import org.jboss.dna.publish.domain.validation.WorkspaceValidator;
@@ -34,6 +35,7 @@
  * @author Dan Florian
  * @since 0.6
  */
+ at Immutable
 public final class Workspace implements IConstants, IDnaObject {
 
     // ===========================================================================================================================

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml	2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,16 @@
                class="org.jboss.dna.publish.ui.swt.actions.UnpublishAction"
                menubarPath="org.jboss.dna.publish.ui.swt.contextMenu/group1"
                enablesFor="*">
+               <enablement>
+                     <or>
+                         <objectClass name="org.eclipse.core.resources.IFile" />
+                         <objectClass name="org.eclipse.core.resources.IFolder" />
+                         <and>
+                               <objectClass name="org.eclipse.core.resources.IProject" />
+                               <objectState name="open" value="true" />
+                         </and>
+                     </or>
+               </enablement>
          </action>
          
          <!-- Publish action -->
@@ -33,6 +43,16 @@
                class="org.jboss.dna.publish.ui.swt.actions.PublishAction"
                menubarPath="org.jboss.dna.publish.ui.swt.contextMenu/group1"
                enablesFor="*">
+               <enablement>
+                     <or>
+                         <objectClass name="org.eclipse.core.resources.IFile" />
+                         <objectClass name="org.eclipse.core.resources.IFolder" />
+                         <and>
+                               <objectClass name="org.eclipse.core.resources.IProject" />
+                               <objectState name="open" value="true" />
+                         </and>
+                     </or>
+               </enablement>
          </action>
       </objectContribution>
    </extension>

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-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java	2009-07-02 20:30:08 UTC (rev 1069)
@@ -63,7 +63,8 @@
     public static String PublishPageNoAvailableRepositoriesStatusMsg;
     public static String PublishPageNoAvailableServersStatusMsg;
     public static String PublishPageNoAvailableWorkspacesStatusMsg;
-    public static String PublishPageNoResourcesStatusMsg;
+    public static String PublishPageNoResourcesToPublishStatusMsg;
+    public static String PublishPageNoResourcesToUnpublishStatusMsg;
     public static String PublishPagePublishOkStatusMsg;
     public static String PublishPagePublishResourcesLabel;
     public static String PublishPageRecurseCheckBox;

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-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties	2009-07-02 20:30:08 UTC (rev 1069)
@@ -52,8 +52,9 @@
 PublishPageNewServerButton = New...
 PublishPageNoAvailableRepositoriesStatusMsg = There are no repositories available on that server
 PublishPageNoAvailableServersStatusMsg = A server must be created first
-PublishPageNoAvailableWorkspacesStatusMsg = There are no workspaces availabe on that server and repository
-PublishPageNoResourcesStatusMsg = You must select one or more workspace resources
+PublishPageNoAvailableWorkspacesStatusMsg = There are no workspaces available on that server and repository
+PublishPageNoResourcesToPublishStatusMsg = There are no files that can be published
+PublishPageNoResourcesToUnpublishStatusMsg = There are no files that can be unpublished
 PublishPagePublishOkStatusMsg = Choose the server, repository, and workspace where the selected resources will be published.
 PublishPagePublishResourcesLabel = These resources will be published to the specified DNA repository:
 PublishPageRecurseCheckBox = Recurse folders and projects

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-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java	2009-07-02 20:30:08 UTC (rev 1069)
@@ -38,6 +38,7 @@
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.IWizard;
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ModifyEvent;
@@ -114,7 +115,7 @@
      * Processes the specified list of files and for (1) each file found adds it to the result and (2) for each project or folder
      * adds all contained files. For projects and folders processing will be recursive based on saved wizard settings.
      * 
-     * @param resources the resources being processed
+     * @param resources the resources being processed (never <code>null</code>)
      * @param recurse the flag indicating if child containers should be traversed
      * @return the files being published or unpublished (never <code>null</code>)
      * @throws CoreException if there is a problem processing the resources
@@ -377,7 +378,6 @@
 
         this.type = type;
         this.resources = resources;
-        this.files = processResources(resources, this.recurse);
     }
 
     // ===========================================================================================================================
@@ -394,7 +394,7 @@
         // row 2: label combobox
         // row 3: label combobox
 
-        { // server row
+        { // row 1: server row
             Composite pnlServer = new Composite(pnl, SWT.NONE);
             GridLayout layout = new GridLayout(3, false);
             layout.marginHeight = 0;
@@ -413,7 +413,7 @@
             this.cbxServer.setToolTipText(I18n.PublishPageServerToolTip);
 
             final IAction action = new NewServerAction(this.getShell(), getServerManager());
-            Button btnNewServer = new Button(pnlServer, SWT.PUSH);
+            final Button btnNewServer = new Button(pnlServer, SWT.PUSH);
             btnNewServer.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
             btnNewServer.setText(I18n.PublishPageNewServerButton);
             btnNewServer.setToolTipText(action.getToolTipText());
@@ -424,9 +424,18 @@
                     refreshServers();
                 }
             });
+
+            // update page message first time selected to get rid of initial message by forcing validation
+            btnNewServer.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected( SelectionEvent e ) {
+                    updateInitialMessage();
+                    btnNewServer.removeSelectionListener(this);
+                }
+            });
         }
 
-        { // repository row
+        { // row 2: repository row
             Label lblRepository = new Label(pnl, SWT.LEFT);
             lblRepository.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
             lblRepository.setText(I18n.PublishPageRepositoryLabel);
@@ -436,7 +445,7 @@
             this.cbxRepository.setToolTipText(I18n.PublishPageRepositoryToolTip);
         }
 
-        { // workspace row
+        { // row 3: workspace row
             Label lblWorkspace = new Label(pnl, SWT.LEFT);
             lblWorkspace.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
             lblWorkspace.setText(I18n.PublishPageWorkspaceLabel);
@@ -454,12 +463,13 @@
 
     private void constructResourcesPanel( Composite parent ) {
         Composite pnl = new Composite(parent, SWT.NONE);
-        pnl.setLayout(new GridLayout(2, false));
+        pnl.setLayout(new GridLayout());
         pnl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
         // pnl layout:
-        // row 1: lbl chk
+        // row 1: lbl
         // row 2: lstResources
+        // row 3: chkbox
 
         { // row 1
             Label lbl = new Label(pnl, SWT.LEFT);
@@ -470,17 +480,6 @@
             } else {
                 lbl.setText(I18n.PublishPageUnpublishResourcesLabel);
             }
-
-            final Button chk = new Button(pnl, SWT.CHECK);
-            chk.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-            chk.setText(I18n.PublishPageRecurseCheckBox);
-            chk.setToolTipText(I18n.PublishPageRecurseCheckBoxToolTip);
-            chk.addSelectionListener(new SelectionAdapter() {
-                @Override
-                public void widgetSelected( SelectionEvent e ) {
-                    handleRecurseChanged(chk.getSelection());
-                }
-            });
         }
 
         { // row 2
@@ -488,10 +487,45 @@
             GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
             gd.horizontalSpan = 2;
             this.lstResources.setLayoutData(gd);
+            final org.eclipse.swt.widgets.List finalLst = this.lstResources;
 
+            // update page message first time selected to get rid of initial message by forcing validation
+            this.lstResources.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected( SelectionEvent e ) {
+                    // do the very first time to get rid of initial message then remove listener
+                    updateInitialMessage();
+                    finalLst.removeSelectionListener(this);
+                }
+            });
+
             // load list with initial files
             loadFiles();
         }
+        
+        { // row 3
+            final Button chkRecurse = new Button(pnl, SWT.CHECK);
+            chkRecurse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+            chkRecurse.setText(I18n.PublishPageRecurseCheckBox);
+            chkRecurse.setToolTipText(I18n.PublishPageRecurseCheckBoxToolTip);
+            chkRecurse.setSelection(this.recurse);
+            chkRecurse.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected( SelectionEvent e ) {
+                    handleRecurseChanged(chkRecurse.getSelection());
+                }
+            });
+
+            // update page message first time selected to get rid of initial message by forcing validation
+            chkRecurse.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected( SelectionEvent e ) {
+                    updateInitialMessage();
+                    chkRecurse.removeSelectionListener(this);
+                }
+            });
+
+        }
     }
 
     /**
@@ -521,6 +555,19 @@
     }
 
     /**
+     * Updates the initial page message.
+     * 
+     * @since 0.6
+     */
+    void updateInitialMessage() {
+        String msg = ((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
+
+        if (msg.equals(getMessage())) {
+            updateState();
+        }
+    }
+
+    /**
      * @return the server manager obtained from the wizard
      * @since 0.6
      */
@@ -843,11 +890,31 @@
             validate();
 
             // set initial message
-            setMessage((type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
+            setMessage((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
         }
     }
 
     /**
+     * {@inheritDoc}
+     * 
+     * @see org.eclipse.jface.wizard.WizardPage#setWizard(org.eclipse.jface.wizard.IWizard)
+     * @since 0.6
+     */
+    @Override
+    public void setWizard( IWizard newWizard ) {
+        super.setWizard(newWizard);
+
+        // need to make sure the wizard has been set on the page since the recurse value is saved in the wizard dialog settings
+        this.recurse = isRecursing();
+
+        try {
+            this.files = processResources(this.resources, this.recurse);
+        } catch (CoreException e) {
+            Activator.getDefault().log(new Status(Severity.ERROR, I18n.PublishPageRecurseProcessingErrorMsg, e));
+        }
+    }
+
+    /**
      * Uninstalls the combobox listeners.
      * 
      * @param listenerControlLock the method in control of registering/unregistering combobox listeners
@@ -868,7 +935,7 @@
      * 
      * @since 0.6
      */
-    private void updateState() {
+    void updateState() {
         // get the current state
         validate();
 
@@ -898,9 +965,8 @@
         String msg = null;
         Severity severity = Severity.ERROR;
 
-        if (this.resources != null && this.resources.isEmpty()) {
-            // should not happen since action should not enable if nothing selected
-            msg = I18n.PublishPageNoResourcesStatusMsg;
+        if ((this.resources == null) || this.resources.isEmpty() || this.files.isEmpty()) {
+            msg = ((type == Type.PUBLISH) ? I18n.PublishPageNoResourcesToPublishStatusMsg : I18n.PublishPageNoResourcesToUnpublishStatusMsg);
         } else if (this.server == null) {
             int count = this.cbxServer.getItemCount();
             msg = ((count == 0) ? I18n.PublishPageNoAvailableServersStatusMsg : I18n.PublishPageMissingServerStatusMsg);

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java	2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java	2009-07-02 20:30:08 UTC (rev 1069)
@@ -167,6 +167,7 @@
             });
         }
 
+        // FIXME implement save password
         { // save button row
             Button btn = new Button(pnl, SWT.CHECK | SWT.LEFT);
             btn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));




More information about the dna-commits mailing list