DNA SVN: r1070 - trunk/dna-jcr/src/test/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: bcarothers
Date: 2009-07-04 09:16:05 -0400 (Sat, 04 Jul 2009)
New Revision: 1070
Added:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrTest.java
Modified:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java
Log:
DNA-472 Reduce Code Duplication for Test Setup
Committed patch that sets up an abstract base class with hooks for customization on a per test case basis. Net reduction of about 500 lines of repeated code in the test library.
Added: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrTest.java (rev 0)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -0,0 +1,126 @@
+package org.jboss.dna.jcr;
+
+import static org.mockito.Mockito.stub;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.jcr.RepositoryException;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.MockSecurityContext;
+import org.jboss.dna.graph.SecurityContext;
+import org.jboss.dna.graph.connector.RepositoryConnection;
+import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
+import org.jboss.dna.graph.connector.RepositorySourceException;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.graph.property.NamespaceRegistry;
+import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
+import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoAnnotations.Mock;
+
+public abstract class AbstractJcrTest {
+
+
+ protected String workspaceName;
+ protected ExecutionContext context;
+ protected InMemoryRepositorySource source;
+ protected JcrWorkspace workspace;
+ protected JcrSession session;
+ protected Graph graph;
+ protected RepositoryConnectionFactory connectionFactory;
+ protected RepositoryNodeTypeManager repoTypeManager;
+ protected Map<String, Object> sessionAttributes;
+ protected Map<JcrRepository.Option, String> options;
+ protected NamespaceRegistry registry;
+ @Mock
+ protected JcrRepository repository;
+
+ protected void beforeEach() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ workspaceName = "workspace1";
+ final String repositorySourceName = "repository";
+
+ // Set up the source ...
+ source = new InMemoryRepositorySource();
+ source.setName(workspaceName);
+ source.setDefaultWorkspaceName(workspaceName);
+
+ // Set up the execution context ...
+ context = new ExecutionContext();
+ // Register the test namespace
+ context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
+
+ // Set up the initial content ...
+ graph = Graph.create(source, context);
+ initializeContent();
+
+ // Stub out the connection factory ...
+ connectionFactory = new RepositoryConnectionFactory() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
+ */
+ @SuppressWarnings( "synthetic-access" )
+ public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
+ return repositorySourceName.equals(sourceName) ? source.getConnection() : null;
+ }
+ };
+
+ // Stub out the repository, since we only need a few methods ...
+ repoTypeManager = new RepositoryNodeTypeManager(context);
+
+ try {
+ this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
+ "/org/jboss/dna/jcr/dna_builtins.cnd"}));
+ this.repoTypeManager.registerNodeTypes(new NodeTemplateNodeTypeSource(getTestTypes()));
+
+ } catch (RepositoryException re) {
+ re.printStackTrace();
+ throw new IllegalStateException("Could not load node type definition files", re);
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ throw new IllegalStateException("Could not access node type definition files", ioe);
+ }
+
+ stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
+ stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
+ stub(repository.getConnectionFactory()).toReturn(connectionFactory);
+
+ initializeOptions();
+ stub(repository.getOptions()).toReturn(options);
+
+ // Set up the session attributes ...
+ // Set up the session attributes ...
+ sessionAttributes = new HashMap<String, Object>();
+ sessionAttributes.put("attribute1", "value1");
+
+ // Now create the workspace ...
+ SecurityContext mockSecurityContext = new MockSecurityContext(null,
+ Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
+ workspace = new JcrWorkspace(repository, workspaceName, context.with(mockSecurityContext), sessionAttributes);
+
+ // Create the session and log in ...
+ session = (JcrSession)workspace.getSession();
+ registry = session.getExecutionContext().getNamespaceRegistry();
+ }
+
+ protected List<NodeTypeTemplate> getTestTypes() {
+ return Collections.emptyList();
+ }
+
+ protected void initializeContent() {
+
+ }
+
+ protected void initializeOptions() {
+ // Stub out the repository options ...
+ options = new EnumMap<JcrRepository.Option, String>(JcrRepository.Option.class);
+ options.put(JcrRepository.Option.PROJECT_NODE_TYPES, Boolean.FALSE.toString());
+
+ }
+}
Property changes on: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java 2009-07-02 20:30:08 UTC (rev 1069)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/ItemDefinitionTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -28,37 +28,24 @@
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
-import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
import javax.jcr.Value;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
-import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
-import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.property.ValueFactory;
+import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.basic.BasicName;
import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
/**
* BDD test cases for property and child node definition inheritance. Could be part of RepositoryNodeTypeManagerTest, but split
* off to isolate tests for this behavior vs. projection/inference and registration/unregistration behavior.
*/
-public class ItemDefinitionTest {
+public class ItemDefinitionTest extends AbstractJcrTest {
private static final Name NODE_TYPE_A = new BasicName(TestLexicon.Namespace.URI, "nodeA");
private static final Name NODE_TYPE_B = new BasicName(TestLexicon.Namespace.URI, "nodeB");
@@ -67,85 +54,22 @@
private static final Name SINGLE_PROP1 = new BasicName(TestLexicon.Namespace.URI, "singleProp1");
private static final Name SINGLE_PROP2 = new BasicName(TestLexicon.Namespace.URI, "singleProp2");
- private String workspaceName;
- protected ExecutionContext context;
- private InMemoryRepositorySource source;
- private JcrWorkspace workspace;
- private JcrSession session;
- private Graph graph;
- private RepositoryConnectionFactory connectionFactory;
- private RepositoryNodeTypeManager repoTypeManager;
- private Map<String, Object> sessionAttributes;
- private ValueFactory<Name> nameFactory;
- @Mock
- private JcrRepository repository;
+ protected NameFactory nameFactory;
+ @Override
@Before
public void beforeEach() throws Exception {
- MockitoAnnotations.initMocks(this);
+ super.beforeEach();
- workspaceName = "workspace1";
- final String repositorySourceName = "repository";
-
- // Set up the source ...
- source = new InMemoryRepositorySource();
- source.setName(workspaceName);
- source.setDefaultWorkspaceName(workspaceName);
-
- // Set up the execution context ...
- context = new ExecutionContext();
- // Register the test namespace
- context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
-
- // Set up the initial content ...
- graph = Graph.create(source, context);
-
- // Make sure the path to the namespaces exists ...
- graph.create("/jcr:system").and().create("/jcr:system/dna:namespaces");
-
- // Stub out the connection factory ...
- connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
- @SuppressWarnings( "synthetic-access" )
- public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- return repositorySourceName.equals(sourceName) ? source.getConnection() : null;
- }
- };
-
- // Stub out the repository, since we only need a few methods ...
- repoTypeManager = new RepositoryNodeTypeManager(context);
- try {
- this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
- "/org/jboss/dna/jcr/dna_builtins.cnd"}));
- this.repoTypeManager.registerNodeTypes(new NodeTemplateNodeTypeSource(getTestTypes()));
- } catch (RepositoryException re) {
- re.printStackTrace();
- throw new IllegalStateException("Could not load node type definition files", re);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- throw new IllegalStateException("Could not access node type definition files", ioe);
- }
-
- stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
- stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
- stub(repository.getConnectionFactory()).toReturn(connectionFactory);
-
- // Set up the session attributes ...
- sessionAttributes = new HashMap<String, Object>();
-
- // Now create the workspace ...
- workspace = new JcrWorkspace(repository, workspaceName, context, sessionAttributes);
-
- // Create the session and log in ...
- session = (JcrSession)workspace.getSession();
-
nameFactory = session.getExecutionContext().getValueFactories().getNameFactory();
}
+ @Override
+ protected void initializeContent() {
+ graph.create("/jcr:system").and().create("/jcr:system/dna:namespaces");
+
+ }
+
@After
public void after() throws Exception {
if (session != null && session.isLive()) {
@@ -267,7 +191,8 @@
* dnatest:singleProp2 of type LONG (note the double-definition)
*/
- private List<NodeTypeTemplate> getTestTypes() {
+ @Override
+ protected List<NodeTypeTemplate> getTestTypes() {
NodeTypeTemplate nodeA = new JcrNodeTypeTemplate(context);
nodeA.setName("dnatest:nodeA");
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java 2009-07-02 20:30:08 UTC (rev 1069)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyDefinitionTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -26,27 +26,14 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
-import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.PropertyDefinition;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
-import org.jboss.dna.graph.MockSecurityContext;
-import org.jboss.dna.graph.SecurityContext;
-import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
-import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
@@ -54,14 +41,12 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
/**
* Indirectly tests the JcrConstaintCheckerFactory through {@link JcrPropertyDefinition#satisfiesConstraints(Value)}, which
* provides the wrapper around the factory that the rest of the API is expected to utilize.
*/
-public class JcrPropertyDefinitionTest {
+public class JcrPropertyDefinitionTest extends AbstractJcrTest {
protected final String[] EXPECTED_BINARY_CONSTRAINTS = new String[] {"[,5)", "[10, 20)", "(30,40]", "[50,]"};
protected final String[] EXPECTED_DATE_CONSTRAINTS = new String[] {"[,+1945-08-01T01:30:00.000Z]",
@@ -73,92 +58,26 @@
protected final String[] EXPECTED_REFERENCE_CONSTRAINTS = new String[] {"dna:root"};
protected final String[] EXPECTED_STRING_CONSTRAINTS = new String[] {"foo", "bar*", ".*baz"};
- private String workspaceName;
- private ExecutionContext context;
- private InMemoryRepositorySource source;
- private JcrWorkspace workspace;
- private JcrSession session;
- private Graph graph;
- private RepositoryConnectionFactory connectionFactory;
- private RepositoryNodeTypeManager repoTypeManager;
- private NodeTypeManager nodeTypeManager;
- private Map<String, Object> sessionAttributes;
- @Mock
- private JcrRepository repository;
+ protected NodeTypeManager nodeTypeManager;
+
+ @Override
@Before
public void beforeEach() throws Exception {
- MockitoAnnotations.initMocks(this);
+ super.beforeEach();
- workspaceName = "workspace1";
- final String repositorySourceName = "repository";
+ nodeTypeManager = workspace.getNodeTypeManager();
+ }
- // Set up the source ...
- source = new InMemoryRepositorySource();
- source.setName(workspaceName);
- source.setDefaultWorkspaceName(workspaceName);
-
- // Set up the execution context ...
- context = new ExecutionContext();
- // Register the test namespace
- context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
-
- // Set up the initial content ...
- graph = Graph.create(source, context);
-
- // Make sure the path to the namespaces exists ...
+ @Override
+ protected void initializeContent() {
graph.create("/jcr:system").and().create("/jcr:system/dna:namespaces");
graph.create("/a").and().create("/a/b").and().create("/a/b/c");
graph.set("jcr:mixinTypes").on("/a").to(JcrMixLexicon.REFERENCEABLE);
- // Stub out the connection factory ...
- connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
- @SuppressWarnings( "synthetic-access" )
- public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- return repositorySourceName.equals(sourceName) ? source.getConnection() : null;
- }
- };
-
- // Stub out the repository, since we only need a few methods ...
- repoTypeManager = new RepositoryNodeTypeManager(context);
-
- try {
- this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
- "/org/jboss/dna/jcr/dna_builtins.cnd"}));
- this.repoTypeManager.registerNodeTypes(new NodeTemplateNodeTypeSource(getTestTypes()));
-
- } catch (RepositoryException re) {
- re.printStackTrace();
- throw new IllegalStateException("Could not load node type definition files", re);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- throw new IllegalStateException("Could not access node type definition files", ioe);
- }
-
- stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
- stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
- stub(repository.getConnectionFactory()).toReturn(connectionFactory);
-
- // Set up the session attributes ...
- sessionAttributes = new HashMap<String, Object>();
- sessionAttributes.put("attribute1", "value1");
-
- // Now create the workspace ...
- SecurityContext mockSecurityContext = new MockSecurityContext("testuser", Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
- workspace = new JcrWorkspace(repository, workspaceName, context.with(mockSecurityContext), sessionAttributes);
-
- // Create the session and log in ...
- session = (JcrSession)workspace.getSession();
-
- nodeTypeManager = workspace.getNodeTypeManager();
}
-
+
@After
public void after() throws Exception {
if (session != null && session.isLive()) {
@@ -650,7 +569,8 @@
assertThat(satisfiesConstraints(prop, new Value[] {value}), is(false));
}
- private List<NodeTypeTemplate> getTestTypes() {
+ @Override
+ protected List<NodeTypeTemplate> getTestTypes() {
NodeTypeTemplate constrainedType = new JcrNodeTypeTemplate(this.context);
constrainedType.setName("dnatest:constrainedType");
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-07-02 20:30:08 UTC (rev 1069)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -35,14 +35,12 @@
import static org.mockito.Mockito.stub;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Principal;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Map;
import java.util.UUID;
import javax.jcr.Item;
import javax.jcr.NamespaceException;
@@ -58,57 +56,29 @@
import javax.jcr.nodetype.NodeType;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.JaasSecurityContext;
-import org.jboss.dna.graph.MockSecurityContext;
-import org.jboss.dna.graph.SecurityContext;
-import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
-import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Path;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
/**
* @author jverhaeg
*/
-public class JcrSessionTest {
+public class JcrSessionTest extends AbstractJcrTest {
private static final String MULTI_LINE_VALUE = "Line\t1\nLine 2\rLine 3\r\nLine 4";
- private String workspaceName;
- private ExecutionContext context;
- private InMemoryRepositorySource source;
- private JcrWorkspace workspace;
- private JcrSession session;
- private Graph graph;
- private RepositoryConnectionFactory connectionFactory;
- private RepositoryNodeTypeManager repoTypeManager;
- private Map<String, Object> sessionAttributes;
- @Mock
- private JcrRepository repository;
-
+ @Override
@Before
public void beforeEach() throws Exception {
- workspaceName = "workspace1";
- final String repositorySourceName = "repository";
+ super.beforeEach();
- // Set up the source ...
- source = new InMemoryRepositorySource();
- source.setName(workspaceName);
- source.setDefaultWorkspaceName(workspaceName);
+ }
- // Set up the execution context ...
- context = new ExecutionContext();
-
- // Set up the initial content ...
- graph = Graph.create(source, context);
+ @Override
+ protected void initializeContent() {
graph.create("/a").and().create("/a/b").and().create("/a/b/c");
graph.set("booleanProperty").on("/a/b").to(true);
graph.set("stringProperty").on("/a/b/c").to("value");
@@ -119,50 +89,9 @@
// Make sure the path to the namespaces exists ...
graph.create("/jcr:system").and().create("/jcr:system/dna:namespaces");
- // Stub out the connection factory ...
- connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
- @SuppressWarnings( "synthetic-access" )
- public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- return repositorySourceName.equals(sourceName) ? source.getConnection() : null;
- }
- };
-
- // Set up the repo type manager
- repoTypeManager = new RepositoryNodeTypeManager(context);
- try {
- this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
- "/org/jboss/dna/jcr/dna_builtins.cnd"}));
- } catch (RepositoryException re) {
- re.printStackTrace();
- throw new IllegalStateException("Could not load node type definition files", re);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- throw new IllegalStateException("Could not access node type definition files", ioe);
- }
-
- // Stub out the repository, since we only need a few methods ...
- MockitoAnnotations.initMocks(this);
- stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
- stub(repository.getConnectionFactory()).toReturn(connectionFactory);
- stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
-
- // Set up the session attributes ...
- sessionAttributes = new HashMap<String, Object>();
- sessionAttributes.put("attribute1", "value1");
-
- // Now create the workspace ...
- SecurityContext mockSecurityContext = new MockSecurityContext(null, Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
- workspace = new JcrWorkspace(repository, workspaceName, context.with(mockSecurityContext), sessionAttributes);
-
- // Create the session and log in ...
- session = (JcrSession)workspace.getSession();
}
+
@After
public void after() throws Exception {
if (session.isLive()) {
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java 2009-07-02 20:30:08 UTC (rev 1069)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrWorkspaceTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -26,47 +26,23 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
import javax.jcr.NamespaceRegistry;
import javax.jcr.Node;
-import javax.jcr.RepositoryException;
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
-import org.jboss.dna.graph.JaasSecurityContext;
import org.jboss.dna.graph.JcrLexicon;
-import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
-import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.security.config.IDTrustConfiguration;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
/**
* @author jverhaeg
*/
-public class JcrWorkspaceTest {
+public class JcrWorkspaceTest extends AbstractJcrTest {
- private String workspaceName;
- private ExecutionContext context;
- private InMemoryRepositorySource source;
- private JcrWorkspace workspace;
- private RepositoryConnectionFactory connectionFactory;
- private Map<String, Object> sessionAttributes;
- @Mock
- private JcrRepository repository;
- private RepositoryNodeTypeManager repoManager;
-
@BeforeClass
public static void beforeClass() {
// Initialize IDTrust
@@ -80,22 +56,14 @@
}
}
+ @Override
@Before
public void beforeEach() throws Exception {
- final String repositorySourceName = "repository";
- workspaceName = "workspace1";
+ super.beforeEach();
+ }
- // Set up the source ...
- source = new InMemoryRepositorySource();
- source.setName(repositorySourceName);
- source.setDefaultWorkspaceName(workspaceName);
-
- // Set up the execution context ...
-
- context = new ExecutionContext().with(new JaasSecurityContext("dna-jcr", "superuser", "superuser".toCharArray()));
-
- // Set up the initial content ...
- Graph graph = Graph.create(source, context);
+ @Override
+ protected void initializeContent() {
graph.create("/a").and().create("/a/b").and().create("/a/b/c").and().create("/b");
graph.set("booleanProperty").on("/a/b").to(true);
graph.set("jcr:primaryType").on("/a/b").to("nt:unstructured");
@@ -104,43 +72,8 @@
// Make sure the path to the namespaces exists ...
graph.create("/jcr:system").and().create("/jcr:system/dna:namespaces");
- // Stub out the connection factory ...
- connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
- @SuppressWarnings( "synthetic-access" )
- public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- return repositorySourceName.equals(sourceName) ? source.getConnection() : null;
- }
- };
-
- // Stub out the repository, since we only need a few methods ...
- MockitoAnnotations.initMocks(this);
-
- repoManager = new RepositoryNodeTypeManager(context);
- try {
- this.repoManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
- "/org/jboss/dna/jcr/dna_builtins.cnd"}));
- } catch (RepositoryException re) {
- re.printStackTrace();
- throw new IllegalStateException("Could not load node type definition files", re);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- throw new IllegalStateException("Could not access node type definition files", ioe);
- }
-
- stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
- stub(repository.getRepositoryTypeManager()).toReturn(repoManager);
- stub(repository.getConnectionFactory()).toReturn(connectionFactory);
-
- // Now create the workspace ...
- sessionAttributes = new HashMap<String, Object>();
- workspace = new JcrWorkspace(repository, workspaceName, context, sessionAttributes);
}
-
+
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowCloneWithNullWorkspaceName() throws Exception {
workspace.clone(null, "/src", "/dest", false);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java 2009-07-02 20:30:08 UTC (rev 1069)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/MixinTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -26,32 +26,16 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
-import java.io.IOException;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.version.OnParentVersionAction;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.JcrNtLexicon;
-import org.jboss.dna.graph.MockSecurityContext;
-import org.jboss.dna.graph.SecurityContext;
-import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
-import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.basic.BasicName;
import org.jboss.dna.jcr.nodetype.NodeDefinitionTemplate;
import org.jboss.dna.jcr.nodetype.NodeTypeTemplate;
@@ -59,10 +43,8 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
-public class MixinTest {
+public class MixinTest extends AbstractJcrTest {
/*
* Declares the following node types:
@@ -87,88 +69,10 @@
static final Name CHILD_NODE_A = new BasicName("", "nodeA");
static final Name CHILD_NODE_B = new BasicName("", "nodeB");
- private String workspaceName;
- private ExecutionContext context;
- private InMemoryRepositorySource source;
- private JcrWorkspace workspace;
- private JcrSession session;
- private Graph graph;
- private RepositoryConnectionFactory connectionFactory;
- private RepositoryNodeTypeManager repoTypeManager;
- private Map<String, Object> sessionAttributes;
- private Map<JcrRepository.Option, String> options;
- private NamespaceRegistry registry;
- @Mock
- private JcrRepository repository;
-
+ @Override
@Before
public void beforeEach() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- workspaceName = "workspace1";
- final String repositorySourceName = "repository";
-
- // Set up the source ...
- source = new InMemoryRepositorySource();
- source.setName(workspaceName);
- source.setDefaultWorkspaceName(workspaceName);
-
- // Set up the execution context ...
- context = new ExecutionContext();
- // Register the test namespace
- context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
-
- // Set up the initial content ...
- graph = Graph.create(source, context);
-
- // Stub out the connection factory ...
- connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
- @SuppressWarnings( "synthetic-access" )
- public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- return repositorySourceName.equals(sourceName) ? source.getConnection() : null;
- }
- };
-
- // Stub out the repository, since we only need a few methods ...
- repoTypeManager = new RepositoryNodeTypeManager(context);
-
- try {
- this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
- "/org/jboss/dna/jcr/dna_builtins.cnd"}));
- this.repoTypeManager.registerNodeTypes(new NodeTemplateNodeTypeSource(getTestTypes()));
-
- } catch (RepositoryException re) {
- re.printStackTrace();
- throw new IllegalStateException("Could not load node type definition files", re);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- throw new IllegalStateException("Could not access node type definition files", ioe);
- }
-
- stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
- stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
- stub(repository.getConnectionFactory()).toReturn(connectionFactory);
-
- // Stub out the repository options ...
- options = new EnumMap<JcrRepository.Option, String>(JcrRepository.Option.class);
- options.put(JcrRepository.Option.PROJECT_NODE_TYPES, Boolean.FALSE.toString());
- stub(repository.getOptions()).toReturn(options);
-
- // Set up the session attributes ...
- sessionAttributes = new HashMap<String, Object>();
-
- // Now create the workspace ...
- SecurityContext mockSecurityContext = new MockSecurityContext("testuser", Collections.singleton(JcrSession.DNA_WRITE_PERMISSION));
- workspace = new JcrWorkspace(repository, workspaceName, context.with(mockSecurityContext), sessionAttributes);
-
- // Create the session and log in ...
- session = (JcrSession)workspace.getSession();
- registry = session.getExecutionContext().getNamespaceRegistry();
+ super.beforeEach();
}
@After
@@ -475,7 +379,8 @@
nodeA.removeMixin(MIXIN_TYPE_B.getString(registry));
}
- private List<NodeTypeTemplate> getTestTypes() {
+ @Override
+ protected List<NodeTypeTemplate> getTestTypes() {
NodeTypeTemplate mixinTypeA = new JcrNodeTypeTemplate(this.context);
mixinTypeA.setName("mixinTypeA");
mixinTypeA.setMixin(true);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java 2009-07-02 20:30:08 UTC (rev 1069)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/RepositoryNodeTypeManagerTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -29,8 +29,6 @@
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.stub;
-import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
@@ -42,63 +40,30 @@
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.version.OnParentVersionAction;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.Graph;
-import org.jboss.dna.graph.MockSecurityContext;
-import org.jboss.dna.graph.SecurityContext;
-import org.jboss.dna.graph.connector.RepositoryConnection;
-import org.jboss.dna.graph.connector.RepositoryConnectionFactory;
-import org.jboss.dna.graph.connector.RepositorySourceException;
-import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-import org.mockito.MockitoAnnotations.Mock;
-public class RepositoryNodeTypeManagerTest {
+public class RepositoryNodeTypeManagerTest extends AbstractJcrTest {
- private String workspaceName;
- private ExecutionContext context;
- private InMemoryRepositorySource source;
- private JcrWorkspace workspace;
- private JcrSession session;
- private Graph graph;
- private RepositoryConnectionFactory connectionFactory;
- private RepositoryNodeTypeManager repoTypeManager;
- private Map<String, Object> sessionAttributes;
- private Map<JcrRepository.Option, String> options;
- @Mock
- private JcrRepository repository;
-
+ @Override
@Before
public void beforeEach() throws Exception {
- MockitoAnnotations.initMocks(this);
+ super.beforeEach();
- workspaceName = "workspace1";
- final String repositorySourceName = "repository";
+ graph.set("jcr:primaryType").on("/jcr:system/dna:namespaces").to(DnaLexicon.NAMESPACES);
- // Set up the source ...
- source = new InMemoryRepositorySource();
- source.setName(workspaceName);
- source.setDefaultWorkspaceName(workspaceName);
+ }
- // Set up the execution context ...
- context = new ExecutionContext();
- // Register the test namespace
- context.getNamespaceRegistry().register(TestLexicon.Namespace.PREFIX, TestLexicon.Namespace.URI);
-
- // Set up the initial content ...
- graph = Graph.create(source, context);
-
+ @Override
+ protected void initializeContent() {
// Make sure the path to the namespaces exists ...
graph.create("/jcr:system"); // .and().create("/jcr:system/dna:namespaces");
graph.set("jcr:primaryType").on("/jcr:system").to(DnaLexicon.SYSTEM);
@@ -106,56 +71,16 @@
graph.create("/a").and().create("/a/b").and().create("/a/b/c");
graph.set("jcr:mixinTypes").on("/a").to(JcrMixLexicon.REFERENCEABLE);
- // Stub out the connection factory ...
- connectionFactory = new RepositoryConnectionFactory() {
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.connector.RepositoryConnectionFactory#createConnection(java.lang.String)
- */
- @SuppressWarnings( "synthetic-access" )
- public RepositoryConnection createConnection( String sourceName ) throws RepositorySourceException {
- return repositorySourceName.equals(sourceName) ? source.getConnection() : null;
- }
- };
+ }
- // Stub out the repository, since we only need a few methods ...
- repoTypeManager = new RepositoryNodeTypeManager(context);
- try {
- this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
- "/org/jboss/dna/jcr/dna_builtins.cnd"}));
- } catch (RepositoryException re) {
- re.printStackTrace();
- throw new IllegalStateException("Could not load node type definition files", re);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- throw new IllegalStateException("Could not access node type definition files", ioe);
- }
-
- stub(repository.getRepositoryTypeManager()).toReturn(repoTypeManager);
- stub(repository.getRepositorySourceName()).toReturn(repositorySourceName);
- stub(repository.getConnectionFactory()).toReturn(connectionFactory);
-
+ @Override
+ protected void initializeOptions() {
// Stub out the repository options ...
options = new EnumMap<JcrRepository.Option, String>(JcrRepository.Option.class);
options.put(JcrRepository.Option.PROJECT_NODE_TYPES, Boolean.TRUE.toString());
- stub(repository.getOptions()).toReturn(options);
- // Set up the session attributes ...
- sessionAttributes = new HashMap<String, Object>();
- sessionAttributes.put("attribute1", "value1");
-
- // Now create the workspace ...
- SecurityContext mockSecurityContext = new MockSecurityContext("testuser", Collections.singleton(JcrSession.DNA_READ_PERMISSION));
- workspace = new JcrWorkspace(repository, workspaceName, context.with(mockSecurityContext), sessionAttributes);
-
- // Create the session and log in ...
- session = (JcrSession)workspace.getSession();
-
- graph.set("jcr:primaryType").on("/jcr:system/dna:namespaces").to(DnaLexicon.NAMESPACES);
-
}
-
+
@After
public void after() throws Exception {
if (session != null && session.isLive()) {
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java 2009-07-02 20:30:08 UTC (rev 1069)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/TypeRegistrationTest.java 2009-07-04 13:16:05 UTC (rev 1070)
@@ -28,15 +28,12 @@
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
-import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
import javax.jcr.nodetype.NoSuchNodeTypeException;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.PropertyDefinition;
-import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.NamespaceRegistry;
@@ -48,42 +45,25 @@
import org.jboss.dna.jcr.nodetype.PropertyDefinitionTemplate;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
-public class TypeRegistrationTest {
+public class TypeRegistrationTest extends AbstractJcrTest {
private static final String TEST_TYPE_NAME = "dna:testNode";
private static final String TEST_TYPE_NAME2 = "dna:testNode2";
private static final String TEST_PROPERTY_NAME = "dna:testProperty";
private static final String TEST_CHILD_NODE_NAME = "dna:testChildNode";
- private ExecutionContext context;
- private RepositoryNodeTypeManager repoTypeManager;
private JcrNodeTypeTemplate ntTemplate;
- private NameFactory nameFactory;
private NamespaceRegistry registry;
+ private NameFactory nameFactory;
+ @Override
@Before
public void beforeEach() throws Exception {
- MockitoAnnotations.initMocks(this);
- context = new ExecutionContext();
- nameFactory = context.getValueFactories().getNameFactory();
- registry = context.getNamespaceRegistry();
-
- repoTypeManager = new RepositoryNodeTypeManager(context);
-
- try {
- this.repoTypeManager.registerNodeTypes(new CndNodeTypeSource(new String[] {"/org/jboss/dna/jcr/jsr_170_builtins.cnd",
- "/org/jboss/dna/jcr/dna_builtins.cnd"}));
- } catch (RepositoryException re) {
- re.printStackTrace();
- throw new IllegalStateException("Could not load node type definition files", re);
- } catch (IOException ioe) {
- ioe.printStackTrace();
- throw new IllegalStateException("Could not access node type definition files", ioe);
- }
-
+ super.beforeEach();
ntTemplate = new JcrNodeTypeTemplate(context);
+ registry = context.getNamespaceRegistry();
+ nameFactory = context.getValueFactories().getNameFactory();
}
@Test( expected = AssertionError.class )
16 years, 9 months
DNA SVN: r1069 - in branches/eclipse: org.jboss.dna.publish/META-INF and 5 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-02 16:30:08 -0400 (Thu, 02 Jul 2009)
New Revision: 1069
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java
branches/eclipse/org.jboss.dna.publish/.classpath
branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java
Log:
Added JCIP immutable, threadsafe annotations. Made ServerManager thread safe. Got recurse flag saving and restoring on PublishPage.
Modified: branches/eclipse/org.jboss.dna.publish/.classpath
===================================================================
--- branches/eclipse/org.jboss.dna.publish/.classpath 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/.classpath 2009-07-02 20:30:08 UTC (rev 1069)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry exported="true" kind="lib" path="jcip-annotations.jar"/>
<classpathentry exported="true" kind="lib" path="slf4j-api-1.5.8.jar"/>
<classpathentry exported="true" kind="lib" path="jettison-1.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
Modified: branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF
===================================================================
--- branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/META-INF/MANIFEST.MF 2009-07-02 20:30:08 UTC (rev 1069)
@@ -9,7 +9,8 @@
Bundle-Localization: plugin
Bundle-ClassPath: dnaPublish.jar,
jettison-1.1.jar,
- slf4j-api-1.5.8.jar
+ slf4j-api-1.5.8.jar,
+ jcip-annotations.jar
Export-Package: org.jboss.dna.publish,
org.jboss.dna.publish.domain,
org.jboss.dna.publish.domain.validation
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java 2009-07-02 20:30:08 UTC (rev 1069)
@@ -31,6 +31,9 @@
import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
@@ -38,6 +41,8 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import net.jcip.annotations.GuardedBy;
+import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.publish.Status.Severity;
import org.jboss.dna.publish.domain.Repository;
import org.jboss.dna.publish.domain.Server;
@@ -54,6 +59,7 @@
* @author Dan Florian
* @since 0.6
*/
+@ThreadSafe
public final class ServerManager implements IConstants {
// ===========================================================================================================================
@@ -111,18 +117,30 @@
*
* @since 0.6
*/
- private final Collection<IServerRegistryListener> listeners;
+ private final CopyOnWriteArrayList<IServerRegistryListener> listeners;
/**
+ * The path where the server registry is persisted or <code>null</code> if not persisted.
+ *
* @since 0.6
*/
private final String stateLocationPath;
/**
+ * The server registry.
+ *
* @since 0.6
*/
+ @GuardedBy( "serverLock" )
private final List<Server> servers;
+ /**
+ * Lock used for when accessing the server registry.
+ *
+ * @since 0.6
+ */
+ private final ReadWriteLock serverLock = new ReentrantReadWriteLock();
+
// ===========================================================================================================================
// Constructors
// ===========================================================================================================================
@@ -133,9 +151,9 @@
* @since 0.6
*/
public ServerManager( String stateLocationPath ) {
- this.servers = Collections.synchronizedList(new ArrayList<Server>());
+ this.servers = new ArrayList<Server>();
this.stateLocationPath = stateLocationPath;
- this.listeners = new ArrayList<IServerRegistryListener>();
+ this.listeners = new CopyOnWriteArrayList<IServerRegistryListener>();
}
// ===========================================================================================================================
@@ -150,11 +168,7 @@
* @since 0.6
*/
public boolean addRegistryListener( IServerRegistryListener listener ) {
- if (!this.listeners.contains(listener)) {
- return this.listeners.add(listener);
- }
-
- return false;
+ return this.listeners.addIfAbsent(listener);
}
/**
@@ -173,7 +187,12 @@
* @since 0.6
*/
public Collection<Server> getServers() {
- return Collections.unmodifiableCollection(this.servers);
+ try {
+ this.serverLock.readLock().lock();
+ return Collections.unmodifiableCollection(new ArrayList<Server>(this.servers));
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
}
/**
@@ -196,8 +215,13 @@
* @since 0.6
*/
public Collection<Repository> getRepositories( Server server ) {
- // TODO implement getRepositories()
- return Collections.emptyList();
+ try {
+ this.serverLock.readLock().lock();
+ // TODO implement getRepositories()
+ return Collections.unmodifiableCollection(new ArrayList<Repository>(/* repositories */));
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
}
/**
@@ -206,8 +230,13 @@
* @since 0.6
*/
public Collection<Workspace> getWorkspaces( Repository repository ) {
- // TODO implement getWorkspaces()
- return Collections.emptyList();
+ try {
+ this.serverLock.readLock().lock();
+ // TODO implement getWorkspaces()
+ return Collections.unmodifiableCollection(new ArrayList<Workspace>(/* workspaces */));
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
}
/**
@@ -220,18 +249,25 @@
*/
private Status internalAddServer( Server server,
boolean notifyListeners ) {
- if (!this.servers.contains(server)) {
- if (this.servers.add(server)) {
- if (notifyListeners) {
- Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
- return processRegistryListenerErrors(errors);
- }
+ boolean added = false;
- return Status.OK_STATUS;
+ try {
+ this.serverLock.writeLock().lock();
+
+ if (!this.servers.contains(server)) {
+ added = this.servers.add(server);
}
+ } finally {
+ this.serverLock.writeLock().unlock();
+ }
- // server was not added to registry for unexpected reason
- return new Status(Severity.ERROR, ServerManagerRegistryAddUnexpectedError, null);
+ if (added) {
+ if (notifyListeners) {
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
+ return processRegistryListenerErrors(errors);
+ }
+
+ return Status.OK_STATUS;
}
// server already exists
@@ -249,9 +285,18 @@
*/
private Status internalRemoveServer( Server server,
boolean notifyListeners ) {
- if (this.servers.remove(server)) {
+ boolean removed = false;
+
+ try {
+ this.serverLock.writeLock().lock();
+ removed = this.servers.remove(server);
+ } finally {
+ this.serverLock.writeLock().unlock();
+ }
+
+ if (removed) {
if (notifyListeners) {
- Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(server));
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
return processRegistryListenerErrors(errors);
}
@@ -271,7 +316,12 @@
* @since 0.6
*/
public boolean isRegistered( Server server ) {
- return this.servers.contains(server);
+ try {
+ this.serverLock.readLock().lock();
+ return this.servers.contains(server);
+ } finally {
+ this.serverLock.readLock().unlock();
+ }
}
/**
@@ -280,35 +330,32 @@
* @since 0.6
*/
private Exception[] notifyRegistryListeners( ServerRegistryEvent event ) {
- if (!this.listeners.isEmpty()) {
- Collection<Exception> errors = null;
- Collection<IServerRegistryListener> registryListeners = new ArrayList<IServerRegistryListener>(this.listeners);
+ Collection<Exception> errors = null;
- for (IServerRegistryListener l : registryListeners) {
- try {
- Exception[] problems = l.serverRegistryChanged(event);
+ for (IServerRegistryListener l : this.listeners) {
+ try {
+ Exception[] problems = l.serverRegistryChanged(event);
- if ((problems != null) && (problems.length != 0)) {
- if (errors == null) {
- errors = new ArrayList<Exception>();
- }
-
- errors.addAll(Arrays.asList(problems));
- }
- } catch (Exception e) {
+ if ((problems != null) && (problems.length != 0)) {
if (errors == null) {
errors = new ArrayList<Exception>();
}
- errors.add(e);
+ errors.addAll(Arrays.asList(problems));
}
- }
+ } catch (Exception e) {
+ if (errors == null) {
+ errors = new ArrayList<Exception>();
+ }
- if ((errors != null) && !errors.isEmpty()) {
- return errors.toArray(new Exception[errors.size()]);
+ errors.add(e);
}
}
+ if ((errors != null) && !errors.isEmpty()) {
+ return errors.toArray(new Exception[errors.size()]);
+ }
+
return null;
}
@@ -482,21 +529,4 @@
return status;
}
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
- public static void main( String[] args ) {
- ServerManager mgr = new ServerManager("/home/dan"); //$NON-NLS-1$
-
- // populate registry
- if (mgr.servers.isEmpty()) {
- for (int i = 0; i < 10; ++i) {
- mgr.addServer(new Server("http://server" + i + ".com", "user" + i, "password" + i)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- }
-
- mgr.saveState();
- }
-
}
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java 2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,7 @@
package org.jboss.dna.publish.domain;
import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
import org.jboss.dna.publish.IConstants;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.domain.validation.RepositoryValidator;
@@ -34,6 +35,7 @@
* @author Dan Florian
* @since 0.6
*/
+@Immutable
public final class Repository implements IConstants, IDnaObject {
// ===========================================================================================================================
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java 2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,7 @@
package org.jboss.dna.publish.domain;
import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
import org.jboss.dna.publish.IConstants;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.domain.validation.RepositoryValidator;
@@ -35,6 +36,7 @@
* @author Dan Florian
* @since 0.6
*/
+@Immutable
public final class Server implements IConstants, IDnaObject {
// ===========================================================================================================================
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java 2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,7 @@
package org.jboss.dna.publish.domain;
import java.text.MessageFormat;
+import net.jcip.annotations.Immutable;
import org.jboss.dna.publish.IConstants;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.domain.validation.WorkspaceValidator;
@@ -34,6 +35,7 @@
* @author Dan Florian
* @since 0.6
*/
+@Immutable
public final class Workspace implements IConstants, IDnaObject {
// ===========================================================================================================================
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml 2009-07-02 20:30:08 UTC (rev 1069)
@@ -24,6 +24,16 @@
class="org.jboss.dna.publish.ui.swt.actions.UnpublishAction"
menubarPath="org.jboss.dna.publish.ui.swt.contextMenu/group1"
enablesFor="*">
+ <enablement>
+ <or>
+ <objectClass name="org.eclipse.core.resources.IFile" />
+ <objectClass name="org.eclipse.core.resources.IFolder" />
+ <and>
+ <objectClass name="org.eclipse.core.resources.IProject" />
+ <objectState name="open" value="true" />
+ </and>
+ </or>
+ </enablement>
</action>
<!-- Publish action -->
@@ -33,6 +43,16 @@
class="org.jboss.dna.publish.ui.swt.actions.PublishAction"
menubarPath="org.jboss.dna.publish.ui.swt.contextMenu/group1"
enablesFor="*">
+ <enablement>
+ <or>
+ <objectClass name="org.eclipse.core.resources.IFile" />
+ <objectClass name="org.eclipse.core.resources.IFolder" />
+ <and>
+ <objectClass name="org.eclipse.core.resources.IProject" />
+ <objectState name="open" value="true" />
+ </and>
+ </or>
+ </enablement>
</action>
</objectContribution>
</extension>
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java 2009-07-02 20:30:08 UTC (rev 1069)
@@ -63,7 +63,8 @@
public static String PublishPageNoAvailableRepositoriesStatusMsg;
public static String PublishPageNoAvailableServersStatusMsg;
public static String PublishPageNoAvailableWorkspacesStatusMsg;
- public static String PublishPageNoResourcesStatusMsg;
+ public static String PublishPageNoResourcesToPublishStatusMsg;
+ public static String PublishPageNoResourcesToUnpublishStatusMsg;
public static String PublishPagePublishOkStatusMsg;
public static String PublishPagePublishResourcesLabel;
public static String PublishPageRecurseCheckBox;
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties 2009-07-02 20:30:08 UTC (rev 1069)
@@ -52,8 +52,9 @@
PublishPageNewServerButton = New...
PublishPageNoAvailableRepositoriesStatusMsg = There are no repositories available on that server
PublishPageNoAvailableServersStatusMsg = A server must be created first
-PublishPageNoAvailableWorkspacesStatusMsg = There are no workspaces availabe on that server and repository
-PublishPageNoResourcesStatusMsg = You must select one or more workspace resources
+PublishPageNoAvailableWorkspacesStatusMsg = There are no workspaces available on that server and repository
+PublishPageNoResourcesToPublishStatusMsg = There are no files that can be published
+PublishPageNoResourcesToUnpublishStatusMsg = There are no files that can be unpublished
PublishPagePublishOkStatusMsg = Choose the server, repository, and workspace where the selected resources will be published.
PublishPagePublishResourcesLabel = These resources will be published to the specified DNA repository:
PublishPageRecurseCheckBox = Recurse folders and projects
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java 2009-07-02 20:30:08 UTC (rev 1069)
@@ -38,6 +38,7 @@
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -114,7 +115,7 @@
* Processes the specified list of files and for (1) each file found adds it to the result and (2) for each project or folder
* adds all contained files. For projects and folders processing will be recursive based on saved wizard settings.
*
- * @param resources the resources being processed
+ * @param resources the resources being processed (never <code>null</code>)
* @param recurse the flag indicating if child containers should be traversed
* @return the files being published or unpublished (never <code>null</code>)
* @throws CoreException if there is a problem processing the resources
@@ -377,7 +378,6 @@
this.type = type;
this.resources = resources;
- this.files = processResources(resources, this.recurse);
}
// ===========================================================================================================================
@@ -394,7 +394,7 @@
// row 2: label combobox
// row 3: label combobox
- { // server row
+ { // row 1: server row
Composite pnlServer = new Composite(pnl, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.marginHeight = 0;
@@ -413,7 +413,7 @@
this.cbxServer.setToolTipText(I18n.PublishPageServerToolTip);
final IAction action = new NewServerAction(this.getShell(), getServerManager());
- Button btnNewServer = new Button(pnlServer, SWT.PUSH);
+ final Button btnNewServer = new Button(pnlServer, SWT.PUSH);
btnNewServer.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
btnNewServer.setText(I18n.PublishPageNewServerButton);
btnNewServer.setToolTipText(action.getToolTipText());
@@ -424,9 +424,18 @@
refreshServers();
}
});
+
+ // update page message first time selected to get rid of initial message by forcing validation
+ btnNewServer.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ updateInitialMessage();
+ btnNewServer.removeSelectionListener(this);
+ }
+ });
}
- { // repository row
+ { // row 2: repository row
Label lblRepository = new Label(pnl, SWT.LEFT);
lblRepository.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
lblRepository.setText(I18n.PublishPageRepositoryLabel);
@@ -436,7 +445,7 @@
this.cbxRepository.setToolTipText(I18n.PublishPageRepositoryToolTip);
}
- { // workspace row
+ { // row 3: workspace row
Label lblWorkspace = new Label(pnl, SWT.LEFT);
lblWorkspace.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
lblWorkspace.setText(I18n.PublishPageWorkspaceLabel);
@@ -454,12 +463,13 @@
private void constructResourcesPanel( Composite parent ) {
Composite pnl = new Composite(parent, SWT.NONE);
- pnl.setLayout(new GridLayout(2, false));
+ pnl.setLayout(new GridLayout());
pnl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// pnl layout:
- // row 1: lbl chk
+ // row 1: lbl
// row 2: lstResources
+ // row 3: chkbox
{ // row 1
Label lbl = new Label(pnl, SWT.LEFT);
@@ -470,17 +480,6 @@
} else {
lbl.setText(I18n.PublishPageUnpublishResourcesLabel);
}
-
- final Button chk = new Button(pnl, SWT.CHECK);
- chk.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
- chk.setText(I18n.PublishPageRecurseCheckBox);
- chk.setToolTipText(I18n.PublishPageRecurseCheckBoxToolTip);
- chk.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected( SelectionEvent e ) {
- handleRecurseChanged(chk.getSelection());
- }
- });
}
{ // row 2
@@ -488,10 +487,45 @@
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.horizontalSpan = 2;
this.lstResources.setLayoutData(gd);
+ final org.eclipse.swt.widgets.List finalLst = this.lstResources;
+ // update page message first time selected to get rid of initial message by forcing validation
+ this.lstResources.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ // do the very first time to get rid of initial message then remove listener
+ updateInitialMessage();
+ finalLst.removeSelectionListener(this);
+ }
+ });
+
// load list with initial files
loadFiles();
}
+
+ { // row 3
+ final Button chkRecurse = new Button(pnl, SWT.CHECK);
+ chkRecurse.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ chkRecurse.setText(I18n.PublishPageRecurseCheckBox);
+ chkRecurse.setToolTipText(I18n.PublishPageRecurseCheckBoxToolTip);
+ chkRecurse.setSelection(this.recurse);
+ chkRecurse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleRecurseChanged(chkRecurse.getSelection());
+ }
+ });
+
+ // update page message first time selected to get rid of initial message by forcing validation
+ chkRecurse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ updateInitialMessage();
+ chkRecurse.removeSelectionListener(this);
+ }
+ });
+
+ }
}
/**
@@ -521,6 +555,19 @@
}
/**
+ * Updates the initial page message.
+ *
+ * @since 0.6
+ */
+ void updateInitialMessage() {
+ String msg = ((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
+
+ if (msg.equals(getMessage())) {
+ updateState();
+ }
+ }
+
+ /**
* @return the server manager obtained from the wizard
* @since 0.6
*/
@@ -843,11 +890,31 @@
validate();
// set initial message
- setMessage((type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
+ setMessage((this.type == Type.PUBLISH) ? I18n.PublishPagePublishOkStatusMsg : I18n.PublishPageUnpublishOkStatusMsg);
}
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.wizard.WizardPage#setWizard(org.eclipse.jface.wizard.IWizard)
+ * @since 0.6
+ */
+ @Override
+ public void setWizard( IWizard newWizard ) {
+ super.setWizard(newWizard);
+
+ // need to make sure the wizard has been set on the page since the recurse value is saved in the wizard dialog settings
+ this.recurse = isRecursing();
+
+ try {
+ this.files = processResources(this.resources, this.recurse);
+ } catch (CoreException e) {
+ Activator.getDefault().log(new Status(Severity.ERROR, I18n.PublishPageRecurseProcessingErrorMsg, e));
+ }
+ }
+
+ /**
* Uninstalls the combobox listeners.
*
* @param listenerControlLock the method in control of registering/unregistering combobox listeners
@@ -868,7 +935,7 @@
*
* @since 0.6
*/
- private void updateState() {
+ void updateState() {
// get the current state
validate();
@@ -898,9 +965,8 @@
String msg = null;
Severity severity = Severity.ERROR;
- if (this.resources != null && this.resources.isEmpty()) {
- // should not happen since action should not enable if nothing selected
- msg = I18n.PublishPageNoResourcesStatusMsg;
+ if ((this.resources == null) || this.resources.isEmpty() || this.files.isEmpty()) {
+ msg = ((type == Type.PUBLISH) ? I18n.PublishPageNoResourcesToPublishStatusMsg : I18n.PublishPageNoResourcesToUnpublishStatusMsg);
} else if (this.server == null) {
int count = this.cbxServer.getItemCount();
msg = ((count == 0) ? I18n.PublishPageNoAvailableServersStatusMsg : I18n.PublishPageMissingServerStatusMsg);
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java 2009-07-01 22:20:46 UTC (rev 1068)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java 2009-07-02 20:30:08 UTC (rev 1069)
@@ -167,6 +167,7 @@
});
}
+ // FIXME implement save password
{ // save button row
Button btn = new Button(pnl, SWT.CHECK | SWT.LEFT);
btn.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
16 years, 9 months
DNA SVN: r1068 - in branches/eclipse: org.jboss.dna.publish/.settings and 13 other directories.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-07-01 18:20:46 -0400 (Wed, 01 Jul 2009)
New Revision: 1068
Added:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/new_server.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Utils.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerContentProvider.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java
branches/eclipse/org.jboss.dna.publish/jcip-annotations.jar
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IServerRegistryListener.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerRegistryEvent.java
Removed:
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/full/
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/repository.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/EclipseStatus.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryContentProvider.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryView.java
Modified:
branches/eclipse/org.jboss.dna.publish.ui.swt/.settings/org.eclipse.jdt.core.prefs
branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF
branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/repository.gif
branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/workspace.gif
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/publish/ui/swt/Activator.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/IUiConstants.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/dialogs/DeleteServerDialog.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java
branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java
branches/eclipse/org.jboss.dna.publish/.settings/org.eclipse.jdt.core.prefs
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Logger.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java
branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java
Log:
More updates to UI.
Modified: branches/eclipse/org.jboss.dna.publish/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/eclipse/org.jboss.dna.publish/.settings/org.eclipse.jdt.core.prefs 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/.settings/org.eclipse.jdt.core.prefs 2009-07-01 22:20:46 UTC (rev 1068)
@@ -1,7 +1,20 @@
-#Wed May 20 08:35:05 CDT 2009
+#Wed Jul 01 08:15:03 CDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
org.eclipse.jdt.core.compiler.source=1.6
Added: branches/eclipse/org.jboss.dna.publish/jcip-annotations.jar
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish/jcip-annotations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IConstants.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -39,8 +39,6 @@
String ErrorSavingServerRegistry = "ErrorSavingServerRegistry"; //$NON-NLS-1$
- String RemovingServerProblemMsg = "RemovingServerProblemMsg"; //$NON-NLS-1$
-
String RepositoryEmptyNameMsg = "RepositoryEmptyNameMsg"; //$NON-NLS-1$
String RepositoryNullServerMsg = "RepositoryNullServerMsg"; //$NON-NLS-1$
@@ -55,6 +53,18 @@
String ServerExistsMsg = "ServerExistsMsg"; //$NON-NLS-1$
+ String ServerManagerRegistryAddUnexpectedError = "ServerManagerRegistryAddUnexpectedError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryListenerError = "ServerManagerRegistryListenerError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryListenerErrorsOccurred = "ServerManagerRegistryListenerErrorsOccurred"; //$NON-NLS-1$
+
+ String ServerManagerRegistryRemoveUnexpectedError = "ServerManagerRegistryRemoveUnexpectedError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryUpdateAddError = "ServerManagerRegistryUpdateAddError"; //$NON-NLS-1$
+
+ String ServerManagerRegistryUpdateRemoveError = "ServerManagerRegistryUpdateRemoveError"; //$NON-NLS-1$
+
String ServerShortDescription = "ServerShortDescription"; //$NON-NLS-1$
String WorkspaceEmptyNameMsg = "WorkspaceEmptyNameMsg"; //$NON-NLS-1$
Added: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IServerRegistryListener.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IServerRegistryListener.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IServerRegistryListener.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,39 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public interface IServerRegistryListener {
+
+ /**
+ * @param event the event being processed
+ * @return any errors caught during the processing or <code>null</code>
+ * @since 0.6
+ */
+ Exception[] serverRegistryChanged( ServerRegistryEvent event );
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/IServerRegistryListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Logger.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Logger.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Logger.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -28,6 +28,7 @@
/**
* @author Dan Florian
+ * @since 0.6
*/
public final class Logger {
@@ -36,36 +37,99 @@
// ===========================================================================================================================
/**
+ * @param status the status whose message is a {@link MessageFormat} pattern.
+ * @param arguments the arguments being inserted into the pattern
+ * @return the message
+ * @since 0.6
+ */
+ private static String getMessage( Status status,
+ Object... arguments ) {
+ return MessageFormat.format(status.getMessage(), arguments);
+ }
+
+ /**
* @param clazz the class whose logger will be used
- * @param error the error being logged
- * @param message the message being logged
+ * @param status the status being logged
* @since 0.6
*/
- public static void error( Class<?> clazz,
- Throwable error,
- String message ) {
+ public static void log( Class<?> clazz,
+ Status status ) {
org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
- if (delegate.isErrorEnabled()) {
- delegate.error(message, error);
+ if (status.isError() && delegate.isErrorEnabled()) {
+ if (status.getException() == null) {
+ delegate.error(status.getMessage());
+ } else {
+ delegate.error(status.getMessage(), status.getException());
+ }
+ } else if (status.isWarning() && delegate.isWarnEnabled()) {
+ if (status.getException() == null) {
+ delegate.warn(status.getMessage());
+ } else {
+ delegate.warn(status.getMessage(), status.getException());
+ }
+ } else if (status.isInfo() && delegate.isInfoEnabled()) {
+ if (status.getException() == null) {
+ delegate.info(status.getMessage());
+ } else {
+ delegate.info(status.getMessage(), status.getException());
+ }
+ } else {
+ if (delegate.isTraceEnabled()) {
+ if (status.getException() == null) {
+ delegate.info(status.getMessage());
+ } else {
+ delegate.info(status.getMessage(), status.getException());
+ }
+ }
}
}
/**
* @param clazz the class whose logger will be used
- * @param error the error being logged
- * @param pattern the message format pattern
+ * @param status the status being logged (status message is a {@link MessageFormat} pattern)
* @param arguments the arguments to be inserted into the pattern
* @since 0.6
*/
- public static void error( Class<?> clazz,
- Throwable error,
- String pattern,
- Object... arguments ) {
+ public static void log( Class<?> clazz,
+ Status status,
+ Object... arguments ) {
org.slf4j.Logger delegate = LoggerFactory.getLogger(clazz);
- if (delegate.isErrorEnabled()) {
- delegate.error(MessageFormat.format(pattern, arguments), error);
+ if (status.isError() && delegate.isErrorEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.error(msg);
+ } else {
+ delegate.error(msg);
+ }
+ } else if (status.isWarning() && delegate.isWarnEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.warn(msg);
+ } else {
+ delegate.warn(msg, status.getException());
+ }
+ } else if (status.isInfo() && delegate.isInfoEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.info(msg);
+ } else {
+ delegate.info(msg, status.getException());
+ }
+ } else {
+ if (delegate.isTraceEnabled()) {
+ String msg = getMessage(status, arguments);
+
+ if (status.getException() == null) {
+ delegate.info(msg);
+ } else {
+ delegate.info(msg, status.getException());
+ }
+ }
}
}
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Messages.properties 2009-07-01 22:20:46 UTC (rev 1068)
@@ -1,3 +1,26 @@
+#
+# 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.
+#
ErrorDeletingServerRegistryFile = There was a problem deleting server registry file "{0}"
ErrorRestoringServerRegistry = Error trying to restore the server registry from file "{0}"
ErrorSavingServerRegistry = Error trying to save the server registry to "{0}"
@@ -2,4 +25,2 @@
-RemovingServerProblemMsg = {0} cannot be removed as it has not been registered
-
RepositoryEmptyNameMsg = A repository name cannot be empty
@@ -14,6 +35,13 @@
ServerInvalidUrlMsg = The value "{0}" is not a valid server URL
ServerShortDescription = DNA Server: URL={0} User={1}
+ServerManagerRegistryAddUnexpectedError = Unexpected error adding server to registry
+ServerManagerRegistryListenerError = This error was reported by an IServerRegistryListener
+ServerManagerRegistryListenerErrorsOccurred = Errors occurred processing a server registry event. Check error log for more details.
+ServerManagerRegistryRemoveUnexpectedError = {0} cannot be removed as it has not been registered
+ServerManagerRegistryUpdateAddError = There was an unexpected error updating the server in the registry. The old version of the server was successfully removed. However, the new version was not updated. Detail: {0}
+ServerManagerRegistryUpdateRemoveError = There was an unexpected error updating the server in the registry. The server has not been updated in the server registry. Detail: {0}
+
WorkspaceEmptyNameMsg = A workspace name cannot be empty
WorkspaceNullRepositoryMsg = A workspace repository cannot be null
WorkspaceShortDescription = DNA Repository Workspace: Name: {0}, {1}
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/Publisher.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -26,7 +26,6 @@
import java.io.File;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
-import java.util.Collection;
import org.jboss.dna.publish.domain.Server;
import org.jboss.dna.publish.domain.Workspace;
@@ -40,37 +39,68 @@
// Constants
// ===========================================================================================================================
-// private static final String SERVER_CONTEXT = "/resources"; //$NON-NLS-1$
+ // private static final String SERVER_CONTEXT = "/resources"; //$NON-NLS-1$
// ===========================================================================================================================
// Class Methods
// ===========================================================================================================================
- private static void setAuthenticator(final Server server) {
+ private static void setAuthenticator( final Server server ) {
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(server.getUser(), server.getPassword().toCharArray());
}
- });
+ });
}
// ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The workspace where the publishing or unpublishing will take place.
+ *
+ * @since 0.6
+ */
+ private final Workspace workspace;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param workspace the workspace to use when publishing or unpublishing
+ * @since 0.6
+ */
+ public Publisher( Workspace workspace ) {
+ this.workspace = workspace;
+ }
+
+ // ===========================================================================================================================
// Methods
// ===========================================================================================================================
- public Status publish( Workspace workspace,
- Collection<File> files ) {
- // TODO implement
+ /**
+ * @param file the file being published
+ * @return a status indicating if the publishing was successful
+ * @since 0.6
+ */
+ public Status publish( File file ) {
+ // TODO implement publish(File)
Server server = workspace.getServer();
setAuthenticator(server);
return null;
}
- public Status unpublish( Workspace workspace,
- Collection<File> files ) {
- // TODO implement
+ /**
+ * @param file the file being unpublished
+ * @return a status indicating if the unpublishing was successful
+ * @since 0.6
+ */
+ public Status unpublish( File file ) {
+ // TODO implement unpublish(File)
return null;
}
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerManager.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -27,6 +27,7 @@
import java.io.FileOutputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -38,7 +39,9 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.jboss.dna.publish.Status.Severity;
+import org.jboss.dna.publish.domain.Repository;
import org.jboss.dna.publish.domain.Server;
+import org.jboss.dna.publish.domain.Workspace;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -104,8 +107,15 @@
// ===========================================================================================================================
/**
+ * The listeners registered to receive {@link ServerRegistryEvent server registry events}.
+ *
* @since 0.6
*/
+ private final Collection<IServerRegistryListener> listeners;
+
+ /**
+ * @since 0.6
+ */
private final String stateLocationPath;
/**
@@ -125,6 +135,7 @@
public ServerManager( String stateLocationPath ) {
this.servers = Collections.synchronizedList(new ArrayList<Server>());
this.stateLocationPath = stateLocationPath;
+ this.listeners = new ArrayList<IServerRegistryListener>();
}
// ===========================================================================================================================
@@ -132,6 +143,21 @@
// ===========================================================================================================================
/**
+ * Listeners already registered will not be added again.
+ *
+ * @param listener the listener being register to receive events
+ * @return <code>true</code> if listener was added
+ * @since 0.6
+ */
+ public boolean addRegistryListener( IServerRegistryListener listener ) {
+ if (!this.listeners.contains(listener)) {
+ return this.listeners.add(listener);
+ }
+
+ return false;
+ }
+
+ /**
* Registers the specified <code>Server</code>.
*
* @param server the server being added
@@ -139,16 +165,7 @@
* @since 0.6
*/
public Status addServer( Server server ) {
- if (!this.servers.contains(server)) {
- this.servers.add(server);
- return Status.OK_STATUS;
- }
-
- // server already exists
- String pattern = MESSAGES.getString(ServerExistsMsg);
- String msg = MessageFormat.format(pattern, server.getShortDescription());
- Status status = new Status(Severity.ERROR, msg, null);
- return status;
+ return internalAddServer(server, true);
}
/**
@@ -174,32 +191,163 @@
}
/**
- * @param server the server being tested
- * @return <code>true</code> if the server has been registered
+ * @param server the server whose repositories are being requested
+ * @return the server repositories (never <code>null</code>)
* @since 0.6
*/
- public boolean isRegistered( Server server ) {
- return this.servers.contains(server);
+ public Collection<Repository> getRepositories( Server server ) {
+ // TODO implement getRepositories()
+ return Collections.emptyList();
}
/**
+ * @param repository the repository whose workspaces are being requested
+ * @return the DNA repository workspaces (never <code>null</code>)
+ * @since 0.6
+ */
+ public Collection<Workspace> getWorkspaces( Repository repository ) {
+ // TODO implement getWorkspaces()
+ return Collections.emptyList();
+ }
+
+ /**
+ * Registers the specified <code>Server</code>.
+ *
+ * @param server the server being added
+ * @param notifyListeners indicates if registry listeners should be notified
+ * @return a status indicating if the server was added to the registry
+ * @since 0.6
+ */
+ private Status internalAddServer( Server server,
+ boolean notifyListeners ) {
+ if (!this.servers.contains(server)) {
+ if (this.servers.add(server)) {
+ if (notifyListeners) {
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createNewEvent(server));
+ return processRegistryListenerErrors(errors);
+ }
+
+ return Status.OK_STATUS;
+ }
+
+ // server was not added to registry for unexpected reason
+ return new Status(Severity.ERROR, ServerManagerRegistryAddUnexpectedError, null);
+ }
+
+ // server already exists
+ String pattern = MESSAGES.getString(ServerExistsMsg);
+ String msg = MessageFormat.format(pattern, server.getShortDescription());
+ Status status = new Status(Severity.ERROR, msg, null);
+ return status;
+ }
+
+ /**
* @param server the server being removed
+ * @param notifyListeners indicates if registry listeners should be notified
* @return a status indicating if the specified server was removed from the registry
* @since 0.6
*/
- public Status removeServer( Server server ) {
+ private Status internalRemoveServer( Server server,
+ boolean notifyListeners ) {
if (this.servers.remove(server)) {
+ if (notifyListeners) {
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createRemoveEvent(server));
+ return processRegistryListenerErrors(errors);
+ }
+
return Status.OK_STATUS;
}
// server could not be removed
- String pattern = MESSAGES.getString(RemovingServerProblemMsg);
+ String pattern = MESSAGES.getString(ServerManagerRegistryRemoveUnexpectedError);
String msg = MessageFormat.format(pattern, server.getShortDescription());
Status status = new Status(Severity.ERROR, msg, null);
return status;
}
/**
+ * @param server the server being tested
+ * @return <code>true</code> if the server has been registered
+ * @since 0.6
+ */
+ public boolean isRegistered( Server server ) {
+ return this.servers.contains(server);
+ }
+
+ /**
+ * @param event the event the registry listeners are to process
+ * @return any errors thrown by or found by the listeners or <code>null</code> (never empty)
+ * @since 0.6
+ */
+ private Exception[] notifyRegistryListeners( ServerRegistryEvent event ) {
+ if (!this.listeners.isEmpty()) {
+ Collection<Exception> errors = null;
+ Collection<IServerRegistryListener> registryListeners = new ArrayList<IServerRegistryListener>(this.listeners);
+
+ for (IServerRegistryListener l : registryListeners) {
+ try {
+ Exception[] problems = l.serverRegistryChanged(event);
+
+ if ((problems != null) && (problems.length != 0)) {
+ if (errors == null) {
+ errors = new ArrayList<Exception>();
+ }
+
+ errors.addAll(Arrays.asList(problems));
+ }
+ } catch (Exception e) {
+ if (errors == null) {
+ errors = new ArrayList<Exception>();
+ }
+
+ errors.add(e);
+ }
+ }
+
+ if ((errors != null) && !errors.isEmpty()) {
+ return errors.toArray(new Exception[errors.size()]);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @param errors the errors reported by the registry listeners
+ * @return a status indicating if registry listeners reported any errors
+ * @since 0.6
+ */
+ private Status processRegistryListenerErrors( Exception[] errors ) {
+ if (errors == null) {
+ return Status.OK_STATUS;
+ }
+
+ for (Exception error : errors) {
+ Logger.log(getClass(), new Status(Severity.ERROR, ServerManagerRegistryListenerError, error));
+ }
+
+ return new Status(Severity.WARNING, ServerManagerRegistryListenerErrorsOccurred, null);
+ }
+
+ /**
+ * @param listener the listener being unregistered and will no longer receive events
+ * @return <code>true</code> if listener was removed
+ * @since 0.6
+ */
+ public boolean removeRegistryListener( IServerRegistryListener listener ) {
+ return this.listeners.remove(listener);
+ }
+
+ /**
+ * @param server the server being removed
+ * @return a status indicating if the specified server was removed from the registry
+ * @since 0.6
+ */
+ public Status removeServer( Server server ) {
+ return internalRemoveServer(server, true);
+ }
+
+ /**
* @return a status indicating if the previous session state was restored successfully
* @since 0.6
*/
@@ -298,6 +446,42 @@
return new File(getStateFileName()).exists();
}
+ /**
+ * Updates the server registry with a new version of a server.
+ *
+ * @param previousServerVersion the version of the server being replaced
+ * @param newServerVersion the new version of the server being put in the server registry
+ * @return a status indicating if the server was updated in the registry
+ * @since 0.6
+ */
+ public Status updateServer( Server previousServerVersion,
+ Server newServerVersion ) {
+ Status status = internalRemoveServer(previousServerVersion, false);
+
+ if (status.isOk()) {
+ status = internalAddServer(newServerVersion, false);
+
+ if (status.isOk()) {
+ // all good so notify listeners
+ Exception[] errors = notifyRegistryListeners(ServerRegistryEvent.createUpdateEvent(previousServerVersion,
+ newServerVersion));
+ return processRegistryListenerErrors(errors);
+ }
+
+ // unexpected problem adding new version of server to registry
+ String pattern = MESSAGES.getString(ServerManagerRegistryUpdateAddError);
+ String msg = MessageFormat.format(pattern, status.getMessage());
+ status = new Status(Severity.ERROR, msg, status.getException());
+ return status;
+ }
+
+ // unexpected problem removing server from registry
+ String pattern = MESSAGES.getString(ServerManagerRegistryUpdateRemoveError);
+ String msg = MessageFormat.format(pattern, status.getMessage());
+ status = new Status(Severity.ERROR, msg, status.getException());
+ return status;
+ }
+
// ===========================================================================================================================
// Methods
// ===========================================================================================================================
Added: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerRegistryEvent.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerRegistryEvent.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerRegistryEvent.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,197 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish;
+
+import org.jboss.dna.publish.domain.Server;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class ServerRegistryEvent {
+
+ // ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ /**
+ * The status severity levels.
+ *
+ * @since 0.6
+ */
+ public enum Type {
+ /**
+ * Indicates that a new server was added to the server registry.
+ *
+ * @since 0.6
+ */
+ NEW,
+
+ /**
+ * Indicates that a server was removed from the server registry.
+ *
+ * @since 0.6
+ */
+ REMOVE,
+
+ /**
+ * Indicates that properties of an existing server in the registry has been changed.
+ *
+ * @since 0.6
+ */
+ UPDATE
+ }
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param newServer the server that was added to the server registry
+ * @return the event
+ * @see Type#NEW
+ * @since 0.6
+ */
+ public static ServerRegistryEvent createNewEvent( Server newServer ) {
+ return new ServerRegistryEvent(Type.NEW, newServer);
+ }
+
+ /**
+ * @param removedServer the server removed from the server registry
+ * @return the event
+ * @see Type#REMOVE
+ * @since 0.6
+ */
+ public static ServerRegistryEvent createRemoveEvent( Server removedServer ) {
+ return new ServerRegistryEvent(Type.REMOVE, removedServer);
+ }
+
+ /**
+ * @param previousServerVersion the server being updated (this instance is no longer found in the server registry)
+ * @param newServerVersion the updated version of the server (this is now contained in the server registry)
+ * @return the event
+ * @see Type#UPDATE
+ * @since 0.6
+ */
+ public static ServerRegistryEvent createUpdateEvent( Server previousServerVersion,
+ Server newServerVersion ) {
+ ServerRegistryEvent event = new ServerRegistryEvent(Type.UPDATE, previousServerVersion);
+ event.updatedServer = newServerVersion;
+ return event;
+ }
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The server being added, removed, or updated.
+ *
+ * @since 0.6
+ */
+ private final Server server;
+
+ /**
+ * The event type.
+ *
+ * @since 0.6
+ */
+ private final Type type;
+
+ /**
+ * The server that is replacing an existing server. Will be <code>null</code> for all types except {@link Type#UPDATE update}.
+ *
+ * @since 0.6
+ */
+ private Server updatedServer;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param type the event type
+ * @param server the server being added, removed, or updated
+ * @since 0.6
+ */
+ private ServerRegistryEvent( Type type,
+ Server server ) {
+ this.type = type;
+ this.server = server;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * @return the added, removed, or the old version of the server that has been updated
+ * @since 0.6
+ */
+ public Server getServer() {
+ return this.server;
+ }
+
+ /**
+ * @return the new version of an existing server that has been updated
+ * @throws UnsupportedOperationException if method is called when the type is not an update
+ * @see Type#UPDATE
+ * @since 0.6
+ */
+ public Server getUpdatedServer() {
+ if (this.type != Type.UPDATE) {
+ throw new UnsupportedOperationException();
+ }
+
+ return this.updatedServer;
+ }
+
+ /**
+ * @return <code>true</code> if the event is adding a new server to the registry
+ * @see Type#NEW
+ * @since 0.6
+ */
+ public boolean isNew() {
+ return (this.type == Type.NEW);
+ }
+
+ /**
+ * @return <code>true</code> if the event is removing a server from the registry
+ * @see Type#REMOVE
+ * @since 0.6
+ */
+ public boolean isRemove() {
+ return (this.type == Type.REMOVE);
+ }
+
+ /**
+ * @return <code>true</code> if the event is updating properties of an existing server in the registry
+ * @see Type#UPDATE
+ * @since 0.6
+ */
+ public boolean isUpdate() {
+ return (this.type == Type.UPDATE);
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/ServerRegistryEvent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/IDnaObject.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -23,8 +23,6 @@
*/
package org.jboss.dna.publish.domain;
-import java.util.List;
-
/**
* The IDnaObject class defines a business object.
*
@@ -34,24 +32,12 @@
public interface IDnaObject {
/**
- * @return an ordered list of children (never <code>null</code>)
- * @since 0.6
- */
- List<? extends IDnaObject> getChildren();
-
- /**
* @return the object name (never <code>null</code>)
* @since 0.6
*/
String getName();
/**
- * @return the parent or <code>null</code>
- * @since 0.6
- */
- IDnaObject getParent();
-
- /**
* @return a description suitable for use in a tooltip (never <code>null</code>)
* @since 0.6
*/
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Repository.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -24,10 +24,6 @@
package org.jboss.dna.publish.domain;
import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
import org.jboss.dna.publish.IConstants;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.domain.validation.RepositoryValidator;
@@ -77,7 +73,7 @@
Server server ) {
// validate inputs
Status status = RepositoryValidator.isValid(name, server);
-
+
if (status.isError()) {
throw new RuntimeException(status.getMessage(), status.getException());
}
@@ -110,19 +106,6 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.publish.domain.IDnaObject#getChildren()
- * @since 0.6
- */
- @Override
- public List<? extends IDnaObject> getChildren() {
- // a repository's children are workspaces
- Collection<Workspace> kids = getWorkspaces();
- return Arrays.asList(kids.toArray(new IDnaObject[kids.size()]));
- }
-
- /**
- * {@inheritDoc}
- *
* @see org.jboss.dna.publish.domain.IDnaObject#getName()
* @since 0.6
*/
@@ -132,18 +115,6 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.publish.domain.IDnaObject#getParent()
- * @since 0.6
- */
- @Override
- public IDnaObject getParent() {
- // a repository's parent is a server
- return getServer();
- }
-
- /**
* @return the server where this repository is located (never <code>null</code>)
* @since 0.6
*/
@@ -164,15 +135,6 @@
}
/**
- * @return the DNA repository workspaces (never <code>null</code>)
- * @since 0.6
- */
- public Collection<Workspace> getWorkspaces() {
- // TODO implement getWorkspaces()
- return Collections.emptyList();
- }
-
- /**
* {@inheritDoc}
*
* @see java.lang.Object#hashCode()
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Server.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -24,12 +24,7 @@
package org.jboss.dna.publish.domain;
import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
import org.jboss.dna.publish.IConstants;
-import org.jboss.dna.publish.ServerManager;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.domain.validation.RepositoryValidator;
import org.jboss.dna.publish.domain.validation.ServerValidator;
@@ -52,13 +47,6 @@
* @since 0.6
*/
private final String password;
-
- /**
- * The server manager that manages the server registry.
- *
- * @since 0.6
- */
- private ServerManager serverManager;
/**
* The server URL.
@@ -127,20 +115,6 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.publish.domain.IDnaObject#getChildren()
- * @see #getRepositories()
- * @since 0.6
- */
- @Override
- public List<? extends IDnaObject> getChildren() {
- // a server's children are repositories
- Collection<Repository> kids = getRepositories();
- return Arrays.asList(kids.toArray(new IDnaObject[kids.size()]));
- }
-
- /**
- * {@inheritDoc}
- *
* @see org.jboss.dna.publish.domain.IDnaObject#getName()
* @since 0.6
*/
@@ -150,18 +124,6 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.publish.domain.IDnaObject#getParent()
- * @since 0.6
- */
- @Override
- public IDnaObject getParent() {
- // a server does not have a parent
- return null;
- }
-
- /**
* @return the server authentication password
* @since 0.6
*/
@@ -170,18 +132,6 @@
}
/**
- * @return the server DNA repositories (never <code>null</code>)
- * @since 0.6
- */
- public Collection<Repository> getRepositories() {
- if (this.serverManager != null) {
- // TODO implement getRepositories()
- }
-
- return Collections.emptyList();
- }
-
- /**
* {@inheritDoc}
*
* @see org.jboss.dna.publish.domain.IDnaObject#getShortDescription()
@@ -223,12 +173,4 @@
return hash;
}
- /**
- * @param serverManager the server manager (may be <code>null</code>)
- * @since 0.6
- */
- public void setServerManager( ServerManager serverManager ) {
- this.serverManager = serverManager;
- }
-
}
Modified: branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish/src/org/jboss/dna/publish/domain/Workspace.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -24,8 +24,6 @@
package org.jboss.dna.publish.domain;
import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.List;
import org.jboss.dna.publish.IConstants;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.domain.validation.WorkspaceValidator;
@@ -73,7 +71,7 @@
Repository repository ) {
// validate inputs
Status status = WorkspaceValidator.isValid(name, repository);
-
+
if (status.isError()) {
throw new RuntimeException(status.getMessage(), status.getException());
}
@@ -106,18 +104,6 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.publish.domain.IDnaObject#getChildren()
- * @since 0.6
- */
- @Override
- public List<? extends IDnaObject> getChildren() {
- // workspaces don't have children for 0.6 (this will change for future versions)
- return Collections.emptyList();
- }
-
- /**
- * {@inheritDoc}
- *
* @see org.jboss.dna.publish.domain.IDnaObject#getName()
* @since 0.6
*/
@@ -127,24 +113,13 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.publish.domain.IDnaObject#getParent()
- * @since 0.6
- */
- @Override
- public IDnaObject getParent() {
- return getRepository();
- }
-
- /**
* @return the repository where this workspace is located (never <code>null</code>)
* @since 0.6
*/
public Repository getRepository() {
return this.repository;
}
-
+
/**
* @return the server where this workspace is located (never <code>null</code>)
* @since 0.6
@@ -164,10 +139,10 @@
String pattern = MESSAGES.getString(WorkspaceShortDescription);
return MessageFormat.format(pattern, this.name, this.repository.getShortDescription());
}
-
+
/**
* {@inheritDoc}
- *
+ *
* @see java.lang.Object#hashCode()
* @since 0.6
*/
@@ -177,6 +152,6 @@
hash = 31 * hash + this.name.hashCode();
hash = 31 * hash + this.repository.hashCode();
return hash;
- }
+ }
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/.settings/org.eclipse.jdt.core.prefs 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/.settings/org.eclipse.jdt.core.prefs 2009-07-01 22:20:46 UTC (rev 1068)
@@ -1,7 +1,20 @@
-#Wed Jun 17 07:47:51 CDT 2009
+#Wed Jul 01 08:14:43 CDT 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private
org.eclipse.jdt.core.compiler.source=1.6
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/META-INF/MANIFEST.MF 2009-07-01 22:20:46 UTC (rev 1068)
@@ -5,9 +5,10 @@
Bundle-Version: 1.0.0
Bundle-Activator: org.jboss.dna.publish.ui.swt.Activator
Bundle-Vendor: %bundleVendor
+Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.jboss.dna.publish,
- org.eclipse.core.resources;bundle-version="3.4.2"
+ org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/build.properties 2009-07-01 22:20:46 UTC (rev 1068)
@@ -5,3 +5,4 @@
plugin.properties,\
icons/,\
plugin.xml
+src.includes = src/
Copied: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects (from rev 1062, branches/eclipse/org.jboss.dna.publish.ui.swt/icons/full/obj16)
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/repository.gif
===================================================================
(Binary files differ)
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/objects/workspace.gif
===================================================================
(Binary files differ)
Copied: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views (from rev 1062, branches/eclipse/org.jboss.dna.publish.ui.swt/icons/full/cview16)
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/delete.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/edit_server.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/new_server.gif
===================================================================
(Binary files differ)
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/new_server.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/icons/views/repository.gif
===================================================================
(Binary files differ)
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.properties 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.properties 2009-07-01 22:20:46 UTC (rev 1068)
@@ -26,5 +26,5 @@
contextMenu.label = DNA
dnaCategory = DNA
publishAction.label = Publish
-repositoryView = DNA Repositories
+serverView = DNA Servers
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-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/plugin.xml 2009-07-01 22:20:46 UTC (rev 1068)
@@ -6,10 +6,10 @@
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
- id="org.jboss.dna.publish.iresourcepopupmenucontribution"
+ id="org.jboss.dna.publish.ui.swt.iresourcepopupmenucontribution"
objectClass="org.eclipse.core.resources.IResource">
<menu
- id="org.jboss.dna.publish.contextMenu"
+ id="org.jboss.dna.publish.ui.swt.contextMenu"
label="%contextMenu.label"
path="additions">
<separator
@@ -22,7 +22,7 @@
id="org.jboss.dna.publish.ui.swt.unpublishAction"
label="%unpublishAction.label"
class="org.jboss.dna.publish.ui.swt.actions.UnpublishAction"
- menubarPath="org.jboss.dna.publish.contextMenu/group1"
+ menubarPath="org.jboss.dna.publish.ui.swt.contextMenu/group1"
enablesFor="*">
</action>
@@ -31,7 +31,7 @@
id="org.jboss.dna.publish.ui.swt.publishAction"
label="%publishAction.label"
class="org.jboss.dna.publish.ui.swt.actions.PublishAction"
- menubarPath="org.jboss.dna.publish.contextMenu/group1"
+ menubarPath="org.jboss.dna.publish.ui.swt.contextMenu/group1"
enablesFor="*">
</action>
</objectContribution>
@@ -47,12 +47,12 @@
<!-- Repository view -->
<view
- id="respositoryView"
- name="%repositoryView"
+ id="serverView"
+ name="%serverView"
category="org.jboss.dna"
- class="org.jboss.dna.publish.ui.swt.views.RepositoryView"
+ class="org.jboss.dna.publish.ui.swt.views.ServerView"
fastViewWidthRatio="0.25"
- icon="icons/full/cview16/repository.gif">
+ icon="icons/objects/server.gif">
</view>
</extension>
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Activator.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Activator.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Activator.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -24,9 +24,9 @@
package org.jboss.dna.publish.ui.swt;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.jboss.dna.publish.Logger;
import org.jboss.dna.publish.ServerManager;
@@ -80,26 +80,31 @@
private ServerManager serverMgr;
// ===========================================================================================================================
- // Constructors
+ // Methods
// ===========================================================================================================================
- /**
- * Constructs the plugin activator. If constructed outside of Eclipse the {@link #initialize(String)} method must be called to
- * construct the {@link ServerManager server manager}.
- *
- * @since 0.6
- */
- public Activator() {
- super();
- plugin = this;
+ public Image getSharedImage(String imageId) {
+ Image result = PlatformUI.getWorkbench().getSharedImages().getImage(imageId);
+
+ if (result != null) {
+ return result;
+ }
+
+ return ImageDescriptor.getMissingImageDescriptor().createImage();
}
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
+ public ImageDescriptor getSharedImageDescriptor(String imageId) {
+ ImageDescriptor result = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(imageId);
+
+ if (result != null) {
+ return result;
+ }
+
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+
/**
- * @param object the object whose image is being requested
+ * @param object the object whose image is being requested (domain object or plugin-relative path)
* @return the image or <code>null</code> if not found
* @since 0.6
*/
@@ -156,7 +161,6 @@
/**
* @return the server manager or <code>null</code> if activator has not been initialized or started
- * @see #initialize(String)
* @see #start(BundleContext)
* @since 0.6
*/
@@ -165,63 +169,33 @@
}
/**
- * Performs plugin initialization. One thing it does is initialize the {@link ServerManager server manager}.
- * <p>
- * Note: This should <strong>ONLY</strong> be called when the OSGi framework is not running (i.e., {@link BundleContext bundle
- * context} is <code>null</code>) and should be called instead of calling {@link #start(BundleContext)}.
- *
- * @param stateLocationPath the file system directory where state files can be stored or <code>null</code> if saving state is
- * not desired
+ * @param status the status being logged
* @since 0.6
*/
- public void initialize( String stateLocationPath ) {
- this.serverMgr = new ServerManager(stateLocationPath);
- Status status = this.serverMgr.restoreState();
-
- // problem restoring server registry
- if (status.isError()) {
- log(getClass(), status);
- }
- }
-
- public void log( Class<?> sourceClass,
- Status status ) {
- if (Platform.isRunning()) {
- IStatus eclipseStatus;
-
- if (status instanceof EclipseStatus) {
- eclipseStatus = ((EclipseStatus)status).getDelegate();
- } else {
- eclipseStatus = new org.eclipse.core.runtime.Status(EclipseStatus.convertSeverity(status.getSeverity()),
+ public void log( Status status ) {
+ IStatus eclipseStatus = new org.eclipse.core.runtime.Status(Utils.convertSeverity(status.getSeverity()),
IUiConstants.PLUGIN_ID, status.getMessage(),
status.getException());
- }
-
- getLog().log(eclipseStatus);
- } else {
- Logger.error(getClass(), status.getException(), status.getMessage());
- }
+ getLog().log(eclipseStatus);
}
- public void log( Class<?> sourceClass,
- IStatus status ) {
- log(sourceClass, new EclipseStatus(status));
- }
-
/**
* {@inheritDoc}
- * <p>
- * If OSGi is not running this does nothing.
*
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
* @since 0.6
*/
@Override
public void start( BundleContext context ) throws Exception {
- if (context != null) {
- // OSGi is running
- super.start(context);
- initialize(plugin.getStateLocation().toFile().getAbsolutePath());
+ super.start(context);
+ plugin = this;
+
+ this.serverMgr = new ServerManager(getStateLocation().toFile().getAbsolutePath());
+ Status status = this.serverMgr.restoreState();
+
+ // problem restoring server registry
+ if (!status.isOk()) {
+ Logger.log(getClass(), status);
}
}
@@ -235,17 +209,15 @@
public void stop( BundleContext context ) throws Exception {
if (this.serverMgr != null) {
Status status = this.serverMgr.saveState();
-
- if (status.isError()) {
- log(getClass(), status);
+
+ if (!status.isOk()) {
+ log(status);
}
this.serverMgr = null;
}
- if (context != null) {
- super.stop(context);
- }
+ super.stop(context);
plugin = null;
}
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/EclipseStatus.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/EclipseStatus.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/EclipseStatus.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -1,112 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.publish.ui.swt;
-
-import org.eclipse.core.runtime.IStatus;
-import org.jboss.dna.publish.Status;
-
-/**
- * Converts an Eclipse status into an non-Eclipse status.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public class EclipseStatus extends Status {
-
- // ===========================================================================================================================
- // Class Methods
- // ===========================================================================================================================
-
- /**
- * Converts the non-Eclipse status severity to an Eclipse severity level. An {@link Status.Severity#UNKNOWN unknown status} is
- * converted to {@link IStatus#CANCEL cancel}. A {@link Status.Severity} is
- *
- * @param severity the eclipse status severity level
- * @return the converted severity level
- * @see IStatus
- * @since 0.6
- */
- public static int convertSeverity( Severity severity ) {
- if (severity == Severity.OK) return IStatus.OK;
- if (severity == Severity.ERROR) return IStatus.ERROR;
- if (severity == Severity.WARNING) return IStatus.WARNING;
- if (severity == Severity.INFO) return IStatus.INFO;
- return IStatus.CANCEL;
- }
-
- /**
- * Converts the Eclipse status severity level to a non-Eclipse severity.
- *
- * @param severity the eclipse status severity level
- * @return the converted severity level
- * @see IStatus
- * @since 0.6
- */
- public static Severity convertSeverity( int severity ) {
- if (severity == IStatus.OK) return Severity.OK;
- if (severity == IStatus.ERROR) return Severity.ERROR;
- if (severity == IStatus.WARNING) return Severity.WARNING;
- if (severity == IStatus.INFO) return Severity.INFO;
- return Severity.UNKNOWN;
- }
-
- // ===========================================================================================================================
- // Fields
- // ===========================================================================================================================
-
- /**
- * The Eclipse status.
- *
- * @since 0.6
- */
- private final IStatus delegate;
-
- // ===========================================================================================================================
- // Constructors
- // ===========================================================================================================================
-
- /**
- * @param delegate the eclipse status delegate
- * @since 0.6
- */
- public EclipseStatus( IStatus delegate ) {
- this.delegate = delegate;
- this.severity = convertSeverity(delegate.getSeverity());
- this.message = delegate.getMessage();
- this.exception = delegate.getException();
- }
-
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
- /**
- * @return the Eclipse status object
- * @since 0.6
- */
- public IStatus getDelegate() {
- return this.delegate;
- }
-
-}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/I18n.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -32,17 +32,19 @@
* @since 0.6
*/
public final class I18n extends NLS {
+
+ public static String BasePublishingActionPublishingWizardErrorMsg;
+ public static String BasePublishingActionUnpublishingWizardErrorMsg;
public static String CollapseActionToolTip;
- public static String DeleteServerActionText;
public static String DeleteServerActionToolTip;
+ public static String DeleteServerDialogErrorsOccurredMsg;
+ public static String DeleteServerDialogMultipleServersMsg;
+ public static String DeleteServerDialogOneServerMsg;
public static String DeleteServerDialogTitle;
- public static String DeleteServerDialogOneServerMessage;
- public static String DeleteServerDialogMultipleServersMessage;
- public static String EditServerActionText;
public static String EditServerActionToolTip;
public static String ErrorDialogTitle;
@@ -57,12 +59,16 @@
public static String PublishPageMissingRepositoryStatusMsg;
public static String PublishPageMissingServerStatusMsg;
public static String PublishPageMissingWorkspaceStatusMsg;
+ public static String PublishPageNewServerButton;
public static String PublishPageNoAvailableRepositoriesStatusMsg;
public static String PublishPageNoAvailableServersStatusMsg;
public static String PublishPageNoAvailableWorkspacesStatusMsg;
public static String PublishPageNoResourcesStatusMsg;
public static String PublishPagePublishOkStatusMsg;
public static String PublishPagePublishResourcesLabel;
+ public static String PublishPageRecurseCheckBox;
+ public static String PublishPageRecurseCheckBoxToolTip;
+ public static String PublishPageRecurseProcessingErrorMsg;
public static String PublishPageRepositoryLabel;
public static String PublishPageRepositoryToolTip;
public static String PublishPageServerLabel;
@@ -93,10 +99,11 @@
public static String ServerPageUserLabel;
public static String ServerPageUserToolTip;
+ public static String ServerWizardEditServerErrorMsg;
public static String ServerWizardEditServerTitle;
+ public static String ServerWizardNewServerErrorMsg;
public static String ServerWizardNewServerTitle;
- public static String NewServerActionText;
public static String NewServerActionToolTip;
static {
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/IUiConstants.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/IUiConstants.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/IUiConstants.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -36,14 +36,30 @@
*/
String PLUGIN_ID = "org.jboss.dna.publish.ui.swt"; //$NON-NLS-1$
- String ICON_PATH = "icons/full/"; //$NON-NLS-1$
+ String ICON_PATH = "icons/"; //$NON-NLS-1$
+
+ //
+ // /icons/objects/
+ //
- String OBJ16 = ICON_PATH + "obj16/"; //$NON-NLS-1$
+ String OBJECT_ICONS_FOLDER = ICON_PATH + "objects/"; //$NON-NLS-1$
- String REPOSITORY_IMAGE_PATH = OBJ16 + "repository.gif"; //$NON-NLS-1$
+ String REPOSITORY_IMAGE_PATH = OBJECT_ICONS_FOLDER + "repository.gif"; //$NON-NLS-1$
- String SERVER_IMAGE_PATH = OBJ16 + "server.gif"; //$NON-NLS-1$
+ String SERVER_IMAGE_PATH = OBJECT_ICONS_FOLDER + "server.gif"; //$NON-NLS-1$
- String WORKSPACE_IMAGE_PATH = OBJ16 + "workspace.gif"; //$NON-NLS-1$
+ String WORKSPACE_IMAGE_PATH = OBJECT_ICONS_FOLDER + "workspace.gif"; //$NON-NLS-1$
+
+ //
+ // /icons/views/
+ //
+ String VIEW_ICONS_FOLDER = ICON_PATH + "views/"; //$NON-NLS-1$
+
+ String DELETE_SERVER_PATH = VIEW_ICONS_FOLDER + "delete.gif"; //$NON-NLS-1$
+
+ String EDIT_SERVER_IMAGE_PATH = VIEW_ICONS_FOLDER + "edit_server.gif"; //$NON-NLS-1$
+
+ String NEW_SERVER_IMAGE_PATH = VIEW_ICONS_FOLDER + "new_server.gif"; //$NON-NLS-1$
+
}
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Utils.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Utils.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Utils.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,86 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish.ui.swt;
+
+import org.eclipse.core.runtime.IStatus;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.Status.Severity;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class Utils {
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * Converts the non-Eclipse status severity to an Eclipse severity level. An {@link Status.Severity#UNKNOWN unknown status} is
+ * converted to {@link IStatus#CANCEL cancel}. A {@link Status.Severity} is
+ *
+ * @param severity the eclipse status severity level
+ * @return the converted severity level
+ * @see IStatus
+ * @since 0.6
+ */
+ public static int convertSeverity( Severity severity ) {
+ if (severity == Severity.OK) return IStatus.OK;
+ if (severity == Severity.ERROR) return IStatus.ERROR;
+ if (severity == Severity.WARNING) return IStatus.WARNING;
+ if (severity == Severity.INFO) return IStatus.INFO;
+ return IStatus.CANCEL;
+ }
+
+ /**
+ * Converts the Eclipse status severity level to a non-Eclipse severity.
+ *
+ * @param severity the eclipse status severity level
+ * @return the converted severity level
+ * @see IStatus
+ * @since 0.6
+ */
+ public static Severity convertSeverity( int severity ) {
+ if (severity == IStatus.OK) return Severity.OK;
+ if (severity == IStatus.ERROR) return Severity.ERROR;
+ if (severity == IStatus.WARNING) return Severity.WARNING;
+ if (severity == IStatus.INFO) return Severity.INFO;
+ return Severity.UNKNOWN;
+ }
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * Don't allow construction.
+ *
+ * @since 0.6
+ */
+ public Utils() {
+ // nothing to do
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/Utils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/BasePublishingAction.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -26,14 +26,19 @@
import java.util.Collections;
import java.util.List;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.Status.Severity;
import org.jboss.dna.publish.ui.swt.Activator;
+import org.jboss.dna.publish.ui.swt.I18n;
import org.jboss.dna.publish.ui.swt.wizards.PublishWizard;
import org.jboss.dna.publish.ui.swt.wizards.PublishOperation.Type;
@@ -60,7 +65,7 @@
* @since 0.6
*/
private Shell shell;
-
+
/**
* Indicates if this is a publishing or unpublishing action.
*
@@ -76,10 +81,10 @@
* @param type indicates the type of action
* @since 0.6
*/
- public BasePublishingAction(Type type) {
+ public BasePublishingAction( Type type ) {
this.type = type;
}
-
+
// ===========================================================================================================================
// Methods
// ===========================================================================================================================
@@ -105,7 +110,20 @@
}
// run wizard
- new WizardDialog(shell, new PublishWizard(this.type, resources, Activator.getDefault().getServerManager()));
+ try {
+ new WizardDialog(shell, new PublishWizard(this.type, resources, Activator.getDefault().getServerManager())).open();
+ } catch (CoreException e) {
+ String msg = null;
+
+ if (this.type == Type.PUBLISH) {
+ msg = I18n.BasePublishingActionPublishingWizardErrorMsg;
+ } else {
+ msg = I18n.BasePublishingActionUnpublishingWizardErrorMsg;
+ }
+
+ Activator.getDefault().log(new Status(Severity.ERROR, msg, e));
+ MessageDialog.openError(this.shell, I18n.ErrorDialogTitle, msg);
+ }
}
/**
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,160 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish.ui.swt.actions;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.jboss.dna.publish.ServerManager;
+import org.jboss.dna.publish.Status;
+import org.jboss.dna.publish.domain.Server;
+import org.jboss.dna.publish.ui.swt.Activator;
+import org.jboss.dna.publish.ui.swt.I18n;
+import org.jboss.dna.publish.ui.swt.dialogs.DeleteServerDialog;
+
+/**
+ * The DeleteServerAction deletes one or more servers from the server registry.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class DeleteServerAction extends BaseSelectionListenerAction {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The server manager used to delete servers.
+ *
+ * @since 0.6
+ */
+ private final ServerManager serverManager;
+
+ /**
+ * The servers being deleted (never <code>null</code>).
+ *
+ * @since 0.6
+ */
+ private final List<Server> serversToDelete;
+
+ /**
+ * The shell used to display the delete confirmation dialog.
+ *
+ * @since 0.6
+ */
+ private final Shell shell;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param shell the parent shell used to display the confirmation dialog
+ * @param serverManager the server manager to use when deleting servers
+ * @since 0.6
+ */
+ public DeleteServerAction( Shell shell,
+ ServerManager serverManager ) {
+ super(""); //$NON-NLS-1$
+ setToolTipText(I18n.DeleteServerActionToolTip);
+ setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ETOOL_DELETE));
+ setDisabledImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ETOOL_DELETE_DISABLED));
+ setEnabled(false);
+
+ this.serversToDelete = new ArrayList<Server>(5);
+ this.shell = shell;
+ this.serverManager = serverManager;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ * @since 0.6
+ */
+ @Override
+ public void run() {
+ Dialog dialog = new DeleteServerDialog(this.shell, this.serversToDelete);
+
+ if (dialog.getReturnCode() == Window.OK) {
+ boolean errorsOccurred = false;
+
+ for (Server server : this.serversToDelete) {
+ Status status = this.serverManager.removeServer(server);
+
+ if (!status.isOk()) {
+ Activator.getDefault().log(status);
+
+ if (status.isError()) {
+ errorsOccurred = true;
+ }
+ }
+ }
+
+ if (errorsOccurred) {
+ MessageDialog.openError(this.shell, I18n.ErrorDialogTitle, I18n.DeleteServerDialogErrorsOccurredMsg);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ * @since 0.6
+ */
+ @Override
+ protected boolean updateSelection( IStructuredSelection selection ) {
+ // disable if empty selection
+ if (selection.isEmpty()) {
+ this.serversToDelete.clear();
+ return false;
+ }
+
+ // disable if one non-server is found
+ for (Object obj : selection.toArray()) {
+ if (obj instanceof Server) {
+ this.serversToDelete.add((Server)obj);
+ } else {
+ this.serversToDelete.clear();
+ return false;
+ }
+ }
+
+ // enable since all objects are servers
+ return true;
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/DeleteServerAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,131 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish.ui.swt.actions;
+
+import static org.jboss.dna.publish.ui.swt.IUiConstants.EDIT_SERVER_IMAGE_PATH;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.jboss.dna.publish.ServerManager;
+import org.jboss.dna.publish.domain.Server;
+import org.jboss.dna.publish.ui.swt.Activator;
+import org.jboss.dna.publish.ui.swt.I18n;
+import org.jboss.dna.publish.ui.swt.wizards.ServerWizard;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class EditServerAction extends BaseSelectionListenerAction {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The selected server being edited.
+ *
+ * @since 0.6
+ */
+ private Server serverBeingEdited;
+
+ /**
+ * The server manager used to create and edit servers.
+ *
+ * @since 0.6
+ */
+ private final ServerManager serverManager;
+
+ /**
+ * The shell used to display the dialog that edits and creates servers.
+ *
+ * @since 0.6
+ */
+ private final Shell shell;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param shell the parent shell used to display the dialog
+ * @param serverManager the server manager to use when creating and editing servers
+ * @since 0.6
+ */
+ public EditServerAction( Shell shell,
+ ServerManager serverManager ) {
+ super(""); //$NON-NLS-1$
+ setToolTipText(I18n.EditServerActionToolTip);
+ setImageDescriptor(Activator.getDefault().getImageDescriptor(EDIT_SERVER_IMAGE_PATH));
+ setEnabled(false);
+
+ this.shell = shell;
+ this.serverManager = serverManager;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ * @since 0.6
+ */
+ @Override
+ public void run() {
+ ServerWizard wizard = new ServerWizard(this.serverManager, this.serverBeingEdited);
+ new WizardDialog(this.shell, wizard).open();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
+ * @since 0.6
+ */
+ @Override
+ protected boolean updateSelection( IStructuredSelection selection ) {
+ // disable if empty selection or multiple objects selected
+ if (selection.isEmpty() || (selection.size() > 1)) {
+ this.serverBeingEdited = null;
+ return false;
+ }
+
+ Object obj = selection.getFirstElement();
+
+ // enable if server is selected
+ if (obj instanceof Server) {
+ this.serverBeingEdited = (Server)obj;
+ return true;
+ }
+
+ // disable if non-server is selected
+ this.serverBeingEdited = null;
+ return false;
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/EditServerAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,97 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish.ui.swt.actions;
+
+import static org.jboss.dna.publish.ui.swt.IUiConstants.NEW_SERVER_IMAGE_PATH;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.jboss.dna.publish.ServerManager;
+import org.jboss.dna.publish.ui.swt.Activator;
+import org.jboss.dna.publish.ui.swt.I18n;
+import org.jboss.dna.publish.ui.swt.wizards.ServerWizard;
+
+/**
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class NewServerAction extends BaseSelectionListenerAction {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * The server manager used to create and edit servers.
+ *
+ * @since 0.6
+ */
+ private final ServerManager serverManager;
+
+ /**
+ * The shell used to display the dialog that edits and creates servers.
+ *
+ * @since 0.6
+ */
+ private final Shell shell;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param shell the parent shell used to display the dialog
+ * @param serverManager the server manager to use when creating and editing servers
+ * @since 0.6
+ */
+ public NewServerAction( Shell shell,
+ ServerManager serverManager ) {
+ super(""); //$NON-NLS-1$
+ setToolTipText(I18n.NewServerActionToolTip);
+ setImageDescriptor(Activator.getDefault().getImageDescriptor(NEW_SERVER_IMAGE_PATH));
+ setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ELCL_REMOVE));
+// setDisabledImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ETOOL_DELETE_DISABLED));
+
+ this.shell = shell;
+ this.serverManager = serverManager;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ * @since 0.6
+ */
+ @Override
+ public void run() {
+ ServerWizard wizard = new ServerWizard(this.serverManager);
+ new WizardDialog(this.shell, wizard).open();
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/actions/NewServerAction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/dialogs/DeleteServerDialog.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/dialogs/DeleteServerDialog.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/dialogs/DeleteServerDialog.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -91,9 +91,9 @@
if (this.serversBeingDeleted.size() == 1) {
IDnaObject server = this.serversBeingDeleted.iterator().next();
- title = NLS.bind(I18n.DeleteServerDialogOneServerMessage, server.getName());
+ title = NLS.bind(I18n.DeleteServerDialogOneServerMsg, server.getName());
} else {
- title = NLS.bind(I18n.DeleteServerDialogOneServerMessage, this.serversBeingDeleted.size());
+ title = NLS.bind(I18n.DeleteServerDialogMultipleServersMsg, this.serversBeingDeleted.size());
}
shell.setText(title);
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/i18n.properties 2009-07-01 22:20:46 UTC (rev 1068)
@@ -1,18 +1,42 @@
+#
+# 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.
+#
+BasePublishingActionPublishingWizardErrorMsg = Unexpected error running the publishing wizard. See log for more details.
+BasePublishingActionUnpublishingWizardErrorMsg = Unexpected error running the unpublishing wizard. See log for more details.
+
CollapseActionToolTip = Collapse All
-DeleteServerActionText = Delete Server
DeleteServerActionToolTip = Delete Server
+DeleteServerDialogErrorsOccurredMsg = There were errors deleting servers from the server registry. See log for more details.
+DeleteServerDialogMultipleServersMsg = Are you sure you want to delete these {0} servers?
+DeleteServerDialogOneServerMsg = Are you sure you want to delete the "{0}" server?
DeleteServerDialogTitle = Confirm Delete Server
-DeleteServerDialogOneServerMessage = Are you sure you want to delete the "{0}" server?
-DeleteServerDialogMultipleServersMessage = Are you sure you want to delete these {0} servers?
-EditServerActionText = Edit Server
EditServerActionToolTip = Edit Server
ErrorDialogTitle = Error
-NewServerActionText = New Server
NewServerActionToolTip = New Server
PublishOperationPublishTaskName = Publishing resources
@@ -25,12 +49,16 @@
PublishPageMissingRepositoryStatusMsg = A repository must be selected
PublishPageMissingServerStatusMsg = A server must be selected
PublishPageMissingWorkspaceStatusMsg = A workspace must be selected
+PublishPageNewServerButton = New...
PublishPageNoAvailableRepositoriesStatusMsg = There are no repositories available on that server
PublishPageNoAvailableServersStatusMsg = A server must be created first
PublishPageNoAvailableWorkspacesStatusMsg = There are no workspaces availabe on that server and repository
PublishPageNoResourcesStatusMsg = You must select one or more workspace resources
PublishPagePublishOkStatusMsg = Choose the server, repository, and workspace where the selected resources will be published.
PublishPagePublishResourcesLabel = These resources will be published to the specified DNA repository:
+PublishPageRecurseCheckBox = Recurse folders and projects
+PublishPageRecurseCheckBoxToolTip = Add all files under folders recursively under selected projects and folders
+PublishPageRecurseProcessingErrorMsg = Unexpected error processing resources. See log for more details.
PublishPageRepositoryLabel = Repository:
PublishPageRepositoryToolTip = The repository where the workspace is located
PublishPageServerLabel = Server:
@@ -61,5 +89,7 @@
ServerPageUserLabel = User:
ServerPageUserToolTip = The user login used when connecting to the server
+ServerWizardEditServerErrorMsg = There were errors editing a server. See log for more details.
ServerWizardEditServerTitle = Edit Server
+ServerWizardNewServerErrorMsg = There were errors creating a new server. See log for more details.
ServerWizardNewServerTitle = New Server
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryContentProvider.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryContentProvider.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryContentProvider.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -1,184 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.publish.ui.swt.views;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.graphics.Image;
-import org.jboss.dna.publish.domain.IDnaObject;
-import org.jboss.dna.publish.ui.swt.Activator;
-
-/**
- * The RepositoryContentProvider is a content and label provider for DNA repositories.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class RepositoryContentProvider implements ITreeContentProvider, ILabelProvider {
-
- // ===========================================================================================================================
- // 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.IContentProvider#dispose()
- * @since 0.6
- */
- @Override
- public void dispose() {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object[] getChildren( Object parentElement ) {
- if (parentElement instanceof IDnaObject) {
- return ((IDnaObject)parentElement).getChildren().toArray();
- }
-
- // should not happen
- assert false;
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Object[] getElements( Object inputElement ) {
- return Activator.getDefault().getServerManager().getServers().toArray();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- * @since 0.6
- */
- @Override
- public Image getImage( Object element ) {
- 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 ) {
- if (element instanceof IDnaObject) {
- return ((IDnaObject)element).getParent();
- }
-
- // should not happen
- assert false;
- return null;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- * @since 0.6
- */
- @Override
- public String getText( Object element ) {
- assert (element instanceof IDnaObject);
- return ((IDnaObject)element).getName();
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- * @since 0.6
- */
- @Override
- public boolean hasChildren( Object element ) {
- return getChildren(element).length > 0;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object,
- * java.lang.Object)
- * @since 0.6
- */
- @Override
- public void inputChanged( Viewer viewer,
- Object oldInput,
- Object newInput ) {
- // nothing to do
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
- * @since 0.6
- */
- @Override
- public boolean isLabelProperty( Object element,
- String property ) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- * @since 0.6
- */
- @Override
- public void removeListener( ILabelProviderListener listener ) {
- // nothing to do
- }
-
-}
Deleted: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryView.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryView.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryView.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -1,257 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.publish.ui.swt.views;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.part.ViewPart;
-import org.jboss.dna.publish.domain.IDnaObject;
-import org.jboss.dna.publish.domain.Server;
-import org.jboss.dna.publish.ui.swt.I18n;
-
-/**
- * The RepositoryView shows all defined servers and their DNA repositories.
- *
- * @author Dan Florian
- * @since 0.6
- */
-public final class RepositoryView extends ViewPart {
-
- // ===========================================================================================================================
- // Fields
- // ===========================================================================================================================
-
- /**
- * Collapses all tree nodes.
- *
- * @since 0.6
- */
- private IAction collapseAllAction;
-
- /**
- * Deletes a server.
- *
- * @since 0.6
- */
- private IAction deleteAction;
-
- /**
- * Edits a server's properties.
- *
- * @since 0.6
- */
- private IAction editAction;
-
- /**
- * Creates a new server.
- *
- * @since 0.6
- */
- private IAction newAction;
-
- /**
- * The viewer's content and label provider.
- *
- * @since 0.6
- */
- private RepositoryContentProvider provider;
-
- /**
- * @since 0.6
- */
- private TreeViewer viewer;
-
- // ===========================================================================================================================
- // Methods
- // ===========================================================================================================================
-
- /**
- * @since 0.6
- */
- private void constructActions() {
- // the collapse all action is always enabled
- this.collapseAllAction = new Action() {
- @Override
- public void run() {
- getViewer().collapseAll();
- }
- };
-
- this.collapseAllAction.setToolTipText(I18n.CollapseActionToolTip);
- this.collapseAllAction.setImageDescriptor(null);
-
- // the delete action will delete one or more servers
- this.deleteAction = null;
- this.deleteAction.setText(I18n.DeleteServerActionText);
- this.deleteAction.setToolTipText(I18n.DeleteServerActionToolTip);
- this.deleteAction.setImageDescriptor(null);
- this.deleteAction.setEnabled(false);
-
- // the edit action is only enabled when one server is selected
- this.editAction = null;
- this.editAction.setText(I18n.EditServerActionText);
- this.editAction.setToolTipText(I18n.EditServerActionToolTip);
- this.editAction.setImageDescriptor(null);
- this.editAction.setEnabled(false);
-
- // the new server action is always enabled
- this.newAction = null;
- this.newAction.setText(I18n.NewServerActionText);
- this.newAction.setToolTipText(I18n.NewServerActionToolTip);
- this.newAction.setImageDescriptor(null);
- }
-
- /**
- * @since 0.6
- */
- private void constructContextMenu() {
- MenuManager menuMgr = new MenuManager();
- menuMgr.add(this.newAction);
- menuMgr.add(this.editAction);
- menuMgr.add(this.deleteAction);
- // menuMgr.setRemoveAllWhenShown(true);
-
- Menu menu = menuMgr.createContextMenu(this.viewer.getTree());
- this.viewer.getTree().setMenu(menu);
- getSite().registerContextMenu(menuMgr, this.viewer);
- }
-
- /**
- * @since 0.6
- */
- private void constructToolBar() {
- IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
- toolBar.add(this.newAction);
- toolBar.add(this.editAction);
- toolBar.add(this.deleteAction);
- toolBar.add(this.collapseAllAction);
- }
-
- /**
- * @param parent the viewer's parent
- * @since 0.6
- */
- private void constructTreeViewer( Composite parent ) {
- this.provider = new RepositoryContentProvider();
- this.viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- this.viewer.setContentProvider(this.provider);
- this.viewer.setLabelProvider(this.provider);
- this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- @Override
- public void selectionChanged( SelectionChangedEvent event ) {
- handleSelectionChanged(event);
- }
- });
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
- * @since 0.6
- */
- @Override
- public void createPartControl( Composite parent ) {
- constructTreeViewer(parent);
- constructActions();
- constructToolBar();
- constructContextMenu();
- }
-
- /**
- * @return the tree viewer
- * @since 0.6
- */
- TreeViewer getViewer() {
- return this.viewer;
- }
-
- /**
- * @param event the event being processed
- * @since 0.6
- */
- void handleSelectionChanged( SelectionChangedEvent event ) {
- IStructuredSelection selection = (IStructuredSelection)event.getSelection();
- updateStatusLine(selection);
- updateActionBars(selection);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
- * @since 0.6
- */
- @Override
- public void setFocus() {
- if (!this.viewer.getControl().isDisposed()) {
- this.viewer.getControl().setFocus();
- }
- }
-
- /**
- * @param selection the current viewer selection (never <code>null</code>)
- * @since 0.6
- */
- private void updateActionBars( IStructuredSelection selection ) {
- if (selection.isEmpty()) {
- this.deleteAction.setEnabled(false);
- this.editAction.setEnabled(false);
- } else {
- assert (selection.size() == 1);
-
- IDnaObject obj = (IDnaObject)selection.getFirstElement();
- boolean enable = (obj instanceof Server);
- this.deleteAction.setEnabled(enable);
- this.editAction.setEnabled(enable);
- }
- }
-
- /**
- * @param selection the current viewer selection (never <code>null</code>)
- * @since 0.6
- */
- private void updateStatusLine( IStructuredSelection selection ) {
- assert (selection.size() < 2);
-
- String msg = (selection.isEmpty() ? "" : ((IDnaObject)selection.getFirstElement()).getShortDescription()); //$NON-NLS-1$
- getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
- }
-
-}
Copied: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerContentProvider.java (from rev 1062, branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryContentProvider.java)
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerContentProvider.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerContentProvider.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,215 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish.ui.swt.views;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.dna.publish.ServerManager;
+import org.jboss.dna.publish.domain.IDnaObject;
+import org.jboss.dna.publish.domain.Repository;
+import org.jboss.dna.publish.domain.Server;
+import org.jboss.dna.publish.domain.Workspace;
+import org.jboss.dna.publish.ui.swt.Activator;
+
+/**
+ * The ServerContentProvider is a content and label provider for DNA repositories.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class ServerContentProvider implements ITreeContentProvider, ILabelProvider {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ private final ServerManager serverManager;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ /**
+ * @param serverManager the server manager being used to find servers, repositories, and workspaces
+ * @since 0.6
+ */
+ public ServerContentProvider( ServerManager serverManager ) {
+ this.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.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);
+
+ if (parentElement instanceof Server) {
+ return this.serverManager.getRepositories((Server)parentElement).toArray();
+ }
+
+ if (parentElement instanceof Repository) {
+ return this.serverManager.getWorkspaces((Repository)parentElement).toArray();
+ }
+
+ 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.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
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java (from rev 1062, branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/RepositoryView.java)
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java (rev 0)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -0,0 +1,261 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.publish.ui.swt.views;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.eclipse.ui.part.ViewPart;
+import org.jboss.dna.publish.IServerRegistryListener;
+import org.jboss.dna.publish.ServerManager;
+import org.jboss.dna.publish.ServerRegistryEvent;
+import org.jboss.dna.publish.domain.IDnaObject;
+import org.jboss.dna.publish.ui.swt.Activator;
+import org.jboss.dna.publish.ui.swt.I18n;
+import org.jboss.dna.publish.ui.swt.actions.DeleteServerAction;
+import org.jboss.dna.publish.ui.swt.actions.EditServerAction;
+import org.jboss.dna.publish.ui.swt.actions.NewServerAction;
+
+/**
+ * The ServerView shows all defined servers and their DNA repositories.
+ *
+ * @author Dan Florian
+ * @since 0.6
+ */
+public final class ServerView extends ViewPart implements IServerRegistryListener {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ /**
+ * Collapses all tree nodes.
+ *
+ * @since 0.6
+ */
+ private IAction collapseAllAction;
+
+ /**
+ * Deletes a server.
+ *
+ * @since 0.6
+ */
+ private BaseSelectionListenerAction deleteAction;
+
+ /**
+ * Edits a server's properties.
+ *
+ * @since 0.6
+ */
+ private BaseSelectionListenerAction editAction;
+
+ /**
+ * Creates a new server.
+ *
+ * @since 0.6
+ */
+ private BaseSelectionListenerAction newAction;
+
+ /**
+ * The viewer's content and label provider.
+ *
+ * @since 0.6
+ */
+ private ServerContentProvider provider;
+
+ /**
+ * @since 0.6
+ */
+ private TreeViewer viewer;
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ /**
+ * @since 0.6
+ */
+ private void constructActions() {
+ // the collapse all action is always enabled
+ this.collapseAllAction = new Action() {
+ @Override
+ public void run() {
+ getViewer().collapseAll();
+ }
+ };
+
+ this.collapseAllAction.setToolTipText(I18n.CollapseActionToolTip);
+ this.collapseAllAction.setImageDescriptor(Activator.getDefault().getSharedImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL));
+
+ // the shell used for dialogs that the actions display
+ Shell shell = this.getSite().getShell();
+
+ // the delete action will delete one or more servers
+ this.deleteAction = new DeleteServerAction(shell, getServerManager());
+ this.viewer.addSelectionChangedListener(this.deleteAction);
+
+ // the edit action is only enabled when one server is selected
+ this.editAction = new EditServerAction(shell, getServerManager());
+ this.viewer.addSelectionChangedListener(this.editAction);
+
+ // the new server action is always enabled
+ this.newAction = new NewServerAction(shell, getServerManager());
+ this.viewer.addSelectionChangedListener(this.newAction);
+ }
+
+ /**
+ * @since 0.6
+ */
+ private void constructContextMenu() {
+ MenuManager menuMgr = new MenuManager();
+ menuMgr.add(this.newAction);
+ menuMgr.add(this.editAction);
+ menuMgr.add(this.deleteAction);
+ // menuMgr.setRemoveAllWhenShown(true);
+
+ Menu menu = menuMgr.createContextMenu(this.viewer.getTree());
+ this.viewer.getTree().setMenu(menu);
+ getSite().registerContextMenu(menuMgr, this.viewer);
+ }
+
+ /**
+ * @since 0.6
+ */
+ private void constructToolBar() {
+ IToolBarManager toolBar = getViewSite().getActionBars().getToolBarManager();
+ toolBar.add(this.newAction);
+ toolBar.add(this.editAction);
+ toolBar.add(this.deleteAction);
+ toolBar.add(this.collapseAllAction);
+ }
+
+ /**
+ * @param parent the viewer's parent
+ * @since 0.6
+ */
+ private void constructTreeViewer( Composite parent ) {
+ this.provider = new ServerContentProvider(getServerManager());
+ this.viewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
+ this.viewer.setContentProvider(this.provider);
+ this.viewer.setLabelProvider(this.provider);
+ this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged( SelectionChangedEvent event ) {
+ handleSelectionChanged(event);
+ }
+ });
+
+ // need to call this (doesn't matter what the param is) to bootstrap the provider.
+ this.viewer.setInput(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ * @since 0.6
+ */
+ @Override
+ public void createPartControl( Composite parent ) {
+ constructTreeViewer(parent);
+ constructActions();
+ constructToolBar();
+ constructContextMenu();
+
+ // register to receive changes to the server registry
+ getServerManager().addRegistryListener(this);
+ }
+
+ /**
+ * @return the server manager being used by this view
+ * @since 0.6
+ */
+ private ServerManager getServerManager() {
+ return Activator.getDefault().getServerManager();
+ }
+
+ /**
+ * @return the tree viewer
+ * @since 0.6
+ */
+ TreeViewer getViewer() {
+ return this.viewer;
+ }
+
+ /**
+ * @param event the event being processed
+ * @since 0.6
+ */
+ void handleSelectionChanged( SelectionChangedEvent event ) {
+ updateStatusLine((IStructuredSelection)event.getSelection());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.publish.IServerRegistryListener#serverRegistryChanged(org.jboss.dna.publish.ServerRegistryEvent)
+ * @since 0.6
+ */
+ @Override
+ public Exception[] serverRegistryChanged( ServerRegistryEvent event ) {
+ this.viewer.refresh();
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ * @since 0.6
+ */
+ @Override
+ public void setFocus() {
+ if (!this.viewer.getControl().isDisposed()) {
+ this.viewer.getControl().setFocus();
+ }
+ }
+
+ /**
+ * @param selection the current viewer selection (never <code>null</code>)
+ * @since 0.6
+ */
+ private void updateStatusLine( IStructuredSelection selection ) {
+ assert (selection.size() < 2);
+
+ String msg = (selection.isEmpty() ? "" : ((IDnaObject)selection.getFirstElement()).getShortDescription()); //$NON-NLS-1$
+ getViewSite().getActionBars().getStatusLineManager().setMessage(msg);
+ }
+
+}
Property changes on: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/views/ServerView.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishOperation.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -23,9 +23,10 @@
*/
package org.jboss.dna.publish.ui.swt.wizards;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import org.eclipse.core.resources.IResource;
+import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.jboss.dna.publish.domain.Workspace;
@@ -67,11 +68,11 @@
// ===========================================================================================================================
/**
- * The resources being published or unpublished.
+ * The files being published or unpublished.
*
* @since 0.6
*/
- private final Collection<IResource> resources;
+ private final List<IFile> files;
/**
* The operation type.
@@ -85,7 +86,7 @@
*
* @since 0.6
*/
- private Workspace workspace;
+ private final Workspace workspace;
// ===========================================================================================================================
// Constructors
@@ -93,12 +94,16 @@
/**
* @param type the operation type
- * @param resources the resources being published or unpublished
+ * @param files the files being published or unpublished
+ * @param workspace the workspace to use when publishing or unpublishing
+ * @since 0.6
*/
public PublishOperation( Type type,
- Collection<IResource> resources ) {
+ List<IFile> files,
+ Workspace workspace ) {
this.type = type;
- this.resources = resources;
+ this.files = files;
+ this.workspace = workspace;
}
// ===========================================================================================================================
@@ -138,15 +143,19 @@
@Override
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
assert (this.workspace != null);
-
+
try {
- // TODO
String name = (isPublishing() ? I18n.PublishOperationPublishTaskName : I18n.PublishOperationUnpublishTaskName);
- monitor.beginTask(name, this.resources.size());
-
- for (IResource resource : this.resources) {
- // TODO call publisher here
+ monitor.beginTask(name, this.files.size());
+
+ for (IFile eclipseFile : this.files) {
+ File file = eclipseFile.getLocation().toFile();
+ // TODO call publisher here (timeout?)
monitor.worked(1);
+
+ if (monitor.isCanceled()) {
+ break;
+ }
}
} catch (Exception e) {
throw new InvocationTargetException(e);
@@ -155,14 +164,4 @@
}
}
- /**
- * The workspace must be set prior to executing the operation.
- *
- * @param workspace the workspace used when publishing or unpublishing (never <code>null</code>)
- * @since 0.6
- */
- protected void setWorkspace( Workspace workspace ) {
- this.workspace = workspace;
- }
-
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishPage.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -25,15 +25,28 @@
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
@@ -44,7 +57,9 @@
import org.jboss.dna.publish.domain.Repository;
import org.jboss.dna.publish.domain.Server;
import org.jboss.dna.publish.domain.Workspace;
+import org.jboss.dna.publish.ui.swt.Activator;
import org.jboss.dna.publish.ui.swt.I18n;
+import org.jboss.dna.publish.ui.swt.actions.NewServerAction;
import org.jboss.dna.publish.ui.swt.wizards.PublishOperation.Type;
/**
@@ -54,6 +69,181 @@
public final class PublishPage extends WizardPage implements ModifyListener {
// ===========================================================================================================================
+ // Constants
+ // ===========================================================================================================================
+
+ /**
+ * The key in the wizard <code>IDialogSettings</code> for the recurse flag.
+ *
+ * @since 0.6
+ */
+ private static final String RECURSE_KEY = "recurse"; //$NON-NLS-1$
+
+ // ===========================================================================================================================
+ // Class Methods
+ // ===========================================================================================================================
+
+ /**
+ * @param container the project or folder whose files are being requested
+ * @param recurse the flag indicating if child containers should be traversed
+ * @return the list of files contained in the specified container (never <code>null</code>)
+ * @throws CoreException if there is a problem finding the files
+ * @since 0.6
+ */
+ private static List<IFile> findFiles( IContainer container,
+ boolean recurse ) throws CoreException {
+ List<IFile> result = new ArrayList<IFile>();
+
+ for (IResource member : container.members()) {
+ if (recurse && (member instanceof IContainer)) {
+ // don't publish closed projects
+ if ((member instanceof IProject) && !((IProject)member).isOpen()) {
+ continue;
+ }
+
+ result.addAll(findFiles((IContainer)member, recurse));
+ } else if ((member instanceof IFile) && ((IFile)member).getLocation().toFile().exists()) {
+ result.add((IFile)member);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Processes the specified list of files and for (1) each file found adds it to the result and (2) for each project or folder
+ * adds all contained files. For projects and folders processing will be recursive based on saved wizard settings.
+ *
+ * @param resources the resources being processed
+ * @param recurse the flag indicating if child containers should be traversed
+ * @return the files being published or unpublished (never <code>null</code>)
+ * @throws CoreException if there is a problem processing the resources
+ * @since 0.6
+ */
+ private static List<IFile> processResources( List<IResource> resources,
+ boolean recurse ) throws CoreException {
+ List<IFile> result = new ArrayList<IFile>();
+
+ // Project Map - the outer map. Its keys are IProjects and its values are a Parent Map
+ // Parent Map - the inner map. Its keys are IContainers (IProject, IFolder) and its values are a list of files
+ Map<IProject, Map<IContainer, List<IFile>>> projectMap = new HashMap<IProject, Map<IContainer, List<IFile>>>();
+
+ // Step 1: Process resources
+ // - For each file make sure there is a project entry and parent entry then add the file to the Parent Map.
+ // - For each folder make sure there is a project entry then add folder entry.
+ // - For each project make sure there is a project entry.
+ //
+ // Step 2: Process maps
+ // - In the Project Map, when the recurse flag is set, entries for projects that have a null value (parent map) will be
+ // traversed finding all child files and them to results.
+ // - In the internal parent map, when the recurse flag is set, entries for parents that have a null value (child
+ // collection) will be traversed finding all child files and add them to results.
+ //
+ // Step 3: Add files from Step 1 to results
+
+ // Step 1 (see above for processing description)
+ for (IResource resource : resources) {
+ IFile file = null;
+ IProject project = null;
+ List<IFile> files = null;
+ Map<IContainer, List<IFile>> parentMap = null;
+
+ if (resource instanceof IFile) {
+ IContainer parent = null; // project or folder
+ file = (IFile)resource;
+ parent = file.getParent();
+ project = file.getProject();
+
+ // make sure there is a project entry
+ if (!projectMap.containsKey(project)) {
+ projectMap.put(project, null);
+ }
+
+ parentMap = projectMap.get(project);
+
+ // make sure there is a parent entry
+ if (parentMap == null) {
+ parentMap = new HashMap<IContainer, List<IFile>>();
+ projectMap.put(project, parentMap);
+ }
+
+ files = parentMap.get(parent);
+
+ // make sure there is a files collection
+ if (files == null) {
+ files = new ArrayList<IFile>();
+ parentMap.put(parent, files);
+ }
+
+ // add file
+ files.add(file);
+ } else if (resource instanceof IFolder) {
+ IFolder folder = (IFolder)resource;
+ project = folder.getProject();
+
+ // make sure there is a project entry
+ if (!projectMap.containsKey(project)) {
+ projectMap.put(project, null);
+ }
+
+ parentMap = projectMap.get(project);
+
+ // make sure there is a folder entry
+ if (parentMap == null) {
+ parentMap = new HashMap<IContainer, List<IFile>>();
+ projectMap.put(project, parentMap);
+ }
+
+ // add folder only if not already there
+ if (!parentMap.containsKey(folder)) {
+ parentMap.put(folder, null);
+ }
+ } else if (resource instanceof IProject) {
+ project = (IProject)resource;
+
+ // if map does not have entry create one
+ if (!projectMap.containsKey(project)) {
+ projectMap.put(project, null);
+ }
+ }
+ }
+
+ // Step 2 (see above for processing description)
+ // Process projects that have nothing under them selected
+ for (IProject project : projectMap.keySet()) {
+ Map<IContainer, List<IFile>> parentMap = projectMap.get(project);
+
+ if (parentMap == null) {
+ result.addAll(findFiles(project, recurse));
+ } else {
+ // process folders with no folder entries
+ for (IContainer folder : parentMap.keySet()) {
+ List<IFile> files = parentMap.get(folder);
+
+ if (files == null) {
+ result.addAll(findFiles(folder, recurse));
+ }
+ }
+ }
+ }
+
+ // Step 3 (see above for processing description)
+ for (IProject project : projectMap.keySet()) {
+ Map<IContainer, List<IFile>> parentMap = projectMap.get(project);
+
+ if (parentMap != null) {
+ for (Entry<IContainer, List<IFile>> entry : parentMap.entrySet()) {
+ if (entry.getValue() != null) {
+ result.addAll(entry.getValue());
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ // ===========================================================================================================================
// Fields
// ===========================================================================================================================
@@ -79,27 +269,34 @@
private Combo cbxWorkspace;
/**
- * Indicates if publishing or unpublishing is being done.
+ * The files being published or unpublished (never <code>null</code>).
*
* @since 0.6
*/
- private final Type type;
+ private List<IFile> files;
/**
- * The collection of resources being published/unpublished.
+ * The method in control of registering/unregistering combobox listners or <code>null</code>.
*
* @since 0.6
*/
- private final List<IResource> resources;
+ private String listenerControlLock = null;
/**
- * The repository where the workspace is located.
+ * The control containing all the files being published or unpublished.
*
* @since 0.6
*/
- private Repository repository;
+ private org.eclipse.swt.widgets.List lstResources;
/**
+ * The flag indicating if child containers should be traversed.
+ *
+ * @since 0.6
+ */
+ private boolean recurse;
+
+ /**
* A collection of repositories for the selected server (never <code>null</code>).
*
* @since 0.6
@@ -107,6 +304,20 @@
private List<Repository> repositories;
/**
+ * The repository where the workspace is located.
+ *
+ * @since 0.6
+ */
+ private Repository repository;
+
+ /**
+ * The collection of resources selected by the user to be published or unpublished.
+ *
+ * @since 0.6
+ */
+ private final List<IResource> resources;
+
+ /**
* The server where the repository is located.
*
* @since 0.6
@@ -128,6 +339,13 @@
private Status status;
/**
+ * Indicates if publishing or unpublishing is being done.
+ *
+ * @since 0.6
+ */
+ private final Type type;
+
+ /**
* The workspace where the resources are being published/unpublished (may be <code>null</code>).
*
* @since 0.6
@@ -148,15 +366,18 @@
/**
* @param type indicates if publishing or unpublishing is being done
* @param resources the resources being published or unpublished (never <code>null</code>)
+ * @throws CoreException if there is a problem processing the input resources
* @since 0.6
*/
public PublishPage( Type type,
- List<IResource> resources ) {
+ List<IResource> resources ) throws CoreException {
super(PublishPage.class.getSimpleName());
setTitle((type == Type.PUBLISH) ? I18n.PublishPagePublishTitle : I18n.PublishPageUnpublishTitle);
+ setPageComplete(false);
this.type = type;
this.resources = resources;
+ this.files = processResources(resources, this.recurse);
}
// ===========================================================================================================================
@@ -169,14 +390,40 @@
pnl.setLayout(new GridLayout(2, false));
pnl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ // row 1: label combobox button
+ // row 2: label combobox
+ // row 3: label combobox
+
{ // server row
- Label lblServer = new Label(pnl, SWT.LEFT);
+ Composite pnlServer = new Composite(pnl, SWT.NONE);
+ GridLayout layout = new GridLayout(3, false);
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ pnlServer.setLayout(layout);
+ GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ gd.horizontalSpan = 2;
+ pnlServer.setLayoutData(gd);
+
+ Label lblServer = new Label(pnlServer, SWT.LEFT);
lblServer.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
lblServer.setText(I18n.PublishPageServerLabel);
- this.cbxServer = new Combo(pnl, SWT.DROP_DOWN | SWT.READ_ONLY);
+ this.cbxServer = new Combo(pnlServer, SWT.DROP_DOWN | SWT.READ_ONLY);
this.cbxServer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
this.cbxServer.setToolTipText(I18n.PublishPageServerToolTip);
+
+ final IAction action = new NewServerAction(this.getShell(), getServerManager());
+ Button btnNewServer = new Button(pnlServer, SWT.PUSH);
+ btnNewServer.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ btnNewServer.setText(I18n.PublishPageNewServerButton);
+ btnNewServer.setToolTipText(action.getToolTipText());
+ btnNewServer.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ action.run();
+ refreshServers();
+ }
+ });
}
{ // repository row
@@ -207,28 +454,44 @@
private void constructResourcesPanel( Composite parent ) {
Composite pnl = new Composite(parent, SWT.NONE);
- pnl.setLayout(new GridLayout());
+ pnl.setLayout(new GridLayout(2, false));
pnl.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- Label lbl = new Label(pnl, SWT.LEFT);
- lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+ // pnl layout:
+ // row 1: lbl chk
+ // row 2: lstResources
- if (type == Type.PUBLISH) {
- lbl.setText(I18n.PublishPagePublishResourcesLabel);
- } else {
- lbl.setText(I18n.PublishPageUnpublishResourcesLabel);
+ { // row 1
+ Label lbl = new Label(pnl, SWT.LEFT);
+ lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+
+ if (type == Type.PUBLISH) {
+ lbl.setText(I18n.PublishPagePublishResourcesLabel);
+ } else {
+ lbl.setText(I18n.PublishPageUnpublishResourcesLabel);
+ }
+
+ final Button chk = new Button(pnl, SWT.CHECK);
+ chk.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+ chk.setText(I18n.PublishPageRecurseCheckBox);
+ chk.setToolTipText(I18n.PublishPageRecurseCheckBoxToolTip);
+ chk.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected( SelectionEvent e ) {
+ handleRecurseChanged(chk.getSelection());
+ }
+ });
}
- org.eclipse.swt.widgets.List lstResources = new org.eclipse.swt.widgets.List(pnl, SWT.BORDER | SWT.H_SCROLL
- | SWT.V_SCROLL);
- lstResources.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ { // row 2
+ this.lstResources = new org.eclipse.swt.widgets.List(pnl, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ gd.horizontalSpan = 2;
+ this.lstResources.setLayoutData(gd);
- // set initial value
- // TODO implement load resources
- String[] data = new String[20];
- for (int i = 0; i < 20; ++i)
- data[i] = "my/resource" + i + ".xmi"; //$NON-NLS-1$ //$NON-NLS-2$
- lstResources.setItems(data);
+ // load list with initial files
+ loadFiles();
+ }
}
/**
@@ -245,20 +508,28 @@
constructResourcesPanel(pnlMain);
setControl(pnlMain);
- resetServers();
- installLocationListeners();
+ refreshServers();
+ installLocationListeners(null);
}
/**
+ * @return the file to publish or unpublish (never <code>null</code>)
+ * @since 0.6
+ */
+ public List<IFile> getFiles() {
+ return this.files;
+ }
+
+ /**
* @return the server manager obtained from the wizard
* @since 0.6
*/
private ServerManager getServerManager() {
- return ((ServerWizard)getWizard()).getServerManager();
+ return ((PublishWizard)getWizard()).getServerManager();
}
/**
- * @return thw workspace to use when publishing or unpublishing
+ * @return thw workspace to use when publishing or unpublishing (page must be complete)
* @since 0.6
*/
public Workspace getWorkspace() {
@@ -267,6 +538,25 @@
}
/**
+ * Saves the recurse setting and reloads the files to be published or unpublished.
+ *
+ * @param selected the flag indicating the new recurse setting
+ * @since 0.6
+ */
+ void handleRecurseChanged( boolean selected ) {
+ this.recurse = selected;
+ saveRecurseSetting();
+
+ try {
+ this.files = processResources(this.resources, isRecursing());
+ loadFiles();
+ } catch (CoreException e) {
+ Activator.getDefault().log(new Status(Severity.ERROR, I18n.PublishPageRecurseProcessingErrorMsg, e));
+ MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, I18n.PublishPageRecurseProcessingErrorMsg);
+ }
+ }
+
+ /**
* Handler for when the repository control value is modified
*
* @since 0.6
@@ -276,7 +566,7 @@
this.repository = this.repositories.get(index);
// clear loaded workspaces
- resetWorkspaces();
+ refreshWorkspaces();
// update page state
updateState();
@@ -291,7 +581,7 @@
this.server = this.servers.get(this.cbxServer.getSelectionIndex());
// need to reload repositories since server changed
- resetRepositories();
+ refreshRepositories();
// update page state
updateState();
@@ -310,15 +600,53 @@
/**
* Installs the combobox listeners.
*
+ * @param listenerControlLock the method in control of registering/unregistering combobox listeners
* @since 0.6
*/
- private void installLocationListeners() {
- this.cbxRepository.addModifyListener(this);
- this.cbxServer.addModifyListener(this);
- this.cbxWorkspace.addModifyListener(this);
+ private void installLocationListeners( String listenerControlLock ) {
+ if ((this.listenerControlLock == null) || this.listenerControlLock.equals(listenerControlLock)) {
+ this.cbxRepository.addModifyListener(this);
+ this.cbxServer.addModifyListener(this);
+ this.cbxWorkspace.addModifyListener(this);
+ this.listenerControlLock = listenerControlLock;
+ this.listenerControlLock = null;
+ }
}
/**
+ * @return the flag indicating if resources found recursively under projects and folders should also be published or
+ * unpublished
+ * @since 0.6
+ */
+ protected boolean isRecursing() {
+ boolean recurse = true;
+
+ if (getDialogSettings().get(RECURSE_KEY) != null) {
+ recurse = getDialogSettings().getBoolean(RECURSE_KEY);
+ }
+
+ return recurse;
+ }
+
+ /**
+ * Populates the list of files to be published based on the recurse flag and the list of workspace selected resources.
+ * Pre-condition is that {@link #processResources(List, boolean)} has been called.
+ *
+ * @since 0.6
+ */
+ private void loadFiles() {
+ String[] data = new String[this.files.size()];
+ int i = 0;
+
+ for (IResource resource : this.files) {
+ data[i] = resource.getFullPath().toString();
+ ++i;
+ }
+
+ this.lstResources.setItems(data);
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
@@ -337,21 +665,23 @@
}
/**
- * Resets the repository-related fields and controls.
+ * Refreshes the repository-related fields and controls based on the server registry. This in turn causes the workspaces to
+ * also to be refreshed.
*
* @since 0.6
*/
- private void resetRepositories() {
+ private void refreshRepositories() {
+ final String LOCK_ID = "refreshRepositories"; //$NON-NLS-1$
this.repository = null;
if (this.server == null) {
this.repositories = Collections.emptyList();
} else {
- this.repositories = new ArrayList<Repository>(this.server.getRepositories());
+ this.repositories = new ArrayList<Repository>(getServerManager().getRepositories(this.server));
}
// uninstall listeners to prevent handling events
- uninstallLocationListeners();
+ uninstallLocationListeners(LOCK_ID);
// clear items
this.cbxRepository.removeAll();
@@ -384,21 +714,26 @@
}
// must reload workspaces
- resetWorkspaces();
+ refreshWorkspaces();
// reinstall listening
- installLocationListeners();
+ installLocationListeners(LOCK_ID);
}
/**
- * Resets the server-related fields and controls.
+ * Refreshes the server-related fields and controls based on the server registry. This in turn causes the repositories and
+ * workspaces to also to be refreshed.
*
* @since 0.6
*/
- private void resetServers() {
+ void refreshServers() {
+ final String LOCK_ID = "refreshServers"; //$NON-NLS-1$
this.server = null;
this.servers = new ArrayList<Server>(getServerManager().getServers());
+ // uninstall listeners to prevent handling events
+ uninstallLocationListeners(LOCK_ID);
+
if (this.servers.size() == 0) {
// disable control if necessary
if (this.cbxServer.getEnabled()) {
@@ -426,25 +761,29 @@
}
// must reload repositories
- resetRepositories();
+ refreshRepositories();
+
+ // reinstall listening
+ installLocationListeners(LOCK_ID);
}
/**
- * Resets the workspace-related fields and controls.
+ * Refreshes the workspace-related fields and controls based on the server registry.
*
* @since 0.6
*/
- private void resetWorkspaces() {
+ private void refreshWorkspaces() {
+ final String LOCK_ID = "refreshWorkspaces"; //$NON-NLS-1$
this.workspace = null;
if (this.repository == null) {
this.workspaces = Collections.emptyList();
} else {
- this.workspaces = new ArrayList<Workspace>(this.repository.getWorkspaces());
+ this.workspaces = new ArrayList<Workspace>(getServerManager().getWorkspaces(this.repository));
}
// uninstall listeners to prevent handling events
- uninstallLocationListeners();
+ uninstallLocationListeners(LOCK_ID);
// clear items
this.cbxWorkspace.removeAll();
@@ -477,10 +816,19 @@
}
// reinstall listening
- installLocationListeners();
+ installLocationListeners(LOCK_ID);
}
/**
+ * Saves the current recurse value to the wizard <code>IDialogSettings</code>.
+ *
+ * @since 0.6
+ */
+ protected void saveRecurseSetting() {
+ getDialogSettings().put(RECURSE_KEY, this.recurse);
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
@@ -502,12 +850,17 @@
/**
* Uninstalls the combobox listeners.
*
+ * @param listenerControlLock the method in control of registering/unregistering combobox listeners
* @since 0.6
*/
- private void uninstallLocationListeners() {
- this.cbxRepository.removeModifyListener(this);
- this.cbxServer.removeModifyListener(this);
- this.cbxWorkspace.removeModifyListener(this);
+ private void uninstallLocationListeners( String listenerControlLock ) {
+ if (this.listenerControlLock == null) {
+ this.listenerControlLock = listenerControlLock;
+ this.cbxRepository.removeModifyListener(this);
+ this.cbxServer.removeModifyListener(this);
+ this.cbxWorkspace.removeModifyListener(this);
+ this.listenerControlLock = listenerControlLock;
+ }
}
/**
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/PublishWizard.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -25,12 +25,12 @@
import java.lang.reflect.InvocationTargetException;
import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.jboss.dna.publish.ServerManager;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.Status.Severity;
@@ -50,13 +50,6 @@
// ===========================================================================================================================
/**
- * The publishing or unpublishing operation.
- *
- * @since 0.6
- */
- private final PublishOperation operation;
-
- /**
* The wizard page containing all the controls that allow publishing/unpublishing of resources.
*
* @since 0.6
@@ -70,6 +63,13 @@
*/
private final ServerManager serverManager;
+ /**
+ * Indicates if the wizard will perform a publishing or unpublishing operation.
+ *
+ * @since 0.6
+ */
+ private final Type type;
+
// ===========================================================================================================================
// Constructors
// ===========================================================================================================================
@@ -78,16 +78,17 @@
* @param type the publishing or unpublishing indicator
* @param resources the resources being published or unpublished (never <code>null</code>)
* @param serverManager the server manager in charge of the server registry (never <code>null</code>)
+ * @throws CoreException if there is a problem processing the resources
* @since 0.6
*/
public PublishWizard( Type type,
List<IResource> resources,
- ServerManager serverManager ) {
- this.operation = new PublishOperation(type, resources);
+ ServerManager serverManager ) throws CoreException {
+ this.type = type;
this.page = new PublishPage(type, resources);
this.serverManager = serverManager;
- setWindowTitle(this.operation.isPublishing() ? I18n.PublishWizardPublishTitle : I18n.PublishWizardUnpublishTitle);
+ setWindowTitle((type == Type.PUBLISH) ? I18n.PublishWizardPublishTitle : I18n.PublishWizardUnpublishTitle);
}
// ===========================================================================================================================
@@ -106,6 +107,30 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.wizard.Wizard#getDialogSettings()
+ * @since 0.6
+ */
+ @Override
+ public IDialogSettings getDialogSettings() {
+ IDialogSettings settings = super.getDialogSettings();
+
+ if (settings == null) {
+ IDialogSettings temp = Activator.getDefault().getDialogSettings();
+ settings = temp.getSection(getClass().getSimpleName());
+
+ if (settings == null) {
+ settings = temp.addNewSection(getClass().getSimpleName());
+ }
+
+ setDialogSettings(settings);
+ }
+
+ return super.getDialogSettings();
+ }
+
+ /**
* @return the server manager (never <code>null</code>)
* @since 0.6
*/
@@ -122,42 +147,21 @@
@Override
public boolean performFinish() {
Workspace workspace = this.page.getWorkspace();
- this.operation.setWorkspace(workspace);
-
+ List<IFile> files = this.page.getFiles();
+ PublishOperation operation = new PublishOperation(this.type, files, workspace);
+
try {
- getContainer().run(true, true, this.operation);
+ getContainer().run(true, true, operation);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
- String message = (this.operation.isPublishing() ? I18n.PublishWizardPublishErrorMsg : I18n.PublishWizardUnpublishErrorMsg);
- Activator.getDefault().log(getClass(), new Status(Severity.ERROR, message, e.getTargetException()));
+ String message = (operation.isPublishing() ? I18n.PublishWizardPublishErrorMsg : I18n.PublishWizardUnpublishErrorMsg);
+ Activator.getDefault().log(new Status(Severity.ERROR, message, e.getTargetException()));
MessageDialog.openError(getContainer().getShell(), I18n.ErrorDialogTitle, message);
return false;
}
-
- return true; //!status.isError();
- }
- // ===========================================================================================================================
- // Test UI
- // ===========================================================================================================================
-
- public static void main( String[] args ) {
- Display display = new Display();
-
- Shell shell = new Shell(display);
- shell.setText("Shell"); //$NON-NLS-1$
- shell.setSize(200, 200);
- shell.open();
-
- WizardDialog dialog = new WizardDialog(shell, new PublishWizard(Type.PUBLISH, null, new ServerManager("/home/dan"))); //$NON-NLS-1$
- dialog.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
- }
-
- display.dispose();
+ return true;
}
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerPage.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -85,11 +85,23 @@
// Constructors
// ===========================================================================================================================
+ /**
+ * Constructs a wizard page that will create a new server.
+ *
+ * @since 0.6
+ */
public ServerPage() {
super(ServerPage.class.getSimpleName());
setTitle(I18n.ServerPageTitle);
+ setPageComplete(false);
}
+ /**
+ * Constructs a wizard page that edits the specified server's properties.
+ *
+ * @param server the server being edited
+ * @since 0.6
+ */
public ServerPage( Server server ) {
super(ServerPage.class.getSimpleName());
setTitle(I18n.ServerPageTitle);
@@ -97,6 +109,7 @@
this.url = server.getUrl();
this.user = server.getUser();
this.password = server.getPassword();
+ setPageComplete(false);
}
// ===========================================================================================================================
@@ -166,7 +179,7 @@
Label lblImage = new Label(pnl, SWT.NONE);
lblImage.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
lblImage.setImage(Display.getDefault().getSystemImage(SWT.ICON_INFORMATION));
-
+
StyledText st = new StyledText(pnl, SWT.READ_ONLY | SWT.MULTI | SWT.NO_FOCUS | SWT.WRAP);
st.setText(I18n.ServerPageSavePasswordLabel);
st.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
@@ -288,9 +301,9 @@
super.setVisible(visible);
if (visible) {
- // set initial state
- validate();
-
+ // set initial state
+ validate();
+
// set initial message
setMessage(I18n.ServerPageOkStatusMsg);
}
Modified: branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java
===================================================================
--- branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java 2009-06-28 02:14:25 UTC (rev 1067)
+++ branches/eclipse/org.jboss.dna.publish.ui.swt/src/org/jboss/dna/publish/ui/swt/wizards/ServerWizard.java 2009-07-01 22:20:46 UTC (rev 1068)
@@ -23,13 +23,12 @@
*/
package org.jboss.dna.publish.ui.swt.wizards;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.jboss.dna.publish.ServerManager;
import org.jboss.dna.publish.Status;
import org.jboss.dna.publish.domain.Server;
+import org.jboss.dna.publish.ui.swt.Activator;
import org.jboss.dna.publish.ui.swt.I18n;
/**
@@ -43,6 +42,13 @@
// ===========================================================================================================================
/**
+ * Non-<code>null</code> if the wizard is editing an existing server.
+ *
+ * @since 0.6
+ */
+ private Server existingServer;
+
+ /**
* The wizard page containing all the controls that allow editing of server properties.
*
* @since 0.6
@@ -61,6 +67,8 @@
// ===========================================================================================================================
/**
+ * Constructs a wizard that creates a new server.
+ *
* @param serverManager the server manager in charge of the server registry (never <code>null</code>)
* @since 0.6
*/
@@ -71,6 +79,8 @@
}
/**
+ * Constructs a wizard that edits an existing server.
+ *
* @param serverManager the server manager in charge of the server registry (never <code>null</code>)
* @param server the server whose properties are being edited (never <code>null</code>)
* @since 0.6
@@ -79,6 +89,7 @@
Server server ) {
this.page = new ServerPage(server);
this.serverManager = serverManager;
+ this.existingServer = server;
setWindowTitle(I18n.ServerWizardEditServerTitle);
}
@@ -113,32 +124,29 @@
*/
@Override
public boolean performFinish() {
+ Status status = null;
Server server = this.page.getServer();
- Status status = this.serverManager.addServer(server);
- return !status.isError();
- }
- // ===========================================================================================================================
- // Test UI
- // ===========================================================================================================================
+ if (this.existingServer == null) {
+ status = this.serverManager.addServer(server);
- public static void main( String[] args ) {
- Display display = new Display();
+ if (status.isError()) {
+ MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, I18n.ServerWizardEditServerErrorMsg);
+ }
+ } else {
+ status = this.serverManager.updateServer(this.existingServer, server);
- Shell shell = new Shell(display);
- shell.setText("Shell"); //$NON-NLS-1$
- shell.setSize(200, 200);
- shell.open();
+ if (status.isError()) {
+ MessageDialog.openError(getShell(), I18n.ErrorDialogTitle, I18n.ServerWizardNewServerErrorMsg);
+ }
+ }
- WizardDialog dialog = new WizardDialog(shell, new ServerWizard(new ServerManager("/home/dan"))); //$NON-NLS-1$
-// WizardDialog dialog = new WizardDialog(shell, new ServerWizard(new ServerManager("/home/dan"), new Server("file:", "user", null)));
- dialog.open();
-
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) display.sleep();
+ // log if necessary
+ if (!status.isOk()) {
+ Activator.getDefault().log(status);
}
- display.dispose();
+ return !status.isError();
}
}
16 years, 10 months