Author: elvisisking
Date: 2009-08-31 09:46:22 -0400 (Mon, 31 Aug 2009)
New Revision: 1182
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/blank.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/DnaResourceHelper.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ReconnectToServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ShowPublishedLocationsAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishedLocationsDialog.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaMessageConsole.java
Removed:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.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/plugin.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
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/dialogs/DeleteServerDialog.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java
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/PublishPage.java
Log:
Created a show published locations action and dialog that shows the workspaces the
selected file has been published to. The dialog also allows the user to copy the workspace
URL where the selected file is published at. The published locations are persisted across
sessions. Refactored the content/label provider name from ServerContentProvider to
DnaContentProvider. Refactored the DnaMessageConsole to be its own class. Added a job ID
to all console messages. Added refresh (now called reconnect) to the context menu of the
server view.
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/dna-web-jcr-rest-client-0.6-SNAPSHOT-jar-with-dependencies.jar
===================================================================
(Binary files differ)
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/blank.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/blank.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.properties 2009-08-28 15:55:28
UTC (rev 1181)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.properties 2009-08-31 13:46:22
UTC (rev 1182)
@@ -29,4 +29,5 @@
dnaCategory = DNA
publishAction.label = Publish
serverView = DNA Servers
+showPublishedLocationsAction.label = Show Published Locations
unpublishAction.label = Unpublish
\ No newline at end of file
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml 2009-08-28 15:55:28 UTC (rev
1181)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml 2009-08-31 13:46:22 UTC (rev
1182)
@@ -17,6 +17,22 @@
</separator>
</menu>
+ <!-- Show Published Locations action -->
+ <action
+
id="org.jboss.dna.web.jcr.rest.client.swt.showPublishedLocationsAction"
+ label="%showPublishedLocationsAction.label"
+
class="org.jboss.dna.web.jcr.rest.client.swt.actions.ShowPublishedLocationsAction"
+ icon="icons/views/blank.gif"
+
menubarPath="org.jboss.dna.web.jcr.rest.client.swt.contextMenu/group1"
+ enablesFor="1">
+ <enablement>
+ <and>
+ <objectClass name="org.eclipse.core.resources.IFile"
/>
+ <objectState name="persistentProperty"
value="org.jboss.dna.web.jcr.rest.client.swt.publishedIn" />
+ </and>
+ </enablement>
+ </action>
+
<!-- Unpublish action -->
<action
id="org.jboss.dna.web.jcr.rest.client.swt.unpublishAction"
@@ -87,8 +103,8 @@
adaptable="true"
label="%decorator.label"
state="true"
-
class="org.jboss.dna.web.jcr.rest.client.swt.views.ServerContentProvider"
- id="dnaDecorator">
+
class="org.jboss.dna.web.jcr.rest.client.swt.views.DnaContentProvider"
+ id="org.jboss.dna.web.jcr.rest.client.swt.dnaDecorator">
<description>
%decorator.description
</description>
@@ -97,7 +113,7 @@
<objectClass
name="org.jboss.dna.web.jcr.rest.client.domain.IDnaObject">
</objectClass>
- <objectClass
+ <objectClass
name="org.eclipse.core.resources.IFile">
</objectClass>
</or>
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/DnaResourceHelper.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/DnaResourceHelper.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/DnaResourceHelper.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -0,0 +1,258 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.StringTokenizer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+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.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+import org.jboss.dna.web.jcr.rest.client.domain.Workspace;
+
+/**
+ * The <code>DnaResourceHelper</code> knows how to get and set the property
on a resource that indicates it has been published to
+ * one or more workspaces.
+ *
+ * @since 0.6
+ */
+public final class DnaResourceHelper {
+
+ //
===========================================================================================================================
+ // Constants
+ //
===========================================================================================================================
+
+ /**
+ * Delimiter between a workspace's properties.
+ *
+ * @since 0.6
+ */
+ private static final String ID_DELIM = "$"; //$NON-NLS-1$
+
+ /**
+ * Delimiter between workspaces.
+ *
+ * @since 0.6
+ */
+ private static final String DELIM = "|"; //$NON-NLS-1$
+
+ /**
+ * The name of the persisted file property indicating if the resource has been
published. This property will only exist if the
+ * file has been published to at least one DNA repository. The value of the property
is a list of DNA repository workspaces
+ * where this file has been published.
+ *
+ * @since 0.6
+ */
+ private static QualifiedName PUBLISHED_RESOURCE_PROPERTY = new
QualifiedName(IUiConstants.PLUGIN_ID, "publishedIn"); //$NON-NLS-1$
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The server manager used by the helper to obtain workspaces.
+ *
+ * @since 0.6
+ */
+ private final ServerManager serverManager;
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * @param serverManager the server manager used by this helper (never
<code>null</code>)
+ * @since 0.6
+ */
+ public DnaResourceHelper( ServerManager serverManager ) {
+ CheckArg.isNotNull(serverManager, "serverManager"); //$NON-NLS-1$
+ this.serverManager = serverManager;
+ }
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * @param file the file that was just published
+ * @param workspace the workspace where the file was published
+ * @throws Exception if there is a problem setting the property
+ * @since 0.6
+ */
+ public void addPublishedProperty( IFile file,
+ Workspace workspace ) throws Exception {
+ CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+ CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+
+ Set<Workspace> workspaces = getPublishedOnWorkspaces(file);
+ workspaces.add(workspace);
+
+ // set new value
+ setPublishedOnPropertyValue(file, workspaces);
+ }
+
+ /**
+ * @param workspaces the workspaces used to create the property value
+ * @return the property value
+ * @since 0.6
+ */
+ private String createPublishedPropertyValue( Set<Workspace> workspaces ) {
+ StringBuilder value = new StringBuilder();
+
+ for (Workspace workspace : workspaces) {
+ value.append(createWorkspaceId(workspace)).append(DELIM);
+ }
+
+ return value.toString();
+ }
+
+ /**
+ * @param workspace the workspace whose identifier is being created
+ * @return the ID
+ * @since 0.6
+ */
+ private String createWorkspaceId( Workspace workspace ) {
+ StringBuilder result = new StringBuilder();
+
result.append(workspace.getServer().getUrl()).append(ID_DELIM).append(workspace.getServer().getUser()).append(ID_DELIM);
+ result.append(workspace.getRepository().getName()).append(ID_DELIM);
+ result.append(workspace.getName());
+
+ return result.toString();
+ }
+
+ /**
+ * @param file the file whose <code>Workspace</code>s it has been
published on is being requested (never <code>null</code>)
+ * @return the workspaces (never <code>null</code>)
+ * @throws Exception if there is a problem reading one of the file's persistent
properties or a problem with the server
+ * manager
+ * @since 0.6
+ */
+ public Set<Workspace> getPublishedOnWorkspaces( IFile file ) throws Exception
{
+ CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+
+ Set<Workspace> publishedOnWorkspaces = null;
+ String value = file.getPersistentProperty(PUBLISHED_RESOURCE_PROPERTY);
+
+ if (value == null) {
+ publishedOnWorkspaces = new HashSet<Workspace>(1);
+ } else {
+ StringTokenizer wsTokenizer = new StringTokenizer(value, DELIM);
+ publishedOnWorkspaces = new
HashSet<Workspace>(wsTokenizer.countTokens());
+
+ while (wsTokenizer.hasMoreTokens()) {
+ StringTokenizer propsTokenizer = new
StringTokenizer(wsTokenizer.nextToken(), ID_DELIM);
+
+ PARSE_WORKSPACE: while (propsTokenizer.hasMoreTokens()) {
+ String url = propsTokenizer.nextToken();
+ String user = propsTokenizer.nextToken();
+ Server server = this.serverManager.findServer(url, user);
+
+ if ((server != null) &&
this.serverManager.ping(server).isOk()) {
+ Collection<Repository> repositories =
this.serverManager.getRepositories(server);
+
+ if (!repositories.isEmpty()) {
+ String repositoryName = propsTokenizer.nextToken();
+
+ for (Repository repository : repositories) {
+ if (repository.getName().equals(repositoryName)) {
+ Collection<Workspace> workspaces =
this.serverManager.getWorkspaces(repository);
+
+ if (!workspaces.isEmpty()) {
+ String workspaceName =
propsTokenizer.nextToken();
+
+ for (Workspace workspace : workspaces) {
+ if
(workspace.getName().equals(workspaceName)) {
+ publishedOnWorkspaces.add(workspace);
+ break PARSE_WORKSPACE;
+ }
+ }
+ }
+
+ }
+ }
+ }
+ } else {
+ // this will remove workspace as being one that the file has been
published on
+ break PARSE_WORKSPACE;
+ }
+ }
+ }
+ }
+
+ return publishedOnWorkspaces;
+ }
+
+ /**
+ * @param file the file whose published status is being requested (never
<code>null</code>)
+ * @return <code>true</code> if the file has been published to any DNA
repository
+ * @since 0.6
+ */
+ public boolean isPublished( IFile file ) {
+ CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+
+ try {
+ return !getPublishedOnWorkspaces(file).isEmpty();
+ } catch (Exception e) {
+ Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.publishedResourcePropertyErrorMsg.text(file), e));
+ }
+
+ return false;
+ }
+
+ /**
+ * @param file the file that was just unpublished
+ * @param workspace the workspace where the file was unpublished
+ * @throws Exception if there is a problem setting the property
+ * @since 0.6
+ */
+ public void removePublishedProperty( IFile file,
+ Workspace workspace ) throws Exception {
+ CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+ CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
+
+ Set<Workspace> workspaces = getPublishedOnWorkspaces(file);
+ workspaces.remove(workspace);
+
+ // set new value
+ setPublishedOnPropertyValue(file, workspaces);
+ }
+
+ private void setPublishedOnPropertyValue( IFile file,
+ Set<Workspace> workspaces ) throws
CoreException {
+ if ((workspaces == null) || workspaces.isEmpty()) {
+ file.setPersistentProperty(PUBLISHED_RESOURCE_PROPERTY, null);
+ } else {
+ String value = createPublishedPropertyValue(workspaces);
+ file.setPersistentProperty(PUBLISHED_RESOURCE_PROPERTY, value);
+ }
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/DnaResourceHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-08-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/IUiConstants.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -35,13 +35,6 @@
*/
String PLUGIN_ID = "org.jboss.dna.web.jcr.rest.client.swt"; //$NON-NLS-1$
- /**
- * The identifier and type of the DNA Message Console. This is where publishing and
unpublishing operations are logged.
- *
- * @since 0.6
- */
- String DNA_CONSOLE_ID =
"org.jboss.dna.web.jcr.rest.client.swt.views.DnaConsole"; //$NON-NLS-1$
-
String ICON_FOLDER = "icons/"; //$NON-NLS-1$
//
@@ -64,6 +57,8 @@
String VIEWS_ICON_FOLDER = ICON_FOLDER + "views/"; //$NON-NLS-1$
+ String BLANK_IMAGE = VIEWS_ICON_FOLDER + "blank.gif"; //$NON-NLS-1$
+
String COLLAPSE_ALL_IMAGE = VIEWS_ICON_FOLDER + "collapse_all.gif";
//$NON-NLS-1$
String DELETE_SERVER_IMAGE = VIEWS_ICON_FOLDER + "delete_server.gif";
//$NON-NLS-1$
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-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -45,6 +45,10 @@
public static I18n deleteServerDialogOneServerMsg;
public static I18n deleteServerDialogTitle;
+ public static I18n dnaConsoleName;
+ public static I18n dnaConsoleProblemCreatingHyperlinkMsg;
+ public static I18n dnaConsoleFilePathNotFoundMsg;
+
public static I18n editServerActionText;
public static I18n editServerActionToolTip;
@@ -54,14 +58,27 @@
public static I18n newServerActionText;
public static I18n newServerActionToolTip;
+
+ public static I18n publishedLocationsDialogCopyUrlButton;
+ public static I18n publishedLocationsDialogCopyUrlButtonToolTip;
+ public static I18n publishedLocationsDialogErrorObtainingUrlMsg;
+ public static I18n publishedLocationsDialogFileUrlColumnHeader;
+ public static I18n publishedLocationsDialogMsg;
+ public static I18n publishedLocationsDialogRepositoryColumnHeader;
+ public static I18n publishedLocationsDialogServerUrlColumnHeader;
+ public static I18n publishedLocationsDialogTitle;
+ public static I18n publishedLocationsDialogUserColumnHeader;
+ public static I18n publishedLocationsDialogWorkspaceColumnHeader;
public static I18n publishedResourcePropertyErrorMsg;
- public static I18n publishJobConsoleName;
+ public static I18n publishJobCanceled;
+ public static I18n publishJobLongDurationMsg;
+ public static I18n publishJobShortDurationMsg;
public static I18n publishJobPublish;
public static I18n publishJobPublishCanceledMsg;
- public static I18n publishJobProblemCreatingHyperlinkMsg;
public static I18n publishJobPublishFile;
+ public static I18n publishJobPublishFile2;
public static I18n publishJobPublishFileFailed;
public static I18n publishJobPublishFileInfo;
public static I18n publishJobPublishFileWarning;
@@ -111,8 +128,6 @@
public static I18n publishWizardUnpublishTitle;
public static I18n publishWizardUnpublishErrorMsg;
- public static I18n refreshActionToolTip;
-
public static I18n serverManagerGetRepositoriesExceptionMsg;
public static I18n serverManagerGetWorkspacesExceptionMsg;
@@ -136,12 +151,17 @@
public static I18n serverPageUserLabel;
public static I18n serverPageUserToolTip;
+ public static I18n serverReconnectActionText;
+ public static I18n serverReconnectActionToolTip;
+
public static I18n serverViewToolTip;
public static I18n serverWizardEditServerErrorMsg;
public static I18n serverWizardEditServerTitle;
public static I18n serverWizardNewServerErrorMsg;
public static I18n serverWizardNewServerTitle;
+
+ public static I18n showPublishedLocationsErrorMsg;
public static I18n testServerActionText;
public static I18n testServerActionToolTip;
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-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/RestClientI18n.properties 2009-08-31
13:46:22 UTC (rev 1182)
@@ -26,7 +26,7 @@
collapseActionToolTip = Collapse All
-deleteServerActionText = Delete Server
+deleteServerActionText = Discard
deleteServerActionToolTip = Delete server from the server registry
deleteServerDialogErrorsOccurredMsg = There were errors deleting servers from the server
registry. See log for more details.
@@ -37,6 +37,10 @@
editServerActionText = Server Properties
editServerActionToolTip = Edit server properties
+dnaConsoleName = DNA
+dnaConsoleProblemCreatingHyperlinkMsg = Unexpected problem creating hyperlink in DNA
Console view
+dnaConsoleFilePathNotFoundMsg = A hyperlink could not be created in the DNA Message
Console because the file path of "{0}" could not be found.
+
errorDialogTitle = Error
missingImage = The following image cannot be found "{0}"
@@ -44,29 +48,42 @@
newServerActionText = New Server
newServerActionToolTip = Create a new server
+publishedLocationsDialogCopyUrlButton = Copy URL
+publishedLocationsDialogCopyUrlButtonToolTip = Copy to the clipboard the selected
workspace URL where the file is published
+publishedLocationsDialogErrorObtainingUrlMsg = Error obtaining URL
+publishedLocationsDialogFileUrlColumnHeader = Published URL
+publishedLocationsDialogMsg = The file "{0}" has been published to the
following DNA workspaces:
+publishedLocationsDialogRepositoryColumnHeader = Repository
+publishedLocationsDialogServerUrlColumnHeader = Server URL
+publishedLocationsDialogTitle = Published Locations
+publishedLocationsDialogUserColumnHeader = User
+publishedLocationsDialogWorkspaceColumnHeader = Workspace
+
publishedResourcePropertyErrorMsg = Error obtaining the "published" property
from the resource "{0}"
-publishJobConsoleName = DNA
-publishJobProblemCreatingHyperlinkMsg = Unexpected problem creating hyperlink in DNA
Console view
+publishJobCanceled = Job {0} was canceled. See log for details.
+publishJobLongDurationMsg = {0} hour(s), {1} minute(s), {2} second(s)
+publishJobShortDurationMsg = less than 1 second
publishJobPublish = [{0}] Publishing {4} file(s) to server "{1}" (repository
"{2}", workspace "{3}") ...
-publishJobPublishCanceledMsg = [{0}] ! Publishing to server "{1}" (repository
"{2}", workspace "{3}") was canceled after {4} file(s) out of {5} were
processed.\n
-publishJobPublishFile = \t[{0}] + Published file "{1}"
-publishJobPublishFileFailed = \t[{0}] * Publishing file "{1}" generated an
ERROR message. See log.
-publishJobPublishFileInfo = \t[{0}] i Publishing file "{1}" generated an INFO
message. See log.
-publishJobPublishFileWarning = \t[{0}] w Publishing file "{1}" generated a
WARNING message. See log.
-publishJobPublishFinishedMsg = [{0}] Done publishing ({4} milliseconds) to server
"{1}" (repository "{2}", workspace "{3}").\n
-publishJobPublishName = DNA Publish
-publishJobPublishTaskName = Publishing resources
+publishJobPublishCanceledMsg = [{0}] !! Publishing to server "{1}" (repository
"{2}", workspace "{3}") was canceled after {4} file(s) out of {5} were
processed.\n
+publishJobPublishFile = \t[{0}] ++ Published file "{1}" to URL\
+publishJobPublishFile2 = "{0}"
+publishJobPublishFileFailed = \t[{0}] ERROR Publishing file "{1}" generated an
ERROR message. See log.
+publishJobPublishFileInfo = \t[{0}] INFO Publishing file "{1}" generated an
INFO message. See log.
+publishJobPublishFileWarning = \t[{0}] WARN Publishing file "{1}" generated a
WARNING message. See log.
+publishJobPublishFinishedMsg = [{0}] Done publishing. Elapsed time: {1}. \n
+publishJobPublishName = DNA Publish [{0}]
+publishJobPublishTaskName = Publishing resources [{0}]
publishJobUnexpectedErrorMsg = Unexpected error occurred. See log for more details.
publishJobUnpublish = [{0}] Unpublishing {4} file(s) from server "{1}"
(repository "{2}", workspace "{3}") ...
-publishJobUnpublishCanceledMsg = [{0}] ! Unpublishing from server "{1}"
(repository "{2}", workspace "{3}") was canceled after {4} file(s) out
of {5} were processed.\n
-publishJobUnpublishFile = \t[{0}] - Unpublished file "{1}"
-publishJobUnpublishFileFailed = \t[{0}] * Unpublishing file "{0}" generated an
ERROR message. See log.
-publishJobUnpublishFileInfo = \t[{0}] i Unpublishing file "{1}" generated an
INFO message. See log.
-publishJobUnpublishFileWarning = \t[{0}] w Unpublishing file "{1}" generated a
WARNING message. See log.
-publishJobUnpublishFinishedMsg = [{0}] Done unpublishing ({4} milliseconds) from server
"{1}" (repository "{2}", workspace "{3}").\n
-publishJobUnpublishName = DNA Unpublish
-publishJobUnpublishTaskName = Unpublishing resources
+publishJobUnpublishCanceledMsg = [{0}] !! Unpublishing from server "{1}"
(repository "{2}", workspace "{3}") was canceled after {4} file(s) out
of {5} were processed.\n
+publishJobUnpublishFile = \t[{0}] -- Unpublished file "{1}"
+publishJobUnpublishFileFailed = \t[{0}] ERROR Unpublishing file "{0}" generated
an ERROR message. See log.
+publishJobUnpublishFileInfo = \t[{0}] INFO Unpublishing file "{1}" generated
an INFO message. See log.
+publishJobUnpublishFileWarning = \t[{0}] WARN Unpublishing file "{1}"
generated a WARNING message. See log.
+publishJobUnpublishFinishedMsg = [{0}] Done unpublishing. Elapsed time: {1}. \n
+publishJobUnpublishName = DNA Unpublish [{0}]
+publishJobUnpublishTaskName = Unpublishing resources [{0}]
publishPagePublishTitle = Publish the selected resources
publishPageLocationGroupTitle = Location
@@ -100,7 +117,8 @@
publishWizardUnpublishErrorMsg = Error Unpublishing
publishWizardUnpublishTitle = Unpublish
-refreshActionToolTip = Refresh
+serverReconnectActionText = Reconnect
+serverReconnectActionToolTip = Reconnect to selected servers or all servers if no servers
selected
serverManagerGetRepositoriesExceptionMsg = There was a problem obtaining repositories for
the server "{0}."
serverManagerGetWorkspacesExceptionMsg = There was a problem obtaining workspaces for
repository "{0}."
@@ -132,5 +150,7 @@
serverWizardNewServerErrorMsg = There were errors creating a new server. See log for more
details.
serverWizardNewServerTitle = New Server
+showPublishedLocationsErrorMsg = Unexpected problem showing published on locations. See
log for more details.
+
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-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/Utils.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -23,13 +23,7 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.StringTokenizer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
@@ -39,7 +33,6 @@
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.domain.Workspace;
/**
* @since 0.6
@@ -47,71 +40,10 @@
public final class Utils {
//
===========================================================================================================================
- // Constants
- //
===========================================================================================================================
-
- /**
- * Delimiter between a workspace's properties.
- *
- * @since 0.6
- */
- private static final String ID_DELIM = "$"; //$NON-NLS-1$
-
- /**
- * Delimiter between workspaces.
- *
- * @since 0.6
- */
- private static final String DELIM = "|"; //$NON-NLS-1$
-
- /**
- * The name of the persisted file property indicating if the resource has been
published. This property will only exist if the
- * file has been published to at least one DNA repository. The value of the property
is a list of DNA repository workspaces
- * where this file has been published.
- *
- * @since 0.6
- */
- private static QualifiedName PUBLISHED_RESOURCE_PROPERTY = new
QualifiedName(IUiConstants.PLUGIN_ID, "publishedIn"); //$NON-NLS-1$
-
- //
===========================================================================================================================
// Class Methods
//
===========================================================================================================================
/**
- * @param file the file that was just published
- * @param workspace the workspace where the file was published
- * @since 0.6
- */
- public static void addPublishedProperty( IFile file,
- Workspace workspace ) {
- CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
- CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
-
- String wsValue = createWorkspaceId(workspace);
-
- try {
- Set<String> workspaces = null;
-
- // get current value
- String value = file.getPersistentProperty(PUBLISHED_RESOURCE_PROPERTY);
-
- if (value == null) {
- workspaces = new HashSet<String>(1);
- } else {
- workspaces = parsePublishedPropertyValue(value);
- }
-
- workspaces.add(wsValue);
-
- // set new value
- value = createPublishedPropertyValue(workspaces);
- file.setPersistentProperty(PUBLISHED_RESOURCE_PROPERTY, value);
- } catch (CoreException e) {
- Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.publishedResourcePropertyErrorMsg.text(file), e));
- }
- }
-
- /**
* 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
@@ -181,35 +113,6 @@
}
/**
- * @param workspaces the workspaces used to create the property value
- * @return the property value
- * @since 0.6
- */
- private static String createPublishedPropertyValue( Set<String> workspaces ) {
- StringBuilder value = new StringBuilder();
-
- for (String workspace : workspaces) {
- value.append(workspace).append(DELIM);
- }
-
- return value.toString();
- }
-
- /**
- * @param workspace the workspace whose identifier is being created
- * @return the ID
- * @since 0.6
- */
- private static String createWorkspaceId( Workspace workspace ) {
- StringBuilder result = new StringBuilder();
-
result.append(workspace.getServer().getUrl()).append(ID_DELIM).append(workspace.getServer().getUser()).append(ID_DELIM);
- result.append(workspace.getRepository().getName()).append(ID_DELIM);
- result.append(workspace.getName());
-
- return result.toString();
- }
-
- /**
* The OK status does not have an image.
*
* @param status the status whose image is being requested (never
<code>null</code>)
@@ -257,72 +160,6 @@
return null;
}
- /**
- * @param file the file whose published status is being requested
- * @return <code>true</code> if the file has been published to any DNA
repository
- * @since 0.6
- */
- public static boolean isPublished( IFile file ) {
- CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
-
- try {
- return (file.getPersistentProperty(PUBLISHED_RESOURCE_PROPERTY) != null);
- } catch (CoreException e) {
- Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.publishedResourcePropertyErrorMsg.text(file), e));
- }
-
- return false;
- }
-
- /**
- * @param value the property value being parsed
- * @return a collection of workspace identifiers
- * @since 0.6
- */
- private static Set<String> parsePublishedPropertyValue( String value ) {
- StringTokenizer st = new StringTokenizer(value, DELIM);
- Set<String> workspaces = new HashSet<String>(st.countTokens());
-
- while (st.hasMoreTokens()) {
- workspaces.add(st.nextToken());
- }
-
- return workspaces;
- }
-
- /**
- * @param file the file that was just unpublished
- * @param workspace the workspace where the file was unpublished
- * @since 0.6
- */
- public static void removePublishedProperty( IFile file,
- Workspace workspace ) {
- CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
- CheckArg.isNotNull(workspace, "workspace"); //$NON-NLS-1$
-
- String wsValue = createWorkspaceId(workspace);
-
- try {
- String value = file.getPersistentProperty(PUBLISHED_RESOURCE_PROPERTY);
-
- if (value != null) {
- Set<String> workspaces = parsePublishedPropertyValue(value);
- workspaces.remove(wsValue);
-
- if (workspaces.isEmpty()) {
- // no other workspaces so remove property
- file.setPersistentProperty(PUBLISHED_RESOURCE_PROPERTY, null);
- } else {
- // set new value
- value = createPublishedPropertyValue(workspaces);
- file.setPersistentProperty(PUBLISHED_RESOURCE_PROPERTY, value);
- }
- }
- } catch (CoreException e) {
- Activator.getDefault().log(new Status(Severity.ERROR,
RestClientI18n.publishedResourcePropertyErrorMsg.text(file), e));
- }
- }
-
//
===========================================================================================================================
// Constructors
//
===========================================================================================================================
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ReconnectToServerAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ReconnectToServerAction.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ReconnectToServerAction.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -0,0 +1,106 @@
+/*
+ * 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.actions;
+
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.REFRESH_IMAGE;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.jboss.dna.web.jcr.rest.client.IServerRegistryListener;
+import org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent;
+import org.jboss.dna.web.jcr.rest.client.swt.Activator;
+import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
+
+/**
+ * The <code>ReconnectToServerAction</code> tries to reconnect to one or more
selected servers or to all servers if none are
+ * selected. This action must be registered to received server registry events.
+ *
+ * @since 0.6
+ */
+public final class ReconnectToServerAction extends Action implements
IServerRegistryListener {
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The server view tree viewer.
+ *
+ * @since 0.6
+ */
+ private final TreeViewer viewer;
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * @param viewer the server view tree viewer
+ * @since 0.6
+ */
+ public ReconnectToServerAction( TreeViewer viewer ) {
+ super(RestClientI18n.serverReconnectActionText.text());
+ setToolTipText(RestClientI18n.serverReconnectActionToolTip.text());
+ setImageDescriptor(Activator.getDefault().getImageDescriptor(REFRESH_IMAGE));
+ setEnabled(false);
+
+ this.viewer = viewer;
+ }
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ * @since 0.6
+ */
+ @Override
+ public void run() {
+ IStructuredSelection selection =
(IStructuredSelection)this.viewer.getSelection();
+
+ if (selection.size() == 0) {
+ this.viewer.refresh();
+ } else {
+ for (Object server : selection.toArray()) {
+ this.viewer.refresh(server);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.dna.web.jcr.rest.client.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.web.jcr.rest.client.ServerRegistryEvent)
+ * @since 0.6
+ */
+ @Override
+ public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {
+ setEnabled(!event.getServerManager().getServers().isEmpty());
+ return null;
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ReconnectToServerAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ShowPublishedLocationsAction.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ShowPublishedLocationsAction.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ShowPublishedLocationsAction.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -0,0 +1,141 @@
+/*
+ * 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.actions;
+
+import static org.jboss.dna.web.jcr.rest.client.swt.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.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.DnaResourceHelper;
+import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
+import org.jboss.dna.web.jcr.rest.client.swt.dialogs.PublishedLocationsDialog;
+
+/**
+ * The <code>PublishAction</code> controls the publishing of one or more
{@link org.eclipse.core.resources.IResource}s to a DNA
+ * repository.
+ *
+ * @since 0.6
+ */
+public final class ShowPublishedLocationsAction extends Action implements
IObjectActionDelegate {
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The current workspace selection.
+ *
+ * @since 0.6
+ */
+ private IStructuredSelection selection;
+
+ /**
+ * The active part's Shell.
+ *
+ * @since 0.6
+ */
+ 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)
+ * @since 0.6
+ */
+ @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();
+ DnaResourceHelper resourceHelper = new DnaResourceHelper(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)
+ * @since 0.6
+ */
+ @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)
+ * @since 0.6
+ */
+ @Override
+ public void setActivePart( IAction action,
+ IWorkbenchPart targetPart ) {
+ this.shell = targetPart.getSite().getShell();
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/actions/ShowPublishedLocationsAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/DeleteServerDialog.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -38,6 +38,7 @@
import org.jboss.dna.web.jcr.rest.client.domain.Server;
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;
/**
* The <code>DeleteServerDialog</code> class provides a UI for deleting a
{@link Server server}.
@@ -126,4 +127,16 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
+ * @since 0.6
+ */
+ @Override
+ protected void initializeBounds() {
+ super.initializeBounds();
+ Utils.centerAndSizeShellRelativeToDisplay(getShell(), 75, 75);
+ }
+
}
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishedLocationsDialog.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishedLocationsDialog.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishedLocationsDialog.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -0,0 +1,513 @@
+/*
+ * 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.BLANK_IMAGE;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_IMAGE_16x;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.REPOSITORY_IMAGE;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.SERVER_IMAGE;
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.WORKSPACE_IMAGE;
+import java.io.File;
+import java.util.Collection;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+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.Server;
+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.Utils;
+
+/**
+ * The <code>PublishedLocationsDialog</code> class provides a UI for viewing
a list of {@link Server servers} a selected file has
+ * been published to.
+ *
+ * @since 0.6
+ */
+public final class PublishedLocationsDialog extends MessageDialog {
+
+ //
===========================================================================================================================
+ // Constants
+ //
===========================================================================================================================
+
+ /**
+ * The column index of the server URL.
+ *
+ * @since 0.6
+ */
+ private static final int SERVER_URL_COL = 0;
+
+ /**
+ * The column index of the server user.
+ *
+ * @since 0.6
+ */
+ private static final int USER_COL = 1;
+
+ /**
+ * The column index of the repository name.
+ *
+ * @since 0.6
+ */
+ private static final int REPOSITORY_COL = 2;
+
+ /**
+ * The column index of the workspace name.
+ *
+ * @since 0.6
+ */
+ private static final int WORKSPACE_COL = 3;
+
+ /**
+ * The column index of the URL where the file was published.
+ *
+ * @since 0.6
+ */
+ private static final int FILE_URL_COL = 4;
+
+ /**
+ * The column indexes of all columns.
+ *
+ * @since 0.6
+ */
+ private static final int[] COLUMNS = {SERVER_URL_COL, USER_COL, REPOSITORY_COL,
WORKSPACE_COL, FILE_URL_COL};
+
+ /**
+ * The column headers.
+ *
+ * @since 0.6
+ */
+ private static final String[] HEADERS =
{RestClientI18n.publishedLocationsDialogServerUrlColumnHeader.text(),
+ RestClientI18n.publishedLocationsDialogUserColumnHeader.text(),
+ RestClientI18n.publishedLocationsDialogRepositoryColumnHeader.text(),
+ RestClientI18n.publishedLocationsDialogWorkspaceColumnHeader.text(),
+ RestClientI18n.publishedLocationsDialogFileUrlColumnHeader.text(),};
+
+ //
===========================================================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The button that copies the file URL to the clipboard.
+ *
+ * @since 0.6
+ */
+ private Button btnCopy;
+
+ /**
+ * The file whose workspaces it was published to is being displayed by this dialog.
+ *
+ * @since 0.6
+ */
+ private final IFile file;
+
+ /**
+ * The server manager who can obtain the URL for the file at each of the workspaces.
+ *
+ * @since 0.6
+ */
+ private final ServerManager serverManager;
+
+ /**
+ * The viewer of the table holding the published locations.
+ *
+ * @since 0.6
+ */
+ private TableViewer viewer;
+
+ /**
+ * Collection of workspaces the selected file has been published to.
+ *
+ * @since 0.6
+ */
+ private final Collection<Workspace> workspaces;
+
+ //
===========================================================================================================================
+ // Constructors
+ //
===========================================================================================================================
+
+ /**
+ * @param parentShell the dialog parent
+ * @param serverManager the server manager that this dialog will get URLs from (never
<code>null</code>)
+ * @param file the file whose workspaces it has been published on is being requested
(never <code>null</code>)
+ * @param workspaces the workspaces (never <code>null</code>)
+ * @since 0.6
+ */
+ public PublishedLocationsDialog( Shell parentShell,
+ ServerManager serverManager,
+ IFile file,
+ Collection<Workspace> workspaces ) {
+ super(parentShell, RestClientI18n.publishedLocationsDialogTitle.text(),
Activator.getDefault().getImage(DNA_IMAGE_16x),
+ RestClientI18n.publishedLocationsDialogMsg.text(file.getFullPath()),
MessageDialog.INFORMATION,
+ new String[] {IDialogConstants.OK_LABEL}, 0);
+
+ CheckArg.isNotNull(serverManager, "serverManager"); //$NON-NLS-1$
+ CheckArg.isNotNull(file, "file"); //$NON-NLS-1$
+ CheckArg.isNotNull(workspaces, "workspaces"); //$NON-NLS-1$
+
+ this.file = file;
+ this.serverManager = serverManager;
+ this.workspaces = workspaces;
+
+ // make sure dialog is resizable
+ setShellStyle(getShellStyle() | SWT.RESIZE);
+ }
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
+ * @since 0.6
+ */
+ @Override
+ protected Control createCustomArea( Composite parent ) {
+ // layout consists of a panel that contains a table and a button
+ Composite panel = new Composite(parent, SWT.NONE);
+ panel.setLayout(new GridLayout(2, false));
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ //
+ // construct table
+ //
+
+ this.viewer = new TableViewer(panel, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
+ LocationsTableProvider provider = new LocationsTableProvider();
+ this.viewer.setLabelProvider(provider);
+ this.viewer.setContentProvider(provider);
+ this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ * @since 0.6
+ */
+ @Override
+ public void selectionChanged( SelectionChangedEvent e ) {
+ handleTableSelection();
+ }
+ });
+
+ // configure table
+ Table table = this.viewer.getTable();
+ table.setLayout(new TableLayout());
+ table.setLayoutData(new GridData(GridData.FILL_BOTH));
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ // create columns
+ for (int numCols = COLUMNS.length, i = 0; i < numCols; ++i) {
+ TableColumn column = new TableColumn(table, SWT.LEFT);
+ column.setText(HEADERS[i]);
+
+ // set image
+ Image image = null;
+
+ if ((i == SERVER_URL_COL) || (i == USER_COL)) {
+ image = Activator.getDefault().getImage(SERVER_IMAGE);
+ } else if (i == REPOSITORY_COL) {
+ image = Activator.getDefault().getImage(REPOSITORY_IMAGE);
+ } else if (i == WORKSPACE_COL) {
+ image = Activator.getDefault().getImage(WORKSPACE_IMAGE);
+ } else {
+ image = Activator.getDefault().getImage(BLANK_IMAGE);
+ }
+
+ column.setImage(image);
+ }
+
+ // populate the table
+ this.viewer.setInput(this);
+
+ // size columns
+ for (TableColumn column : table.getColumns()) {
+ column.pack();
+ column.setWidth(column.getWidth() + 10);
+ }
+
+ //
+ // construct button
+ //
+
+ this.btnCopy = new Button(panel, SWT.PUSH);
+
this.btnCopy.setText(RestClientI18n.publishedLocationsDialogCopyUrlButton.text());
+
this.btnCopy.setToolTipText(RestClientI18n.publishedLocationsDialogCopyUrlButtonToolTip.text());
+ this.btnCopy.addSelectionListener(new SelectionAdapter() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ * @since 0.6
+ */
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleCopyUrl();
+ }
+ });
+
+ return panel;
+ }
+
+ /**
+ * @return the file system file this dialog is showing the published locations of
(never <code>null</code>)
+ * @since 0.6
+ */
+ private File getFile() {
+ return this.file.getLocation().toFile();
+ }
+
+ /**
+ * This path does not include the name of the file.
+ *
+ * @return the path the file was published (never <code>null</code>)
+ * @since 0.6
+ */
+ private String getPath() {
+ return this.file.getParent().getFullPath().toString();
+ }
+
+ /**
+ * @param workspace the workspace where the file was published
+ * @return the URL where the file was published
+ * @since 0.6
+ */
+ String getPublishedAtUrl( Workspace workspace ) {
+ try {
+ return this.serverManager.getUrl(getFile(), getPath(),
workspace).toString();
+ } catch (Exception e) {
+ String message =
RestClientI18n.publishedLocationsDialogErrorObtainingUrlMsg.text();
+ Activator.getDefault().log(new Status(Severity.ERROR, message, e));
+ return message;
+ }
+
+ }
+
+ /**
+ * @return the workspaces the file has been published to (never
<code>null</code>)
+ * @since 0.6
+ */
+ Object[] getWorkspaces() {
+ return this.workspaces.toArray();
+ }
+
+ /**
+ * Handler for when the copy URL button is clicked.
+ *
+ * @since 0.6
+ */
+ void handleCopyUrl() {
+ Workspace workspace =
(Workspace)((IStructuredSelection)this.viewer.getSelection()).getFirstElement();
+ String url = getPublishedAtUrl(workspace);
+ Clipboard clipboard = new Clipboard(Display.getCurrent());
+ clipboard.setContents(new Object[] {url}, new Transfer[]
{TextTransfer.getInstance()});
+ }
+
+ /**
+ * Handler for when a table row is selected.
+ *
+ * @since 0.6
+ */
+ void handleTableSelection() {
+ IStructuredSelection selection =
(IStructuredSelection)this.viewer.getSelection();
+ boolean enable = (selection.size() == 1);
+
+ if (this.btnCopy.getEnabled() != enable) {
+ this.btnCopy.setEnabled(enable);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#initializeBounds()
+ * @since 0.6
+ */
+ @Override
+ protected void initializeBounds() {
+ super.initializeBounds();
+ Utils.centerAndSizeShellRelativeToDisplay(getShell(), 75, 75);
+ }
+
+ //
===========================================================================================================================
+ // Inner Class
+ //
===========================================================================================================================
+
+ /**
+ * The <code>LocationsTableProvider</code> provides content, labels, and
images for the table.
+ *
+ * @since 0.6
+ */
+ class LocationsTableProvider implements IStructuredContentProvider,
ITableLabelProvider {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ * @since 0.6
+ */
+ @Override
+ public void addListener( ILabelProviderListener listener ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
+ * @since 0.6
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
+ * @since 0.6
+ */
+ @Override
+ public Image getColumnImage( Object element,
+ int columnIndex ) {
+ 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 ) {
+ Workspace workspace = (Workspace)element;
+
+ if (columnIndex == SERVER_URL_COL) {
+ return workspace.getServer().getUrl();
+ }
+
+ if (columnIndex == USER_COL) {
+ return workspace.getServer().getUser();
+ }
+
+ if (columnIndex == REPOSITORY_COL) {
+ return workspace.getRepository().getName();
+ }
+
+ if (columnIndex == WORKSPACE_COL) {
+ return workspace.getName();
+ }
+
+ if (columnIndex == FILE_URL_COL) {
+ return getPublishedAtUrl(workspace);
+ }
+
+ // should never get here
+ assert false;
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public Object[] getElements( Object inputElement ) {
+ return getWorkspaces();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public void inputChanged( Viewer viewer,
+ Object oldInput,
+ Object newInput ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
java.lang.String)
+ * @since 0.6
+ */
+ @Override
+ public boolean isLabelProperty( Object element,
+ String property ) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ * @since 0.6
+ */
+ @Override
+ public void removeListener( ILabelProviderListener listener ) {
+ // nothing to do
+ }
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/dialogs/PublishedLocationsDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java
(from rev 1171,
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.java)
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -0,0 +1,355 @@
+/*
+ * 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.views;
+
+import static
org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.PUBLISHED_OVERLAY_IMAGE;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IDecoration;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ILightweightLabelDecorator;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IDecoratorManager;
+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.IDnaObject;
+import org.jboss.dna.web.jcr.rest.client.domain.Repository;
+import org.jboss.dna.web.jcr.rest.client.domain.Server;
+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.DnaResourceHelper;
+import org.jboss.dna.web.jcr.rest.client.swt.RestClientI18n;
+import org.jboss.dna.web.jcr.rest.client.swt.Utils;
+
+/**
+ * The <code>DnaContentProvider</code> is a content and label provider for
DNA repositories.
+ *
+ * @since 0.6
+ */
+public final class DnaContentProvider extends ColumnLabelProvider implements
ILightweightLabelDecorator, ITreeContentProvider {
+
+ //
===========================================================================================================================
+ // Constants
+ //
===========================================================================================================================
+
+ /**
+ * The decorator ID.
+ *
+ * @since 0.6
+ */
+ private static final String ID =
"org.jboss.dna.web.jcr.rest.client.swt.dnaDecorator"; //$NON-NLS-1$
+
+ //
===========================================================================================================================
+ // Class Methods
+ //
===========================================================================================================================
+
+ /**
+ * @return the DNA decorator
+ * @since 0.6
+ */
+ public static DnaContentProvider getDecorator() {
+ IDecoratorManager decoratorMgr =
Activator.getDefault().getWorkbench().getDecoratorManager();
+
+ if (decoratorMgr.getEnabled(ID)) {
+ return (DnaContentProvider)decoratorMgr.getBaseLabelProvider(ID);
+ }
+
+ return null;
+ }
+
+ //
===========================================dnaDecorator================================================================================
+ // Fields
+ //
===========================================================================================================================
+
+ /**
+ * The server manager where the server registry is managed.
+ *
+ * @since 0.6
+ */
+ private ServerManager serverManager;
+
+ //
===========================================================================================================================
+ // Methods
+ //
===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ * @since 0.6
+ */
+ @Override
+ public void addListener( ILabelProviderListener listener ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
org.eclipse.jface.viewers.IDecoration)
+ * @since 0.6
+ */
+ @Override
+ public void decorate( final Object element,
+ IDecoration decoration ) {
+ ImageDescriptor overlay = null;
+ final Display display = Display.getDefault();
+
+ if (display.isDisposed()) {
+ return;
+ }
+
+ // must be an IDnaObject
+ if (getServerManager() != null) {
+ if (element instanceof Server) {
+ Status status = getServerManager().ping((Server)element);
+ overlay = Utils.getOverlayImage(status);
+ } else if ((element instanceof IFile) && new
DnaResourceHelper(getServerManager()).isPublished((IFile)element)) {
+ overlay =
Activator.getDefault().getImageDescriptor(PUBLISHED_OVERLAY_IMAGE);
+ }
+
+ if (overlay != null) {
+ decoration.addOverlay(overlay);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ * @since 0.6
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public Object[] getChildren( Object parentElement ) {
+ assert (parentElement instanceof IDnaObject);
+
+ try {
+ if ((parentElement instanceof Server) && (getServerManager() !=
null)) {
+ return
getServerManager().getRepositories((Server)parentElement).toArray();
+ }
+ } catch (Exception e) {
+ String msg =
RestClientI18n.serverManagerGetRepositoriesExceptionMsg.text(((Server)parentElement).getShortDescription());
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+ }
+
+ try {
+ if ((parentElement instanceof Repository) && (getServerManager() !=
null)) {
+ return
getServerManager().getWorkspaces((Repository)parentElement).toArray();
+ }
+ } catch (Exception e) {
+ String msg = RestClientI18n.serverManagerGetWorkspacesExceptionMsg.text();
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+ }
+
+ return new Object[0];
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public Object[] getElements( Object inputElement ) {
+ return ((getServerManager() == null) ? new Object[0] :
getServerManager().getServers().toArray());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public Image getImage( Object element ) {
+ return Activator.getDefault().getImage(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public Object getParent( Object element ) {
+ assert (element instanceof IDnaObject);
+
+ if (element instanceof Workspace) {
+ return ((Workspace)element).getRepository();
+ }
+
+ if (element instanceof Repository) {
+ return ((Repository)element).getServer();
+ }
+
+ // server
+ return null;
+ }
+
+ /**
+ * @return the server manager or <code>null</code>
+ * @since 0.6
+ */
+ private ServerManager getServerManager() {
+ if (this.serverManager == null) {
+ this.serverManager = Activator.getDefault().getServerManager();
+ }
+
+ return this.serverManager;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public String getText( Object element ) {
+ assert (element instanceof IDnaObject);
+ return ((IDnaObject)element).getName();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.CellLabelProvider#getToolTipImage(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public Image getToolTipImage( Object object ) {
+ return getImage(object);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public String getToolTipText( Object element ) {
+ if (element instanceof IDnaObject) {
+ return ((IDnaObject)element).getShortDescription();
+ }
+
+ return super.getToolTipText(element);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.CellLabelProvider#getToolTipTimeDisplayed(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public int getToolTipTimeDisplayed( Object object ) {
+ return 3000;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public boolean hasChildren( Object element ) {
+ return getChildren(element).length > 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ * @since 0.6
+ */
+ @Override
+ public void inputChanged( Viewer viewer,
+ Object oldInput,
+ Object newInput ) {
+ // this.viewer = (StructuredViewer)viewer;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
java.lang.String)
+ * @since 0.6
+ */
+ @Override
+ public boolean isLabelProperty( Object element,
+ String property ) {
+ return false;
+ }
+
+ public void refresh( final Object element ) {
+ final Display display = Display.getDefault();
+
+ if (display.isDisposed()) {
+ return;
+ }
+
+ display.asyncExec(new Runnable() {
+ @SuppressWarnings( "synthetic-access" )
+ @Override
+ public void run() {
+ fireLabelProviderChanged(new
LabelProviderChangedEvent(DnaContentProvider.this, element));
+ }
+ });
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
+ * @since 0.6
+ */
+ @Override
+ public void removeListener( ILabelProviderListener listener ) {
+ // nothing to do
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaMessageConsole.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaMessageConsole.java
(rev 0)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaMessageConsole.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -0,0 +1,359 @@
+/*
+ * 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.views;
+
+import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_IMAGE_16x;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.debug.ui.console.FileLink;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.FindReplaceDocumentAdapter;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+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.Status;
+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;
+
+/**
+ * The <code>DnaMessageConsole</code> is a message console view where status
of publishing operations are logged. This class
+ * ensures all writes to the console are done in the UI thread.
+ *
+ * @since 0.6
+ */
+public final class DnaMessageConsole extends MessageConsole {
+
+ //
=======================================================================================================================
+ // Constants
+ //
=======================================================================================================================
+
+ /**
+ * The identifier and type of the DNA Message Console.
+ *
+ * @since 0.6
+ */
+ private static final String ID =
"org.jboss.dna.web.jcr.rest.client.swt.views.DnaMessageConsole"; //$NON-NLS-1$
+
+ /**
+ * The message console name.
+ *
+ * @since 0.6
+ */
+ private static final String NAME = RestClientI18n.dnaConsoleName.text();
+
+ //
=======================================================================================================================
+ // Class Methods
+ //
=======================================================================================================================
+
+ /**
+ * Note: The <code>DnaMessageConsole</code> should
<strong>NOT</strong> be cached as the user can open/close/create instances.
+ *
+ * @return the DNA Message Console if available or a new one (never
<code>null</code>)
+ * @since 0.6
+ */
+ private static DnaMessageConsole getDnaConsole() {
+ DnaMessageConsole console = null;
+ IConsoleManager consoleMgr = ConsolePlugin.getDefault().getConsoleManager();
+ IConsole[] consoles = consoleMgr.getConsoles();
+
+ // see if DNA console is open
+ for (int i = 0; i < consoles.length; ++i) {
+ if (NAME.equals(consoles[i].getName())) {
+ console = (DnaMessageConsole)consoles[i];
+ break;
+ }
+ }
+
+ // create DNA console if necessary
+ if (console == null) {
+ console = new DnaMessageConsole();
+ consoleMgr.addConsoles(new IConsole[] {console});
+ }
+
+ return console;
+ }
+
+ /**
+ * @param message the message being written to the console (never
<code>null</code>)
+ * @param emphasize indicates if the message should be emphasized in the console
+ * @since 0.6
+ */
+ public static void write( String message,
+ boolean emphasize ) {
+ CheckArg.isNotNull(message, "message"); //$NON-NLS-1$
+ DnaMessageConsole console = getDnaConsole();
+ console.print(message, emphasize, false, null);
+ }
+
+ /**
+ * @param message the message being written to the console
+ * @param file the file whose full path, which is contained in the message, will be
made into a hyperlink (may be
+ * <code>null</code>)
+ * @since 0.6
+ */
+ public static void write( String message,
+ IFile file ) {
+ CheckArg.isNotNull(message, "message"); //$NON-NLS-1$
+
+ DnaMessageConsole console = getDnaConsole();
+ console.print(message, false, false, file);
+ }
+
+ /**
+ * Adds a line feed to the console after the message is printed.
+ *
+ * @param message the message being written to the console (never
<code>null</code>)
+ * @since 0.6
+ */
+ public static void writeln( String message ) {
+ CheckArg.isNotNull(message, "message"); //$NON-NLS-1$
+ writeln(message, null);
+ }
+
+ /**
+ * Adds a line feed to the console after the message is printed.
+ *
+ * @param message the message being written to the console (never
<code>null</code>)
+ * @param file the file whose full path, which is contained in the message, will be
made into a hyperlink (may be
+ * <code>null</code>)
+ * @since 0.6
+ */
+ public static void writeln( String message,
+ IFile file ) {
+ CheckArg.isNotNull(message, "message"); //$NON-NLS-1$
+
+ DnaMessageConsole console = getDnaConsole();
+ console.print(message, false, true, file);
+ }
+
+ //
=======================================================================================================================
+ // Constructors
+ //
=======================================================================================================================
+
+ /**
+ * @since 0.6
+ */
+ private DnaMessageConsole() {
+ super(NAME, Activator.getDefault().getImageDescriptor(DNA_IMAGE_16x));
+ }
+
+ //
=======================================================================================================================
+ // Methods
+ //
=======================================================================================================================
+
+ /**
+ * @param message the message being searched for
+ * @param file the file whose full path appears in the message and will become a
hyperlink
+ * @since 0.6
+ */
+ void addDocumentListener( String message,
+ IFile file ) {
+ getDocument().addDocumentListener(new HyperlinkCreator(message, this, file));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.console.AbstractConsole#getType()
+ * @since 0.6
+ */
+ @Override
+ public String getType() {
+ return ID;
+ }
+
+ /**
+ * @param message the message being written to the console (never
<code>null</code>)
+ * @param emphasize a flag indicating if the message should be emphasized
+ * @param doLineFeedAtEnd a flag indicating if a line feed should be done after
writing the message
+ * @param file the file to create a hyperlink for (may be
<code>null</code>)
+ * @since 0.6
+ */
+ private void print( final String message,
+ final boolean emphasize,
+ final boolean doLineFeedAtEnd,
+ final IFile file ) {
+ final Display display = Display.getDefault();
+
+ if (!display.isDisposed()) {
+ display.asyncExec(new Runnable() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Runnable#run()
+ * @since 0.6
+ */
+ @Override
+ public void run() {
+ if (!display.isDisposed()) {
+ MessageConsoleStream stream = setup();
+
+ // configure stream
+ if (emphasize) {
+ stream.setColor(display.getSystemColor(SWT.COLOR_BLUE));
+ }
+
+ // register document listener before writing to console
+ if (file != null) {
+ addDocumentListener(message, file);
+ }
+
+ // write message
+ if (doLineFeedAtEnd) {
+ stream.println(message);
+ } else {
+ stream.print(message);
+ }
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Performs any setup required before writing to the console.
+ *
+ * @return the stream that can be written to
+ * @since 0.6
+ */
+ MessageConsoleStream setup() {
+ activate(); // show and focus console view
+ return newMessageStream();
+ }
+
+ //
===========================================================================================================================
+ // Inner Class
+ //
===========================================================================================================================
+
+ /**
+ * The <code>HyperlinkCreator</code> creates a hyperlink in a DNA Message
Console for the first occurrence of the full path of
+ * a specified file.
+ *
+ * @since 0.6
+ */
+ class HyperlinkCreator implements IDocumentListener {
+
+ //
=======================================================================================================================
+ // Fields
+ //
=======================================================================================================================
+
+ /**
+ * The console where the message is printed to and the hyperlink will be
created.
+ *
+ * @since 0.6
+ */
+ private final DnaMessageConsole console;
+
+ /**
+ * The file whose full path will become a hyperlink.
+ *
+ * @since 0.6
+ */
+ private final IFile file;
+
+ /**
+ * The message where the file path is located in.
+ *
+ * @since 0.6
+ */
+ private final String message;
+
+ //
=======================================================================================================================
+ // Constructors
+ //
=======================================================================================================================
+
+ /**
+ * @param message the message that contains the full path of the file
+ * @param console the console where the message appears
+ * @param file the file whose full path appears in the message and will become a
hyperlink
+ * @since 0.6
+ */
+ public HyperlinkCreator( String message,
+ DnaMessageConsole console,
+ IFile file ) {
+ this.message = message;
+ this.console = console;
+ this.file = file;
+ }
+
+ //
=======================================================================================================================
+ // Methods
+ //
=======================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
+ * @since 0.6
+ */
+ @Override
+ public void documentAboutToBeChanged( DocumentEvent arg0 ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
+ * @since 0.6
+ */
+ @Override
+ public void documentChanged( DocumentEvent event ) {
+ IDocument document = event.getDocument();
+
+ try {
+ FindReplaceDocumentAdapter finder = new
FindReplaceDocumentAdapter(document);
+ IRegion region = finder.find(document.getLength() - 1, this.message,
false, true, false, false);
+
+ if (region != null) {
+ String target = this.file.getFullPath().toString();
+ int index = this.message.indexOf(target);
+
+ if (index == -1) {
+ throw new
BadLocationException(RestClientI18n.dnaConsoleFilePathNotFoundMsg.text(target));
+ }
+
+ this.console.addHyperlink(new FileLink(file, null, -1, -1, -1),
region.getOffset() + 1, target.length());
+
+ // created hyperlink so no need to listen any longer
+ document.removeDocumentListener(this);
+ }
+ } catch (BadLocationException e) {
+ Activator.getDefault().log(new Status(Severity.ERROR,
+
RestClientI18n.dnaConsoleProblemCreatingHyperlinkMsg.text(), e));
+ document.removeDocumentListener(this);
+ }
+ }
+ }
+
+}
Property changes on:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/DnaMessageConsole.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/views/ServerContentProvider.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.java 2009-08-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerContentProvider.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -1,317 +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.views;
-
-import static
org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.PUBLISHED_OVERLAY_IMAGE;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IDecoration;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ILightweightLabelDecorator;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-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.IDnaObject;
-import org.jboss.dna.web.jcr.rest.client.domain.Repository;
-import org.jboss.dna.web.jcr.rest.client.domain.Server;
-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.Utils;
-
-/**
- * The <code>ServerContentProvider</code> is a content and label provider for
DNA repositories.
- *
- * @since 0.6
- */
-public final class ServerContentProvider extends ColumnLabelProvider implements
ILightweightLabelDecorator, ITreeContentProvider {
-
- //
===========================================================================================================================
- // Fields
- //
===========================================================================================================================
-
- /**
- * The server manager where the server registry is managed.
- *
- * @since 0.6
- */
- private final ServerManager serverManager;
-
- //
===========================================================================================================================
- // Constructors
- //
===========================================================================================================================
-
- /**
- * @since 0.6
- */
- public ServerContentProvider() {
- this.serverManager = Activator.getDefault().getServerManager();
- }
-
- //
===========================================================================================================================
- // Methods
- //
===========================================================================================================================
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- * @since 0.6
- */
- @Override
- public void addListener( ILabelProviderListener listener ) {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.ILightweightLabelDecorator#decorate(java.lang.Object,
org.eclipse.jface.viewers.IDecoration)
- * @since 0.6
- */
- @Override
- public void decorate( final Object element,
- IDecoration decoration ) {
- ImageDescriptor overlay = null;
- final Display display = Display.getDefault();
-
- if (display.isDisposed()) {
- return;
- }
-
- // must be an IDnaObject
- if (element instanceof Server) {
- Status status =
Activator.getDefault().getServerManager().ping((Server)element);
- overlay = Utils.getOverlayImage(status);
- } else if (element instanceof IFile) {
- if (Utils.isPublished((IFile)element)) {
- overlay =
Activator.getDefault().getImageDescriptor(PUBLISHED_OVERLAY_IMAGE);
- }
- }
-
- if (overlay != null) {
- decoration.addOverlay(overlay);
- }
-
- display.asyncExec(new Runnable() {
- @SuppressWarnings( "synthetic-access" )
- @Override
- public void run() {
- if (!display.isDisposed()) {
- fireLabelProviderChanged(new
LabelProviderChangedEvent(ServerContentProvider.this, element));
- }
- }
- });
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- * @since 0.6
- */
- @Override
- public void dispose() {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object[] getChildren( Object parentElement ) {
- assert (parentElement instanceof IDnaObject);
-
- try {
- if (parentElement instanceof Server) {
- return
this.serverManager.getRepositories((Server)parentElement).toArray();
- }
- } catch (Exception e) {
- String msg =
RestClientI18n.serverManagerGetRepositoriesExceptionMsg.text(((Server)parentElement).getShortDescription());
- Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
- }
-
- try {
- if (parentElement instanceof Repository) {
- return
this.serverManager.getWorkspaces((Repository)parentElement).toArray();
- }
- } catch (Exception e) {
- String msg = RestClientI18n.serverManagerGetWorkspacesExceptionMsg.text();
- Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
- }
-
- return new Object[0];
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object[] getElements( Object inputElement ) {
- return this.serverManager.getServers().toArray();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Image getImage( Object element ) {
- return Activator.getDefault().getImage(element);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object getParent( Object element ) {
- assert (element instanceof IDnaObject);
-
- if (element instanceof Workspace) {
- return ((Workspace)element).getRepository();
- }
-
- if (element instanceof Repository) {
- return ((Repository)element).getServer();
- }
-
- // server
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- * @since 0.6
- */
- @Override
- public String getText( Object element ) {
- assert (element instanceof IDnaObject);
- return ((IDnaObject)element).getName();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.CellLabelProvider#getToolTipImage(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Image getToolTipImage( Object object ) {
- return getImage(object);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
- * @since 0.6
- */
- @Override
- public String getToolTipText( Object element ) {
- if (element instanceof IDnaObject) {
- return ((IDnaObject)element).getShortDescription();
- }
-
- return super.getToolTipText(element);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.CellLabelProvider#getToolTipTimeDisplayed(java.lang.Object)
- * @since 0.6
- */
- @Override
- public int getToolTipTimeDisplayed( Object object ) {
- return 3000;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- * @since 0.6
- */
- @Override
- public boolean hasChildren( Object element ) {
- return getChildren(element).length > 0;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
- * java.lang.Object)
- * @since 0.6
- */
- @Override
- public void inputChanged( Viewer viewer,
- Object oldInput,
- Object newInput ) {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
java.lang.String)
- * @since 0.6
- */
- @Override
- public boolean isLabelProperty( Object element,
- String property ) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see
org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- * @since 0.6
- */
- @Override
- public void removeListener( ILabelProviderListener listener ) {
- // nothing to do
- }
-
-}
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java
===================================================================
---
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java 2009-08-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/views/ServerView.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -24,7 +24,6 @@
package org.jboss.dna.web.jcr.rest.client.swt.views;
import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.COLLAPSE_ALL_IMAGE;
-import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.REFRESH_IMAGE;
import static
org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.SERVER_VIEW_HELP_CONTEXT;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
@@ -55,6 +54,7 @@
import org.jboss.dna.web.jcr.rest.client.swt.actions.DeleteServerAction;
import org.jboss.dna.web.jcr.rest.client.swt.actions.EditServerAction;
import org.jboss.dna.web.jcr.rest.client.swt.actions.NewServerAction;
+import org.jboss.dna.web.jcr.rest.client.swt.actions.ReconnectToServerAction;
/**
* The <code>ServerView</code> shows all defined servers and their DNA
repositories.
@@ -100,14 +100,14 @@
*
* @since 0.6
*/
- private ServerContentProvider provider;
+ private DnaContentProvider provider;
/**
- * Refreshes the tree.
+ * Refreshes the server connections.
*
* @since 0.6
*/
- private IAction refreshAction;
+ private ReconnectToServerAction reconnectAction;
/**
* @since 0.6
@@ -134,22 +134,9 @@
this.collapseAllAction.setImageDescriptor(Activator.getDefault().getImageDescriptor(COLLAPSE_ALL_IMAGE));
// the refresh action is always enabled
- this.refreshAction = new Action() {
- @Override
- public void run() {
- IStructuredSelection selection =
(IStructuredSelection)getViewer().getSelection();
-
- if (selection.size() == 1) {
- getViewer().refresh(selection.getFirstElement());
- } else {
- getViewer().refresh();
- }
- }
- };
+ this.reconnectAction = new ReconnectToServerAction(this.viewer);
+ getServerManager().addRegistryListener(this.reconnectAction);
- this.refreshAction.setToolTipText(RestClientI18n.refreshActionToolTip.text());
-
this.refreshAction.setImageDescriptor(Activator.getDefault().getImageDescriptor(REFRESH_IMAGE));
-
// the shell used for dialogs that the actions display
Shell shell = this.getSite().getShell();
@@ -174,7 +161,7 @@
menuMgr.add(this.newAction);
menuMgr.add(this.editAction);
menuMgr.add(this.deleteAction);
- // menuMgr.setRemoveAllWhenShown(true);
+ menuMgr.add(this.reconnectAction);
Menu menu = menuMgr.createContextMenu(this.viewer.getTree());
this.viewer.getTree().setMenu(menu);
@@ -189,7 +176,7 @@
toolBar.add(this.newAction);
toolBar.add(this.editAction);
toolBar.add(this.deleteAction);
- toolBar.add(this.refreshAction);
+ toolBar.add(this.reconnectAction);
toolBar.add(this.collapseAllAction);
}
@@ -198,7 +185,7 @@
* @since 0.6
*/
private void constructTreeViewer( Composite parent ) {
- this.provider = new ServerContentProvider();
+ this.provider = new DnaContentProvider();
this.viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
this.viewer.setContentProvider(this.provider);
Modified:
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 2009-08-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishJob.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -23,36 +23,25 @@
*/
package org.jboss.dna.web.jcr.rest.client.swt.wizards;
-import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_CONSOLE_ID;
import static
org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.DNA_PUBLISHING_JOB_FAMILY;
import static org.jboss.dna.web.jcr.rest.client.swt.IUiConstants.PLUGIN_ID;
import java.io.File;
+import java.net.URL;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
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.debug.ui.console.FileLink;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IRegion;
-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.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.DnaResourceHelper;
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.views.DnaContentProvider;
+import org.jboss.dna.web.jcr.rest.client.swt.views.DnaMessageConsole;
/**
* The <code>PublishJob</code> publishes or unpublishes one or more files
using the {@link ServerManager}.
@@ -87,13 +76,6 @@
}
/**
- * The name of the message console that is written to.
- *
- * @since 0.6
- */
- static final String CONSOLE_NAME = RestClientI18n.publishJobConsoleName.text();
-
- /**
* A unique job identifier given to each publishing/unpublishing job.
*
* @since 0.6
@@ -106,18 +88,20 @@
/**
* @param type the job type (never <code>null</code>)
+ * @param jobId the job identifier
* @return the job name
* @since 0.6
*/
- private static String getJobName( Type type ) {
+ private static String getJobName( Type type,
+ int jobId ) {
CheckArg.isNotNull(type, "type"); //$NON-NLS-1$
if (Type.PUBLISH == type) {
- return RestClientI18n.publishJobPublishName.text();
+ return RestClientI18n.publishJobPublishName.text(jobId);
}
// unpublish
- return RestClientI18n.publishJobUnpublishName.text();
+ return RestClientI18n.publishJobUnpublishName.text(jobId);
}
//
===========================================================================================================================
@@ -132,6 +116,13 @@
private final List<IFile> files;
/**
+ * The unique job identifier.
+ *
+ * @since 0.6
+ */
+ private final int jobId;
+
+ /**
* The job type.
*
* @since 0.6
@@ -158,13 +149,14 @@
public PublishJob( Type type,
List<IFile> files,
Workspace workspace ) {
- super(getJobName(type));
+ super(getJobName(type, JOB_ID.incrementAndGet()));
CheckArg.isNotNull(files, "files"); //$NON-NLS-1$
this.type = type;
this.files = files;
this.workspace = workspace;
+ this.jobId = JOB_ID.get();
setUser(true); // allow user to run in background
}
@@ -185,31 +177,11 @@
}
/**
- * Note: The <code>DnaConsole</code> should
<strong>NOT</strong> be cached as the user can open/close/create instances.
- *
- * @return the DNA Message Console if available or a new one
+ * @return the server manager
* @since 0.6
*/
- private DnaConsole getDnaConsole() {
- DnaConsole 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 = (DnaConsole)consoles[i];
- break;
- }
- }
-
- // create DNA console if necessary
- if (console == null) {
- console = new DnaConsole();
- consoleMgr.addConsoles(new IConsole[] {console});
- }
-
- return console;
+ private ServerManager getServerManager() {
+ return Activator.getDefault().getServerManager();
}
/**
@@ -229,84 +201,99 @@
@Override
protected IStatus run( IProgressMonitor monitor ) {
assert (this.workspace != null);
- int jobId = JOB_ID.getAndIncrement();
long startTime = System.currentTimeMillis();
try {
- String name = (isPublishing() ?
RestClientI18n.publishJobPublishTaskName.text() :
RestClientI18n.publishJobUnpublishTaskName.text());
- monitor.beginTask(name, this.files.size());
+ int fileCount = this.files.size();
+ String name = (isPublishing() ?
RestClientI18n.publishJobPublishTaskName.text(this.jobId)
+ :
RestClientI18n.publishJobUnpublishTaskName.text(this.jobId));
+ monitor.beginTask(name, fileCount);
monitor.setTaskName(name);
+ String serverUrl = this.workspace.getServer().getUrl();
+ String repositoryName = this.workspace.getRepository().getName();
+ String workspaceName = this.workspace.getName();
+
// write initial message to console
if (isPublishing()) {
- writeToConsole(getDnaConsole(),
RestClientI18n.publishJobPublish.text(jobId,
-
this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName(),
-
this.files.size()));
+
DnaMessageConsole.writeln(RestClientI18n.publishJobPublish.text(this.jobId,
+
serverUrl,
+
repositoryName,
+
workspaceName,
+
fileCount));
} else {
- writeToConsole(getDnaConsole(),
RestClientI18n.publishJobUnpublish.text(jobId,
-
this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName(),
-
this.files.size()));
+
DnaMessageConsole.writeln(RestClientI18n.publishJobUnpublish.text(this.jobId,
+
serverUrl,
+
repositoryName,
+
workspaceName,
+
fileCount));
}
- // process the files
+ DnaResourceHelper resourceHelper = new
DnaResourceHelper(getServerManager());
int numProcessed = 0;
+ // process the files
for (IFile eclipseFile : this.files) {
if (monitor.isCanceled()) {
- String msg = null;
-
if (isPublishing()) {
- msg = RestClientI18n.publishJobPublishCanceledMsg.text(jobId,
-
this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName(),
-
numProcessed,
-
this.files.size());
+
DnaMessageConsole.writeln(RestClientI18n.publishJobPublishCanceledMsg.text(this.jobId,
+
serverUrl,
+
repositoryName,
+
workspaceName,
+
numProcessed,
+
fileCount));
} else {
- msg = RestClientI18n.publishJobUnpublishCanceledMsg.text(jobId,
-
this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName(),
-
numProcessed,
-
this.files.size());
+
DnaMessageConsole.writeln(RestClientI18n.publishJobUnpublishCanceledMsg.text(this.jobId,
+
serverUrl,
+
repositoryName,
+
workspaceName,
+
numProcessed,
+
fileCount));
}
- writeToConsole(getDnaConsole(), msg); // write cancel msg to console
- throw new InterruptedException(msg);
+ throw new
InterruptedException(RestClientI18n.publishJobCanceled.text(jobId));
}
File file = eclipseFile.getLocation().toFile();
+ String path = eclipseFile.getParent().getFullPath().toString();
Status status = null;
if (isPublishing()) {
- status =
Activator.getDefault().getServerManager().publish(this.workspace,
-
eclipseFile.getFullPath().toString(),
- file);
+ status = getServerManager().publish(this.workspace, path, file);
// set persistent property on resource indicating it has been
published
if (!status.isError()) {
- Utils.addPublishedProperty(eclipseFile, workspace);
+ resourceHelper.addPublishedProperty(eclipseFile, workspace);
+ DnaContentProvider decorator =
DnaContentProvider.getDecorator();
+
+ if (decorator != null) {
+ // decorator.refresh(eclipseFile);
+ }
}
} else {
- status =
Activator.getDefault().getServerManager().unpublish(this.workspace,
-
eclipseFile.getFullPath().toString(),
- file);
+ status = getServerManager().unpublish(this.workspace, path, file);
// clear persistent property on resource indicating it has been
unpublished
if (!status.isError()) {
- Utils.removePublishedProperty(eclipseFile, workspace);
+ resourceHelper.removePublishedProperty(eclipseFile, workspace);
+ DnaContentProvider decorator =
DnaContentProvider.getDecorator();
+
+ if (decorator != null) {
+ // decorator.refresh(eclipseFile);
+ }
}
}
++numProcessed;
monitor.worked(1);
- // write outcome msg to console
- writeToConsole(jobId, eclipseFile, status);
+ // write outcome message to console
+ if (isPublishing() && status.isOk()) {
+ URL url = getServerManager().getUrl(file, path, this.workspace);
+ writeToConsole(eclipseFile, url, status);
+ } else {
+ writeToConsole(eclipseFile, null, status);
+ }
}
return org.eclipse.core.runtime.Status.OK_STATUS;
@@ -323,158 +310,79 @@
} finally {
monitor.done();
- // add operation done msg
- // TODO need to format this duration better
- long duration = System.currentTimeMillis() - startTime;
+ // add operation completed message
+ String duration;
+ long milliseconds = (System.currentTimeMillis() - startTime);
+ long hours = milliseconds / (1000 * 60 * 60);
+ long minutes = (milliseconds % (1000 * 60 * 60)) / (1000 * 60);
+ long seconds = ((milliseconds % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
+ if ((seconds > 0) || (minutes > 0) || (hours > 0)) {
+ duration = RestClientI18n.publishJobLongDurationMsg.text(hours, minutes,
seconds);
+ } else {
+ duration = RestClientI18n.publishJobShortDurationMsg.text();
+ }
+
if (isPublishing()) {
- writeToConsole(getDnaConsole(),
- RestClientI18n.publishJobPublishFinishedMsg.text(jobId,
-
this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName(),
-
duration));
+
DnaMessageConsole.writeln(RestClientI18n.publishJobPublishFinishedMsg.text(this.jobId,
duration));
} else {
- writeToConsole(getDnaConsole(),
- RestClientI18n.publishJobUnpublishFinishedMsg.text(jobId,
-
this.workspace.getServer().getUrl(),
-
this.workspace.getRepository().getName(),
-
this.workspace.getName(),
-
duration));
+
DnaMessageConsole.writeln(RestClientI18n.publishJobUnpublishFinishedMsg.text(this.jobId,
duration));
}
}
}
/**
- * @param jobId the job ID
+ * Create a hyperlink in console.
+ *
* @param file the file involved in the publishing operation
+ * @param url the destination file URL or <code>null</code>
* @param status the status of the publishing operation
* @since 0.6
*/
- private void writeToConsole( int jobId,
- final IFile file,
+ private void writeToConsole( final IFile file,
+ URL url,
Status status ) {
- String msg = null;
+ String message = null;
if (status.isOk()) {
if (isPublishing()) {
- msg = RestClientI18n.publishJobPublishFile.text(jobId,
file.getFullPath());
+
DnaMessageConsole.write(RestClientI18n.publishJobPublishFile.text(this.jobId,
file.getFullPath()), false);
+
DnaMessageConsole.write(RestClientI18n.publishJobPublishFile2.text(url.toString()),
true);
+ message = ""; //$NON-NLS-1$
} else {
- msg = RestClientI18n.publishJobUnpublishFile.text(jobId,
file.getFullPath());
+ message = RestClientI18n.publishJobUnpublishFile.text(this.jobId,
file.getFullPath());
}
} else if (status.isError()) {
if (isPublishing()) {
- msg = RestClientI18n.publishJobPublishFileFailed.text(jobId,
file.getFullPath());
+ message = RestClientI18n.publishJobPublishFileFailed.text(this.jobId,
file.getFullPath());
} else {
- msg = RestClientI18n.publishJobUnpublishFileFailed.text(jobId,
file.getFullPath());
+ message = RestClientI18n.publishJobUnpublishFileFailed.text(this.jobId,
file.getFullPath());
}
// log
Activator.getDefault().log(status);
} else if (status.isWarning()) {
if (isPublishing()) {
- msg = RestClientI18n.publishJobPublishFileWarning.text(jobId,
file.getFullPath());
+ message = RestClientI18n.publishJobPublishFileWarning.text(this.jobId,
file.getFullPath());
} else {
- msg = RestClientI18n.publishJobUnpublishFileWarning.text(jobId,
file.getFullPath());
+ message = RestClientI18n.publishJobUnpublishFileWarning.text(this.jobId,
file.getFullPath());
}
// log
Activator.getDefault().log(status);
} else {
if (isPublishing()) {
- msg = RestClientI18n.publishJobPublishFileInfo.text(jobId,
file.getFullPath());
+ message = RestClientI18n.publishJobPublishFileInfo.text(this.jobId,
file.getFullPath());
} else {
- msg = RestClientI18n.publishJobUnpublishFileInfo.text(jobId,
file.getFullPath());
+ message = RestClientI18n.publishJobUnpublishFileInfo.text(this.jobId,
file.getFullPath());
}
// log
Activator.getDefault().log(status);
}
- // write to DNA Console
- final DnaConsole dnaConsole = getDnaConsole();
- final String consoleMsg = msg;
- final IDocument doc = dnaConsole.getDocument();
-
- // add listener that will add the hyperlink in the console for the file just
published/unpublished
- doc.addDocumentListener(new IDocumentListener() {
- @Override
- public void documentAboutToBeChanged( DocumentEvent event ) {
- // nothing to do
- }
-
- @Override
- public void documentChanged( DocumentEvent event ) {
- try {
- // add hyperlink to console
- int startIndex = consoleMsg.indexOf('"');
-
- if (startIndex != -1) {
- ++startIndex; // move after the '""
- int lastIndex = consoleMsg.lastIndexOf('"');
-
- if (lastIndex != -1) {
- --lastIndex; // move before the '"'
- FindReplaceDocumentAdapter finder = new
FindReplaceDocumentAdapter(doc);
- IRegion region = finder.find(0, consoleMsg, true, true,
false, false);
-
- if (region != null) {
- dnaConsole.addHyperlink(new FileLink(file, null, -1, -1,
-1),
- (region.getOffset() +
startIndex),
- (lastIndex - startIndex + 1));
- doc.removeDocumentListener(this);
- }
- }
- }
- } catch (BadLocationException e) {
- Activator.getDefault().log(new Status(Severity.ERROR,
-
RestClientI18n.publishJobProblemCreatingHyperlinkMsg.text(), e));
- doc.removeDocumentListener(this);
- }
- }
- });
-
- writeToConsole(dnaConsole, msg);
+ // write to console creating a hyperlink
+ DnaMessageConsole.writeln(message, file);
}
- /**
- * @param console the DNA console being written to
- * @param message the message being written
- * @since 0.6
- */
- private void writeToConsole( MessageConsole console,
- String message ) {
- // show and focus console view
- console.activate();
-
- // write message
- MessageConsoleStream out = console.newMessageStream();
- out.println(message);
- }
-
- //
===========================================================================================================================
- // Inner Class
- //
===========================================================================================================================
-
- class DnaConsole extends MessageConsole {
-
- /**
- * @since 0.6
- */
- public DnaConsole() {
- super(CONSOLE_NAME, null);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.console.AbstractConsole#getType()
- * @since 0.6
- */
- @Override
- public String getType() {
- return DNA_CONSOLE_ID;
- }
- }
-
}
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-28
15:55:28 UTC (rev 1181)
+++
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/web/jcr/rest/client/swt/wizards/PublishPage.java 2009-08-31
13:46:22 UTC (rev 1182)
@@ -430,9 +430,6 @@
btnNewServer.removeSelectionListener(this);
}
});
-
- // register to receive server registry events that will be generated when the
new server dialog is run
- getServerManager().addRegistryListener(this);
}
{ // row 2: repository row
@@ -550,8 +547,8 @@
IWorkbenchHelpSystem helpSystem =
Activator.getDefault().getWorkbench().getHelpSystem();
helpSystem.setHelp(pnlMain, PUBLISH_DIALOG_HELP_CONTEXT);
- // load the UI with data
- refreshServers();
+ // register to receive server registry events (this will populate the UI)
+ getServerManager().addRegistryListener(this);
}
/**