Author: elvisisking
Date: 2009-08-14 15:19:06 -0400 (Fri, 14 Aug 2009)
New Revision: 1162
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishJob.java
Removed:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/PublishAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/UnpublishAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/DeleteServerDialog.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java
Log:
Now using the Eclipse Job API for publishing and unpublishing. Deleted
PublishingResultsDialog since writing to Eclipse Console View seems to be enough. Added a
test connection button on the ServerPage.
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-sources.jar
===================================================================
(Binary files differ)
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -54,22 +54,28 @@
public static I18n newServerActionText;
public static I18n newServerActionToolTip;
+
+ public static I18n publishJobPublishCanceledMsg;
+ public static I18n publishJobConsoleName;
+ public static I18n publishJobPublish;
+ public static I18n publishJobPublishFile;
+ public static I18n publishJobPublishFileFailed;
+ public static I18n publishJobPublishFileInfo;
+ public static I18n publishJobPublishFileWarning;
+ public static I18n publishJobPublishFinishedMsg;
+ public static I18n publishJobPublishName;
+ public static I18n publishJobPublishTaskName;
+ public static I18n publishJobUnexpectedErrorMsg;
+ public static I18n publishJobUnpublish;
+ public static I18n publishJobUnpublishCanceledMsg;
+ public static I18n publishJobUnpublishFile;
+ public static I18n publishJobUnpublishFileFailed;
+ public static I18n publishJobUnpublishFileInfo;
+ public static I18n publishJobUnpublishFileWarning;
+ public static I18n publishJobUnpublishFinishedMsg;
+ public static I18n publishJobUnpublishName;
+ public static I18n publishJobUnpublishTaskName;
- public static I18n publishingResultsPublishNotAttemptedMsg;
- public static I18n publishingResultsTooManyResultsMsg;
- public static I18n publishingResultsUnknownSeverityMsg;
- public static I18n publishingResultsUnpublishNotAttemptedMsg;
-
- public static I18n publishOperationConsoleName;
- public static I18n publishOperationPublish;
- public static I18n publishOperationPublishFile;
- public static I18n publishOperationPublishFileFailed;
- public static I18n publishOperationPublishTaskName;
- public static I18n publishOperationUnpublish;
- public static I18n publishOperationUnpublishFile;
- public static I18n publishOperationUnpublishFileFailed;
- public static I18n publishOperationUnpublishTaskName;
-
public static I18n publishPagePublishTitle;
public static I18n publishPageLocationGroupTitle;
public static I18n publishPageMissingRepositoryStatusMsg;
@@ -97,19 +103,6 @@
public static I18n publishPageWorkspacePublishToolTip;
public static I18n publishPageWorkspaceUnpublishToolTip;
- public static I18n publishResultsDialogErrorIncompletePublishingMsg;
- public static I18n publishResultsDialogErrorIncompleteUnpublishingMsg;
- public static I18n publishResultsDialogErrorPublishingMsg;
- public static I18n publishResultsDialogErrorUnpublishingMsg;
- public static I18n publishResultsDialogFileHeader;
- public static I18n publishResultsDialogIncompletePublishMsg;
- public static I18n publishResultsDialogIncompleteUnpublishMsg;
- public static I18n publishResultsDialogMessageHeader;
- public static I18n publishResultsDialogPublishMsg;
- public static I18n publishResultsDialogStatisticsMsg;
- public static I18n publishResultsDialogTitle;
- public static I18n publishResultsDialogUnpublishMsg;
-
public static I18n publishWizardPublishErrorMsg;
public static I18n publishWizardPublishTitle;
public static I18n publishWizardUnpublishTitle;
@@ -128,6 +121,12 @@
public static I18n serverPageSavePasswordButton;
public static I18n serverPageSavePasswordLabel;
public static I18n serverPageSavePasswordToolTip;
+ public static I18n serverPageTestConnectionLabel;
+ public static I18n serverPageTestConnectionButton;
+ public static I18n serverPageTestConnectionButtonToolTip;
+ public static I18n serverPageTestConnectionDialogFailureMsg;
+ public static I18n serverPageTestConnectionDialogTitle;
+ public static I18n serverPageTestConnectionDialogSuccessMsg;
public static I18n serverPageTitle;
public static I18n serverPageUrlLabel;
public static I18n serverPageUrlToolTip;
@@ -141,6 +140,9 @@
public static I18n serverWizardNewServerErrorMsg;
public static I18n serverWizardNewServerTitle;
+ public static I18n testServerActionText;
+ public static I18n testServerActionToolTip;
+
static {
try {
I18n.initialize(RestClientI18n.class);
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties 2009-08-14
19:19:06 UTC (rev 1162)
@@ -31,7 +31,7 @@
deleteServerDialogErrorsOccurredMsg = There were errors deleting servers from the server
registry. See log for more details.
deleteServerDialogMultipleServersMsg = Are you sure you want to delete these {0}
servers?
-deleteServerDialogOneServerMsg = Are you sure you want to delete the "{0}"
server?
+deleteServerDialogOneServerMsg = Are you sure you want to delete the server with URL of
"{0}" and user "{1}?"
deleteServerDialogTitle = Confirm Delete Server
editServerActionText = Server Properties
@@ -44,21 +44,27 @@
newServerActionText = New Server
newServerActionToolTip = Create a new server
-publishingResultsPublishNotAttemptedMsg = Publishing not attempted
-publishingResultsTooManyResultsMsg = Adding a status to the results failed since there is
not enough files involved in the publishing operation.
-publishingResultsUnknownSeverityMsg = "{0}" is an unknown status severity
-publishingResultsUnpublishNotAttemptedMsg = Unpublishing not attempted
+publishJobConsoleName = DNA
+publishJobPublish = Publishing {3} file(s) to server "{0}" (repository
"{1}", workspace "{2}") ...
+publishJobPublishCanceledMsg = i Publishing to server "{0}" (repository
"{1}", workspace "{2}") was canceled after {3} file(s) out of {4} were
processed.
+publishJobPublishFile = \t+ Published file "{0}" to location "{1}"
+publishJobPublishFileFailed = \t* ERROR publishing file "{0}" to location
"{1}"
+publishJobPublishFileInfo = \ti {0}
+publishJobPublishFileWarning = \tw {0}
+publishJobPublishFinishedMsg = Done publishing ({3} milliseconds) to server
"{0}" (repository "{1}", workspace "{2}").
+publishJobPublishName = DNA Publish
+publishJobPublishTaskName = Publishing resources
+publishJobUnexpectedErrorMsg = Unexpected error occurred. See log for more details.
+publishJobUnpublish = Unpublishing {3} file(s) from server "{0}" (repository
"{1}", workspace "{2}") ...
+publishJobUnpublishCanceledMsg = * Unpublishing from server "{0}" (repository
"{1}", workspace "{2}") was canceled after {3} file(s) out of {4} were
processed.
+publishJobUnpublishFile = \t- Unpublished file "{0}" from location
"{1}"
+publishJobUnpublishFileFailed = \t* ERROR unpublished file "{0}" from location
"{1}"
+publishJobUnpublishFileInfo = \ti {0}
+publishJobUnpublishFileWarning = \tw {0}
+publishJobUnpublishFinishedMsg = Done unpublishing ({3} milliseconds) from server
"{0}" (repository "{1}", workspace "{2}").
+publishJobUnpublishName = DNA Unpublish
+publishJobUnpublishTaskName = Unpublishing resources
-publishOperationConsoleName = DNA
-publishOperationPublish = DNA publish to server "{0}", repository
"{1}", workspace "{2}"
-publishOperationPublishFile = \t+ Published file "{0}" to location
"{1}"
-publishOperationPublishFileFailed = \t* ERROR publishing file "{0}" to location
"{1}"
-publishOperationPublishTaskName = Publishing resources
-publishOperationUnpublish = DNA unpublish from server "{0}", repository
"{1}", workspace "{2}"
-publishOperationUnpublishFile = \t- Unpublished file "{0}" from location
"{1}"
-publishOperationUnpublishFileFailed = \t* ERROR unpublished file "{0}" from
location "{1}"
-publishOperationUnpublishTaskName = Unpublishing resources
-
publishPagePublishTitle = Publish the selected resources
publishPageLocationGroupTitle = Location
publishPageMissingRepositoryStatusMsg = A repository must be selected
@@ -70,7 +76,7 @@
publishPageNoAvailableWorkspacesStatusMsg = There are no workspaces available on that
server and repository
publishPageNoResourcesToPublishStatusMsg = There are no files that can be published
publishPageNoResourcesToUnpublishStatusMsg = There are no files that can be unpublished
-publishPagePublishOkStatusMsg = Choose the server, repository, and workspace where the
selected resources will be published. Then click "Finish" to execute the publish
operation.
+publishPagePublishOkStatusMsg = Choose the server, repository, and workspace where the
resources will be published. Click "Finish" to execute the publish operation.
publishPagePublishResourcesLabel = These resources will be uploaded to the specified DNA
workspace:
publishPageRecurseCheckBox = Recurse folders and projects
publishPageRecurseCheckBoxToolTip = Add all files under folders recursively under
selected projects and folders
@@ -79,26 +85,13 @@
publishPageRepositoryToolTip = The repository where the workspace is located
publishPageServerLabel = Server:
publishPageServerToolTip = The server where the repository is located
-publishPageUnpublishOkStatusMsg = Choose the server, repository, and workspace where the
selected resources will be unpublished. Then click "Finish" to execute the
unpublish operation.
+publishPageUnpublishOkStatusMsg = Choose the server, repository, and workspace where the
resources will be unpublished. Click "Finish" to execute the unpublish
operation.
publishPageUnpublishResourcesLabel = These resources will be removed from the specified
DNA workspace:
publishPageUnpublishTitle = Unpublish the selected resources
publishPageWorkspaceLabel = Workspace:
publishPageWorkspacePublishToolTip = The workspace where the resources are being
published
publishPageWorkspaceUnpublishToolTip = The workspace where the resources are being
unpublished
-publishResultsDialogErrorIncompletePublishingMsg = There was a problem publishing some or
all of the files. The publishing operation did not complete. See results below and the log
for more details. Error message: "{0}."
-publishResultsDialogErrorIncompleteUnpublishingMsg = There was a problem publishing some
or all of the files. The unpublishing operation did not complete. See results below and
the log for more details. Error message: "{0}."
-publishResultsDialogErrorPublishingMsg = There was a problem publishing some or all of
the files. See results below and the log for more details. Error message:
"{0}."
-publishResultsDialogErrorUnpublishingMsg = There was a problem publishing some or all of
the files. See results below and the log for more details. Error message:
"{0}."
-publishResultsDialogFileHeader = File
-publishResultsDialogIncompletePublishMsg = {0} file(s) were successfully published
(uploaded) to the DNA repository workspace but the publishing operation did not complete.
-publishResultsDialogIncompleteUnpublishMsg = {0} file(s) were successfully unpublished
(removed) from the DNA repository workspace but the unpublishing operation did not
complete.
-publishResultsDialogMessageHeader = Message
-publishResultsDialogPublishMsg = {0} file(s) were successfully published (uploaded) to
the DNA repository workspace.
-publishResultsDialogStatisticsMsg = There were {1} error(s), {2} info(s), and {3}
warning(s).
-publishResultsDialogTitle = Results
-publishResultsDialogUnpublishMsg = {0} file(s) were successfully unpublished (removed)
from the DNA repository workspace.
-
publishWizardPublishErrorMsg = Error Publishing
publishWizardPublishTitle = Publish
publishWizardUnpublishErrorMsg = Error Unpublishing
@@ -117,6 +110,12 @@
serverPageSavePasswordButton = Save password
serverPageSavePasswordLabel = Saved secret data is stored on your computer in a file
that's difficult, but not impossible, for an intruder to read.
serverPageSavePasswordToolTip = Indicates if the clear text password should be stored on
the local file system
+serverPageTestConnectionLabel = Validate server connection:
+serverPageTestConnectionButton = Test
+serverPageTestConnectionButtonToolTip = Try to establish a connection to the server
+serverPageTestConnectionDialogFailureMsg = Unable to connect using the specified server
properties. The server properties could be invalid or the server may be offline.
+serverPageTestConnectionDialogTitle = Test Server Connection
+serverPageTestConnectionDialogSuccessMsg = Successfully connected using the specified
server properties.
serverPageTitle = Enter Server Information
serverPageUrlLabel = URL:
serverPageUrlToolTip = The URL used to connect to the server
@@ -129,3 +128,6 @@
serverWizardEditServerTitle = Edit Server
serverWizardNewServerErrorMsg = There were errors creating a new server. See log for more
details.
serverWizardNewServerTitle = New Server
+
+testServerActionText = Connect
+testServerActionToolTip = Connect to the server identified by the abover URL, user, and
password
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -44,14 +44,14 @@
/**
* Sizes the shell to the minimum of it's current size or the width and height
display percentages.
*
- * @param shell the shell being resized if necessary and located
+ * @param shell the shell being resized (if necessary) and located
* @param widthPercentage a number between 1 and 100 indicating a percentage of the
screen size (defaults to 50 if bad value)
* @param heightPercentage a number between 1 and 100 indicating a percentage of the
screen size (defaults to 50 if bad value)
* @since 0.6
*/
- public static void sizeShellRelativeToDisplayAndCentery( Shell shell,
- int widthPercentage,
- int heightPercentage ) {
+ public static void centerAndSizeShellRelativeToDisplay( Shell shell,
+ int widthPercentage,
+ int heightPercentage ) {
if ((widthPercentage < 1) || (widthPercentage > 100)) {
widthPercentage = 50;
}
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/BasePublishingAction.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -40,8 +40,9 @@
import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
+import org.jboss.dna.web.jcr.rest.client.swt.Utils;
import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishWizard;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishJob.Type;
/**
* @since 0.6
@@ -114,9 +115,10 @@
WizardDialog dialog = new WizardDialog(shell, new PublishWizard(this.type,
resources,
Activator.getDefault().getServerManager())) {
@Override
- protected void configureShell( Shell newShell ) {
- super.configureShell(newShell);
- newShell.setImage(Activator.getDefault().getImage(DNA_IMAGE_16x));
+ protected void initializeBounds() {
+ super.initializeBounds();
+ getShell().setImage(Activator.getDefault().getImage(DNA_IMAGE_16x));
+ Utils.centerAndSizeShellRelativeToDisplay(getShell(), 75, 75);
}
};
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/PublishAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/PublishAction.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/PublishAction.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -23,7 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.actions;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishJob.Type;
/**
* The <code>PublishAction</code> controls the publishing of one or more
{@link org.eclipse.core.resources.IResource}s to a DNA
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/UnpublishAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/UnpublishAction.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/UnpublishAction.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -23,7 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.actions;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishJob.Type;
/**
* The <code>UnpublishAction</code> controls the unpublishing of one or more
{@link org.eclipse.core.resources.IResource}s from a
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/DeleteServerDialog.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/DeleteServerDialog.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/DeleteServerDialog.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -94,8 +94,8 @@
String msg;
if (this.serversBeingDeleted.size() == 1) {
- IDnaObject server = this.serversBeingDeleted.iterator().next();
- msg = RestClientI18n.deleteServerDialogOneServerMsg.text(server.getName());
+ Server server = this.serversBeingDeleted.iterator().next();
+ msg = RestClientI18n.deleteServerDialogOneServerMsg.text(server.getName(),
server.getUser());
} else {
msg =
RestClientI18n.deleteServerDialogMultipleServersMsg.text(this.serversBeingDeleted.size());
}
Deleted:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishingResultsDialog.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -1,365 +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.web.jcr.rest.client.swt.dialogs;
-
-import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.CHECKMARK_IMAGE_PATH;
-import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_IMAGE_16x;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.swt.Activator;
-import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
-import org.jboss.dna.web.jcr.rest.client.swt.Utils;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishingResults;
-
-/**
- * The <code>PublishingResultsDialog</code> displays the results of a
publishing operation.
- *
- * @since 0.6
- */
-public final class PublishingResultsDialog extends MessageDialog {
-
- //
===========================================================================================================================
- // Constants
- //
===========================================================================================================================
-
- /**
- * The table column index of the column where the file name is displayed.
- *
- * @since 0.6
- */
- private static final int FILE_COL = 0;
-
- /**
- * The table column index of the column where the status severity is displayed.
- *
- * @since 0.6
- */
- private static final int SEVERITY_COL = 1;
-
- /**
- * The table column index of the column where the error message is displayed.
- *
- * @since 0.6
- */
- private static final int MESSAGE_COL = 2;
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * An error caught during the publish operation (may be
<code>null</code>).
- *
- * @since 0.6
- */
- private Throwable error;
-
- /**
- * The results of the publishing operation.
- *
- * @since 0.6
- */
- private final PublishingResults results;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * @param parentShell the dialog parent
- * @param results the results being displayed (never <code>null</code>)
- * @since 0.6
- */
- public PublishingResultsDialog( Shell parentShell,
- PublishingResults results ) {
- super(parentShell, RestClientI18n.publishResultsDialogTitle.text(),
Activator.getDefault().getImage(DNA_IMAGE_16x), null,
- MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL}, 0);
- this.results = results;
-
- // make sure dialog is resizable
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- /**
- * @param parentShell the dialog parent
- * @param results the results being displayed (never <code>null</code>)
- * @param error an unexpected error caught during the publish operation
- * @since 0.6
- */
- public PublishingResultsDialog( Shell parentShell,
- PublishingResults results,
- Throwable error ) {
- super(parentShell, RestClientI18n.publishResultsDialogTitle.text(),
Activator.getDefault().getImage(DNA_IMAGE_16x), null,
- MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0);
- this.results = results;
- this.error = error;
-
- // make sure dialog is resizable
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- //
===========================================================================================================================
- // 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 message
- int successCount = this.results.getFiles().size() -
this.results.getErrorCount();
- boolean completed = this.results.isComplete();
-
- if (this.results.getType() == PublishOperation.Type.PUBLISH) {
- if (completed) {
- if ((this.error == null)) {
- this.message =
RestClientI18n.publishResultsDialogPublishMsg.text(successCount);
- } else {
- this.message =
RestClientI18n.publishResultsDialogErrorPublishingMsg.text(this.error.getLocalizedMessage());
- }
- } else {
- if ((this.error == null)) {
- this.message =
RestClientI18n.publishResultsDialogIncompletePublishMsg.text(successCount);
- } else {
- this.message =
RestClientI18n.publishResultsDialogErrorIncompletePublishingMsg.text(this.error.getLocalizedMessage());
- }
- }
- } else {
- if (completed) {
- if ((this.error == null)) {
- this.message =
RestClientI18n.publishResultsDialogUnpublishMsg.text(successCount);
- } else {
- this.message =
RestClientI18n.publishResultsDialogErrorUnpublishingMsg.text(this.error.getLocalizedMessage());
- }
- } else {
- if ((this.error == null)) {
- this.message =
RestClientI18n.publishResultsDialogIncompleteUnpublishMsg.text(successCount);
- } else {
- this.message =
RestClientI18n.publishResultsDialogErrorIncompleteUnpublishingMsg.text(this.error.getLocalizedMessage());
- }
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.window.Window#constrainShellSize()
- * @since 0.6
- */
- @Override
- protected void constrainShellSize() {
- super.constrainShellSize();
- Utils.sizeShellRelativeToDisplayAndCentery(getShell(), 50, 50);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
- * @since 0.6
- */
- @Override
- protected Control createCustomArea( Composite parent ) {
- Composite pnl = new Composite(parent, SWT.NONE);
- pnl.setLayout(new GridLayout());
- GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
- pnl.setLayoutData(gd);
-
- TableViewer viewer = new TableViewer(pnl, SWT.V_SCROLL | SWT.H_SCROLL |
SWT.BORDER | SWT.SINGLE | SWT.FULL_SELECTION);
- ResultsProvider provider = new ResultsProvider();
- viewer.setContentProvider(provider);
- viewer.setLabelProvider(provider);
-
- Table table = viewer.getTable();
- table.setLayout(new GridLayout());
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- TableColumn col = new TableColumn(table, SWT.LEFT);
- col.setText(RestClientI18n.publishResultsDialogFileHeader.text());
-
- col = new TableColumn(table, SWT.CENTER);
- col.setResizable(false);
-
- col = new TableColumn(table, SWT.LEFT);
- col.setText(RestClientI18n.publishResultsDialogMessageHeader.text());
-
- // populate the table
- viewer.setInput(this);
-
- // size columns
- for (TableColumn column : table.getColumns()) {
- column.pack();
- column.setWidth(column.getWidth() + 2);
- }
-
- // add statistics label
- StyledText st = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI | SWT.NO_FOCUS |
SWT.WRAP);
-
st.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- st.setCaret(null);
- gd = new GridData(GridData.FILL_BOTH);
- gd.grabExcessVerticalSpace = false;
- gd.horizontalIndent = ((GridLayout)pnl.getLayout()).horizontalSpacing * 5;
- st.setLayoutData(gd);
-
- // set message
- Object[] counts = new Object[] {this.results.getOksCount(),
this.results.getErrorCount(), this.results.getInfoCount(),
- this.results.getWarningsCount()};
- String msg = RestClientI18n.publishResultsDialogStatisticsMsg.text(counts);
- st.setText(msg);
-
- return pnl;
- }
-
- /**
- * @return the files that were involved in the publishing operation
- * @since 0.6
- */
- List<IFile> getFiles() {
- return this.results.getFiles();
- }
-
- /**
- * @param file the file whose status is being requested
- * @return the status or <code>null</code> if not found
- * @since 0.6
- */
- Status getStatus( IFile file ) {
- return this.results.getStatus(file);
- }
-
- //
===========================================================================================================================
- // Inner Class
- //
===========================================================================================================================
-
- /**
- * The <code>ResultsProvider</code> class is the label provider and
content provider for the table that is shown in the
- * dialog.
- *
- * @since 0.6
- */
- class ResultsProvider extends LabelProvider implements IStructuredContentProvider,
ITableLabelProvider {
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
- * @since 0.6
- */
- @Override
- public Image getColumnImage( Object element,
- int columnIndex ) {
- if (columnIndex == SEVERITY_COL) {
- Status status = getStatus((IFile)element);
-
- if (status.isOk()) {
- return Activator.getDefault().getImage(CHECKMARK_IMAGE_PATH);
- }
-
- return Utils.getImage(status);
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
- * @since 0.6
- */
- @Override
- public String getColumnText( Object element,
- int columnIndex ) {
- if (columnIndex == FILE_COL) {
- return ((IFile)element).getFullPath().toString();
- }
-
- if (columnIndex == MESSAGE_COL) {
- Status status = getStatus((IFile)element);
-
- if (!status.isOk()) {
- return status.getMessage();
- }
- }
-
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object[] getElements( Object inputElement ) {
- return getFiles().toArray();
- }
-
- /**
- * {@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
- }
-
- }
-
-}
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishJob.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishJob.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishJob.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -0,0 +1,342 @@
+/*
+ * 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.web.jcr.rest.client.swt.wizards;
+
+import java.io.File;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.console.ConsolePlugin;
+import org.eclipse.ui.console.IConsole;
+import org.eclipse.ui.console.IConsoleManager;
+import org.eclipse.ui.console.MessageConsole;
+import org.eclipse.ui.console.MessageConsoleStream;
+import org.jboss.dna.common.util.CheckArg;
+import org.jboss.dna.web.jcr.rest.client.ServerManager;
+import org.jboss.dna.web.jcr.rest.client.Status;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+import org.jboss.dna.web.jcr.rest.client.swt.Activator;
+import org.jboss.dna.web.jcr.rest.client.swt.IUiConstants;
+import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
+
+/**
+ * The <code>PublishJob</code> publishes or unpublishes one or more files
using the {@link ServerManager}.
+ *
+ * @since 0.6
+ */
+public final class PublishJob extends Job {
+
+ //
===========================================================================================================================
+ // Constants
+ //
===========================================================================================================================
+
+ /**
+ * The job type.
+ *
+ * @since 0.6
+ */
+ public enum Type {
+ /**
+ * Indicates a publish job.
+ *
+ * @since 0.6
+ */
+ PUBLISH,
+
+ /**
+ * Indicates an unpublish job.
+ *
+ * @since 0.6
+ */
+ UNPUBLISH
+ }
+
+ /**
+ * The name of the message console that is written to.
+ *
+ * @since 0.6
+ */
+ private static final String CONSOLE_NAME =
RestClientI18n.publishJobConsoleName.text();
+
+ //
===========================================================================================================================
+ // Class Methods
+ //
===========================================================================================================================
+
+ /**
+ * @param type the job type (never <code>null</code>)
+ * @return the job name
+ * @since 0.6
+ */
+ private static String getJobName( Type type ) {
+ CheckArg.isNotNull(type, "type"); //$NON-NLS-1$
+
+ if (Type.PUBLISH == type) {
+ return RestClientI18n.publishJobPublishName.text();
+ }
+
+ // unpublish
+ return RestClientI18n.publishJobUnpublishName.text();
+ }
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The files being published or unpublished.
+ *
+ * @since 0.6
+ */
+ private final List<IFile> files;
+
+ /**
+ * The job type.
+ *
+ * @since 0.6
+ */
+ private final Type type;
+
+ /**
+ * The workspace to use when publishing or unpublishing.
+ *
+ * @since 0.6
+ */
+ private final Workspace workspace;
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * @param type the job type (never <code>null</code>)
+ * @param files the files being published or unpublished (never
<code>null</code>)
+ * @param workspace the workspace to use when publishing or unpublishing (never
<code>null</code>)
+ * @since 0.6
+ */
+ public PublishJob( Type type,
+ List<IFile> files,
+ Workspace workspace ) {
+ super(getJobName(type));
+
+ CheckArg.isNotNull(files, "files"); //$NON-NLS-1$
+
+ this.type = type;
+ this.files = files;
+ this.workspace = workspace;
+
+ setUser(true); // allow user to run in background
+ }
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * @return <code>true</code> if a publishing job
+ * @since 0.6
+ */
+ private boolean isPublishing() {
+ return (this.type == Type.PUBLISH);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
+ * @since 0.6
+ */
+ @Override
+ protected IStatus run( IProgressMonitor monitor ) {
+ assert (this.workspace != null);
+ long startTime = System.currentTimeMillis();
+
+ try {
+ String name = (isPublishing() ?
RestClientI18n.publishJobPublishTaskName.text() :
RestClientI18n.publishJobUnpublishTaskName.text());
+ monitor.beginTask(name, this.files.size());
+ monitor.setTaskName(name);
+
+ // write initial message to console
+ if (isPublishing()) {
+
writeToConsole(RestClientI18n.publishJobPublish.text(this.workspace.getServer().getUrl(),
+
this.workspace.getRepository().getName(),
+
this.workspace.getName(),
+
this.files.size()));
+ } else {
+
writeToConsole(RestClientI18n.publishJobUnpublish.text(this.workspace.getServer().getUrl(),
+
this.workspace.getRepository().getName(),
+
this.workspace.getName(),
+
this.files.size()));
+ }
+
+ // process the files
+ int numProcessed = 0;
+
+ for (IFile eclipseFile : this.files) {
+ if (monitor.isCanceled()) {
+ String msg = null;
+
+ if (isPublishing()) {
+ msg =
RestClientI18n.publishJobPublishCanceledMsg.text(this.workspace.getServer().getUrl(),
+
this.workspace.getRepository().getName(),
+
this.workspace.getName(),
+
numProcessed,
+
this.files.size());
+ } else {
+ msg =
RestClientI18n.publishJobUnpublishCanceledMsg.text(this.workspace.getServer().getUrl(),
+
this.workspace.getRepository().getName(),
+
this.workspace.getName(),
+
numProcessed,
+
this.files.size());
+ }
+
+ writeToConsole(msg); // write cancel msg to console
+ throw new InterruptedException(msg);
+ }
+
+ File file = eclipseFile.getLocation().toFile();
+ Status status = null;
+
+ if (isPublishing()) {
+ status =
Activator.getDefault().getServerManager().publish(this.workspace,
+
eclipseFile.getFullPath().toString(),
+ file);
+ } else {
+ status =
Activator.getDefault().getServerManager().unpublish(this.workspace,
+
eclipseFile.getFullPath().toString(),
+ file);
+ }
+
+ ++numProcessed;
+ monitor.worked(1);
+
+ // write success msg to console
+ writeToConsole(file, eclipseFile.getParent().getFullPath().toString(),
status);
+ }
+
+ return org.eclipse.core.runtime.Status.OK_STATUS;
+ } catch (Exception e) {
+ String msg = null;
+
+ if (e instanceof InterruptedException) {
+ msg = e.getLocalizedMessage();
+ } else {
+ msg = RestClientI18n.publishJobUnexpectedErrorMsg.text();
+ }
+
+ return new org.eclipse.core.runtime.Status(IStatus.ERROR,
IUiConstants.PLUGIN_ID, msg, e);
+ } finally {
+ monitor.done();
+ // add done msg
+ // TODO need to format this duration better
+ long duration = System.currentTimeMillis() - startTime;
+
+ if (isPublishing()) {
+
writeToConsole(RestClientI18n.publishJobPublishFinishedMsg.text(this.workspace.getServer().getUrl(),
+
this.workspace.getRepository().getName(),
+
this.workspace.getName(),
+
duration));
+ } else {
+
writeToConsole(RestClientI18n.publishJobUnpublishFinishedMsg.text(this.workspace.getServer().getUrl(),
+
this.workspace.getRepository().getName(),
+
this.workspace.getName(),
+
duration));
+ }
+ }
+ }
+
+ /**
+ * @param file the file involved in the publishing operation
+ * @param workspacePath the path in the workspace where the file is located
+ * @param status the status of the publishing operation
+ * @since 0.6
+ */
+ private void writeToConsole( File file,
+ String workspacePath,
+ Status status ) {
+ String msg = null;
+
+ if (status.isOk()) {
+ if (isPublishing()) {
+ msg = RestClientI18n.publishJobPublishFile.text(file.getAbsolutePath(),
workspacePath);
+ } else {
+ msg = RestClientI18n.publishJobUnpublishFile.text(file.getAbsolutePath(),
workspacePath);
+ }
+ } else if (status.isError()) {
+ if (isPublishing()) {
+ msg =
RestClientI18n.publishJobPublishFileFailed.text(file.getAbsolutePath(), workspacePath);
+ } else {
+ msg =
RestClientI18n.publishJobUnpublishFileFailed.text(file.getAbsolutePath(), workspacePath);
+ }
+ } else if (status.isWarning()) {
+ if (isPublishing()) {
+ msg =
RestClientI18n.publishJobPublishFileWarning.text(status.getMessage());
+ } else {
+ msg =
RestClientI18n.publishJobUnpublishFileWarning.text(status.getMessage());
+ }
+ } else if (status.isInfo()) {
+ if (isPublishing()) {
+ msg =
RestClientI18n.publishJobPublishFileInfo.text(status.getMessage());
+ } else {
+ msg =
RestClientI18n.publishJobUnpublishFileInfo.text(status.getMessage());
+ }
+ }
+
+ // TODO create hyperlink in console for the file
+ writeToConsole(msg);
+ }
+
+ /**
+ * @param message the message being written to the DNA console
+ * @since 0.6
+ */
+ private void writeToConsole( String message ) {
+ MessageConsole console = null;
+ IConsoleManager consoleMgr = ConsolePlugin.getDefault().getConsoleManager();
+ IConsole[] consoles = consoleMgr.getConsoles();
+
+ // see if DNA console already exists
+ for (int i = 0; i < consoles.length; ++i) {
+ if (CONSOLE_NAME.equals(consoles[i].getName())) {
+ console = (MessageConsole)consoles[i];
+ break;
+ }
+ }
+
+ // create DNA console if necessary
+ if (console == null) {
+ console = new MessageConsole(CONSOLE_NAME, null);
+ consoleMgr.addConsoles(new IConsole[] {console});
+ }
+
+ // show and focus console view
+ console.activate();
+
+ // write message
+ MessageConsoleStream out = console.newMessageStream();
+ out.println(message);
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishJob.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishOperation.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -1,282 +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.web.jcr.rest.client.swt.wizards;
-
-import java.io.File;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.ui.console.ConsolePlugin;
-import org.eclipse.ui.console.IConsole;
-import org.eclipse.ui.console.IConsoleManager;
-import org.eclipse.ui.console.MessageConsole;
-import org.eclipse.ui.console.MessageConsoleStream;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.web.jcr.rest.client.ServerManager;
-import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
-import org.jboss.dna.web.jcr.rest.client.swt.Activator;
-import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
-
-/**
- * The <code>PublishOperation</code> publishes or unpublishes one or more
files using the {@link ServerManager}.
- *
- * @since 0.6
- */
-public final class PublishOperation {
-
- //
===========================================================================================================================
- // Constants
- //
===========================================================================================================================
-
- /**
- * The operation type.
- *
- * @since 0.6
- */
- public enum Type {
- /**
- * Indicates a publish operation.
- *
- * @since 0.6
- */
- PUBLISH,
-
- /**
- * Indicates an unpublish operation.
- *
- * @since 0.6
- */
- UNPUBLISH
- }
-
- /**
- * The name of the message console that is written to.
- *
- * @since 0.6
- */
- private static final String CONSOLE_NAME =
RestClientI18n.publishOperationConsoleName.text();
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * The files being published or unpublished.
- *
- * @since 0.6
- */
- private final List<IFile> files;
-
- /**
- * The operation type.
- *
- * @since 0.6
- */
- private final Type type;
-
- /**
- * The results of the publishing operation.
- *
- * @since 0.6
- */
- private PublishingResults results;
-
- /**
- * The workspace to use when publishing or unpublishing.
- *
- * @since 0.6
- */
- private final Workspace workspace;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * @param type the operation type (never <code>null</code>)
- * @param files the files being published or unpublished (never
<code>null</code>)
- * @param workspace the workspace to use when publishing or unpublishing (never
<code>null</code>)
- * @since 0.6
- */
- public PublishOperation( Type type,
- List<IFile> files,
- Workspace workspace ) {
- CheckArg.isNotNull(type, "type"); //$NON-NLS-1$
- CheckArg.isNotNull(files, "files"); //$NON-NLS-1$
- CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
-
- this.type = type;
- this.files = files;
- this.workspace = workspace;
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * @return the results of the publishing operation or <code>null</code>
if operation has not been executed
- * @since 0.6
- */
- public PublishingResults getResults() {
- return this.results;
- }
-
- /**
- * @return <code>true</code> if a publishing operation
- * @since 0.6
- */
- public boolean isPublishing() {
- return (this.type == Type.PUBLISH);
- }
-
- /**
- * @return <code>true</code> if an unpublishing operation
- * @since 0.6
- */
- public boolean isUnpublishing() {
- return this.type == Type.UNPUBLISH;
- }
-
- /**
- * @param monitor the progress monitor
- * @throws InvocationTargetException if an unexpected error occurs
- * @throws InterruptedException if the user cancels the monitor
- * @since 0.6
- */
- public void execute( IProgressMonitor monitor ) throws InvocationTargetException,
InterruptedException {
- assert (this.workspace != null);
-
- this.results = new PublishingResults(this.type, this.files);
-
- try {
- String name = (isPublishing() ?
RestClientI18n.publishOperationPublishTaskName.text() :
RestClientI18n.publishOperationUnpublishTaskName.text());
- monitor.beginTask(name, this.files.size());
- monitor.setTaskName(name);
-
- // write initial message to console
- if (isPublishing()) {
-
writeToConsole(RestClientI18n.publishOperationPublish.text(this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName()));
- } else {
-
writeToConsole(RestClientI18n.publishOperationUnpublish.text(this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName()));
- }
-
- for (IFile eclipseFile : this.files) {
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
-
- File file = eclipseFile.getLocation().toFile();
- Status status = null;
-
- if (isPublishing()) {
- status =
Activator.getDefault().getServerManager().publish(this.workspace,
-
eclipseFile.getFullPath().toString(),
- file);
- } else {
- status =
Activator.getDefault().getServerManager().unpublish(this.workspace,
-
eclipseFile.getFullPath().toString(),
- file);
- }
-
- monitor.worked(1);
- this.results.addStatus(status);
-
- // write to console
- writeToConsole(file, eclipseFile.getParent().getFullPath().toString(),
status);
- }
-
- // add a gap before next console message
- writeToConsole("\n"); //$NON-NLS-1$
- } catch (InterruptedException e) {
- throw e;
- } catch (Exception e) {
- throw new InvocationTargetException(e);
- } finally {
- results.closeOut();
- monitor.done();
- }
- }
-
- /**
- * @param file the file involved in the publishing operation
- * @param workspacePath the path in the workspace where the file is located
- * @param status the status of the publishing operation
- * @since 0.6
- */
- private void writeToConsole( File file,
- String workspacePath,
- Status status ) {
- String msg = null;
-
- if (status.isError()) {
- msg = (isPublishing() ?
RestClientI18n.publishOperationPublishFileFailed.text(file.getAbsolutePath(),
workspacePath)
- :
RestClientI18n.publishOperationUnpublishFileFailed.text(file.getAbsolutePath(),
workspacePath));
- } else {
- msg = (isPublishing() ?
RestClientI18n.publishOperationPublishFile.text(file.getAbsolutePath(), workspacePath)
- :
RestClientI18n.publishOperationUnpublishFile.text(file.getAbsolutePath(),
workspacePath));
- }
-
- // TODO create hyperlink in console for the file
- writeToConsole(msg);
- }
-
- /**
- * @param message the message being written to the DNA console
- * @since 0.6
- */
- private void writeToConsole( String message ) {
- MessageConsole console = null;
- IConsoleManager consoleMgr = ConsolePlugin.getDefault().getConsoleManager();
- IConsole[] consoles = consoleMgr.getConsoles();
-
- // see if DNA console already exists
- for (int i = 0; i < consoles.length; ++i) {
- if (CONSOLE_NAME.equals(consoles[i].getName())) {
- console = (MessageConsole)consoles[i];
- break;
- }
- }
-
- // create DNA console if necessary
- if (console == null) {
- console = new MessageConsole(CONSOLE_NAME, null);
- consoleMgr.addConsoles(new IConsole[] {console});
- }
-
- // show and focus console view
- console.activate();
-
- // write message
- MessageConsoleStream out = console.newMessageStream();
- out.println(message);
- }
-
-}
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -63,7 +63,7 @@
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
import org.jboss.dna.web.jcr.rest.client.swt.actions.NewServerAction;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishJob.Type;
/**
* The <code>PublishPage</code> is a UI for publishing or unpublishing one or
more files to a DNA repository.
@@ -280,13 +280,6 @@
private List<IFile> files;
/**
- * The method in control of registering/unregistering combobox listners or
<code>null</code>.
- *
- * @since 0.6
- */
- private String listenerControlLock = null;
-
- /**
* The control containing all the files being published or unpublished.
*
* @since 0.6
@@ -376,8 +369,7 @@
public PublishPage( Type type,
List<IResource> resources ) throws CoreException {
super(PublishPage.class.getSimpleName());
- setTitle((type == Type.PUBLISH) ? RestClientI18n.publishPagePublishTitle.text()
- :
RestClientI18n.publishPageUnpublishTitle.text());
+ setTitle((type == Type.PUBLISH) ? RestClientI18n.publishPagePublishTitle.text() :
RestClientI18n.publishPageUnpublishTitle.text());
setPageComplete(false);
this.type = type;
@@ -530,7 +522,6 @@
chkRecurse.removeSelectionListener(this);
}
});
-
}
}
@@ -548,6 +539,12 @@
constructResourcesPanel(pnlMain);
setControl(pnlMain);
+ // add combobox listeners
+ this.cbxRepository.addModifyListener(this);
+ this.cbxServer.addModifyListener(this);
+ this.cbxWorkspace.addModifyListener(this);
+
+ // load the UI with data
refreshServers();
}
@@ -577,8 +574,7 @@
* @since 0.6
*/
void updateInitialMessage() {
- String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
- :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
+ String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text() :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
if (msg.equals(getMessage())) {
updateState();
@@ -633,8 +629,12 @@
*/
void handleRepositoryModified() {
int index = this.cbxRepository.getSelectionIndex();
- this.repository = this.repositories.get(index);
+ // make sure there is a selection
+ if (index != -1) {
+ this.repository = this.repositories.get(index);
+ }
+
// clear loaded workspaces
refreshWorkspaces();
@@ -663,23 +663,14 @@
* @since 0.6
*/
void handleWorkspaceModified() {
- this.workspace = this.workspaces.get(this.cbxWorkspace.getSelectionIndex());
- updateState();
- }
+ int index = this.cbxWorkspace.getSelectionIndex();
- /**
- * Installs the combobox listeners.
- *
- * @param listenerControlLock the method in control of registering/unregistering
combobox listeners
- * @since 0.6
- */
- private void installLocationListeners( String listenerControlLock ) {
- if ((this.listenerControlLock == null) ||
this.listenerControlLock.equals(listenerControlLock)) {
- this.cbxRepository.addModifyListener(this);
- this.cbxServer.addModifyListener(this);
- this.cbxWorkspace.addModifyListener(this);
- this.listenerControlLock = null;
+ // make sure there is a selection
+ if (index != -1) {
+ this.workspace = this.workspaces.get(index);
}
+
+ updateState();
}
/**
@@ -740,7 +731,6 @@
* @since 0.6
*/
private void refreshRepositories() {
- final String LOCK_ID = "refreshRepositories"; //$NON-NLS-1$
this.repository = null;
if (this.server == null) {
@@ -759,9 +749,6 @@
}
}
- // uninstall listeners to prevent handling events
- uninstallLocationListeners(LOCK_ID);
-
// clear items
this.cbxRepository.removeAll();
@@ -794,9 +781,6 @@
// must reload workspaces
refreshWorkspaces();
-
- // reinstall listening
- installLocationListeners(LOCK_ID);
}
/**
@@ -806,13 +790,9 @@
* @since 0.6
*/
void refreshServers() {
- final String LOCK_ID = "refreshServers"; //$NON-NLS-1$
this.server = null;
this.servers = new ArrayList<Server>(getServerManager().getServers());
- // uninstall listeners to prevent handling events
- uninstallLocationListeners(LOCK_ID);
-
if (this.servers.size() == 0) {
// disable control if necessary
if (this.cbxServer.getEnabled()) {
@@ -841,9 +821,6 @@
// must reload repositories
refreshRepositories();
-
- // reinstall listening
- installLocationListeners(LOCK_ID);
}
/**
@@ -852,7 +829,6 @@
* @since 0.6
*/
private void refreshWorkspaces() {
- final String LOCK_ID = "refreshWorkspaces"; //$NON-NLS-1$
this.workspace = null;
if (this.repository == null) {
@@ -871,9 +847,6 @@
}
}
- // uninstall listeners to prevent handling events
- uninstallLocationListeners(LOCK_ID);
-
// clear items
this.cbxWorkspace.removeAll();
@@ -903,9 +876,6 @@
this.cbxWorkspace.setEnabled(true);
}
}
-
- // reinstall listening
- installLocationListeners(LOCK_ID);
}
/**
@@ -953,11 +923,10 @@
// set initial message
if (this.status.isOk()) {
- String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
- :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
- setMessage(msg);
+ String msg = ((this.type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text() :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
+ setMessage(msg, IMessageProvider.NONE);
} else {
- setErrorMessage(this.status.getMessage());
+ setMessage(this.status.getMessage(), IMessageProvider.ERROR);
}
}
}
@@ -983,22 +952,6 @@
}
/**
- * Uninstalls the combobox listeners.
- *
- * @param listenerControlLock the method in control of registering/unregistering
combobox listeners
- * @since 0.6
- */
- private void uninstallLocationListeners( String listenerControlLock ) {
- if (this.listenerControlLock == null) {
- this.listenerControlLock = listenerControlLock;
- this.cbxRepository.removeModifyListener(this);
- this.cbxServer.removeModifyListener(this);
- this.cbxWorkspace.removeModifyListener(this);
- this.listenerControlLock = listenerControlLock;
- }
- }
-
- /**
* Updates message, message icon, and OK button enablement based on validation
results
*
* @since 0.6
@@ -1012,14 +965,14 @@
// update page message
if (this.status.isError()) {
- setErrorMessage(this.status.getMessage());
+ setMessage(this.status.getMessage(), IMessageProvider.ERROR);
} else {
if (this.status.isWarning()) {
setMessage(this.status.getMessage(), IMessageProvider.WARNING);
} else if (this.status.isInfo()) {
setMessage(this.status.getMessage(), IMessageProvider.INFORMATION);
} else {
- setMessage(this.status.getMessage());
+ setMessage(this.status.getMessage(), IMessageProvider.NONE);
}
}
}
@@ -1034,24 +987,19 @@
Severity severity = Severity.ERROR;
if ((this.resources == null) || this.resources.isEmpty() || this.files.isEmpty())
{
- msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPageNoResourcesToPublishStatusMsg.text()
- :
RestClientI18n.publishPageNoResourcesToUnpublishStatusMsg.text());
+ msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPageNoResourcesToPublishStatusMsg.text() :
RestClientI18n.publishPageNoResourcesToUnpublishStatusMsg.text());
} else if (this.server == null) {
int count = this.cbxServer.getItemCount();
- msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableServersStatusMsg.text()
- :
RestClientI18n.publishPageMissingServerStatusMsg.text());
+ msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableServersStatusMsg.text() :
RestClientI18n.publishPageMissingServerStatusMsg.text());
} else if (this.repository == null) {
int count = this.cbxRepository.getItemCount();
- msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableRepositoriesStatusMsg.text()
- :
RestClientI18n.publishPageMissingRepositoryStatusMsg.text());
+ msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableRepositoriesStatusMsg.text() :
RestClientI18n.publishPageMissingRepositoryStatusMsg.text());
} else if (this.workspace == null) {
int count = this.cbxWorkspace.getItemCount();
- msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableWorkspacesStatusMsg.text()
- :
RestClientI18n.publishPageMissingWorkspaceStatusMsg.text());
+ msg = ((count == 0) ?
RestClientI18n.publishPageNoAvailableWorkspacesStatusMsg.text() :
RestClientI18n.publishPageMissingWorkspaceStatusMsg.text());
} else {
severity = Severity.OK;
- msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text()
- :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
+ msg = ((type == Type.PUBLISH) ?
RestClientI18n.publishPagePublishOkStatusMsg.text() :
RestClientI18n.publishPageUnpublishOkStatusMsg.text());
}
this.status = new Status(severity, msg, null);
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishWizard.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -24,25 +24,18 @@
package org.jboss.dna.web.jcr.rest.client.swt.wizards;
import static
org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_WIZARD_BANNER_IMAGE_PATH;
-import java.lang.reflect.InvocationTargetException;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.wizard.Wizard;
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.web.jcr.rest.client.ServerManager;
-import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Status.Severity;
import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
import org.jboss.dna.web.jcr.rest.client.swt.Activator;
import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
-import org.jboss.dna.web.jcr.rest.client.swt.dialogs.PublishingResultsDialog;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
+import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishJob.Type;
/**
* @since 0.6
@@ -96,8 +89,7 @@
this.page = new PublishPage(type, resources);
this.serverManager = serverManager;
- setWindowTitle((type == Type.PUBLISH) ?
RestClientI18n.publishWizardPublishTitle.text()
- :
RestClientI18n.publishWizardUnpublishTitle.text());
+ setWindowTitle((type == Type.PUBLISH) ?
RestClientI18n.publishWizardPublishTitle.text() :
RestClientI18n.publishWizardUnpublishTitle.text());
setDefaultPageImageDescriptor(Activator.getDefault().getImageDescriptor(DNA_WIZARD_BANNER_IMAGE_PATH));
}
@@ -156,50 +148,11 @@
*/
@Override
public boolean performFinish() {
- Throwable error = null;
Workspace workspace = this.page.getWorkspace();
List<IFile> files = this.page.getFiles();
- final PublishOperation operation = new PublishOperation(this.type, files,
workspace);
+ PublishJob job = new PublishJob(this.type, files, workspace);
+ job.schedule();
- // display progress dialog
- IRunnableWithProgress op = new IRunnableWithProgress() {
- @Override
- public void run( IProgressMonitor monitor ) throws InvocationTargetException,
InterruptedException {
- operation.execute(monitor);
- }
- };
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
-
- try {
- dialog.run(true, true, op);
- } catch (Throwable e) {
- if (!(e instanceof InterruptedException)) {
- error = e;
-
- if (e instanceof InvocationTargetException) {
- error = ((InvocationTargetException)e).getTargetException();
- }
-
- String message = (operation.isPublishing() ?
RestClientI18n.publishWizardPublishErrorMsg.text()
- :
RestClientI18n.publishWizardUnpublishErrorMsg.text());
- Activator.getDefault().log(new Status(Severity.ERROR, message, error));
- }
- } finally {
- dialog.getProgressMonitor().done();
-
- // show results
- PublishingResultsDialog resultsDialog = null;
-
- if (error == null) {
- resultsDialog = new PublishingResultsDialog(getShell(),
operation.getResults());
- } else {
- resultsDialog = new PublishingResultsDialog(getShell(),
operation.getResults(), error);
- }
-
- resultsDialog.open();
- }
-
return true;
}
Deleted:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishingResults.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -1,264 +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.web.jcr.rest.client.swt.wizards;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.web.jcr.rest.client.Status;
-import org.jboss.dna.web.jcr.rest.client.Status.Severity;
-import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
-import org.jboss.dna.web.jcr.rest.client.swt.wizards.PublishOperation.Type;
-
-/**
- * @since 0.6
- */
-public final class PublishingResults {
-
- //
===========================================================================================================================
- // Constants
- //
===========================================================================================================================
-
- /**
- * Status indicating the file was not attempted to be published.
- *
- * @since 0.6
- */
- private static final Status PUBLISH_NOT_ATTEMPTED_STATUS = new Status(Severity.INFO,
-
RestClientI18n.publishingResultsPublishNotAttemptedMsg.text(),
- null);
-
- /**
- * Status indicating the file was not attempted to be published.
- *
- * @since 0.6
- */
- private static final Status UNPUBLISH_NOT_ATTEMPTED_STATUS = new
Status(Severity.INFO,
-
RestClientI18n.publishingResultsUnpublishNotAttemptedMsg.text(),
- null);
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * Indicates if a status for each file has been added.
- *
- * @since 0.6
- */
- private boolean complete;
-
- /**
- * The files involved in the publishing operation.
- *
- * @since 0.6
- */
- private final List<IFile> files;
-
- /**
- * The number of {@link Status status} objects that have an {@link Severity#ERROR
error} severity.
- *
- * @since 0.6
- */
- private int numErrors;
-
- /**
- * The number of {@link Status status} objects that have an {@link Severity#INFO
info} severity.
- *
- * @since 0.6
- */
- private int numInfos;
-
- /**
- * The number of {@link Status status} objects that have an {@link Severity#OK OK}
severity.
- *
- * @since 0.6
- */
- private int numOks;
-
- /**
- * The number of {@link Status status} objects that have a {@link Severity#WARNING
warning} severity.
- *
- * @since 0.6
- */
- private int numWarnings;
-
- /**
- * When complete there will be one status for each file.
- *
- * @since 0.6
- */
- private final List<Status> statuses;
-
- /**
- * The type of publishing operation these results pertain to.
- *
- * @since 0.6
- */
- private final Type type;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * @param type the type of publishing operation (never
<code>null</code>)
- * @param files the files involved in the publishing operation (never
<code>null</code>)
- * @since 0.6
- */
- public PublishingResults( Type type,
- List<IFile> files ) {
- CheckArg.isNotNull(type, "type"); //$NON-NLS-1$
- CheckArg.isNotNull(files, "files"); //$NON-NLS-1$
-
- this.type = type;
- this.files = files;
- this.statuses = new ArrayList<Status>(this.files.size());
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * @param status the status being added (never <code>null</code>)
- * @throws RuntimeException if the number of status objects is greater than the
number of files
- * @since 0.6
- */
- public void addStatus( Status status ) {
- CheckArg.isNotNull(status, "status"); //$NON-NLS-1$
-
- if (this.files.size() < (this.statuses.size() + 1)) {
- throw new
RuntimeException(RestClientI18n.publishingResultsTooManyResultsMsg.text());
- }
-
- this.statuses.add(status);
-
- if (status.isError()) ++this.numErrors;
- else if (status.isInfo()) ++this.numInfos;
- else if (status.isOk()) ++this.numOks;
- else if (status.isWarning()) ++this.numWarnings;
- else throw new
RuntimeException(RestClientI18n.publishingResultsUnknownSeverityMsg.text(status.getSeverity()));
-
- this.complete = (this.files.size() == this.statuses.size());
- }
-
- /**
- * Finalizes the results by making sure there is one status object for each file. No
need to call if all files have a status.
- *
- * @since 0.6
- */
- public void closeOut() {
- if (this.files.size() != this.statuses.size()) {
- Status status = ((Type.PUBLISH == this.type) ? PUBLISH_NOT_ATTEMPTED_STATUS :
UNPUBLISH_NOT_ATTEMPTED_STATUS);
-
- for (int count = this.files.size() - this.statuses.size(), i = 0; i <
count; ++i) {
- addStatus(status);
- }
- }
- }
-
- /**
- * @return the number of errors in the result
- * @since 0.6
- */
- public int getErrorCount() {
- return this.numErrors;
- }
-
- /**
- * @return the files involved in the publishing operation (never
<code>null</code>)
- * @since 0.6
- */
- public List<IFile> getFiles() {
- return this.files;
- }
-
- /**
- * @return the number of infos in the result
- * @since 0.6
- */
- public int getInfoCount() {
- return this.numInfos;
- }
-
- /**
- * @return the number of OKs in the result
- * @since 0.6
- */
- public int getOksCount() {
- return this.numOks;
- }
-
- /**
- * @param file the file whose status is being requested (never
<code>null</code>)
- * @return the status or <code>null</code> if there is no status for the
specified file
- * @since 0.6
- */
- public Status getStatus( IFile file ) {
- CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
- int index = this.files.indexOf(file);
-
- if (index == -1) {
- return null;
- }
-
- return this.statuses.get(index);
- }
-
- /**
- * @return the status of each file involved in the publishing operation (never
<code>null</code> but can be incomplete)
- * @see #isComplete()
- * @since 0.6
- */
- public List<Status> getStatuses() {
- return this.statuses;
- }
-
- /**
- * @return the publishing operation type (never <code>null</code>)
- * @since 0.6
- */
- public Type getType() {
- return this.type;
- }
-
- /**
- * @return the number of warnings in the result
- * @since 0.6
- */
- public int getWarningsCount() {
- return this.numWarnings;
- }
-
- /**
- * @return <code>true</code> if there is one status object for each file
- * @since 0.6
- */
- public boolean isComplete() {
- return this.complete;
- }
-
-}
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java 2009-08-14
16:29:03 UTC (rev 1161)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/ServerPage.java 2009-08-14
19:19:06 UTC (rev 1162)
@@ -23,14 +23,18 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.wizards;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -55,11 +59,11 @@
//
===========================================================================================================================
/**
- * Indicates if the password should be persisted.
+ * The button used to test the connection to the server. Should only be enabled when
server properties are valid.
*
* @since 0.6
*/
- private boolean savePassword;
+ private Button btnTestConnection;
/**
* The user password needed to login to the server.
@@ -69,6 +73,13 @@
private String password;
/**
+ * Indicates if the password should be persisted.
+ *
+ * @since 0.6
+ */
+ private boolean savePassword;
+
+ /**
* The server being editor or <code>null</code> if creating a new
server.
*
* @since 0.6
@@ -232,6 +243,34 @@
}
}
+ private void constructTestConnectionPanel( Composite parent ) {
+ Composite pnl = new Composite(parent, SWT.NONE);
+ pnl.setLayout(new GridLayout(2, false));
+ pnl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ Label lbl = new Label(pnl, SWT.LEFT);
+ lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ lbl.setText(RestClientI18n.serverPageTestConnectionLabel.text());
+
+ this.btnTestConnection = new Button(pnl, SWT.PUSH);
+
this.btnTestConnection.setText(RestClientI18n.serverPageTestConnectionButton.text());
+
this.btnTestConnection.setToolTipText(RestClientI18n.serverPageTestConnectionButtonToolTip.text());
+
+ // add margins to the side of the text
+ GridData gd = new GridData(SWT.LEFT, SWT.CENTER, false, false);
+ int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ Point minSize = this.btnTestConnection.computeSize(SWT.DEFAULT, SWT.DEFAULT,
true);
+ gd.widthHint = Math.max(widthHint, minSize.x + 10);
+ this.btnTestConnection.setLayoutData(gd);
+
+ this.btnTestConnection.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleTestConnection();
+ }
+ });
+ }
+
private void constructUrlPanel( Composite parent ) {
Composite pnl = new Composite(parent, SWT.NONE);
pnl.setLayout(new GridLayout(2, false));
@@ -270,6 +309,7 @@
pnlMain.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
constructUrlPanel(pnlMain);
constructAuthenticationPanel(pnlMain);
+ constructTestConnectionPanel(pnlMain);
setControl(pnlMain);
}
@@ -292,7 +332,7 @@
* @return the server manager obtained from the wizard
* @since 0.6
*/
- private ServerManager getServerManager() {
+ ServerManager getServerManager() {
return ((ServerWizard)getWizard()).getServerManager();
}
@@ -316,6 +356,34 @@
}
/**
+ * Tests the connection of the server specified by the properties entered on this
page. Precondition is that server properties
+ * are valid.
+ *
+ * @since 0.6
+ */
+ void handleTestConnection() {
+ final Server server = getServer();
+ final boolean[] success = new boolean[1];
+
+ BusyIndicator.showWhile(null, new Runnable() {
+ @Override
+ public void run() {
+ success[0] = getServerManager().ping(server).isOk();
+ }
+ });
+
+ if (success[0]) {
+ MessageDialog.openInformation(getShell(),
+
RestClientI18n.serverPageTestConnectionDialogTitle.text(),
+
RestClientI18n.serverPageTestConnectionDialogSuccessMsg.text());
+ } else {
+ MessageDialog.openError(getShell(),
+
RestClientI18n.serverPageTestConnectionDialogTitle.text(),
+
RestClientI18n.serverPageTestConnectionDialogFailureMsg.text());
+ }
+ }
+
+ /**
* Handler for when the URL control value is modified
*
* @param newUrl the new URL value
@@ -376,8 +444,9 @@
// get the current status
validate();
- // update OK/Finish button enablement
+ // update OK/Finish button and test button enablement
setPageComplete(!this.status.isError());
+ this.btnTestConnection.setEnabled(isPageComplete());
// update message
if (this.status.isError()) {