Author: elvisisking
Date: 2009-06-22 17:28:39 -0400 (Mon, 22 Jun 2009)
New Revision: 1060
Added:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.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/validation/
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/RepositoryValidator.java
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/WorkspaceValidator.java
Removed:
branches/eclipse/org.jboss.dna.publish/icons/
branches/eclipse/org.jboss.dna.publish/plugin.xml
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Activator.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/I18n.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/PublishAction.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/UnpublishAction.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/i18n.properties
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/IUiConstants.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/UiUtil.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/DeleteServerDialog.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/ServerDialog.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryContentProvider.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryView.java
Modified:
branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF
branches/eclipse/org.jboss.dna.publish/build.properties
branches/eclipse/org.jboss.dna.publish/plugin.properties
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.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/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:
Refactored UI code to new project.
Modified: branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF
===================================================================
--- branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF 2009-06-22 16:50:22 UTC
(rev 1059)
+++ branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF 2009-06-22 21:28:39 UTC
(rev 1060)
@@ -3,13 +3,12 @@
Bundle-Name: %bundleName
Bundle-SymbolicName: org.jboss.dna.publish; singleton:=true
Bundle-Version: 1.0.0
-Bundle-Activator: org.jboss.dna.publish.Activator
Bundle-Vendor: %bundleVendor
-Require-Bundle: org.eclipse.ui,
- org.eclipse.core.runtime,
- org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-ClassPath: dnaPublish.jar,
jettison-1.1.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/build.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish/build.properties 2009-06-22 16:50:22 UTC (rev
1059)
+++ branches/eclipse/org.jboss.dna.publish/build.properties 2009-06-22 21:28:39 UTC (rev
1060)
@@ -1,8 +1,6 @@
-bin.includes = plugin.xml,\
- META-INF/,\
+bin.includes = META-INF/,\
plugin.properties,\
jettison-1.1.jar,\
- icons/,\
dnaPublish.jar
jars.compile.order = dnaPublish.jar
src.includes = src/
Modified: branches/eclipse/org.jboss.dna.publish/plugin.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish/plugin.properties 2009-06-22 16:50:22 UTC (rev
1059)
+++ branches/eclipse/org.jboss.dna.publish/plugin.properties 2009-06-22 21:28:39 UTC (rev
1060)
@@ -23,8 +23,3 @@
#
bundleName = DNA Eclipse Publishing Plug-in
bundleVendor = Red Hat, Inc.
-contextMenu.label = DNA
-dnaCategory = DNA
-publishAction.label = Publish
-repositoryView = DNA Repositories
-unpublishAction.label = Unpublish
\ No newline at end of file
Deleted: branches/eclipse/org.jboss.dna.publish/plugin.xml
===================================================================
--- branches/eclipse/org.jboss.dna.publish/plugin.xml 2009-06-22 16:50:22 UTC (rev 1059)
+++ branches/eclipse/org.jboss.dna.publish/plugin.xml 2009-06-22 21:28:39 UTC (rev 1060)
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
-
-<!-- Define the IResource object contribution actions to all popup menus -->
- <extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- id="org.jboss.dna.publish.iresourcepopupmenucontribution"
- objectClass="org.eclipse.core.resources.IResource">
- <menu
- id="org.jboss.dna.publish.contextMenu"
- label="%contextMenu.label"
- path="additions">
- <separator
- name="group1">
- </separator>
- </menu>
-
- <!-- Unpublish action -->
- <action
- id="org.jboss.dna.publish.unpublishAction"
- label="%unpublishAction.label"
- class="org.jboss.dna.publish.actions.UnpublishAction"
- menubarPath="org.jboss.dna.publish.contextMenu/group1"
- enablesFor="*">
- </action>
-
- <!-- Publish action -->
- <action
- id="org.jboss.dna.publish.publishAction"
- label="%publishAction.label"
- class="org.jboss.dna.publish.actions.PublishAction"
- menubarPath="org.jboss.dna.publish.contextMenu/group1"
- enablesFor="*">
- </action>
- </objectContribution>
- </extension>
-
-<!-- View extensions -->
- <extension
- point="org.eclipse.ui.views">
- <category
- id="org.jboss.dna"
- name="%dnaCategory">
- </category>
-
- <!-- Repository view -->
- <view
- id="respositoryView"
- name="%repositoryView"
- category="org.jboss.dna"
- class="org.jboss.dna.publish.ui.views.RepositoryView"
- fastViewWidthRatio="0.25"
- icon="icons/full/cview16/repository.gif">
- </view>
- </extension>
-
-</plugin>
Deleted: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Activator.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Activator.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Activator.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,216 +0,0 @@
-/*
- * 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;
-
-import static org.jboss.dna.publish.IConstants.PLUGIN_ID;
-import java.net.MalformedURLException;
-import java.net.URL;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class Activator extends AbstractUIPlugin {
-
- //
===========================================================================================================================
- // Class Fields
- //
===========================================================================================================================
-
- /**
- * The shared plugin instance.
- *
- * @since 0.6
- */
- private static Activator plugin;
-
- //
===========================================================================================================================
- // Class Methods
- //
===========================================================================================================================
-
- /**
- * @param key the relative path to the image file
- * @return the image descriptor or <code>null</code>
- * @since 0.6
- */
- private ImageDescriptor createImageDescriptor( String key ) {
- try {
- URL url = new URL(getBundle().getEntry("/").toString() + key);
//$NON-NLS-1$
- ImageDescriptor descriptor = ImageDescriptor.createFromURL(url);
- ImageRegistry registry = getImageRegistry();
- registry.put(key, descriptor);
- return descriptor;
- } catch (final MalformedURLException e) {
- // TODO log this or return missing image
- return null;
- }
- }
-
- /**
- * @return the shared instance or <code>null</code> if bundle is not
started
- * @since 0.6
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- * @param path the path
- * @return the image descriptor for the image file at the given plug-in relative
path
- * @since 0.6
- */
- public static ImageDescriptor getImageDescriptor( String path ) {
- return imageDescriptorFromPlugin(PLUGIN_ID, path);
- }
-
- /**
- * Retrieves the image associated with the specified key from the {@link
org.eclipse.jface.resource.ImageRegistry image
- * registry}, creating the image and registering it if it doesn't already exist.
A <code>null</code> key will cause the
- * missing image descriptor to be returned.
- *
- * @param relativePathToImage the relative path to the image to retrieve. This must
be in the form of the path to the image
- * file relative to this plug-in's folder (can be
<code>null</code>).
- * @return the image associated with the specified path or the default missing image
- * @since 0.6
- */
- public final Image getImage( String relativePathToImage ) {
- final ImageRegistry registry = getImageRegistry();
- Image img = registry.get(relativePathToImage);
-
- if (img != null) {
- return img;
- }
-
- // image has never been cached
- try {
- createImageDescriptor(relativePathToImage);
- img = registry.get(relativePathToImage);
- return (img != null ? img :
ImageDescriptor.getMissingImageDescriptor().createImage());
- } catch (SWTException e) {
- // TODO log this or return missing image
- return null;
- }
- }
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * The server manager of this plugin.
- *
- * @since 0.6
- */
- private ServerManager serverMgr;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * Constructs the plugin activator.
- * <p>
- * Note: If this is called outside the OSGi framework you
<strong>MUST</strong> also call {@link #initialize(String)}.
- *
- * @since 0.6
- * @see #initialize(String)
- */
- public Activator() {
- // nothing to do but wanted javadocs for the default constructor
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * @return the {@link ServerManager Server Manager} or <code>null</code>
if not plugin is not initialized
- * @see #initialize(String)
- * @since 0.6
- */
- public ServerManager getServerManager() {
- return this.serverMgr;
- }
-
- /**
- * Performs plugin initialization. One thing it does is initialize the {@link
ServerManager}.
- * <p>
- * Note: This should <strong>ONLY</strong> be called when the OSGi
framework is not running (i.e., {@link BundleContext bundle
- * context} is <code>null</code>).
- *
- * @since 0.6
- */
- public void initialize( String stateLocationPath ) {
- plugin = this;
- serverMgr = new ServerManager(stateLocationPath);
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * When the OSGi framework is not running (i.e., <code>context</code> is
<code>null</code>) you <strong>MUST</strong> also
- * call {@link #initialize(String)}.
- *
- * @see
org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- * @since 0.6
- * @see #initialize(String)
- */
- @Override
- public void start( BundleContext context ) throws Exception {
- if (context != null) {
- super.start(context);
- initialize(plugin.getStateLocation().toFile().getAbsolutePath());
- }
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * Also informs the {@link ServerManager} to shutdown.
- * <p>
- * Note: This can safely be called when the OSGi framework is not running (i.e.,
<code>context</code> is <code>null</code>).
- *
- * @see
org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- * @since 0.6
- */
- @Override
- public void stop( BundleContext context ) throws Exception {
- serverMgr.saveState();
-
- if (context != null) {
- super.stop(context);
- }
-
- plugin = null;
- serverMgr = null;
- }
-
-}
Deleted: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/I18n.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/I18n.java 2009-06-22
16:50:22 UTC (rev 1059)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/I18n.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,76 +0,0 @@
-/*
- * 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;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * The I18n class handles localization messages.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class I18n extends NLS {
-
- public static String CollapseActionToolTip;
-
- public static String DeleteServerActionText;
- public static String DeleteServerActionToolTip;
-
- public static String DeleteServerDialogTitle;
- public static String DeleteServerDialogOneServerMessage;
- public static String DeleteServerDialogMultipleServersMessage;
-
- public static String EditServerActionText;
- public static String EditServerActionToolTip;
-
- public static String ServerDialogEditTitle;
- public static String ServerDialogNewTitle;
- public static String ServerDialogPasswordLabel;
- public static String ServerDialogSavePasswordButton;
- public static String ServerDialogSavePasswordLabel;
- public static String ServerDialogUserLabel;
- public static String ServerDialogUrlLabel;
-
- public static String NewServerActionText;
- public static String NewServerActionToolTip;
-
- public static String RepositoryInvalidNameMsg;
- public static String RepositoryInvalidServerMsg;
- public static String RepositoryShortDescription;
-
- public static String ServerShortDescription;
- public static String ServerInvalidPasswordMsg;
- public static String ServerInvalidUrlMsg;
- public static String ServerInvalidUserMsg;
-
- public static String WorkspaceInvalidNameMsg;
- public static String WorkspaceInvalidRepositoryMsg;
- public static String WorkspaceShortDescription;
-
- static {
- // load message bundle
- NLS.initializeMessages(I18n.class.getPackage() + "i18n", I18n.class);
//$NON-NLS-1$
- }
-}
Modified:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,12 +1,60 @@
+/*
+ * 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;
+import java.util.ResourceBundle;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
public interface IConstants {
+
+ ResourceBundle MESSAGES =
ResourceBundle.getBundle(IConstants.class.getPackage().getName() + ".Messages");
//$NON-NLS-1$
+
+ String RemovingServerProblemMsg = "RemovingServerProblemMsg";
//$NON-NLS-1$
+
+ String RepositoryEmptyNameMsg = "RepositoryEmptyNameMsg"; //$NON-NLS-1$
+
+ String RepositoryNullServerMsg = "RepositoryNullServerMsg"; //$NON-NLS-1$
+
+ String RepositoryShortDescription = "RepositoryShortDescription";
//$NON-NLS-1$
+
+ String ServerEmptyUrlMsg = "ServerEmptyUrlMsg"; //$NON-NLS-1$
+
+ String ServerInvalidUrlMsg = "ServerInvalidUrlMsg"; //$NON-NLS-1$
+
+ String ServerEmptyUserMsg = "ServerEmptyUserMsg"; //$NON-NLS-1$
+
+ String ServerExistsMsg = "ServerExistsMsg"; //$NON-NLS-1$
+
+ String ServerShortDescription = "ServerShortDescription"; //$NON-NLS-1$
+
+ String WorkspaceEmptyNameMsg = "WorkspaceEmptyNameMsg"; //$NON-NLS-1$
+
+ String WorkspaceNullRepositoryMsg = "WorkspaceNullRepositoryMsg";
//$NON-NLS-1$
+
+ String WorkspaceShortDescription = "WorkspaceShortDescription";
//$NON-NLS-1$
- /**
- * The Plug-in's identifier.
- *
- * @since 0.6
- */
- public static final String PLUGIN_ID = "org.jboss.dna.publish";
//$NON-NLS-1$
-
}
Added:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties 2009-06-22
21:28:39 UTC (rev 1060)
@@ -0,0 +1,15 @@
+RemovingServerProblemMsg = {0} cannot be removed as it has not been registered
+
+RepositoryEmptyNameMsg = A repository name cannot be empty
+RepositoryNullServerMsg = A repository server cannot be null
+RepositoryShortDescription = DNA Repository: Name: {0}, {1}
+
+ServerEmptyUserMsg = The user cannot be empty
+ServerEmptyUrlMsg = A server URL cannot be empty
+ServerExistsMsg = {0} already exists so it cannot be added
+ServerInvalidUrlMsg = The value "{0}" is not a valid server URL
+ServerShortDescription = DNA Server: URL={0} User={1}
+
+WorkspaceEmptyNameMsg = A workspace name cannot be empty
+WorkspaceNullRepositoryMsg = A workspace repository cannot be null
+WorkspaceShortDescription = DNA Repository Workspace: Name: {0}, {1}
Property changes on:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.util.Collection;
+import org.jboss.dna.publish.domain.Server;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public class Publisher {
+
+ public Status publish( Server server,
+ Collection<File> files ) {
+ // TODO implement
+ return null;
+ }
+
+ public Status unpublish( Server server,
+ Collection<File> files ) {
+ // TODO implement
+ return null;
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -23,13 +23,27 @@
*/
package org.jboss.dna.publish;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import org.jboss.dna.publish.Status.Severity;
import org.jboss.dna.publish.domain.Server;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* The Server Manager class managers the creation, deletion, and editing of servers.
@@ -37,9 +51,55 @@
* @author Dan Florian
* @since 0.6
*/
-public final class ServerManager {
+public final class ServerManager implements IConstants {
//
===========================================================================================================================
+ // Constants
+ //
===========================================================================================================================
+
+ /**
+ * The tag used to persist a server's login password.
+ *
+ * @since 0.6
+ */
+ private static final String PASSWORD_TAG = "password"; //$NON-NLS-1$
+
+ /**
+ * The file name used when persisting the server registry.
+ *
+ * @since 0.6
+ */
+ private static final String REGISTRY_FILE = "serverRegistry.xml";
//$NON-NLS-1$
+
+ /**
+ * The tag used when persisting a server.
+ *
+ * @since 0.6
+ */
+ private static final String SERVER_TAG = "server"; //$NON-NLS-1$
+
+ /**
+ * The server collection tag used when persisting the server registry.
+ *
+ * @since 0.6
+ */
+ private static final String SERVERS_TAG = "servers"; //$NON-NLS-1$
+
+ /**
+ * The tag used to persist a server's URL.
+ *
+ * @since 0.6
+ */
+ private static final String URL_TAG = "url"; //$NON-NLS-1$
+
+ /**
+ * The tag used to persist a server's login user.
+ *
+ * @since 0.6
+ */
+ private static final String USER_TAG = "user"; //$NON-NLS-1$
+
+ //
===========================================================================================================================
// Fields
//
===========================================================================================================================
@@ -62,9 +122,9 @@
* persistence is not desired)
* @since 0.6
*/
- public ServerManager( String path ) {
+ public ServerManager( String stateLocationPath ) {
this.servers = Collections.synchronizedList(new ArrayList<Server>());
- this.stateLocationPath = path;
+ this.stateLocationPath = stateLocationPath;
restoreState();
}
@@ -79,14 +139,17 @@
* @return a status indicating if the server was added to the registry
* @since 0.6
*/
- public IStatus addServer( Server server ) {
+ public Status addServer( Server server ) {
if (!this.servers.contains(server)) {
this.servers.add(server);
return Status.OK_STATUS;
}
- // TODO implement error status
- return null;
+ // server already exists
+ String pattern = MESSAGES.getString(ServerExistsMsg);
+ String msg = MessageFormat.format(pattern, server.getShortDescription());
+ Status status = new Status(Severity.ERROR, msg, null);
+ return status;
}
/**
@@ -96,27 +159,75 @@
public Collection<Server> getServers() {
return Collections.unmodifiableCollection(this.servers);
}
+
+ /**
+ * @return the name of the state file that the server registry is persisted to
+ * @since 0.6
+ */
+ private String getStateFileName() {
+ return this.stateLocationPath + File.separatorChar + REGISTRY_FILE;
+ }
/**
+ * @param server the server being tested
+ * @return <code>true</code> if the server has been registered
+ * @since 0.6
+ */
+ public boolean isRegistered( Server server ) {
+ return this.servers.contains(server);
+ }
+
+ /**
* @param server the server being removed
* @return a status indicating if the specified server was removed from the registry
* @since 0.6
*/
- public IStatus removeServer( Server server ) {
+ public Status removeServer( Server server ) {
if (this.servers.remove(server)) {
return Status.OK_STATUS;
}
- // TODO implement error status
- return null;
+ // server could not be removed
+ String pattern = MESSAGES.getString(RemovingServerProblemMsg);
+ String msg = MessageFormat.format(pattern, server.getShortDescription());
+ Status status = new Status(Severity.ERROR, msg, null);
+ return status;
}
/**
+ * @return a status indicating if the previous session state was restored
* @since 0.6
*/
- private IStatus restoreState() {
+ private Status restoreState() {
if (this.stateLocationPath != null) {
- // TODO implement
+ if (stateFileExists()) {
+ try {
+ DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.parse(new File(getStateFileName()));
+ Node root = doc.getDocumentElement();
+ NodeList servers = root.getChildNodes();
+
+ for (int size = servers.getLength(), i = 0; i < size; ++i) {
+ Node server = servers.item(i);
+
+ if (server.getNodeType() != Node.TEXT_NODE) {
+ NamedNodeMap attributeMap = server.getAttributes();
+
+ 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()));
+ }
+ }
+ }
+ } catch (Exception e) {
+ // TODO log
+ }
+ }
}
// do nothing of there is no save location
@@ -129,13 +240,67 @@
* @return a status indicating if the registry was successfully saved
* @since 0.6
*/
- public IStatus saveState() {
- if (this.stateLocationPath != null) {
- // TODO implement
+ public Status saveState() {
+ try {
+ if ((this.stateLocationPath != null) && !getServers().isEmpty()) {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+
+ // create root element
+ Element root = doc.createElement(SERVERS_TAG);
+ doc.appendChild(root);
+
+ for (Server server : getServers()) {
+ Element serverElement = doc.createElement(SERVER_TAG);
+ root.appendChild(serverElement);
+
+ serverElement.setAttribute(URL_TAG, server.getUrl());
+ serverElement.setAttribute(USER_TAG, server.getUser());
+ serverElement.setAttribute(PASSWORD_TAG, server.getPassword());
+ }
+
+ DOMSource source = new DOMSource(doc);
+ StreamResult resultXML = new StreamResult(new
FileOutputStream(getStateFileName()));
+ TransformerFactory transFactory = TransformerFactory.newInstance();
+ Transformer transformer = transFactory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
//$NON-NLS-1$
+
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-am...;,
"2"); //$NON-NLS-1$ //$NON-NLS-2$
+ transformer.transform(source, resultXML);
+ } else if ((this.stateLocationPath != null) && stateFileExists()) {
+ // delete current registry file is all servers have been deleted
+ new File(getStateFileName()).delete();
+ }
+ } catch (Exception e) {
+ // TODO log
}
- // do nothing of there is no save location
return Status.OK_STATUS;
}
+ /**
+ * @return <code>true</code> if the state file already exists
+ * @since 0.6
+ */
+ private boolean stateFileExists() {
+ return new File(getStateFileName()).exists();
+ }
+
+ //
===========================================================================================================================
+ // 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();
+ }
+
}
Added: 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
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Status.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -0,0 +1,198 @@
+/*
+ * 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 class Status {
+
+ //
===========================================================================================================================
+ // Constants
+ //
===========================================================================================================================
+
+ /**
+ * The status severity levels.
+ *
+ * @since 0.6
+ */
+ public enum Severity {
+ /**
+ * Indicates an error status.
+ *
+ * @since 0.6
+ */
+ ERROR,
+
+ /**
+ * Indicates an informational status.
+ *
+ * @since 0.6
+ */
+ INFO,
+
+ /**
+ * Indicates an OK status.
+ *
+ * @since 0.6
+ */
+ OK,
+
+ /**
+ * Indicates an unknown status. This is automatically assigned if status is
constructed with a <code>null</code> severity.
+ *
+ * @since 0.6
+ */
+ UNKNOWN,
+
+ /**
+ * Indicates a warning status.
+ *
+ * @since 0.6
+ */
+ WARNING
+ }
+
+ /**
+ * A status with an OK severity and no message and no exception.
+ *
+ * @see Severity#OK
+ * @since 0.6
+ */
+ public static final Status OK_STATUS = new Status(Severity.OK, null, null);
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The exception of this status or <code>null</code>.
+ *
+ * @since 0.6
+ */
+ private final Throwable exception;
+
+ /**
+ * The localized message of this status (never <code>null</code>).
+ *
+ * @since 0.6
+ */
+ private final String message;
+
+ /**
+ * The severity level of this status.
+ *
+ * @since 0.6
+ */
+ private final Severity severity;
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * @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 exception the status exception or <code>null</code>
+ * @since 0.6
+ */
+ public Status( Severity severity,
+ String message,
+ Throwable exception ) {
+ this.severity = ((severity == null) ? Severity.UNKNOWN : severity);
+ this.message = message;
+ this.exception = exception;
+ }
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * @return the status exception (may be <code>null</code>)
+ * @since 0.6
+ */
+ public Throwable getException() {
+ return this.exception;
+ }
+
+ /**
+ * @return the status message (never <code>null</code> but can be empty)
+ * @since 0.6
+ */
+ public String getMessage() {
+ return ((this.message == null) ? "" : this.message); //$NON-NLS-1$
+ }
+
+ /**
+ * @return <code>true</code> if the status is an error
+ * @see Severity#ERROR
+ * @since 0.6
+ */
+ public boolean isError() {
+ return (this.severity == Severity.ERROR);
+ }
+
+ /**
+ * @return <code>true</code> if the status is an info
+ * @see Severity#INFO
+ * @since 0.6
+ */
+ public boolean isInfo() {
+ return (this.severity == Severity.INFO);
+ }
+
+ /**
+ * @return <code>true</code> if the status is OK
+ * @see Severity#OK
+ * @since 0.6
+ */
+ public boolean isOk() {
+ return (this.severity == Severity.OK);
+ }
+
+ /**
+ * @return <code>true</code> if the status is a warning
+ * @see Severity#WARNING
+ * @since 0.6
+ */
+ public boolean isWarning() {
+ return (this.severity == Severity.WARNING);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ * @since 0.6
+ */
+ @Override
+ public String toString() {
+ StringBuilder txt = new StringBuilder("Status "); //$NON-NLS-1$
+ txt.append(this.severity.toString()).append(":
").append(getMessage()).append(": ").append(getException()); //$NON-NLS-1$
//$NON-NLS-2$
+ return txt.toString();
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Status.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/PublishAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/PublishAction.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/PublishAction.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,78 +0,0 @@
-/*
- * 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.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * The PublishAction controls the publishing of one or more {@link
org.eclipse.core.resources.IResource}s to a DNA repository.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class PublishAction implements IObjectActionDelegate {
-
- /**
- * The active part's Shell.
- *
- * @since 0.6
- */
-// private Shell shell;
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- * @since 0.6
- */
- public void run( IAction action ) {
- // TODO implement
- }
-
- /**
- * {@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();
- }
-
-}
Deleted:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/UnpublishAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/UnpublishAction.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/actions/UnpublishAction.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,79 +0,0 @@
-/*
- * 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.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * The UnpublishAction controls the unpublishing of on or more {@link
org.eclipse.core.resources.IResource}s from a DNA
- * repository.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class UnpublishAction implements IObjectActionDelegate {
-
- /**
- * The active part's Shell.
- *
- * @since 0.6
- */
-// private Shell shell;
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- * @since 0.6
- */
- public void run( IAction action ) {
- // TODO implement
- }
-
- /**
- * {@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/src/org/jboss/dna/publish/domain/Repository.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -23,12 +23,14 @@
*/
package org.jboss.dna.publish.domain;
+import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.eclipse.osgi.util.NLS;
-import org.jboss.dna.publish.I18n;
+import org.jboss.dna.publish.IConstants;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.domain.validation.RepositoryValidator;
/**
* The Repository class is the business object for a DNA repository.
@@ -36,34 +38,9 @@
* @author Dan Florian
* @since 0.6
*/
-public final class Repository implements IDnaObject {
+public final class Repository implements IConstants, IDnaObject {
//
===========================================================================================================================
- // Class Methods
- //
===========================================================================================================================
-
- /**
- * This method validates a proposed name and should be called before constructing a
{@link Repository}.
- *
- * @param proposedName the name being validated
- * @return <code>true</code> if the name is valid
- * @since 0.6
- */
- public static boolean validateName( String proposedName ) {
- return ((proposedName != null) && (proposedName.length() != 0));
- }
-
- /**
- * This method validates a proposed {@link Server server} and should be called before
constructing a {@link Repository}.
- *
- * @param proposedServer the server being tested
- * @return <code>true</code> if the server is valid
- */
- public static boolean validateServer( Server proposedServer ) {
- return (proposedServer != null);
- }
-
- //
===========================================================================================================================
// Fields
//
===========================================================================================================================
@@ -92,23 +69,20 @@
*
* @param name the repository name
* @param server the server where this repository resides
- * @see #validateName(String)
- * @see #validateServer(Server)
+ * @see RepositoryValidator
* @throws RuntimeException if any of the input parameters are invalid
* @since 0.6
*/
public Repository( String name,
Server server ) {
- // validate inputs first
- if (!validateName(name)) {
- throw new RuntimeException(NLS.bind(I18n.RepositoryInvalidNameMsg, name));
+ // validate inputs
+ Status status = RepositoryValidator.isValid(name, server);
+
+ if (status.isError()) {
+ throw new RuntimeException(status.getMessage(), status.getException());
}
- if (!validateServer(server)) {
- throw new RuntimeException(I18n.RepositoryInvalidServerMsg);
- }
-
- // OK to construct
+ // valid so construct
this.name = name;
this.server = server;
}
@@ -185,7 +159,8 @@
*/
@Override
public String getShortDescription() {
- return NLS.bind(I18n.RepositoryShortDescription, this.name,
this.server.getShortDescription());
+ String pattern = MESSAGES.getString(RepositoryShortDescription);
+ return MessageFormat.format(pattern, this.name,
this.server.getShortDescription());
}
/**
@@ -193,7 +168,7 @@
* @since 0.6
*/
public Collection<Workspace> getWorkspaces() {
- // TODO implement
+ // TODO implement getWorkspaces()
return Collections.emptyList();
}
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-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -23,12 +23,16 @@
*/
package org.jboss.dna.publish.domain;
+import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.eclipse.osgi.util.NLS;
-import org.jboss.dna.publish.I18n;
+import org.jboss.dna.publish.IConstants;
+import org.jboss.dna.publish.ServerManager;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.domain.validation.RepositoryValidator;
+import org.jboss.dna.publish.domain.validation.ServerValidator;
/**
* The Server class is the business object for a server that is hosting one or more DNA
repositories.
@@ -36,50 +40,27 @@
* @author Dan Florian
* @since 0.6
*/
-public final class Server implements IDnaObject {
+public final class Server implements IConstants, IDnaObject {
//
===========================================================================================================================
- // Class Methods
+ // Fields
//
===========================================================================================================================
/**
- * This method validates a proposed server URL and should be called before
constructing a {@link Server}.
+ * The password to use when logging on to the server.
*
- * @param proposedUrl the URL being validated
- * @return <code>true</code> if the URL is valid
* @since 0.6
*/
- public static boolean validateUrl( String proposedUrl ) {
- return ((proposedUrl != null) && (proposedUrl.length() != 0));
- }
-
+ private final String password;
+
/**
- * This method validates a proposed server authentication user and should be called
before constructing a {@link Server}.
+ * The server manager that manages the server registry.
*
- * @param proposedUser the user being validated
- * @return <code>true</code> if the user is valid
* @since 0.6
*/
- public static boolean validateUser( String proposedUser ) {
- return ((proposedUser != null) && (proposedUser.length() != 0));
- }
+ private ServerManager serverManager;
/**
- * This method validates a proposed server authentication password and should be
called before constructing a {@link Server}.
- *
- * @param proposedPassword the password being validated
- * @return <code>true</code> if the password is valid
- * @since 0.6
- */
- public static boolean validatePassword( String proposedPassword ) {
- return ((proposedPassword != null) && (proposedPassword.length() != 0));
- }
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
* The server URL.
*
* @since 0.6
@@ -93,13 +74,6 @@
*/
private final String user;
- /**
- * The password to use when logging on to the server.
- *
- * @since 0.6
- */
- private final String pswd;
-
//
===========================================================================================================================
// Constructors
//
===========================================================================================================================
@@ -108,34 +82,26 @@
* Constructs on new <code>Server</code>.
*
* @param url the server URL
- * @param user the server authentication user
- * @param pswd the server authentication password
- * @see #validateUrl(String)
- * @see #validateUser(String)
- * @see #validatePassword(String)
+ * @param user the server user
+ * @param password the server password
+ * @see RepositoryValidator
* @throws RuntimeException if any of the input parameters are invalid
* @since 0.6
*/
public Server( String url,
String user,
- String pswd ) {
- // valid inputs first
- if (!validateUrl(url)) {
- throw new RuntimeException(NLS.bind(I18n.ServerInvalidUrlMsg, url));
- }
+ String password ) {
+ // valid inputs
+ Status status = ServerValidator.isValid(url, user, password);
- if (!validateUrl(user)) {
- throw new RuntimeException(NLS.bind(I18n.ServerInvalidUserMsg, user));
+ if (status.isError()) {
+ throw new RuntimeException(status.getMessage(), status.getException());
}
- if (!validateUrl(pswd)) {
- throw new RuntimeException(NLS.bind(I18n.ServerInvalidPasswordMsg, pswd));
- }
-
- // OK to construct
+ // valid so construct
this.url = url;
this.user = user;
- this.pswd = pswd;
+ this.password = password;
}
//
===========================================================================================================================
@@ -200,7 +166,7 @@
* @since 0.6
*/
public String getPassword() {
- return this.pswd;
+ return this.password;
}
/**
@@ -208,7 +174,10 @@
* @since 0.6
*/
public Collection<Repository> getRepositories() {
- // TODO implement
+ if (this.serverManager != null) {
+ // TODO implement getRepositories()
+ }
+
return Collections.emptyList();
}
@@ -220,7 +189,8 @@
*/
@Override
public String getShortDescription() {
- return NLS.bind(I18n.ServerShortDescription, this.url, this.user);
+ String pattern = MESSAGES.getString(ServerShortDescription);
+ return MessageFormat.format(pattern, this.url, this.user);
}
/**
@@ -253,4 +223,12 @@
return hash;
}
+ /**
+ * @param serverManager the server manager (may be <code>null</code>)
+ * @since 0.6
+ */
+ public void setServerManager( ServerManager serverManager ) {
+ this.serverManager = serverManager;
+ }
+
}
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-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -23,10 +23,12 @@
*/
package org.jboss.dna.publish.domain;
+import java.text.MessageFormat;
import java.util.Collections;
import java.util.List;
-import org.eclipse.osgi.util.NLS;
-import org.jboss.dna.publish.I18n;
+import org.jboss.dna.publish.IConstants;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.domain.validation.WorkspaceValidator;
/**
* The Workspace class is the business object for a DNA repository workspace.
@@ -34,35 +36,9 @@
* @author Dan Florian
* @since 0.6
*/
-public class Workspace implements IDnaObject {
+public final class Workspace implements IConstants, IDnaObject {
//
===========================================================================================================================
- // Class Methods
- //
===========================================================================================================================
-
- /**
- * This method validates a proposed name and should be called before constructing a
{@link Workspace}.
- *
- * @param proposedName the name being validated
- * @return <code>true</code> if the name is valid
- * @since 0.6
- */
- public static boolean validateName( String proposedName ) {
- return ((proposedName != null) && (proposedName.length() != 0));
- }
-
- /**
- * This method validates a proposed {@link Repository repository} and should be
called before constructing a {@link Workspace}
- * .
- *
- * @param proposedRepository the repository being tested
- * @return <code>true</code> if the repository is valid
- */
- public static boolean validateRepository( Repository proposedRepository ) {
- return (proposedRepository != null);
- }
-
- //
===========================================================================================================================
// Fields
//
===========================================================================================================================
@@ -88,24 +64,21 @@
* Constructs a new <code>Workspace</code>.
*
* @param name the workspace name
- * @param server the repository where this workspace resides
- * @see #validateName(String)
- * @see #validateRepository(Server)
+ * @param repository the repository where this workspace resides
+ * @see WorkspaceValidator
* @throws RuntimeException if any of the input parameters are invalid
* @since 0.6
*/
public Workspace( String name,
Repository repository ) {
- // validate inputs first
- if (!validateName(name)) {
- throw new RuntimeException(NLS.bind(I18n.WorkspaceInvalidNameMsg, name));
+ // validate inputs
+ Status status = WorkspaceValidator.isValid(name, repository);
+
+ if (status.isError()) {
+ throw new RuntimeException(status.getMessage(), status.getException());
}
- if (!validateRepository(repository)) {
- throw new RuntimeException(I18n.WorkspaceInvalidRepositoryMsg);
- }
-
- // OK to construct
+ // valid so construct
this.name = name;
this.repository = repository;
}
@@ -173,7 +146,22 @@
*/
@Override
public String getShortDescription() {
- return NLS.bind(I18n.WorkspaceShortDescription, this.name,
this.repository.getShortDescription());
+ String pattern = MESSAGES.getString(WorkspaceShortDescription);
+ return MessageFormat.format(pattern, this.name,
this.repository.getShortDescription());
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#hashCode()
+ * @since 0.6
+ */
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 31 * hash + this.name.hashCode();
+ hash = 31 * hash + this.repository.hashCode();
+ return hash;
+ }
}
Added:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/RepositoryValidator.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/RepositoryValidator.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/RepositoryValidator.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -0,0 +1,97 @@
+/*
+ * 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.domain.validation;
+
+import org.jboss.dna.publish.IConstants;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.Status.Severity;
+import org.jboss.dna.publish.domain.Server;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class RepositoryValidator implements IConstants {
+
+ //
===========================================================================================================================
+ // Class Methods
+ //
===========================================================================================================================
+
+ /**
+ * @param name the name being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isNameValid( String name ) {
+ if ((name == null) || (name.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(RepositoryEmptyNameMsg),
null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param server the server being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isServerValid( Server server ) {
+ if (server == null) {
+ return new Status(Severity.ERROR,
MESSAGES.getString(RepositoryNullServerMsg), null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param name the name being validated
+ * @param server the server being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isValid( String name,
+ Server server ) {
+ Status status = isNameValid(name);
+
+ if (!status.isError()) {
+ status = isServerValid(server);
+ }
+
+ return status;
+ }
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * Disallow construction.
+ *
+ * @since 0.6
+ */
+ private RepositoryValidator() {
+ // nothing to do
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/RepositoryValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/ServerValidator.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -0,0 +1,152 @@
+/*
+ * 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.domain.validation;
+
+import java.net.URL;
+import java.text.MessageFormat;
+import org.jboss.dna.publish.IConstants;
+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.Server;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class ServerValidator implements IConstants {
+
+ //
===========================================================================================================================
+ // Class Methods
+ //
===========================================================================================================================
+
+ /**
+ * @param password the password being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isPasswordValid( String password ) {
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param url the URL being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isUrlValid( String url ) {
+ if ((url == null) || (url.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(ServerEmptyUrlMsg),
null);
+ }
+
+ try {
+ new URL(url);
+ } catch (Exception e) {
+ String pattern = MESSAGES.getString(ServerInvalidUrlMsg);
+ String msg = MessageFormat.format(pattern, url);
+ return new Status(Severity.ERROR, msg, null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param user the user being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isUserValid( String user ) {
+ if ((user == null) || (user.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(ServerEmptyUserMsg),
null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param url the URL being validated
+ * @param user the user being validated
+ * @param password the password being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isValid( String url,
+ String user,
+ String password ) {
+ Status status = isUrlValid(url);
+
+ if (!status.isError()) {
+ status = isUserValid(user);
+
+ if (!status.isError()) {
+ status = isPasswordValid(password);
+ }
+ }
+
+ return status;
+ }
+
+ /**
+ * @param url the URL being validated
+ * @param user the user being validated
+ * @param password the password being validated
+ * @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)
+ * @since 0.6
+ */
+ public static Status isValid( String url,
+ String user,
+ String password,
+ ServerManager serverManager ) {
+ Status status = isValid(url, user, password);
+
+ // make sure a server with the same properties does not exist
+ if (!status.isError()) {
+ Server newServer = new Server(url, user, password);
+
+ if (serverManager.isRegistered(newServer)) {
+ String pattern = MESSAGES.getString(ServerExistsMsg);
+ String msg = MessageFormat.format(pattern,
newServer.getShortDescription());
+ status = new Status(Severity.ERROR, msg, null);
+ }
+ }
+
+ return status;
+ }
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * Disallow construction.
+ *
+ * @since 0.6
+ */
+ private ServerValidator() {
+ // nothing to do
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/ServerValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/WorkspaceValidator.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/WorkspaceValidator.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/WorkspaceValidator.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -0,0 +1,97 @@
+/*
+ * 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.domain.validation;
+
+import org.jboss.dna.publish.IConstants;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.Status.Severity;
+import org.jboss.dna.publish.domain.Repository;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class WorkspaceValidator implements IConstants {
+
+ //
===========================================================================================================================
+ // Class Methods
+ //
===========================================================================================================================
+
+ /**
+ * @param name the name being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isNameValid( String name ) {
+ if ((name == null) || (name.length() == 0)) {
+ return new Status(Severity.ERROR, MESSAGES.getString(WorkspaceEmptyNameMsg),
null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param repository the repository being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isRepositoryValid( Repository repository ) {
+ if (repository == null) {
+ return new Status(Severity.ERROR,
MESSAGES.getString(WorkspaceNullRepositoryMsg), null);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ /**
+ * @param name the name being validated
+ * @param repository the repository being validated
+ * @return a validation status (never <code>null</code>)
+ * @since 0.6
+ */
+ public static Status isValid( String name,
+ Repository repository ) {
+ Status status = isNameValid(name);
+
+ if (!status.isError()) {
+ status = isRepositoryValid(repository);
+ }
+
+ return status;
+ }
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * Disallow construction.
+ *
+ * @since 0.6
+ */
+ private WorkspaceValidator() {
+ // nothing to do
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/validation/WorkspaceValidator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/i18n.properties
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/i18n.properties 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/i18n.properties 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,35 +0,0 @@
-CollapseActionToolTip = Collapse All
-
-DeleteServerActionText = Delete Server
-DeleteServerActionToolTip = Delete Server
-
-DeleteServerDialogTitle = Confirm Delete Server
-DeleteServerDialogOneServerMessage = Are you sure you want to delete the "{0}"
server?
-DeleteServerDialogMultipleServersMessage = Are you sure you want to delete these {0}
servers?
-
-EditServerActionText = Edit Server
-EditServerActionToolTip = Edit Server
-
-NewServerActionText = New Server
-NewServerActionToolTip = New Server
-
-RepositoryInvalidNameMsg = The value "{0}" is not a valid repository name
-RepositoryInvalidServerMsg = A repository server cannot be null
-RepositoryShortDescription = DNA Repository: Name: {0}, {1}
-
-ServerDialogEditTitle = Edit Server
-ServerDialogNewTitle = New Server
-ServerDialogPasswordLabel = Password:
-ServerDialogSavePasswordButton = Save password
-ServerDialogSavePasswordLabel = Saved secret data is stored on your computer in a file
that's difficult, but not impossible, for an intruder to read.
-ServerDialogUserLabel = User:
-ServerDialogUrlLabel = URL:
-
-ServerShortDescription = DNA Server: URL={0} User={1}
-ServerInvalidPasswordMsg = The value "{0}" is not a valid server authentication
password
-ServerInvalidUrlMsg = The value "{0}" is not a valid server URL
-ServerInvalidUserMsg = The value "{0}" is not a valid server authentication
user
-
-WorkspaceInvalidNameMsg = The value "{0}" is not a valid repository name
-WorkspaceInvalidRepositoryMsg = A workspace repository cannot be null
-WorkspaceShortDescription = DNA Repository Workspace: Name: {0}, {1}
Deleted:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/IUiConstants.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/IUiConstants.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/IUiConstants.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,27 +0,0 @@
-/*
- * 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;
-
-public interface IUiConstants {
-}
Deleted: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/UiUtil.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/UiUtil.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/UiUtil.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,94 +0,0 @@
-/*
- * 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;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.jboss.dna.publish.Activator;
-import org.jboss.dna.publish.domain.IDnaObject;
-import org.jboss.dna.publish.domain.Repository;
-import org.jboss.dna.publish.domain.Server;
-import org.jboss.dna.publish.domain.Workspace;
-
-/**
- * @author Dan Florian
- * @since 0.6
- */
-public final class UiUtil {
-
- //
===========================================================================================================================
- // Constants
- //
===========================================================================================================================
-
- private static final String ICON_PATH = "icons/full/"; //$NON-NLS-1$
-
- public static final String OBJ16 = ICON_PATH + "obj16/"; //$NON-NLS-1$
-
- private static final String REPOSITORY_IMAGE_PATH = OBJ16 +
"repository.gif"; //$NON-NLS-1$
-
- private static final String SERVER_IMAGE_PATH = OBJ16 + "server.gif";
//$NON-NLS-1$
-
- private static final String WORKSPACE_IMAGE_PATH = OBJ16 + "workspace.gif";
//$NON-NLS-1$
-
- //
===========================================================================================================================
- // Class Methods
- //
===========================================================================================================================
-
- /**
- * @param obj the object whose image is being requested
- * @return the image or <code>null</code>
- * @since 0.6
- */
- public static ImageDescriptor getImage( Object obj ) {
- if (obj instanceof Workspace) {
- return Activator.getImageDescriptor(WORKSPACE_IMAGE_PATH);
- }
-
- if (obj instanceof Repository) {
- return Activator.getImageDescriptor(REPOSITORY_IMAGE_PATH);
- }
-
- if (obj instanceof Server) {
- return Activator.getImageDescriptor(SERVER_IMAGE_PATH);
- }
-
- // should have an icon for every business object
- assert (!(obj instanceof IDnaObject));
-
- return null;
- }
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * Don't allow public construction.
- *
- * @since 0.6
- */
- private UiUtil() {
- // nothing to do
- }
-
-}
Deleted:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/DeleteServerDialog.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/DeleteServerDialog.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/DeleteServerDialog.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,121 +0,0 @@
-/*
- * 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.dialogs;
-
-import java.util.Collection;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.jboss.dna.publish.I18n;
-import org.jboss.dna.publish.domain.IDnaObject;
-import org.jboss.dna.publish.domain.Server;
-
-/**
- * The <code>DeleteServerDialog</code> class provides a UI for deleting a
{@link org.jboss.dna.publish.domain.Server server}.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public class DeleteServerDialog extends MessageDialog {
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * Collection of servers which will be deleted.
- *
- * @since 0.6
- */
- private final Collection<Server> serversBeingDeleted;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * @param parentShell the dialog parent
- * @param serversBeingDeleted the servers being deleted (may not be
<code>null</code>)
- * @since 0.6
- */
- public DeleteServerDialog( Shell parentShell,
- Collection<Server> serversBeingDeleted ) {
- super(parentShell, I18n.DeleteServerDialogTitle, null, null,
MessageDialog.QUESTION, new String[] {
- IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
- this.serversBeingDeleted = serversBeingDeleted;
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.dialogs.MessageDialog#configureShell(org.eclipse.swt.widgets.Shell)
- * @since 0.6
- */
- @Override
- protected void configureShell( Shell shell ) {
- super.configureShell(shell);
-
- // now set title
- String title;
-
- if (this.serversBeingDeleted.size() == 1) {
- IDnaObject server = this.serversBeingDeleted.iterator().next();
- title = NLS.bind(I18n.DeleteServerDialogOneServerMessage, server.getName());
- } else {
- title = NLS.bind(I18n.DeleteServerDialogOneServerMessage,
this.serversBeingDeleted.size());
- }
-
- shell.setText(title);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
- * @since 0.6
- */
- @Override
- protected Control createCustomArea( Composite parent ) {
- if (this.serversBeingDeleted.size() != 1) {
- List serverList = new List(parent, SWT.NONE);
-
serverList.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
-
- for (IDnaObject server : this.serversBeingDeleted) {
- serverList.add(server.getName());
- }
- }
-
- return null;
- }
-}
Deleted:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/ServerDialog.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/ServerDialog.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/dialogs/ServerDialog.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,192 +0,0 @@
-/*
- * 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.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.jboss.dna.publish.I18n;
-import org.jboss.dna.publish.domain.Server;
-
-/**
- * The <code>EditServerDialog</code> class provides a UI for editing a {@link
org.jboss.dna.publish.domain.Server server}'s
- * properties.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public class ServerDialog extends Dialog {
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- private String pswd;
-
- private String url;
-
- private String user;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- public ServerDialog( Shell parent ) {
- super(parent);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- public ServerDialog( Shell parent,
- Server server ) {
- this(parent);
-
- this.url = server.getUrl();
- this.user = server.getUser();
- this.pswd = server.getPassword();
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.Dialog#close()
- */
- @Override
- public boolean close() {
- boolean closed = super.close();
-
- // make sure if cancel was pressed that the call to get classpath jars does not
return anything
- if (getReturnCode() != Window.OK) {
- this.pswd = null;
- this.url = null;
- this.user = null;
- }
-
- return closed;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
- * @since 0.6
- */
- @Override
- protected void configureShell( Shell shell ) {
- super.configureShell(shell);
- shell.setText(this.url == null ? I18n.ServerDialogNewTitle :
I18n.ServerDialogEditTitle);
- }
-
- private void constructAuthenticationPanel( Composite parent ) {
- Group pnl = new Group(parent, SWT.NONE);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- pnl.setLayout(layout);
-
- GridData gd = new GridData(SWT.LEFT, SWT.TOP, true, false);
- pnl.setLayoutData(gd);
-
- // user row
- Label lbl = new Label(pnl, SWT.LEFT);
- lbl.setText(I18n.ServerDialogUserLabel);
-
- // password row
- lbl = new Label(pnl, SWT.LEFT);
- lbl.setText(I18n.ServerDialogPasswordLabel);
-
- // save password row
- Button btn = new Button(parent, SWT.CHECK | SWT.LEFT);
- btn.setText(I18n.ServerDialogSavePasswordButton);
-
- // save password message row
- StyledText st = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI | SWT.NO_FOCUS |
SWT.WRAP);
- st.setText(I18n.ServerDialogSavePasswordLabel);
-
st.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- st.setCaret(null);
- gd = new GridData(GridData.FILL_BOTH);
- gd.grabExcessVerticalSpace = false;
- gd.horizontalIndent = 4;
- gd.verticalIndent = 8;
- st.setLayoutData(gd);
- }
-
- private void constructUrlPanel( Composite parent ) {
- // Composite pnl = new Composite(parent, SWT.NONE);
-
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- * @since 0.6
- */
- @Override
- protected Control createDialogArea( Composite parent ) {
- Composite pnlMain = new Composite(parent, SWT.NONE);
- constructUrlPanel(parent);
- constructAuthenticationPanel(parent);
-
- return pnlMain;
- }
-
- /**
- * @return the server authentication password
- * @since 0.6
- */
- public String getPassword() {
- return this.pswd;
- }
-
- /**
- * @return the server authentication user
- * @since 0.6
- */
- public String getUser() {
- return this.user;
- }
-
- /**
- * @return the server URL
- * @since 0.6
- */
- public String getUrl() {
- return this.url;
- }
-
-}
Deleted:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryContentProvider.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryContentProvider.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryContentProvider.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,181 +0,0 @@
-/*
- * 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.views;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.dna.publish.Activator;
-import org.jboss.dna.publish.domain.IDnaObject;
-
-/**
- * The RepositoryContentProvider is a content and label provider for DNA repositories.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class RepositoryContentProvider implements ITreeContentProvider,
ILabelProvider {
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- * @since 0.6
- */
- @Override
- public void addListener( ILabelProviderListener listener ) {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- * @since 0.6
- */
- @Override
- public void dispose() {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object[] getChildren( Object parentElement ) {
- if (parentElement instanceof IDnaObject) {
- return ((IDnaObject)parentElement).getChildren().toArray();
- }
-
- // should not happen
- assert false;
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object[] getElements( Object inputElement ) {
- return Activator.getDefault().getServerManager().getServers().toArray();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Image getImage( Object element ) {
- // TODO implement
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object getParent( Object element ) {
- if (element instanceof IDnaObject) {
- return ((IDnaObject)element).getParent();
- }
-
- // should not happen
- assert false;
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- * @since 0.6
- */
- @Override
- public String getText( Object element ) {
- assert (element instanceof IDnaObject);
- return ((IDnaObject)element).getName();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- * @since 0.6
- */
- @Override
- public boolean hasChildren( Object element ) {
- return getChildren(element).length > 0;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
- * java.lang.Object)
- * @since 0.6
- */
- @Override
- public void inputChanged( Viewer viewer,
- Object oldInput,
- Object newInput ) {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
java.lang.String)
- * @since 0.6
- */
- @Override
- public boolean isLabelProperty( Object element,
- String property ) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- * @since 0.6
- */
- @Override
- public void removeListener( ILabelProviderListener listener ) {
- // nothing to do
- }
-
-}
Deleted:
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryView.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryView.java 2009-06-22
16:50:22 UTC (rev 1059)
+++
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ui/views/RepositoryView.java 2009-06-22
21:28:39 UTC (rev 1060)
@@ -1,256 +0,0 @@
-/*
- * 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.views;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.part.ViewPart;
-import org.jboss.dna.publish.I18n;
-import org.jboss.dna.publish.domain.IDnaObject;
-import org.jboss.dna.publish.domain.Server;
-
-/**
- * The RepositoryView shows all defined servers and their DNA repositories.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class RepositoryView extends ViewPart {
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * Collapses all tree nodes.
- *
- * @since 0.6
- */
- private IAction collapseAllAction;
-
- /**
- * Deletes a server.
- *
- * @since 0.6
- */
- private IAction deleteAction;
-
- /**
- * Edits a server's properties.
- *
- * @since 0.6
- */
- private IAction editAction;
-
- /**
- * Creates a new server.
- *
- * @since 0.6
- */
- private IAction newAction;
-
- /**
- * The viewer's content and label provider.
- *
- * @since 0.6
- */
- private RepositoryContentProvider provider;
-
- /**
- * @since 0.6
- */
- private TreeViewer viewer;
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * @since 0.6
- */
- private void constructActions() {
- // the collapse all action is always enabled
- this.collapseAllAction = new Action() {
- @Override
- public void run() {
- getViewer().collapseAll();
- }
- };
-
- this.collapseAllAction.setToolTipText(I18n.CollapseActionToolTip);
- this.collapseAllAction.setImageDescriptor(null);
-
- // the delete action will delete one or more servers
- this.deleteAction = null;
- this.deleteAction.setText(I18n.DeleteServerActionText);
- this.deleteAction.setToolTipText(I18n.DeleteServerActionToolTip);
- this.deleteAction.setImageDescriptor(null);
- this.deleteAction.setEnabled(false);
-
- // the edit action is only enabled when one server is selected
- this.editAction = null;
- this.editAction.setText(I18n.EditServerActionText);
- this.editAction.setToolTipText(I18n.EditServerActionToolTip);
- this.editAction.setImageDescriptor(null);
- this.editAction.setEnabled(false);
-
- // the new server action is always enabled
- this.newAction = null;
- this.newAction.setText(I18n.NewServerActionText);
- this.newAction.setToolTipText(I18n.NewServerActionToolTip);
- this.newAction.setImageDescriptor(null);
- }
-
- /**
- * @since 0.6
- */
- private void constructContextMenu() {
- MenuManager menuMgr = new MenuManager();
- menuMgr.add(this.newAction);
- menuMgr.add(this.editAction);
- menuMgr.add(this.deleteAction);
- // menuMgr.setRemoveAllWhenShown(true);
-
- Menu menu = menuMgr.createContextMenu(this.viewer.getTree());
- this.viewer.getTree().setMenu(menu);
- getSite().registerContextMenu(menuMgr, this.viewer);
- }
-
- /**
- * @since 0.6
- */
- private void constructToolBar() {
- IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
- toolBar.add(this.newAction);
- toolBar.add(this.editAction);
- toolBar.add(this.deleteAction);
- toolBar.add(this.collapseAllAction);
- }
-
- /**
- * @param parent the viewer's parent
- * @since 0.6
- */
- private void constructTreeViewer( Composite parent ) {
- this.provider = new RepositoryContentProvider();
- this.viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- this.viewer.setContentProvider(this.provider);
- this.viewer.setLabelProvider(this.provider);
- this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- @Override
- public void selectionChanged( SelectionChangedEvent event ) {
- handleSelectionChanged(event);
- }
- });
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- * @since 0.6
- */
- @Override
- public void createPartControl( Composite parent ) {
- constructTreeViewer(parent);
- constructActions();
- constructToolBar();
- constructContextMenu();
- }
-
- /**
- * @return the tree viewer
- * @since 0.6
- */
- TreeViewer getViewer() {
- return this.viewer;
- }
-
- /**
- * @param event the event being processed
- * @since 0.6
- */
- void handleSelectionChanged( SelectionChangedEvent event ) {
- IStructuredSelection selection = (IStructuredSelection)event.getSelection();
- updateStatusLine(selection);
- updateActionBars(selection);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- * @since 0.6
- */
- @Override
- public void setFocus() {
- if (!this.viewer.getControl().isDisposed()) {
- this.viewer.getControl().setFocus();
- }
- }
-
- /**
- * @param selection the current viewer selection (never
<code>null</code>)
- * @since 0.6
- */
- private void updateActionBars( IStructuredSelection selection ) {
- if (selection.isEmpty()) {
- this.deleteAction.setEnabled(false);
- this.editAction.setEnabled(false);
- } else {
- assert (selection.size() == 1);
-
- IDnaObject obj = (IDnaObject)selection.getFirstElement();
- boolean enable = (obj instanceof Server);
- this.deleteAction.setEnabled(enable);
- this.editAction.setEnabled(enable);
- }
- }
-
- /**
- * @param selection the current viewer selection (never
<code>null</code>)
- * @since 0.6
- */
- private void updateStatusLine( IStructuredSelection selection ) {
- assert (selection.size() < 2);
-
- String msg = (selection.isEmpty() ? "" :
((IDnaObject)selection.getFirstElement()).getShortDescription()); //$NON-NLS-1$
- getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
- }
-}