Author: elvisisking
Date: 2009-07-06 18:25:55 -0400 (Mon, 06 Jul 2009)
New Revision: 1073
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/collapse_all.gif
Removed:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete.gif
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Activator.java
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/IUiConstants.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.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/views/ServerView.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/ServerManager.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
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/ServerValidator.java
Log:
Got the save password stuff working and persisting. Images are working in views but will
need to come up with some specialized images for the business objects. Finished making
ServerManager thread safe.
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-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -416,12 +416,13 @@
if (attributeMap == null) continue;
- for (int numAttrs = attributeMap.getLength(), j = 0; j <
numAttrs; ++j) {
- Node urlNode = attributeMap.getNamedItem(URL_TAG);
- Node userNode = attributeMap.getNamedItem(USER_TAG);
- Node passwordNode =
attributeMap.getNamedItem(PASSWORD_TAG);
- addServer(new Server(urlNode.getNodeValue(),
userNode.getNodeValue(), passwordNode.getNodeValue()));
- }
+ Node urlNode = attributeMap.getNamedItem(URL_TAG);
+ Node userNode = attributeMap.getNamedItem(USER_TAG);
+ Node passwordNode = attributeMap.getNamedItem(PASSWORD_TAG);
+ String pswd = ((passwordNode == null) ? null :
(String)passwordNode.getNodeValue());
+
+ // add server to registry
+ addServer(new Server(urlNode.getNodeValue(),
userNode.getNodeValue(), pswd, (pswd != null)));
}
}
} catch (Exception e) {
@@ -458,7 +459,10 @@
serverElement.setAttribute(URL_TAG, server.getUrl());
serverElement.setAttribute(USER_TAG, server.getUser());
- serverElement.setAttribute(PASSWORD_TAG, server.getPassword());
+
+ if (server.isPasswordBeingPersisted()) {
+ serverElement.setAttribute(PASSWORD_TAG, server.getPassword());
+ }
}
DOMSource source = new DOMSource(doc);
@@ -503,23 +507,30 @@
*/
public Status updateServer( Server previousServerVersion,
Server newServerVersion ) {
- Status status = internalRemoveServer(previousServerVersion, false);
+ Status status = null;
- if (status.isOk()) {
- status = internalAddServer(newServerVersion, false);
+ try {
+ this.serverLock.writeLock().lock();
+ status = internalRemoveServer(previousServerVersion, false);
if (status.isOk()) {
- // all good so notify listeners
- Exception[] errors =
notifyRegistryListeners(ServerRegistryEvent.createUpdateEvent(previousServerVersion,
-
newServerVersion));
- return processRegistryListenerErrors(errors);
+ status = internalAddServer(newServerVersion, false);
+
+ if (status.isOk()) {
+ // all good so notify listeners
+ Exception[] errors =
notifyRegistryListeners(ServerRegistryEvent.createUpdateEvent(previousServerVersion,
+
newServerVersion));
+ return processRegistryListenerErrors(errors);
+ }
+
+ // unexpected problem adding new version of server to registry
+ String pattern =
MESSAGES.getString(ServerManagerRegistryUpdateAddError);
+ String msg = MessageFormat.format(pattern, status.getMessage());
+ status = new Status(Severity.ERROR, msg, status.getException());
+ return status;
}
-
- // unexpected problem adding new version of server to registry
- String pattern = MESSAGES.getString(ServerManagerRegistryUpdateAddError);
- String msg = MessageFormat.format(pattern, status.getMessage());
- status = new Status(Severity.ERROR, msg, status.getException());
- return status;
+ } finally {
+ this.serverLock.writeLock().unlock();
}
// unexpected problem removing server from registry
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-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -32,6 +32,15 @@
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-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -91,6 +91,18 @@
/**
* {@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-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -51,6 +51,13 @@
private final String password;
/**
+ * Indicates if the password should be stored locally when the server is persisted.
+ *
+ * @since 0.6
+ */
+ private final boolean persistPassword;
+
+ /**
* The server URL.
*
* @since 0.6
@@ -74,15 +81,17 @@
* @param url the server URL
* @param user the server user
* @param password the server password
+ * @param persistPassword <code>true</code> if the password should be
stored
* @see RepositoryValidator
* @throws RuntimeException if any of the input parameters are invalid
* @since 0.6
*/
public Server( String url,
String user,
- String password ) {
+ String password,
+ boolean persistPassword ) {
// valid inputs
- Status status = ServerValidator.isValid(url, user, password);
+ Status status = ServerValidator.isValid(url, user, password, persistPassword);
if (status.isError()) {
throw new RuntimeException(status.getMessage(), status.getException());
@@ -92,6 +101,7 @@
this.url = url;
this.user = user;
this.password = password;
+ this.persistPassword = persistPassword;
}
//
===========================================================================================================================
@@ -101,6 +111,35 @@
/**
* {@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
*/
@@ -175,4 +214,12 @@
return hash;
}
+ /**
+ * @return persistPassword <code>true</code> if the password is being
persisted
+ * @since 0.6
+ */
+ public boolean isPasswordBeingPersisted() {
+ return this.persistPassword;
+ }
+
}
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-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -89,6 +89,18 @@
/**
* {@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/validation/ServerValidator.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/ServerValidator.java 2009-07-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/ServerValidator.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -85,15 +85,19 @@
}
/**
+ * This does not verify that a server with the same primary field values doesn't
already exist.
+ *
* @param url the URL being validated
* @param user the user being validated
* @param password the password being validated
+ * @param persistPassword <code>true</code> if the password should be
persisted
* @return a validation status (never <code>null</code>)
* @since 0.6
*/
public static Status isValid( String url,
String user,
- String password ) {
+ String password,
+ boolean persistPassword ) {
Status status = isUrlValid(url);
if (!status.isError()) {
@@ -108,23 +112,28 @@
}
/**
+ * Validates the server properties and makes sure no other exists in the server
registry that also has the same primary field
+ * values.
+ *
* @param url the URL being validated
* @param user the user being validated
* @param password the password being validated
+ * @param persistPassword <code>true</code> if the password should be
persisted
* @param serverManager the server manager controlling the server registry (may not
be <code>null</code>)
* @return a validation status (never <code>null</code>)
- * @see #isValid(String, String, String)
+ * @see #isValid(String, String, String, boolean)
* @since 0.6
*/
public static Status isValid( String url,
String user,
String password,
+ boolean persistPassword,
ServerManager serverManager ) {
- Status status = isValid(url, user, password);
+ Status status = isValid(url, user, password, persistPassword);
// make sure a server with the same properties does not exist
if (!status.isError()) {
- Server newServer = new Server(url, user, password);
+ Server newServer = new Server(url, user, password, persistPassword);
if (serverManager.isRegistered(newServer)) {
String pattern = MESSAGES.getString(ServerExistsMsg);
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/collapse_all.gif
===================================================================
(Binary files differ)
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/collapse_all.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete.gif
===================================================================
(Binary files differ)
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Activator.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Activator.java 2009-07-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Activator.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -23,14 +23,19 @@
*/
package org.jboss.dna.publish.ui.swt;
+import java.net.MalformedURLException;
+import java.net.URL;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.dna.publish.Logger;
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.IDnaObject;
import org.jboss.dna.publish.domain.Repository;
import org.jboss.dna.publish.domain.Server;
@@ -73,6 +78,13 @@
//
===========================================================================================================================
/**
+ * The image used when the requested image cannot be found.
+ *
+ * @since 0.6
+ */
+ private Image missingImage;
+
+ /**
* The manager in charge of the server registry.
*
* @since 0.6
@@ -83,26 +95,55 @@
// Methods
//
===========================================================================================================================
- public Image getSharedImage(String imageId) {
- Image result = PlatformUI.getWorkbench().getSharedImages().getImage(imageId);
-
- if (result != null) {
- return result;
+ private ImageDescriptor createImageDescriptor( String key ) {
+ try {
+ URL url = new URL(getBundle().getEntry("/").toString() + key);
//$NON-NLS-1$
+ return ImageDescriptor.createFromURL(url);
+ } catch (final MalformedURLException e) {
+ log(new Status(Severity.ERROR, I18n.bind(I18n.MissingImage, key), e));
+ return null;
}
-
- return ImageDescriptor.getMissingImageDescriptor().createImage();
}
- public ImageDescriptor getSharedImageDescriptor(String imageId) {
+ /**
+ * @return the image to use when a requested image cannot be found
+ * @since 0.6
+ */
+ private Image getMissingImage() {
+ if (this.missingImage == null) {
+ this.missingImage =
ImageDescriptor.getMissingImageDescriptor().createImage();
+ }
+
+ return this.missingImage;
+ }
+
+ /**
+ * @param imageId the shared image identifier
+ * @return the image or <code>null</code>
+ * @see ISharedImages
+ * @since 0.6
+ */
+ public Image getSharedImage( String imageId ) {
+ Image result = PlatformUI.getWorkbench().getSharedImages().getImage(imageId);
+ return ((result == null) ? getMissingImage() : result);
+ }
+
+ /**
+ * @param imageId the shared image identifier
+ * @return the image descriptor or <code>null</code>
+ * @see ISharedImages
+ * @since 0.6
+ */
+ public ImageDescriptor getSharedImageDescriptor( String imageId ) {
ImageDescriptor result =
PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imageId);
-
+
if (result != null) {
return result;
}
-
+
return ImageDescriptor.getMissingImageDescriptor();
}
-
+
/**
* @param object the object whose image is being requested (domain object or
plugin-relative path)
* @return the image or <code>null</code> if not found
@@ -125,7 +166,21 @@
}
if (key != null) {
- return getImageRegistry().get(key);
+ ImageRegistry registry = getImageRegistry();
+ Image image = registry.get(key);
+
+ if (image == null) {
+ ImageDescriptor descriptor = createImageDescriptor(key);
+
+ if (descriptor == null) {
+ return getMissingImage();
+ }
+
+ image = descriptor.createImage();
+ registry.put(key, image);
+ }
+
+ return image;
}
return null;
@@ -153,7 +208,8 @@
}
if (key != null) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID,
((String)object));
+ ImageDescriptor descriptor =
AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ((String)object));
+ return ((descriptor == null) ? ImageDescriptor.getMissingImageDescriptor() :
descriptor);
}
return null;
@@ -207,6 +263,10 @@
*/
@Override
public void stop( BundleContext context ) throws Exception {
+ if (missingImage != null) {
+ missingImage.dispose();
+ }
+
if (this.serverMgr != null) {
Status status = this.serverMgr.saveState();
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-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -38,6 +38,7 @@
public static String CollapseActionToolTip;
+ public static String DeleteServerActionText;
public static String DeleteServerActionToolTip;
public static String DeleteServerDialogErrorsOccurredMsg;
@@ -45,10 +46,16 @@
public static String DeleteServerDialogOneServerMsg;
public static String DeleteServerDialogTitle;
+ public static String EditServerActionText;
public static String EditServerActionToolTip;
public static String ErrorDialogTitle;
+ public static String MissingImage;
+
+ public static String NewServerActionText;
+ public static String NewServerActionToolTip;
+
public static String PublishOperationPublishTaskName;
public static String PublishOperationPublishTitle;
public static String PublishOperationUnpublishTaskName;
@@ -104,8 +111,6 @@
public static String ServerWizardEditServerTitle;
public static String ServerWizardNewServerErrorMsg;
public static String ServerWizardNewServerTitle;
-
- public static String NewServerActionToolTip;
static {
// load message bundle
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/IUiConstants.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/IUiConstants.java 2009-07-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/IUiConstants.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -56,7 +56,7 @@
String VIEW_ICONS_FOLDER = ICON_PATH + "views/"; //$NON-NLS-1$
- String DELETE_SERVER_PATH = VIEW_ICONS_FOLDER + "delete.gif";
//$NON-NLS-1$
+ String COLLAPSE_ALL_IMAGE_PATH = VIEW_ICONS_FOLDER + "collapse_all.gif";
//$NON-NLS-1$
String EDIT_SERVER_IMAGE_PATH = VIEW_ICONS_FOLDER + "edit_server.gif";
//$NON-NLS-1$
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java 2009-07-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -83,10 +83,10 @@
*/
public DeleteServerAction( Shell shell,
ServerManager serverManager ) {
- super(""); //$NON-NLS-1$
+ super(I18n.DeleteServerActionText);
setToolTipText(I18n.DeleteServerActionToolTip);
-
setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ETOOL_DELETE));
-
setDisabledImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ETOOL_DELETE_DISABLED));
+
setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
+
setDisabledImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
setEnabled(false);
this.serversToDelete = new ArrayList<Server>(5);
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java 2009-07-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -76,7 +76,7 @@
*/
public EditServerAction( Shell shell,
ServerManager serverManager ) {
- super(""); //$NON-NLS-1$
+ super(I18n.EditServerActionText);
setToolTipText(I18n.EditServerActionToolTip);
setImageDescriptor(Activator.getDefault().getImageDescriptor(EDIT_SERVER_IMAGE_PATH));
setEnabled(false);
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java 2009-07-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java 2009-07-06
22:25:55 UTC (rev 1073)
@@ -26,7 +26,6 @@
import static org.jboss.dna.publish.ui.swt.IUiConstants.NEW_SERVER_IMAGE_PATH;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.jboss.dna.publish.ServerManager;
import org.jboss.dna.publish.ui.swt.Activator;
@@ -68,11 +67,9 @@
*/
public NewServerAction( Shell shell,
ServerManager serverManager ) {
- super(""); //$NON-NLS-1$
+ super(I18n.NewServerActionText);
setToolTipText(I18n.NewServerActionToolTip);
setImageDescriptor(Activator.getDefault().getImageDescriptor(NEW_SERVER_IMAGE_PATH));
-
setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ELCL_REMOVE));
-//
setDisabledImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ETOOL_DELETE_DISABLED));
this.shell = shell;
this.serverManager = serverManager;
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-05
00:16:52 UTC (rev 1072)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties 2009-07-06
22:25:55 UTC (rev 1073)
@@ -26,19 +26,24 @@
CollapseActionToolTip = Collapse All
-DeleteServerActionToolTip = Delete Server
+DeleteServerActionText = Delete Server
+DeleteServerActionToolTip = Delete server from the server registry
DeleteServerDialogErrorsOccurredMsg = There were errors deleting servers from the server
registry. See log for more details.
DeleteServerDialogMultipleServersMsg = Are you sure you want to delete these {0}
servers?
DeleteServerDialogOneServerMsg = Are you sure you want to delete the "{0}"
server?
DeleteServerDialogTitle = Confirm Delete Server
-EditServerActionToolTip = Edit Server
+EditServerActionText = Edit Server
+EditServerActionToolTip = Edit server properties
ErrorDialogTitle = Error
-NewServerActionToolTip = New Server
+MissingImage = The following image cannot be found "{0}"
+NewServerActionText = New Server
+NewServerActionToolTip = Create and register a new server
+
PublishOperationPublishTaskName = Publishing resources
PublishOperationPublishTitle = Publish
PublishOperationUnpublishTaskName = Unpublishing resources
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-05
00:16:52 UTC (rev 1072)
+++
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)
@@ -23,6 +23,7 @@
*/
package org.jboss.dna.publish.ui.swt.views;
+import static org.jboss.dna.publish.ui.swt.IUiConstants.COLLAPSE_ALL_IMAGE_PATH;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
@@ -35,7 +36,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
import org.eclipse.ui.part.ViewPart;
import org.jboss.dna.publish.IServerRegistryListener;
@@ -117,7 +117,7 @@
};
this.collapseAllAction.setToolTipText(I18n.CollapseActionToolTip);
-
this.collapseAllAction.setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL));
+
this.collapseAllAction.setImageDescriptor(Activator.getDefault().getImageDescriptor(COLLAPSE_ALL_IMAGE_PATH));
// the shell used for dialogs that the actions display
Shell shell = this.getSite().getShell();
@@ -167,7 +167,7 @@
*/
private void constructTreeViewer( Composite parent ) {
this.provider = new ServerContentProvider(getServerManager());
- this.viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ this.viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
this.viewer.setContentProvider(this.provider);
this.viewer.setLabelProvider(this.provider);
this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
@@ -197,6 +197,18 @@
// register to receive changes to the server registry
getServerManager().addRegistryListener(this);
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#dispose()
+ * @since 0.6
+ */
+ @Override
+ public void dispose() {
+ getServerManager().removeRegistryListener(this);
+ super.dispose();
+ }
/**
* @return the server manager being used by this view
@@ -230,7 +242,13 @@
*/
@Override
public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {
- this.viewer.refresh();
+ // 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();
+ }
+
return null;
}
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-05
00:16:52 UTC (rev 1072)
+++
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)
@@ -29,6 +29,8 @@
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -54,6 +56,13 @@
//
===========================================================================================================================
/**
+ * Indicates if the password should be persisted.
+ *
+ * @since 0.6
+ */
+ private boolean savePassword;
+
+ /**
* The user password needed to login to the server.
*
* @since 0.6
@@ -61,6 +70,13 @@
private String password;
/**
+ * The server being editor or <code>null</code> if creating a new
server.
+ *
+ * @since 0.6
+ */
+ private Server server;
+
+ /**
* The current validation status.
*
* @since 0.6
@@ -106,10 +122,11 @@
super(ServerPage.class.getSimpleName());
setTitle(I18n.ServerPageTitle);
+ this.server = server;
this.url = server.getUrl();
this.user = server.getUser();
this.password = server.getPassword();
- setPageComplete(false);
+ this.savePassword = server.isPasswordBeingPersisted();
}
//
===========================================================================================================================
@@ -154,11 +171,12 @@
txtPassword.setToolTipText(I18n.ServerPagePasswordToolTip);
txtPassword.setEchoChar('*');
- // set initial value
+ // set initial value before hooking up listener
if (this.password != null) {
txtPassword.setText(this.password);
}
+ // listener for when value changes
txtPassword.addModifyListener(new ModifyListener() {
@Override
public void modifyText( ModifyEvent e ) {
@@ -167,13 +185,34 @@
});
}
- // FIXME implement save password
{ // save button row
- Button btn = new Button(pnl, SWT.CHECK | SWT.LEFT);
+ final Button btn = new Button(pnl, SWT.CHECK | SWT.LEFT);
btn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
((GridData)btn.getLayoutData()).horizontalSpan = 2;
btn.setText(I18n.ServerPageSavePasswordButton);
btn.setToolTipText(I18n.ServerPageSavePasswordToolTip);
+
+ // set initial value before hooking up listeners
+ if (this.savePassword) {
+ btn.setSelection(true);
+ }
+
+ // listener for when value changes
+ btn.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleSavePasswordChanged(((Button)e.widget).getSelection());
+ }
+ });
+
+ // update page message first time selected to get rid of initial message by
forcing validation
+ btn.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ updateInitialMessage();
+ btn.removeSelectionListener(this);
+ }
+ });
}
{ // save password message row
@@ -243,7 +282,7 @@
*/
public Server getServer() {
if (!this.status.isError()) {
- return new Server(this.url, this.user, this.password);
+ return new Server(this.url, this.user, this.password, this.savePassword);
}
// should never be called if error status
@@ -270,6 +309,14 @@
}
/**
+ * @param savePassword <code>true</code> if the password should be
persisted on the local file system
+ * @since 0.6
+ */
+ void handleSavePasswordChanged( boolean savePassword ) {
+ this.savePassword = savePassword;
+ }
+
+ /**
* Handler for when the URL control value is modified
*
* @param newUrl the new URL value
@@ -292,6 +339,17 @@
}
/**
+ * If the initial message is being displayed do a validation.
+ *
+ * @since 0.6
+ */
+ void updateInitialMessage() {
+ if (I18n.ServerPageOkStatusMsg.equals(getMessage())) {
+ updateState();
+ }
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
@@ -342,7 +400,16 @@
* @since 0.6
*/
private void validate() {
- this.status = ServerValidator.isValid(this.url, this.user, this.password,
getServerManager());
+ if (this.server == null) {
+ this.status = ServerValidator.isValid(this.url, this.user, this.password,
this.savePassword, getServerManager());
+ } else {
+ this.status = ServerValidator.isValid(this.url, this.user, this.password,
this.savePassword);
+
+ 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-05
00:16:52 UTC (rev 1072)
+++
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)
@@ -124,7 +124,7 @@
*/
@Override
public boolean performFinish() {
- Status status = null;
+ Status status = Status.OK_STATUS;
Server server = this.page.getServer();
if (this.existingServer == null) {
@@ -133,7 +133,7 @@
if (status.isError()) {
MessageDialog.openError(getShell(), I18n.ErrorDialogTitle,
I18n.ServerWizardEditServerErrorMsg);
}
- } else {
+ } else if (this.existingServer.different(server)) {
status = this.serverManager.updateServer(this.existingServer, server);
if (status.isError()) {