[dna-commits] DNA SVN: r1074 - in branches/eclipse: org.jboss.dna.publish/src/org/jboss/dna/publish/domain and 2 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Tue Jul 7 14:53:08 EDT 2009


Author: elvisisking
Date: 2009-07-07 14:53:08 -0400 (Tue, 07 Jul 2009)
New Revision: 1074

Added:
   branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Utils.java
Modified:
   branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java
   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.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java
   branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Status.java
   branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.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:
In PublishPage a fixed a bug with the combo listeners. In ServerView added a double-click to open dialog to edit server properties. Fixed equals in Server business object. Other miscellaneous changes (error messages, support utilities, minor change to IDnaObject API).

Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Status.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Status.java	2009-07-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Status.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -23,10 +23,13 @@
  */
 package org.jboss.dna.publish;
 
+import net.jcip.annotations.Immutable;
+
 /**
  * @author Dan Florian
  * @since 0.6
  */
+ at Immutable
 public class Status {
 
     // ===========================================================================================================================
@@ -92,36 +95,29 @@
      * 
      * @since 0.6
      */
-    protected Throwable exception;
+    protected final Throwable exception;
 
     /**
-     * The localized message of this status (never <code>null</code>).
+     * The localized message of this status (can be <code>null</code>).
      * 
      * @since 0.6
      */
-    protected String message;
+    protected final String message;
 
     /**
      * The severity level of this status.
      * 
      * @since 0.6
      */
-    protected Severity severity;
+    protected final Severity severity;
 
     // ===========================================================================================================================
     // Constructors
     // ===========================================================================================================================
 
     /**
-     * @since 0.6
-     */
-    protected Status() {
-        // nothing to do
-    }
-
-    /**
-     * @param severity the status severity (<code>null</code> will be converted to {@link Severity#UNKNOWN}.
-     * @param message the status message or <code>null</code>
+     * @param severity the status severity (if <code>null</code> it will be converted to {@link Severity#UNKNOWN}.
+     * @param message the status message (if <code>null</code> it will be returned as an empty string)
      * @param exception the status exception or <code>null</code>
      * @since 0.6
      */

Added: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Utils.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Utils.java	                        (rev 0)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Utils.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -0,0 +1,66 @@
+/*
+ * 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;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class Utils {
+
+    // ===========================================================================================================================
+    // Class Methods
+    // ===========================================================================================================================
+
+    /**
+     * @param thisObj an object being compared
+     * @param thatObj the other object being compared
+     * @return <code>true</code> if both objects are null or both are not null and equal
+     * @since 0.6
+     */
+    public static boolean equivalent( Object thisObj,
+                                      Object thatObj ) {
+        // true if both objects are null
+        if (thisObj == null) {
+            return (thatObj == null);
+        }
+
+        if (thatObj == null) return false;
+        return thisObj.equals(thatObj);
+    }
+
+    // ===========================================================================================================================
+    // Constructors
+    // ===========================================================================================================================
+
+    /**
+     * Don't allow construction.
+     * 
+     * @since 0.6
+     */
+    public Utils() {
+        // nothing to do
+    }
+
+}


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

Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java	2009-07-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -32,15 +32,6 @@
 public interface IDnaObject {
 
     /**
-     * Compares all properties rather than just the properties that determine equality. Objects that are equal can be different.
-     * 
-     * @param obj the object with which to compare
-     * @return <code>true</code> if different
-     * @since 0.6
-     */
-    boolean different( IDnaObject obj );
-
-    /**
      * @return the object name (never <code>null</code>)
      * @since 0.6
      */

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-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -91,18 +91,6 @@
 
     /**
      * {@inheritDoc}
-     *
-     * @see org.jboss.dna.publish.domain.IDnaObject#different(org.jboss.dna.publish.domain.IDnaObject)
-     * @since 0.6
-     */
-    @Override
-    public boolean different( IDnaObject obj ) {
-        // there are no fields not involved in equals check
-        return !equals(obj);
-    }
-
-    /**
-     * {@inheritDoc}
      * 
      * @see java.lang.Object#equals(java.lang.Object)
      * @since 0.6

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-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -27,6 +27,7 @@
 import net.jcip.annotations.Immutable;
 import org.jboss.dna.publish.IConstants;
 import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.Utils;
 import org.jboss.dna.publish.domain.validation.RepositoryValidator;
 import org.jboss.dna.publish.domain.validation.ServerValidator;
 
@@ -111,35 +112,6 @@
     /**
      * {@inheritDoc}
      * 
-     * @see org.jboss.dna.publish.domain.IDnaObject#different(org.jboss.dna.publish.domain.IDnaObject)
-     * @since 0.6
-     */
-    @Override
-    public boolean different( IDnaObject obj ) {
-        if (equals(obj)) {
-            // check fields not involved in equals check
-            Server otherServer = (Server)obj;
-            boolean result = false;
-
-            if (this.password == null) {
-                result = (otherServer.password != null);
-            } else {
-                result = !this.password.equals(otherServer.password);
-            }
-
-            if (!result) {
-                result = (this.persistPassword != otherServer.persistPassword);
-            }
-
-            return result;
-        }
-
-        return true;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
      * @see java.lang.Object#equals(java.lang.Object)
      * @since 0.6
      */
@@ -150,7 +122,9 @@
 
         // must have another server
         Server otherServer = (Server)obj;
-        return (this.url.equals(otherServer.url) && this.user.equals(otherServer.user));
+        return Utils.equivalent(this.url, otherServer.url) && Utils.equivalent(this.user, otherServer.user)
+               && Utils.equivalent(this.password, otherServer.password)
+               && Utils.equivalent(this.persistPassword, otherServer.persistPassword);
     }
 
     /**
@@ -210,7 +184,17 @@
     public int hashCode() {
         int hash = 7;
         hash = 31 * hash + this.url.hashCode();
-        hash = 31 * hash + this.user.hashCode();
+
+        if (this.user != null) {
+            hash = 31 * hash + this.user.hashCode();
+        }
+
+        if (this.password != null) {
+            hash = 31 * hash + this.password.hashCode();
+        }
+
+        hash = 31 * hash + Boolean.valueOf(this.persistPassword).hashCode();
+
         return hash;
     }
 

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-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -89,18 +89,6 @@
 
     /**
      * {@inheritDoc}
-     *
-     * @see org.jboss.dna.publish.domain.IDnaObject#different(org.jboss.dna.publish.domain.IDnaObject)
-     * @since 0.6
-     */
-    @Override
-    public boolean different( IDnaObject obj ) {
-        // there are no fields not involved in equals check
-        return !equals(obj);
-    }
-
-    /**
-     * {@inheritDoc}
      * 
      * @see java.lang.Object#equals(java.lang.Object)
      * @since 0.6

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java	2009-07-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -28,6 +28,8 @@
 import org.eclipse.jface.action.IAction;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -176,7 +178,13 @@
                 handleSelectionChanged(event);
             }
         });
-        
+        this.viewer.addDoubleClickListener(new IDoubleClickListener() {
+            @Override
+            public void doubleClick( DoubleClickEvent arg0 ) {
+                handleDoubleClick();
+            }
+        });
+
         // need to call this (doesn't matter what the param is) to bootstrap the provider.
         this.viewer.setInput(this);
     }
@@ -197,10 +205,10 @@
         // register to receive changes to the server registry
         getServerManager().addRegistryListener(this);
     }
-    
+
     /**
      * {@inheritDoc}
-     *
+     * 
      * @see org.eclipse.ui.part.WorkbenchPart#dispose()
      * @since 0.6
      */
@@ -227,6 +235,15 @@
     }
 
     /**
+     * Opens a dialog to edit server properties.
+     * 
+     * @since 0.6
+     */
+    void handleDoubleClick() {
+        this.editAction.run();
+    }
+
+    /**
      * @param event the event being processed
      * @since 0.6
      */
