Author: elvisisking
Date: 2010-07-30 14:37:27 -0400 (Fri, 30 Jul 2010)
New Revision: 23844
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-2.1-SNAPSHOT-jar-with-dependencies.jar
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-2.1-SNAPSHOT-sources.jar
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingHandler.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishHandler.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishHandler.java
Removed:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-jar-with-dependencies.jar
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-sources.jar
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingAction.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishAction.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsAction.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishAction.java
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/.classpath
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/build.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/ServerManager.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/ServerManagerTest.java
Log:
JBIDE-6652, JBIDE-6654: Renamed "ModeShape Servers" View to just be called
"ModeShape." The ModeShape context menu actions now only show whenever at least
one ModeShape server has been registered in the ModeShape view. This was done by
converting over to using the "org.eclipse.ui.menus" extension point which
requires handlers and commands. Upgraded the ModeShape dependency jar to version 2.1.
Fixed a bug in modifyText handler in PublishPage.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/.classpath
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/.classpath 2010-07-30 17:41:49
UTC (rev 23843)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/.classpath 2010-07-30 18:37:27
UTC (rev 23844)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib"
path="modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-jar-with-dependencies.jar"
sourcepath="modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-sources.jar"/>
+ <classpathentry exported="true" kind="lib"
path="modeshape-web-jcr-rest-client-2.1-SNAPSHOT-jar-with-dependencies.jar"
sourcepath="modeshape-web-jcr-rest-client-2.1-SNAPSHOT-sources.jar"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF 2010-07-30
17:41:49 UTC (rev 23843)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/META-INF/MANIFEST.MF 2010-07-30
18:37:27 UTC (rev 23844)
@@ -14,7 +14,7 @@
org.eclipse.debug.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
-Bundle-ClassPath:
modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-jar-with-dependencies.jar,
+Bundle-ClassPath: modeshape-web-jcr-rest-client-2.1-SNAPSHOT-jar-with-dependencies.jar,
.
Export-Package: org.jboss.tools.modeshape.rest,
org.modeshape.web.jcr.rest.client,
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/build.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/build.properties 2010-07-30
17:41:49 UTC (rev 23843)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/build.properties 2010-07-30
18:37:27 UTC (rev 23844)
@@ -19,9 +19,9 @@
about.properties,\
feature.png,\
.,\
- modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-jar-with-dependencies.jar,\
docs/,\
- about.html
+ about.html,\
+ modeshape-web-jcr-rest-client-2.1-SNAPSHOT-jar-with-dependencies.jar
src.includes = src/
jars.compile.order = .
source.. = src/
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-1.0.0-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-2.1-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-2.1-SNAPSHOT-jar-with-dependencies.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-2.1-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/modeshape-web-jcr-rest-client-2.1-SNAPSHOT-sources.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties 2010-07-30
17:41:49 UTC (rev 23843)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.properties 2010-07-30
18:37:27 UTC (rev 23844)
@@ -12,10 +12,10 @@
bundleName = ModeShape REST Eclipse Publishing Plug-in
bundleVendor = Red Hat, Inc.
contextMenu.label = ModeShape
-decorator.description = Decorates objects in the Server View
-decorator.label = ModeShape Server View Decorator
+decorator.description = Decorates objects in the ModeShape View
+decorator.label = ModeShape View Decorator
modeShapeCategory = ModeShape
-publishAction.label = Publish
-serverView = ModeShape Servers
-showPublishedLocationsAction.label = Show Published Locations
-unpublishAction.label = Unpublish
\ No newline at end of file
+publishCommand.name = Publish
+serverView = ModeShape
+showPublishedLocationsCommand.name = Show Published Locations
+unpublishCommand.name = Unpublish
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml 2010-07-30 17:41:49
UTC (rev 23843)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/plugin.xml 2010-07-30 18:37:27
UTC (rev 23844)
@@ -12,78 +12,142 @@
- individual contributors.
-->
<plugin>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.jboss.tools.modeshape.rest.actions.PublishHandler"
+
commandId="org.jboss.tools.modeshape.rest.actions.PublishCommand">
+ <enabledWhen>
+ <iterate ifEmpty="false">
+ <or>
+ <instanceof
+ value="org.eclipse.core.resources.IFile">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IFolder">
+ </instanceof>
+ <and>
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ </and>
+ </or>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+ class="org.jboss.tools.modeshape.rest.actions.UnpublishHandler"
+
commandId="org.jboss.tools.modeshape.rest.actions.UnpublishCommand">
+ <enabledWhen>
+ <iterate ifEmpty="false">
+ <or>
+ <instanceof
+ value="org.eclipse.core.resources.IFile">
+ </instanceof>
+ <instanceof
+ value="org.eclipse.core.resources.IFolder">
+ </instanceof>
+ <and>
+ <instanceof
+ value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ </and>
+ </or>
+ </iterate>
+ </enabledWhen>
+ </handler>
+ <handler
+
class="org.jboss.tools.modeshape.rest.actions.ShowPublishedLocationsHandler"
+
commandId="org.jboss.tools.modeshape.rest.actions.ShowPublishedLocationsCommand">
+ <enabledWhen>
+ <and>
+ <count value="1"/>
+ <iterate ifEmpty="false">
+ <and>
+ <instanceof
value="org.eclipse.core.resources.IFile"/>
+ <test
+
property="org.eclipse.core.resources.persistentProperty"
+
args="org.jboss.tools.modeshape.rest.publishedLocations">
+ </test>
+ </and>
+ </iterate>
+ </and>
+ </enabledWhen>
+ </handler>
+ </extension>
-<!-- Define the IResource object contribution actions to all popup menus -->
<extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- id="org.jboss.tools.modeshape.rest.iresourcepopupmenucontribution"
- objectClass="org.eclipse.core.resources.IResource">
+ point="org.eclipse.ui.commands">
+ <category
+ id="org.modeshape"
+ name="%modeShapeCategory">
+ </category>
+ <command
+ categoryId="org.modeshape"
+ id="org.jboss.tools.modeshape.rest.actions.PublishCommand"
+ name="%publishCommand.name">
+ </command>
+ <command
+ categoryId="org.modeshape"
+ id="org.jboss.tools.modeshape.rest.actions.UnpublishCommand"
+ name="%unpublishCommand.name">
+ </command>
+ <command
+ categoryId="org.modeshape"
+
id="org.jboss.tools.modeshape.rest.actions.ShowPublishedLocationsCommand"
+ name="%showPublishedLocationsCommand.name">
+ </command>
+ </extension>
+
+<!-- Define the popup menu contributions -->
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="true"
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<menu
- id="org.jboss.tools.modeshape.rest.contextMenu"
- label="%contextMenu.label"
- path="additions">
- <separator
- name="modeshape">
- </separator>
+ label="%contextMenu.label">
+ <command
+
commandId="org.jboss.tools.modeshape.rest.actions.PublishCommand"
+ label="%publishCommand.name"
+ style="push">
+ </command>
+ <command
+
commandId="org.jboss.tools.modeshape.rest.actions.UnpublishCommand"
+ label="%unpublishCommand.name"
+ style="push">
+ </command>
+ <command
+
commandId="org.jboss.tools.modeshape.rest.actions.ShowPublishedLocationsCommand"
+ label="%showPublishedLocationsCommand.name"
+ style="push">
+ </command>
+ <visibleWhen
+ checkEnabled="false">
+ <and>
+ <systemTest
+
property="org.jboss.tools.modeshape.rest.serverExists"
+ value="true">
+ </systemTest>
+ <iterate ifEmpty="false">
+ <or>
+ <instanceof
+ value="org.eclipse.core.resources.IFile">
+ </instanceof>
+ <instanceof
+
value="org.eclipse.core.resources.IFolder">
+ </instanceof>
+ <and>
+ <instanceof
+
value="org.eclipse.core.resources.IProject">
+ </instanceof>
+ </and>
+ </or>
+ </iterate>
+ </and>
+ </visibleWhen>
</menu>
-
- <!-- Show Published Locations action -->
- <action
-
id="org.jboss.tools.modeshape.rest.showPublishedLocationsAction"
- label="%showPublishedLocationsAction.label"
-
class="org.jboss.tools.modeshape.rest.actions.ShowPublishedLocationsAction"
- icon="icons/views/blank.gif"
- menubarPath="org.jboss.tools.modeshape.rest.contextMenu/group1"
- enablesFor="1">
- <enablement>
- <and>
- <objectClass name="org.eclipse.core.resources.IFile"
/>
- <objectState name="persistentProperty"
value="org.jboss.tools.modeshape.rest.publishedLocations" />
- </and>
- </enablement>
- </action>
-
- <!-- Unpublish action -->
- <action
- id="org.jboss.tools.modeshape.rest.unpublishAction"
- label="%unpublishAction.label"
- class="org.jboss.tools.modeshape.rest.actions.UnpublishAction"
- icon="icons/views/unpublish.png"
- menubarPath="org.jboss.tools.modeshape.rest.contextMenu/group1"
- enablesFor="*">
- <enablement>
- <or>
- <objectClass
name="org.eclipse.core.resources.IFile" />
- <objectClass
name="org.eclipse.core.resources.IFolder" />
- <and>
- <objectClass
name="org.eclipse.core.resources.IProject" />
- <objectState name="open"
value="true" />
- </and>
- </or>
- </enablement>
- </action>
-
- <!-- Publish action -->
- <action
- id="org.jboss.tools.modeshape.rest.publishAction"
- label="%publishAction.label"
- class="org.jboss.tools.modeshape.rest.actions.PublishAction"
- icon="icons/views/publish.png"
- menubarPath="org.jboss.tools.modeshape.rest.contextMenu/group1"
- enablesFor="*">
- <enablement>
- <or>
- <objectClass
name="org.eclipse.core.resources.IFile" />
- <objectClass
name="org.eclipse.core.resources.IFolder" />
- <and>
- <objectClass
name="org.eclipse.core.resources.IProject" />
- <objectState name="open"
value="true" />
- </and>
- </or>
- </enablement>
- </action>
- </objectContribution>
+ </menuContribution>
</extension>
<!-- View extensions -->
@@ -94,7 +158,7 @@
name="%modeShapeCategory">
</category>
- <!-- Repository view -->
+ <!-- Server view -->
<view
id="serverView"
name="%serverView"
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/ServerManager.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/ServerManager.java 2010-07-30
17:41:49 UTC (rev 23843)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/ServerManager.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -68,6 +68,12 @@
private static final String REGISTRY_FILE = "serverRegistry.xml";
/**
+ * The name of the system property that is set when at least one server exists. This
property is used by the menus extension
+ * that is responsible for showing the ModeShape context menu items.
+ */
+ public static final String SERVER_EXISTS_PROPERTY =
"org.jboss.tools.modeshape.rest.serverExists";
+
+ /**
* The tag used when persisting a server.
*/
private static final String SERVER_TAG = "server";
@@ -314,6 +320,15 @@
}
if (added) {
+ // set system property if not set
+ String serverExists = System.getProperty(SERVER_EXISTS_PROPERTY);
+
+ if (serverExists == null) {
+ // value of "true" is coded in the plugin.xml as well
+ System.setProperty(SERVER_EXISTS_PROPERTY, "true");
+ }
+
+ // let listeners know of new server
if (notifyListeners) {
Exception[] errors =
notifyRegistryListeners(ServerRegistryEvent.createNewEvent(this, server));
return processRegistryListenerErrors(errors);
@@ -350,6 +365,12 @@
}
if (removed) {
+ // remove system property if no more servers
+ if (getServers().isEmpty()) {
+ System.clearProperty(SERVER_EXISTS_PROPERTY);
+ }
+
+ // let listeners know of new server
if (notifyListeners) {
Exception[] errors =
notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(this, server));
return processRegistryListenerErrors(errors);
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingAction.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingAction.java 2010-07-30
17:41:49 UTC (rev 23843)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingAction.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -1,152 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution and is
- * available at
http://www.eclipse.org/legal/epl-v10.html.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.actions;
-
-import static org.jboss.tools.modeshape.rest.IUiConstants.ModeShape_IMAGE_16x;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.jboss.tools.modeshape.rest.Activator;
-import org.jboss.tools.modeshape.rest.RestClientI18n;
-import org.jboss.tools.modeshape.rest.Utils;
-import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
-import org.jboss.tools.modeshape.rest.wizards.PublishWizard;
-import org.modeshape.web.jcr.rest.client.Status;
-import org.modeshape.web.jcr.rest.client.Status.Severity;
-
-/**
- * The <code>BasePublishingAction</code> is a base class for all publishing
actions.
- */
-public abstract class BasePublishingAction implements IObjectActionDelegate {
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * The current workspace selection.
- */
- private IStructuredSelection selection;
-
- /**
- * The active part's Shell.
- */
- private Shell shell;
-
- /**
- * Indicates if this is a publishing or unpublishing action.
- */
- private final Type type;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * @param type indicates the type of action
- */
- public BasePublishingAction( Type type ) {
- this.type = type;
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- @Override
- @SuppressWarnings( "unchecked" )
- public void run( IAction action ) {
- assert (this.selection != null);
- assert (!this.selection.isEmpty());
-
- List<IResource> resources;
-
- if (this.selection.size() == 1) {
- resources =
Collections.singletonList((IResource)this.selection.getFirstElement());
- } else {
- resources = this.selection.toList();
- }
-
- // run wizard
- try {
- WizardDialog dialog = new WizardDialog(shell, new PublishWizard(this.type,
resources,
-
Activator.getDefault().getServerManager())) {
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
- */
- @Override
- protected void initializeBounds() {
- super.initializeBounds();
-
getShell().setImage(Activator.getDefault().getImage(ModeShape_IMAGE_16x));
- Utils.centerAndSizeShellRelativeToDisplay(getShell(), 75, 75);
- }
- };
-
- dialog.open();
- } catch (CoreException e) {
- String msg = null;
-
- if (this.type == Type.PUBLISH) {
- msg =
RestClientI18n.basePublishingActionPublishingWizardErrorMsg.text();
- } else {
- msg =
RestClientI18n.basePublishingActionUnpublishingWizardErrorMsg.text();
- }
-
- Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
- MessageDialog.openError(this.shell, RestClientI18n.errorDialogTitle.text(),
msg);
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- @Override
- public void selectionChanged( IAction action,
- ISelection selection ) {
- if (selection instanceof IStructuredSelection) {
- this.selection = (IStructuredSelection)selection;
- } else {
- this.selection = null;
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
org.eclipse.ui.IWorkbenchPart)
- */
- @Override
- public void setActivePart( IAction action,
- IWorkbenchPart targetPart ) {
- this.shell = targetPart.getSite().getShell();
- }
-
-}
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingHandler.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingHandler.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingHandler.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+
+package org.jboss.tools.modeshape.rest.actions;
+
+import static org.jboss.tools.modeshape.rest.IUiConstants.ModeShape_IMAGE_16x;
+import java.util.Collections;
+import java.util.List;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.jboss.tools.modeshape.rest.Activator;
+import org.jboss.tools.modeshape.rest.RestClientI18n;
+import org.jboss.tools.modeshape.rest.Utils;
+import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
+import org.jboss.tools.modeshape.rest.wizards.PublishWizard;
+import org.modeshape.web.jcr.rest.client.Status;
+import org.modeshape.web.jcr.rest.client.Status.Severity;
+
+/**
+ * The <code>BasePublishingHandler</code> is a base class for the publishing
and unpublishing handlers.
+ */
+abstract class BasePublishingHandler implements IHandler {
+
+ /**
+ * Indicates if this is a publishing or unpublishing handler.
+ */
+ private final Type type;
+
+ /**
+ * @param type indicates the type of handler
+ */
+ protected BasePublishingHandler( Type type ) {
+ this.type = type;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener)
+ */
+ @Override
+ public void addHandlerListener( IHandlerListener handlerListener ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute( ExecutionEvent event ) {
+ ISelection temp = HandlerUtil.getCurrentSelection(event);
+ assert (temp != null);
+ assert (!temp.isEmpty());
+ assert (temp instanceof IStructuredSelection);
+
+ IStructuredSelection selection = (IStructuredSelection)temp;
+ List<IResource> resources;
+
+ if (selection.size() == 1) {
+ resources =
Collections.singletonList((IResource)selection.getFirstElement());
+ } else {
+ resources = selection.toList();
+ }
+
+ // run wizard
+ Shell shell = HandlerUtil.getActiveShell(event);
+
+ try {
+ WizardDialog dialog = new WizardDialog(shell, new PublishWizard(this.type,
resources,
+
Activator.getDefault().getServerManager())) {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
+ */
+ @Override
+ protected void initializeBounds() {
+ super.initializeBounds();
+
getShell().setImage(Activator.getDefault().getImage(ModeShape_IMAGE_16x));
+ Utils.centerAndSizeShellRelativeToDisplay(getShell(), 75, 75);
+ }
+ };
+
+ dialog.open();
+ } catch (CoreException e) {
+ String msg = null;
+
+ if (this.type == Type.PUBLISH) {
+ msg =
RestClientI18n.basePublishingActionPublishingWizardErrorMsg.text();
+ } else {
+ msg =
RestClientI18n.basePublishingActionUnpublishingWizardErrorMsg.text();
+ }
+
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+ MessageDialog.openError(shell, RestClientI18n.errorDialogTitle.text(), msg);
+ }
+
+ // per javadoc must return null
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#isHandled()
+ */
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener)
+ */
+ @Override
+ public void removeHandlerListener( IHandlerListener handlerListener ) {
+ // nothing to do
+ }
+
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/BasePublishingHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishAction.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishAction.java 2010-07-30
17:41:49 UTC (rev 23843)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishAction.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -1,30 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution and is
- * available at
http://www.eclipse.org/legal/epl-v10.html.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.actions;
-
-import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
-
-/**
- * The <code>PublishAction</code> controls the publishing of one or more
{@link org.eclipse.core.resources.IResource}s to a
- * repository.
- */
-public final class PublishAction extends BasePublishingAction {
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- public PublishAction() {
- super(Type.PUBLISH);
- }
-
-}
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishHandler.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishHandler.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishHandler.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -0,0 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+
+package org.jboss.tools.modeshape.rest.actions;
+
+import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
+
+/**
+ * The <code>PublishHandler</code> controls the publishing (uploading) of one
or more {@link org.eclipse.core.resources.IResource}
+ * s to a ModeShape repository.
+ */
+public final class PublishHandler extends BasePublishingHandler {
+
+ /**
+ * Constructs a handler for publishing (uploading) of files to a ModeShape
repository.
+ */
+ public PublishHandler() {
+ super(Type.PUBLISH);
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/PublishHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsAction.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsAction.java 2010-07-30
17:41:49 UTC (rev 23843)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsAction.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -1,120 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution and is
- * available at
http://www.eclipse.org/legal/epl-v10.html.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.actions;
-
-import static org.jboss.tools.modeshape.rest.IUiConstants.DELETE_SERVER_IMAGE;
-import java.util.Set;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.jboss.tools.modeshape.rest.Activator;
-import org.jboss.tools.modeshape.rest.PublishedResourceHelper;
-import org.jboss.tools.modeshape.rest.RestClientI18n;
-import org.jboss.tools.modeshape.rest.ServerManager;
-import org.jboss.tools.modeshape.rest.dialogs.PublishedLocationsDialog;
-import org.modeshape.web.jcr.rest.client.Status;
-import org.modeshape.web.jcr.rest.client.Status.Severity;
-import org.modeshape.web.jcr.rest.client.domain.Workspace;
-
-/**
- * The <code>PublishAction</code> controls the publishing of one or more
{@link org.eclipse.core.resources.IResource}s to a
- * ModeShape repository.
- */
-public final class ShowPublishedLocationsAction extends Action implements
IObjectActionDelegate {
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * The current workspace selection.
- */
- private IStructuredSelection selection;
-
- /**
- * The active part's Shell.
- */
- private Shell shell;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- public ShowPublishedLocationsAction() {
- super(RestClientI18n.deleteServerActionText.text(),
Activator.getDefault().getImageDescriptor(DELETE_SERVER_IMAGE));
- setToolTipText(RestClientI18n.deleteServerActionToolTip.text());
- setEnabled(false);
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- @Override
- public void run( IAction action ) {
- assert ((this.selection != null) && (this.selection.size() == 1));
- assert (this.selection.getFirstElement() instanceof IFile);
-
- // open dialog
- ServerManager serverManager = Activator.getDefault().getServerManager();
- PublishedResourceHelper resourceHelper = new
PublishedResourceHelper(serverManager);
-
- try {
- Set<Workspace> workspaces =
resourceHelper.getPublishedOnWorkspaces((IFile)this.selection.getFirstElement());
- new PublishedLocationsDialog(this.shell, serverManager,
(IFile)this.selection.getFirstElement(), workspaces).open();
- } catch (Exception e) {
- Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.showPublishedLocationsErrorMsg.text(), e));
- MessageDialog.openError(this.shell,
- RestClientI18n.errorDialogTitle.text(),
-
RestClientI18n.showPublishedLocationsErrorMsg.text());
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- @Override
- public void selectionChanged( IAction action,
- ISelection selection ) {
- if (selection instanceof IStructuredSelection) {
- this.selection = (IStructuredSelection)selection;
- } else {
- this.selection = null;
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction,
org.eclipse.ui.IWorkbenchPart)
- */
- @Override
- public void setActivePart( IAction action,
- IWorkbenchPart targetPart ) {
- this.shell = targetPart.getSite().getShell();
- }
-
-}
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+
+package org.jboss.tools.modeshape.rest.actions;
+
+import java.util.Set;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.commands.IHandlerListener;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.jboss.tools.modeshape.rest.Activator;
+import org.jboss.tools.modeshape.rest.PublishedResourceHelper;
+import org.jboss.tools.modeshape.rest.RestClientI18n;
+import org.jboss.tools.modeshape.rest.ServerManager;
+import org.jboss.tools.modeshape.rest.dialogs.PublishedLocationsDialog;
+import org.modeshape.web.jcr.rest.client.Status;
+import org.modeshape.web.jcr.rest.client.Status.Severity;
+import org.modeshape.web.jcr.rest.client.domain.Workspace;
+
+/**
+ * The <code>ShowPublishedLocationsHandler</code> displays a dialog that
shows information on which ModeShape repositories a
+ * {@link org.eclipse.core.resources.IFile file} has been published to.
+ */
+public final class ShowPublishedLocationsHandler implements IHandler {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.commands.IHandler#addHandlerListener(org.eclipse.core.commands.IHandlerListener)
+ */
+ @Override
+ public void addHandlerListener( IHandlerListener handlerListener ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute( ExecutionEvent event ) {
+ ISelection temp = HandlerUtil.getCurrentSelection(event);
+ assert (temp != null) : "selection is null"; //$NON-NLS-1$
+ assert (!temp.isEmpty()) : "selection is empty"; //$NON-NLS-1$
+ assert (temp instanceof IStructuredSelection) : "selection is not an
IStructuredSelection"; //$NON-NLS-1$
+
+ IStructuredSelection selection = (IStructuredSelection)temp;
+ assert (selection.size() == 1) : "selection size is greater than one";
//$NON-NLS-1$
+ assert (selection.getFirstElement() instanceof IFile) : "selected element is
not a file"; //$NON-NLS-1$
+
+ // open dialog
+ ServerManager serverManager = Activator.getDefault().getServerManager();
+ PublishedResourceHelper resourceHelper = new
PublishedResourceHelper(serverManager);
+ Shell shell = HandlerUtil.getActiveShell(event);
+
+ try {
+ Set<Workspace> workspaces =
resourceHelper.getPublishedOnWorkspaces((IFile)selection.getFirstElement());
+ PublishedLocationsDialog dialog = new PublishedLocationsDialog(shell,
serverManager,
+
(IFile)selection.getFirstElement(), workspaces);
+ dialog.open();
+ } catch (Exception e) {
+ Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.showPublishedLocationsErrorMsg.text(), e));
+ MessageDialog.openError(shell,
+ RestClientI18n.errorDialogTitle.text(),
+
RestClientI18n.showPublishedLocationsErrorMsg.text());
+ }
+
+ // per javadoc must return null
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.commands.IHandler#isHandled()
+ */
+ @Override
+ public boolean isHandled() {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.commands.IHandler#removeHandlerListener(org.eclipse.core.commands.IHandlerListener)
+ */
+ @Override
+ public void removeHandlerListener( IHandlerListener handlerListener ) {
+ // nothing to do
+ }
+
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/ShowPublishedLocationsHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishAction.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishAction.java 2010-07-30
17:41:49 UTC (rev 23843)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishAction.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -1,30 +0,0 @@
-/*
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership.
- *
- * This software is made available by Red Hat, Inc. under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution and is
- * available at
http://www.eclipse.org/legal/epl-v10.html.
- *
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- */
-package org.jboss.tools.modeshape.rest.actions;
-
-import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
-
-/**
- * The <code>UnpublishAction</code> controls the unpublishing of one or more
{@link org.eclipse.core.resources.IResource}s from a
- * ModeShape repository.
- */
-public final class UnpublishAction extends BasePublishingAction {
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- public UnpublishAction() {
- super(Type.UNPUBLISH);
- }
-
-}
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishHandler.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishHandler.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishHandler.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright
ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual
contributors.
+ */
+
+package org.jboss.tools.modeshape.rest.actions;
+
+import org.jboss.tools.modeshape.rest.jobs.PublishJob.Type;
+
+/**
+ * The <code>UnpublishHandler</code> controls the unpublishing (removing) of
one or more
+ * {@link org.eclipse.core.resources.IResource}s from a ModeShape repository.
+ */
+public final class UnpublishHandler extends BasePublishingHandler {
+
+ /**
+ * Constructs a handler for unpublishing (removing) of files from a ModeShape
repository.
+ */
+ public UnpublishHandler() {
+ super(Type.UNPUBLISH);
+ }
+
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/actions/UnpublishHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2010-07-30
17:41:49 UTC (rev 23843)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.rest/src/org/jboss/tools/modeshape/rest/wizards/PublishPage.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -715,7 +715,7 @@
handleServerModified();
} else if (e.widget == this.cbxRepository) {
handleRepositoryModified();
- } else if (e.widget == this.cbxRepository) {
+ } else if (e.widget == this.cbxWorkspace) {
handleWorkspaceModified();
} else {
assert false; // should not happen
Modified:
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/ServerManagerTest.java
===================================================================
---
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/ServerManagerTest.java 2010-07-30
17:41:49 UTC (rev 23843)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.rest.test/src/org/jboss/tools/modeshape/rest/ServerManagerTest.java 2010-07-30
18:37:27 UTC (rev 23844)
@@ -12,11 +12,9 @@
package org.jboss.tools.modeshape.rest;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
-import org.jboss.tools.modeshape.rest.IServerRegistryListener;
-import org.jboss.tools.modeshape.rest.PersistedServer;
-import org.jboss.tools.modeshape.rest.ServerManager;
-import org.jboss.tools.modeshape.rest.ServerRegistryEvent;
import org.junit.Before;
import org.junit.Test;
import org.modeshape.web.jcr.rest.client.Status;
@@ -105,6 +103,12 @@
}
@Test
+ public void shouldHaveServerExistsSystemPropertyIfThereIsARegisteredServer() {
+ this.serverManager.addServer(SERVER1);
+ assertThat(System.getProperty(ServerManager.SERVER_EXISTS_PROPERTY),
notNullValue());
+ }
+
+ @Test
public void shouldHaveOkStatusWhenUpdateServerSuccessfully() {
this.serverManager.addServer(SERVER1);
assertThat(this.serverManager.updateServer(SERVER1, SERVER1_UPDATE).isOk(),
is(true));
@@ -151,6 +155,12 @@
}
@Test
+ public void shouldNotHaveServerExistsSystemPropertyIfNoRegisteredServers() {
+ // make sure initially property doesn't exist
+ assertThat(System.getProperty(ServerManager.SERVER_EXISTS_PROPERTY),
nullValue());
+ }
+
+ @Test
public void shouldNotReceiveNotificationIfListenerUnregistered() {
RegistryListener listener = new RegistryListener();