@@ -242,13 +259,7 @@
      */
     @Override
     public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {
-        // FIXME viewer is not updating objects that have property changes that don't effect equality
-        if (event.isUpdate()) {
-            this.viewer.refresh(event.getUpdatedServer());
-        } else {
-            this.viewer.refresh();
-        }
-        
+        this.viewer.refresh();
         return null;
     }
 

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-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -502,7 +502,7 @@
             // 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));
@@ -543,7 +543,6 @@
         setControl(pnlMain);
 
         refreshServers();
-        installLocationListeners(null);
     }
 
     /**
@@ -655,7 +654,6 @@
             this.cbxRepository.addModifyListener(this);
             this.cbxServer.addModifyListener(this);
             this.cbxWorkspace.addModifyListener(this);
-            this.listenerControlLock = listenerControlLock;
             this.listenerControlLock = null;
         }
     }
@@ -886,11 +884,23 @@
         super.setVisible(visible);
 
         if (visible) {
-            // set initial state
+            // set initial status
             validate();
 
             // set initial message
-            setMessage((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
+            String initialMsg = ((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
+
+            // if no resources to publish set the message to that else set to initial message
+            if (!this.status.isOk()) {
+                if (I18n.PublishPageNoResourcesToPublishStatusMsg.equals(this.status.getMessage())
+                    || I18n.PublishPageNoResourcesToUnpublishStatusMsg.equals(this.status.getMessage())) {
+                    setErrorMessage(this.status.getMessage());
+                } else {
+                    setMessage(initialMsg);
+                }
+            } else {
+                setMessage(initialMsg);
+            }
         }
     }
 

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-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -403,10 +403,11 @@
         if (this.server == null) {
             this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword, getServerManager());
         } else {
+            // make sure all fields are valid without seeing if server exists in registry
             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())) {
-                // make sure changes don't make it equal to an existing server
                 this.status = ServerValidator.isValid(this.url, this.user, this.password, this.savePassword, getServerManager());
             }
         }

Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java	2009-07-06 22:25:55 UTC (rev 1073)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java	2009-07-07 18:53:08 UTC (rev 1074)
@@ -133,7 +133,7 @@
             if (status.isError()) {
                 MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, I18n.ServerWizardEditServerErrorMsg);
             }
-        } else if (this.existingServer.different(server)) {
+        } else if (!this.existingServer.equals(server)) {
             status = this.serverManager.updateServer(this.existingServer, server);
 
             if (status.isError()) {




More information about the dna-commits mailing list