JBoss Tools SVN: r40111 - trunk/build/parent.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2012-04-10 11:29:32 -0400 (Tue, 10 Apr 2012)
New Revision: 40111
Modified:
trunk/build/parent/pom.xml
Log:
remove http://dl.google.com/eclipse/plugin/3.7/ from parent pom - we now mirror everything we need on download.jboss.org because it's all EPL
Modified: trunk/build/parent/pom.xml
===================================================================
--- trunk/build/parent/pom.xml 2012-04-10 09:07:00 UTC (rev 40110)
+++ trunk/build/parent/pom.xml 2012-04-10 15:29:32 UTC (rev 40111)
@@ -548,29 +548,7 @@
</repositories>
</profile>
- <!-- GWT dependencies which we can't mirror and must reference directly. -->
- <!-- still needed? JBIDE-10595 vs. JBIDE-10742 -->
<profile>
- <id>gwt</id>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- <repositories>
- <repository>
- <id>gwt</id>
- <url>http://dl.google.com/eclipse/plugin/3.7/</url>
- <layout>p2</layout>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- </releases>
- </repository>
- </repositories>
- </profile>
-
- <profile>
<id>osx</id>
<activation>
<property>
13 years, 8 months
JBoss Tools SVN: r40110 - in trunk/maven/plugins: org.jboss.tools.maven.core/poms and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: fbricon
Date: 2012-04-10 05:07:00 -0400 (Tue, 10 Apr 2012)
New Revision: 40110
Added:
trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate36X-template.xml
trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate41X-template.xml
Modified:
trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties
trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml
trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate332-template.xml
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java
trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java
trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java
Log:
JBIDE-10911: Add new Hibernate 3.6.x and 4.x maven provided libraries
https://issues.jboss.org/browse/JBIDE-10911
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties 2012-04-10 07:42:08 UTC (rev 40109)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/plugin.properties 2012-04-10 09:07:00 UTC (rev 40110)
@@ -8,6 +8,8 @@
Maven_JSF_1_1_Libraries=Maven JSF 1.1 Libraries
Maven_JSF_2_0_Libraries=Maven JSF 2.0 Libraries
Hibernate_3_3_2_Libraries=Hibernate 3.3.2 Libraries
+Hibernate_3_6_X_Libraries=Hibernate 3.6.10 Libraries
+Hibernate_4_1_X_Libraries=Hibernate 4.1.0 Libraries
Maven_Portlet_1_0_Libraries=Maven Portlet 1.0 Libraries
Maven_Portlet_2_0_Libraries=Maven Portlet 2.0 Libraries
Maven_Portletbridge_2_0_0_ALPHA_Libraries=Maven Portletbridge 2.0.0 ALPHA Libraries
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml 2012-04-10 07:42:08 UTC (rev 40109)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/plugin.xml 2012-04-10 09:07:00 UTC (rev 40110)
@@ -156,8 +156,58 @@
</enablement>
</provider>
</extension>
-
<extension point="org.eclipse.jst.common.project.facet.core.libraryProviders">
+ <provider id="hibernate41X-maven-library-provider" extends="maven-library-provider">
+ <label>%Hibernate_4_1_X_Libraries</label>
+ <param name="template" value="platform:/plugin/org.jboss.tools.maven.core/poms/hibernate41X-template.xml"/>
+ <enablement>
+ <and>
+ <with variable="projectFacets">
+ <test property="org.jboss.tools.maven.core.projectFacets" value="jpt.jpa,jboss.m2" forcePluginActivation="true"/>
+ </with>
+ <with variable="requestingProjectFacet">
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jpt.jpa:2.0" forcePluginActivation="true"/>
+ </with>
+ <with variable="jpaPlatform">
+ <equals value="hibernate2_0"/>
+ </with>
+ </and>
+ </enablement>
+ </provider>
+ </extension>
+ <extension point="org.eclipse.jst.common.project.facet.core.libraryProviders">
+ <provider id="hibernate36X-maven-library-provider" extends="maven-library-provider">
+ <label>%Hibernate_3_6_X_Libraries</label>
+ <param name="template" value="platform:/plugin/org.jboss.tools.maven.core/poms/hibernate36X-template.xml"/>
+ <enablement>
+ <or>
+ <and>
+ <with variable="projectFacets">
+ <test property="org.jboss.tools.maven.core.projectFacets" value="jpt.jpa,jboss.m2" forcePluginActivation="true"/>
+ </with>
+ <with variable="requestingProjectFacet">
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jpt.jpa:2.0" forcePluginActivation="true"/>
+ </with>
+ <with variable="jpaPlatform">
+ <equals value="hibernate2_0"/>
+ </with>
+ </and>
+ <and>
+ <with variable="projectFacets">
+ <test property="org.jboss.tools.maven.core.projectFacets" value="jpt.jpa,jboss.m2" forcePluginActivation="true"/>
+ </with>
+ <with variable="requestingProjectFacet">
+ <test property="org.eclipse.wst.common.project.facet.core.projectFacet" value="jpt.jpa:1.0" forcePluginActivation="true"/>
+ </with>
+ <with variable="jpaPlatform">
+ <equals value="hibernate"/>
+ </with>
+ </and>
+ </or>
+ </enablement>
+ </provider>
+ </extension>
+ <extension point="org.eclipse.jst.common.project.facet.core.libraryProviders">
<provider id="portlet10-maven-library-provider" extends="maven-library-provider">
<label>%Maven_Portlet_1_0_Libraries</label>
<param name="template" value="platform:/plugin/org.jboss.tools.maven.core/poms/portlet-template10.xml"/>
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate332-template.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate332-template.xml 2012-04-10 07:42:08 UTC (rev 40109)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate332-template.xml 2012-04-10 09:07:00 UTC (rev 40110)
@@ -6,35 +6,6 @@
<artifactId>template</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
-
- <repositories>
- <repository>
- <id>jboss-public-repository-group</id>
- <name>JBoss Community Public Maven Repository</name>
- <url>https://repository.jboss.org/nexus/content/groups/public/</url>
- <layout>default</layout>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </snapshots>
- </repository>
- <repository>
- <id>repository.jboss.org</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.org/maven2</url>
- </repository>
- <repository>
- <snapshots />
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2</url>
- </repository>
- </repositories>
-
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
@@ -115,13 +86,16 @@
</exclusion>
</exclusions>
</dependency>
-
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>3.1.1.GA</version>
+ <exclusions>
+ <exclusion>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
-
</dependencies>
-
</project>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate36X-template.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate36X-template.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate36X-template.xml 2012-04-10 09:07:00 UTC (rev 40110)
@@ -0,0 +1,116 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>template</groupId>
+ <artifactId>template</artifactId>
+ <packaging>pom</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <!-- inspired from https://raw.github.com/jbossas/quickstart/master/hibernate3/pom.xml -->
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>3.6.10.Final</version>
+
+ <!-- Some transitive dependencies of Hibernate 3 are available
+ in JBoss AS 7 as modules, so we don't include them in WEB-INF/lib, but instead
+ depend on the modules -->
+ <exclusions>
+ <exclusion>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Define dependency version of hibernate-entitymanager -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>3.6.10.Final</version>
+ <!-- Some transitive dependencies of Hibernate 3 are available
+ in JBoss AS 7 as modules, so we don't include them in WEB-INF/lib, but instead
+ depend on the modules -->
+ <exclusions>
+ <exclusion>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Define dependency version of hibernate-validator -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>3.1.0.GA</version>
+ <!-- Some transitive dependencies of Hibernate 3 are available
+ in JBoss AS 7 as modules, so we don't include them in WEB-INF/lib, but instead
+ depend on the modules -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Define dependency version of hibernate-commons-annotations -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-commons-annotations</artifactId>
+ <version>3.2.0.Final</version>
+ <!-- Some transitive dependencies of Hibernate 3 are available
+ in JBoss AS 7 as modules, so we don't include them in WEB-INF/lib, but instead
+ depend on the modules -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search</artifactId>
+ <version>4.1.0.Final</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate41X-template.xml
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate41X-template.xml (rev 0)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/poms/hibernate41X-template.xml 2012-04-10 09:07:00 UTC (rev 40110)
@@ -0,0 +1,90 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>template</groupId>
+ <artifactId>template</artifactId>
+ <packaging>pom</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.bom</groupId>
+ <artifactId>jboss-javaee-6.0-with-hibernate</artifactId>
+ <version>1.0.0.M7</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+<dependencies>
+ <!-- Hibernate ORM sub-modules -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <!-- this already part of JDK6 -->
+ <exclusions>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ </exclusions>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-envers</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-c3p0</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-ehcache</artifactId>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search</artifactId>
+ <version>4.1.0.Final</version>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search-analyzers</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search-engine</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search-orm</artifactId>
+ </dependency>
+ -->
+ <!-- Tools
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator-annotation-processor</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ </dependency>
+ -->
+</dependencies>
+</project>
\ No newline at end of file
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java 2012-04-10 07:42:08 UTC (rev 40109)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/MavenCoreActivator.java 2012-04-10 09:07:00 UTC (rev 40110)
@@ -692,8 +692,7 @@
}
}
- public static void addLibraryProviderOperationConfig(
- LibraryProviderOperationConfig config) {
+ public static void addLibraryProviderOperationConfig(LibraryProviderOperationConfig config) {
libraryProviderOperationConfigs.add(config);
}
Modified: trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java 2012-04-10 07:42:08 UTC (rev 40109)
+++ trunk/maven/plugins/org.jboss.tools.maven.core/src/org/jboss/tools/maven/core/libprov/MavenLibraryProviderInstallOperation.java 2012-04-10 09:07:00 UTC (rev 40110)
@@ -17,6 +17,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,6 +30,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.apache.maven.model.DependencyManagement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -82,8 +84,8 @@
PomResourceImpl resource = loadResource(pom);
Model projectModel = resource.getModel();
Model libraryModel = mavenConfig.getModel();
- MavenCoreActivator.mergeModel(projectModel, libraryModel);
try {
+ MavenCoreActivator.mergeModel(projectModel, libraryModel);
Map<String,String> options = new HashMap<String,String>();
options.put(XMIResource.OPTION_ENCODING, MavenCoreActivator.ENCODING);
resource.save(options);
@@ -115,9 +117,34 @@
if(pomModel.getDescription() != null && pomModel.getDescription().length() > 0) {
model.setDescription(pomModel.getDescription());
}
- EList<Dependency> pomDependencies = pomModel.getDependencies();
- List<org.apache.maven.model.Dependency> dependencies = model.getDependencies();
- for (Dependency pomDependency:pomDependencies) {
+
+ if (pomModel.getDependencyManagement() != null && pomModel.getDependencyManagement().isSetDependencies()) {
+ model.setDependencyManagement(new DependencyManagement());
+ model.getDependencyManagement().setDependencies(convertDependencies(pomModel.getDependencyManagement().getDependencies()));
+ }
+ model.setDependencies(convertDependencies(pomModel.getDependencies()));
+
+ EList<Repository> pomRepositories = pomModel.getRepositories();
+ List<org.apache.maven.model.Repository> repositories = model.getRepositories();
+ for (Repository pomRepository:pomRepositories) {
+ org.apache.maven.model.Repository repository = new org.apache.maven.model.Repository();
+ repository.setId(pomRepository.getId());
+ repository.setLayout(pomRepository.getLayout());
+ repository.setName(pomRepository.getName());
+ RepositoryPolicy pomReleases = pomRepository.getReleases();
+ repository.setReleases(getRepositoryPolicy(pomReleases));
+ RepositoryPolicy pomSnapshots = pomRepository.getSnapshots();
+ repository.setSnapshots(getRepositoryPolicy(pomSnapshots));
+ repository.setLayout(pomRepository.getLayout());
+ repository.setUrl(pomRepository.getUrl());
+ repositories.add(repository);
+ }
+ createMavenModel(file, model);
+ }
+
+ private List<org.apache.maven.model.Dependency> convertDependencies(EList<Dependency> pomDependencies) {
+ List<org.apache.maven.model.Dependency> dependencies = new ArrayList<org.apache.maven.model.Dependency>(pomDependencies.size());
+ for (Dependency pomDependency:pomDependencies) {
org.apache.maven.model.Dependency dependency = new org.apache.maven.model.Dependency();
dependency.setArtifactId(pomDependency.getArtifactId());
dependency.setGroupId(pomDependency.getGroupId());
@@ -137,22 +164,7 @@
}
dependencies.add(dependency);
}
- EList<Repository> pomRepositories = pomModel.getRepositories();
- List<org.apache.maven.model.Repository> repositories = model.getRepositories();
- for (Repository pomRepository:pomRepositories) {
- org.apache.maven.model.Repository repository = new org.apache.maven.model.Repository();
- repository.setId(pomRepository.getId());
- repository.setLayout(pomRepository.getLayout());
- repository.setName(pomRepository.getName());
- RepositoryPolicy pomReleases = pomRepository.getReleases();
- repository.setReleases(getRepositoryPolicy(pomReleases));
- RepositoryPolicy pomSnapshots = pomRepository.getSnapshots();
- repository.setSnapshots(getRepositoryPolicy(pomSnapshots));
- repository.setLayout(pomRepository.getLayout());
- repository.setUrl(pomRepository.getUrl());
- repositories.add(repository);
- }
- createMavenModel(file, model);
+ return dependencies;
}
public void createMavenModel(File file, org.apache.maven.model.Model model) throws CoreException {
Modified: trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java
===================================================================
--- trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java 2012-04-10 07:42:08 UTC (rev 40109)
+++ trunk/maven/plugins/org.jboss.tools.maven.ui/src/org/jboss/tools/maven/ui/internal/libprov/DependencyEditingSupport.java 2012-04-10 09:07:00 UTC (rev 40110)
@@ -131,13 +131,13 @@
dependency.setVersion(valueString);
break;
case 3:
- if (intValue > scopes.length) {
+ if (intValue < 0 || intValue > scopes.length) {
intValue = 0;
}
dependency.setScope(scopes[intValue]);
break;
case 4:
- if (intValue > types.length) {
+ if (intValue < 0 || intValue > types.length) {
intValue = 0;
}
dependency.setType(types[intValue]);
13 years, 8 months
JBoss Tools SVN: r40109 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-04-10 03:42:08 -0400 (Tue, 10 Apr 2012)
New Revision: 40109
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java
Log:
JBIDE-9824 (semi-related illegal monitor state exception during run on server for as7+)
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java 2012-04-10 07:32:20 UTC (rev 40108)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/JBoss7ModuleStateVerifier.java 2012-04-10 07:42:08 UTC (rev 40109)
@@ -43,9 +43,6 @@
} catch(InterruptedException ie) {
return;
}
- synchronized(monitor) {
- monitor.setCanceled(true);
- }
}
};
t.start();
@@ -56,7 +53,7 @@
// call is over, can notify the thread to go finish itself
synchronized(monitor) {
if( !monitor.isCanceled() )
- t.notify();
+ t.interrupt();
}
}
13 years, 8 months
JBoss Tools SVN: r40108 - trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-04-10 03:32:20 -0400 (Tue, 10 Apr 2012)
New Revision: 40108
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java
Log:
JBIDE-11456 if graceful stop for as7-related servers fails, force-stop.
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java 2012-04-10 07:01:44 UTC (rev 40107)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/server/internal/v7/LocalJBoss7BehaviorDelegate.java 2012-04-10 07:32:20 UTC (rev 40108)
@@ -38,16 +38,23 @@
public void stopImpl(boolean force) {
if (force || previousStopFailed) {
forceStop();
- previousStopFailed = false;
} else {
setServerStopping();
IStatus result = gracefullStop();
if (!result.isOK()) {
previousStopFailed = true;
setServerStarted();
+ } else {
+ forceStop();
}
}
}
+
+ @Override
+ protected synchronized void forceStop() {
+ super.forceStop();
+ previousStopFailed = false;
+ }
@Override
protected IStatus gracefullStop() {
13 years, 8 months
JBoss Tools SVN: r40107 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-04-10 03:01:44 -0400 (Tue, 10 Apr 2012)
New Revision: 40107
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
Log:
JBIDE-11488 to trunk b3
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-04-10 05:40:26 UTC (rev 40106)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBossRuntimeWizardFragment.java 2012-04-10 07:01:44 UTC (rev 40107)
@@ -209,12 +209,16 @@
protected void fillConfigWidgets(IRuntime rt) {
IJBossServerRuntime jbsrt = getRuntime();
String dirText = jbsrt.getConfigLocation();
- configDirText.setText(dirText == null ? IConstants.SERVER : dirText);
- configurations.setConfiguration(jbsrt.getJBossConfiguration() == null
+ configDirText.setText(isEmpty(dirText) ? IConstants.SERVER : dirText);
+ configurations.setConfiguration(isEmpty(jbsrt.getJBossConfiguration())
? IConstants.DEFAULT_CONFIGURATION : jbsrt.getJBossConfiguration());
configurations.getTable().setVisible(true);
}
+ protected boolean isEmpty(String s) {
+ return s == null || s.length() == 0;
+ }
+
protected void fillJREWidgets(IRuntime rt) {
IJBossServerRuntime jbsrt = getRuntime();
if (jbsrt.isUsingDefaultJRE()) {
13 years, 8 months
JBoss Tools SVN: r40106 - trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2012-04-10 01:40:26 -0400 (Tue, 10 Apr 2012)
New Revision: 40106
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java
Log:
JBIDE-11058 - test case never updated
Modified: trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java
===================================================================
--- trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java 2012-04-10 01:07:15 UTC (rev 40105)
+++ trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/server/StringSubstitutionTest.java 2012-04-10 05:40:26 UTC (rev 40106)
@@ -21,14 +21,14 @@
String ret = new ConfigNameResolver().performSubstitutions("some/path", server.getName());
assertEquals("some/path", ret);
- ret = new ConfigNameResolver().performSubstitutions("some/path/${jboss_as7_config_file}" , server.getName());
+ ret = new ConfigNameResolver().performSubstitutions("some/path/${jboss_config_file}" , server.getName());
assertEquals("some/path/standalone.xml", ret);
IRuntimeWorkingCopy rtwc = rt.createWorkingCopy();
LocalJBoss7ServerRuntime rtwc7 = (LocalJBoss7ServerRuntime)rtwc.loadAdapter(LocalJBoss7ServerRuntime.class, new NullProgressMonitor());
rtwc7.setConfigurationFile("someFile.xml");
rtwc.save(false, new NullProgressMonitor());
- ret = new ConfigNameResolver().performSubstitutions("some/path/${jboss_as7_config_file}" , server.getName());
+ ret = new ConfigNameResolver().performSubstitutions("some/path/${jboss_config_file}" , server.getName());
assertEquals("some/path/someFile.xml", ret);
}
13 years, 8 months
JBoss Tools SVN: r40104 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2012-04-09 20:22:47 -0400 (Mon, 09 Apr 2012)
New Revision: 40104
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java
Log:
https://issues.jboss.org/browse/JBIDE-11501 JBoss AS 7.1. "Browse ..." button for configuration file looks ugly under Windows 7
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java 2012-04-10 00:10:21 UTC (rev 40103)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/wizards/JBoss7RuntimeWizardFragment.java 2012-04-10 00:22:47 UTC (rev 40104)
@@ -76,7 +76,7 @@
configDirLabel.setText("Configuration file: ");
configDirText = new Text(configComposite, SWT.BORDER);
- configBrowse = new Button(configComposite, SWT.DEFAULT);
+ configBrowse = new Button(configComposite, SWT.NONE);
configBrowse.setText(Messages.browse);
// Organize them
13 years, 8 months
JBoss Tools SVN: r40103 - in trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el: internal/core/parser/token and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2012-04-09 20:10:21 -0400 (Mon, 09 Apr 2012)
New Revision: 40103
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java
Log:
JBIDE-11497
https://issues.jboss.org/browse/JBIDE-11497.
EL parser should report unclosed quote.
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java 2012-04-09 22:09:05 UTC (rev 40102)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/ElCoreMessages.java 2012-04-10 00:10:21 UTC (rev 40103)
@@ -19,6 +19,7 @@
public static String OperationRule_ExpectingRParen;
public static String OperationTokenDescription_Name;
public static String PrimitiveValueTokenDescription_ArgMustResolveToIntegerOrString;
+ public static String StringTokenDescription_StringIsNotClosed;
public static String PrimitiveValueTokenDescription_Name;
public static String StringTokenDescription_Name;
public static String WhiteSpaceTokenDescription_Name;
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2012-04-09 22:09:05 UTC (rev 40102)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/messages.properties 2012-04-10 00:10:21 UTC (rev 40103)
@@ -13,6 +13,7 @@
OperationRule_ExpectingRParen=Expecting ')'
OperationTokenDescription_Name=Operator
PrimitiveValueTokenDescription_ArgMustResolveToIntegerOrString=Argument must resolve to integer or string.
+StringTokenDescription_StringIsNotClosed=String is not closed.
PrimitiveValueTokenDescription_Name=Primitive
StringTokenDescription_Name=String
WhiteSpaceTokenDescription_Name=Whitespace
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java 2012-04-09 22:09:05 UTC (rev 40102)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java 2012-04-10 00:10:21 UTC (rev 40103)
@@ -12,7 +12,9 @@
import org.jboss.tools.common.el.core.ElCoreMessages;
import org.jboss.tools.common.el.core.parser.ITokenDescription;
+import org.jboss.tools.common.el.core.parser.SyntaxError;
import org.jboss.tools.common.el.core.parser.Tokenizer;
+import org.jboss.tools.common.el.internal.core.parser.rule.BasicStates;
/**
*
@@ -53,6 +55,11 @@
}
}
tokenizer.addToken(getType(), offset, i);
+ if(ch == '\0') {
+ SyntaxError error = new SyntaxError(offset, BasicStates.STATE_EXPECTING_ARG);
+ error.setProblem(ElCoreMessages.StringTokenDescription_StringIsNotClosed);
+ tokenizer.addSyntaxError(error);
+ }
return i > offset;
}
13 years, 8 months
JBoss Tools SVN: r40102 - in trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui: src/org/jboss/tools/modeshape/jcr/ui/cnd and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: elvisisking
Date: 2012-04-09 18:09:05 -0400 (Mon, 09 Apr 2012)
New Revision: 40102
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Removed unneeded runtime exporting of UI packages. CND notation preference changes were changing the file in the editor when they were changed. Now the editor must be saved to get the new setting.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF 2012-04-09 21:36:05 UTC (rev 40101)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF 2012-04-09 22:09:05 UTC (rev 40102)
@@ -17,6 +17,3 @@
org.eclipse.ui.ide,
org.jboss.tools.modeshape.client;bundle-version="1.1.0"
Bundle-Activator: org.jboss.tools.modeshape.jcr.ui.Activator
-Export-Package: org.jboss.tools.modeshape.jcr.ui,
- org.jboss.tools.modeshape.jcr.ui.cnd,
- org.jboss.tools.modeshape.jcr.ui.preferences
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-04-09 21:36:05 UTC (rev 40101)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-04-09 22:09:05 UTC (rev 40102)
@@ -28,8 +28,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IMessageProvider;
@@ -75,8 +73,8 @@
/**
*
*/
-public final class CndEditor extends SharedHeaderFormEditor implements IPersistableEditor, IPreferenceChangeListener,
- IResourceChangeListener, PropertyChangeListener {
+public final class CndEditor extends SharedHeaderFormEditor implements IPersistableEditor, IResourceChangeListener,
+ PropertyChangeListener {
private CompactNodeTypeDefinition cndBeingEdited;
@@ -99,7 +97,6 @@
*/
public CndEditor() {
this.formsPage = new CndFormsEditorPage(this);
- JcrPreferenceStore.addPreferenceChangeListener(this);
}
/**
@@ -271,7 +268,6 @@
@Override
public void dispose() {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
- JcrPreferenceStore.removePreferenceChangeListener(this);
super.dispose();
}
@@ -511,20 +507,6 @@
/**
* {@inheritDoc}
*
- * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
- */
- @Override
- public void preferenceChange( final PreferenceChangeEvent event ) {
- try {
- saveDocument(getEditorInput(), getProgressMonitor());
- } catch (final Exception e) {
- Activator.getSharedInstance().getLog().log(new Status(IStatus.ERROR, JcrUiConstants.PLUGIN_ID, null, e));
- }
- }
-
- /**
- * {@inheritDoc}
- *
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
13 years, 8 months
JBoss Tools SVN: r40101 - in trunk/modeshape: plugins/org.jboss.tools.modeshape.jcr/.settings and 13 other directories.
by jbosstools-commits@lists.jboss.org
Author: elvisisking
Date: 2012-04-09 17:36:05 -0400 (Mon, 09 Apr 2012)
New Revision: 40101
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/plugin.xml
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Activator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java
Removed:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/bundle.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.pde.core.prefs
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/LocalName.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/QualifiedName.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Abstract.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Autocreated.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultType.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultValues.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ListAttributeState.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeTypeAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/PropertyAttributes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/RequiredTypes.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ValueConstraints.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/LocalNameTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultTypeTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValuesTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraintsTest.java
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Added a preference page where you can change the CND notation type. CNDs saved after the preference change will use the new setting. Business objects now use the preference settings when generating their CND notation. Empty node type names now can be parsed. Child node default type is now a combo of available node types. QualifiedNameEditor now allows residual names.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.pde.core.prefs
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.pde.core.prefs 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/.settings/org.eclipse.pde.core.prefs 2012-04-09 21:36:05 UTC (rev 40101)
@@ -1,4 +1,4 @@
-#Fri Feb 03 08:28:48 EST 2012
+#Wed Apr 04 13:41:44 CDT 2012
eclipse.preferences.version=1
-pluginProject.extensions=false
+pluginProject.extensions=true
resolve.requirebundle=false
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/META-INF/MANIFEST.MF 2012-04-09 21:36:05 UTC (rev 40101)
@@ -12,4 +12,6 @@
org.eclipse.core.runtime
Export-Package: org.jboss.tools.modeshape.jcr,
org.jboss.tools.modeshape.jcr.attributes,
- org.jboss.tools.modeshape.jcr.cnd
+ org.jboss.tools.modeshape.jcr.cnd,
+ org.jboss.tools.modeshape.jcr.preference
+Bundle-Activator: org.jboss.tools.modeshape.jcr.Activator
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.properties 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/build.properties 2012-04-09 21:36:05 UTC (rev 40101)
@@ -12,7 +12,8 @@
bin.includes = META-INF/,\
.,\
OSGI-INF/,\
- cnd/jsr_283_builtins.cnd
+ cnd/,\
+ plugin.xml
jars.compile.order = .
source.. = src/
output.. = bin/
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/plugin.xml
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/plugin.xml (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/plugin.xml 2012-04-09 21:36:05 UTC (rev 40101)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <!-- Initialize preference to default values. -->
+ <extension
+ id="org.jboss.tools.modeshape.jcr.preferences"
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore">
+ </initializer>
+ </extension>
+
+</plugin>
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/plugin.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Activator.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Activator.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Activator.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.jcr;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ *
+ */
+public class Activator extends Plugin {
+
+ /**
+ * The plug-in bundle's symbolic name.
+ */
+ public static final String PLUGIN_ID = Utils.class.getPackage().getName();
+
+ private static Activator _instance;
+
+ /**
+ * @return the shared instance
+ */
+ public static Activator get() {
+ return _instance;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start( BundleContext context ) throws Exception {
+ super.start(context);
+ _instance = this;
+ }
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Activator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ChildNodeDefinition.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -21,8 +21,8 @@
import org.jboss.tools.modeshape.jcr.attributes.NodeAttributes;
import org.jboss.tools.modeshape.jcr.attributes.OnParentVersion;
import org.jboss.tools.modeshape.jcr.attributes.RequiredTypes;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* The <code>ChildNodeDefinition</code> class represents node type child node definition.
@@ -223,27 +223,8 @@
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public int compareTo( final Object object ) {
- final ChildNodeDefinition that = (ChildNodeDefinition)object;
- final String thisName = getName();
- final String thatName = that.getName();
-
- if (Utils.isEmpty(thisName)) {
- if (Utils.isEmpty(thatName)) {
- return 0;
- }
-
- // thatName is not empty
- return 1;
- }
-
- // thisName is not empty
- if (thatName == null) {
- return 1;
- }
-
- // thisName and thatName are not empty
- return thisName.compareTo(thatName);
+ public int compareTo( final ItemDefinition itemDefinition ) {
+ return getQualifiedName().compareTo(itemDefinition.getQualifiedName());
}
/**
@@ -352,10 +333,6 @@
return this.defaultType;
}
- private String getFormatDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_PROPERTY_DELIMITER);
- }
-
/**
* {@inheritDoc}
*
@@ -381,10 +358,6 @@
return this.attributes.getOnParentVersion().asJcrValue();
}
- private String getPrefixEndDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_DEFINITION_END_PREFIX_DELIMITER);
- }
-
/**
* {@inheritDoc}
*
@@ -718,12 +691,14 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
+ JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+
final StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
- builder.append(getPrefixEndDelimiter());
+ builder.append((NotationType.LONG == notationType) ? Utils.SPACE_STRING : Utils.EMPTY_STRING);
- final String DELIM = getFormatDelimiter();
-
+ final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.CHILD_NODE_PROPERTY_DELIMITER);
builder.append(this.name.toCndNotation(notationType));
+
Utils.build(builder, true, DELIM, this.requiredTypes.toCndNotation(notationType));
Utils.build(builder, true, DELIM, this.defaultType.toCndNotation(notationType));
Utils.build(builder, true, DELIM, this.attributes.toCndNotation(notationType));
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/ItemDefinition.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -12,7 +12,7 @@
/**
* An interface for property definitions and child node definitions.
*/
-public interface ItemDefinition extends CndElement, Comparable {
+public interface ItemDefinition extends CndElement, Comparable<ItemDefinition> {
/**
* Defines a residual set of child items.
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/LocalName.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/LocalName.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/LocalName.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -8,28 +8,32 @@
package org.jboss.tools.modeshape.jcr;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
*
*/
public class LocalName implements CndElement, Comparable<LocalName> {
- private Mode mode = Mode.UNQOUTED;
-
private String value;
/**
- * Constructs an empty name in unquoated mode.
+ * Constructs an empty name.
*/
public LocalName() {
- this.mode = Mode.UNQOUTED;
+ this(Utils.EMPTY_STRING);
}
/**
* @param initialValue the initial name value (can be <code>null</code> or empty)
*/
public LocalName( final String initialValue ) {
- this.value = initialValue;
+ if (initialValue == null) {
+ this.value = Utils.EMPTY_STRING;
+ } else {
+ this.value = initialValue;
+ }
}
/**
@@ -39,7 +43,7 @@
*/
@Override
public int compareTo( final LocalName that ) {
- if (equals(that) || Utils.equivalent(get(), that.get())) {
+ if (equals(that) || Utils.equals(get(), that.get())) {
return 0;
}
@@ -92,27 +96,6 @@
}
/**
- * @return <code>true</code> if double quotes should be used in CND notation
- */
- public boolean isDoubleQuoted() {
- return (this.mode == Mode.DOUBLE_QUOTED);
- }
-
- /**
- * @return <code>true</code> if single quotes should be used in CND notation
- */
- public boolean isSingleQuoted() {
- return (this.mode == Mode.SINGLE_QUOTED);
- }
-
- /**
- * @return <code>true</code> if no quotes should be used in CND notation
- */
- public boolean isUnquoted() {
- return (this.mode == Mode.UNQOUTED);
- }
-
- /**
* @param newValue the new name value (can be <code>null</code> or empty)
* @return <code>true</code> if the name was changed
*/
@@ -130,21 +113,6 @@
}
/**
- * @param newMode the new mode (cannot be <code>null</code>)
- * @return <code>true</code> if the mode was changed
- */
- public boolean setMode( final Mode newMode ) {
- Utils.verifyIsNotNull(newMode, "newMode"); //$NON-NLS-1$
-
- if (this.mode != newMode) {
- this.mode = newMode;
- return true;
- }
-
- return false;
- }
-
- /**
* {@inheritDoc}
*
* @see org.jboss.tools.modeshape.jcr.cnd.CndElement#toCndNotation(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
@@ -152,15 +120,20 @@
@Override
public String toCndNotation( final NotationType notationType ) {
final StringBuilder builder = new StringBuilder();
- Mode notationMode = this.mode;
- if (!Utils.isEmpty(this.value) && this.value.contains(Utils.SPACE_STRING) && (this.mode == Mode.UNQOUTED)) {
- notationMode = Mode.SINGLE_QUOTED;
+ if (Utils.isEmpty(this.value)) {
+ return Utils.EMPTY_STRING;
}
- builder.append(notationMode);
+ String quoteString = JcrPreferenceStore.get().get(JcrPreferenceConstants.CndPreference.QUOTE_CHAR);
+
+ if (Utils.isEmpty(quoteString) && !Utils.isEmpty(this.value) && this.value.contains(Utils.SPACE_STRING)) {
+ quoteString = Utils.SINGLE_QUOTE;
+ }
+
+ builder.append(quoteString);
builder.append((this.value == null) ? Utils.EMPTY_STRING : this.value);
- builder.append(notationMode);
+ builder.append(quoteString);
return builder.toString();
}
@@ -178,41 +151,4 @@
return this.value;
}
-
- /**
- * The quotation preference when using the name in CND notation.
- */
- public enum Mode {
-
- /**
- * The name is surrounded by double quotes in the CND notation.
- */
- DOUBLE_QUOTED("\""), //$NON-NLS-1$
-
- /**
- * The name is surrounded by single quotes in the CND notation.
- */
- SINGLE_QUOTED("'"), //$NON-NLS-1$
-
- /**
- * The name is not surrounded by quotes in the CND notation.
- */
- UNQOUTED(Utils.EMPTY_STRING);
-
- private final String delim;
-
- private Mode( final String delim ) {
- this.delim = delim;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see java.lang.Enum#toString()
- */
- @Override
- public String toString() {
- return this.delim;
- }
- }
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -17,7 +17,7 @@
/**
* The name for the child definition's name property.
*/
- public static String childDefinitionName;
+ public static String childNodeDefinitionName;
/**
* A message indicating the CND has no namespace or node type definitions.
@@ -31,6 +31,12 @@
public static String defaultTypeExistsButMarkedAsVariant;
/**
+ * A message indicating a child node definition has a default type but that it does not match a required type. Two parameters, the
+ * child node definition name and the default type name, are required.
+ */
+ public static String defaultTypeDoesNotMatchRequiredType;
+
+ /**
* The name for the child definition's default type property.
*/
public static String defaultTypeName;
@@ -211,11 +217,23 @@
public static String invalidQueryOperator;
/**
+ * A message indicating the prefix is invalid for a built-in namespace mapping URI. Two parameters, the invalid prefix and the
+ * built-in namespace mapping URI, are required.
+ */
+ public static String invalidPrefixForBuiltInNamespaceUri;
+
+ /**
* A message indicating an invalid URI was found. One parameter, the invalid URI, is required.
*/
public static String invalidUri;
/**
+ * A message indicating the URI is invalid for a built-in namespace mapping prefix. Two parameters, the invalid URI and the
+ * built-in namespace mapping prefix, are required.
+ */
+ public static String invalidUriForBuiltInNamespacePrefix;
+
+ /**
* An error message indicating that the JSR built-ins CND could not be found in the workspace. One parameter, the path of the
* CND file, is required.
*/
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NamespaceMapping.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -11,6 +11,8 @@
import java.beans.PropertyChangeListener;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
/**
@@ -171,7 +173,7 @@
try {
((PropertyChangeListener)listener).propertyChange(event);
} catch (final Exception e) {
- // TODO log this
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
this.listeners.remove(listener);
}
}
@@ -225,11 +227,11 @@
public String toCndNotation( final NotationType notationType ) {
final StringBuilder builder = new StringBuilder();
builder.append(NOTATION_PREFIX);
- builder.append(this.prefix.get());
+ builder.append(this.prefix.toCndNotation(notationType));
builder.append(NOTATION_DELIMITER);
- builder.append(LocalName.Mode.SINGLE_QUOTED); // the CND parser seems to require URI surrounded by quotes
+ builder.append(Utils.SINGLE_QUOTE);
builder.append(this.uri.get());
- builder.append(LocalName.Mode.SINGLE_QUOTED);
+ builder.append(Utils.SINGLE_QUOTE);
builder.append(NOTATION_SUFFIX);
return builder.toString();
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/NodeTypeDefinition.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -25,8 +25,8 @@
import org.jboss.tools.modeshape.jcr.attributes.NodeTypeAttributes;
import org.jboss.tools.modeshape.jcr.attributes.SuperTypes;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* Represents a CND node type definition.
@@ -827,21 +827,21 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
final StringBuilder builder = new StringBuilder();
{ // name
builder.append(NAME_NOTATION_PREFIX)
.append(this.name.toCndNotation(notationType))
.append(NAME_NOTATION_SUFFIX)
- .append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER));
+ .append(prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER));
}
{ // super types
final String notation = this.superTypes.toCndNotation(notationType);
if (!Utils.isEmpty(notation)) {
- builder.append(notation)
- .append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.SUPER_TYPES_END_DELIMITER));
+ builder.append(notation).append(prefStore.get(JcrPreferenceConstants.CndPreference.SUPER_TYPES_END_DELIMITER));
}
}
@@ -852,15 +852,15 @@
builder.append(notation);
}
- builder.append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER));
+ builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER));
}
{ // elements
final List<CndElement> elements = getElements();
if (!Utils.isEmpty(elements)) {
- final String elementStartDelimiter = CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ELEMENTS_START_DELIMITER);
- final String elementDelimiter = CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ELEMENT_DELIMITER);
+ final String elementStartDelimiter = prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENTS_START_DELIMITER);
+ final String elementDelimiter = prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENT_DELIMITER);
for (final CndElement element : elements) {
builder.append(elementStartDelimiter);
@@ -868,7 +868,7 @@
builder.append(elementDelimiter);
}
- builder.append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ELEMENTS_END_DELIMITER));
+ builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.ELEMENTS_END_DELIMITER));
}
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/PropertyDefinition.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -26,8 +26,8 @@
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators;
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
import org.jboss.tools.modeshape.jcr.attributes.ValueConstraints;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* The <code>PropertyDefinition</code> class represents node type property definition.
@@ -298,27 +298,8 @@
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
- public int compareTo( final Object object ) {
- final PropertyDefinition that = (PropertyDefinition)object;
- final String thisName = getName();
- final String thatName = that.getName();
-
- if (Utils.isEmpty(thisName)) {
- if (Utils.isEmpty(thatName)) {
- return 0;
- }
-
- // thatName is not empty
- return 1;
- }
-
- // thisName is not empty
- if (thatName == null) {
- return 1;
- }
-
- // thisName and thatName are not empty
- return thisName.compareTo(thatName);
+ public int compareTo( final ItemDefinition itemDefinition ) {
+ return getQualifiedName().compareTo(itemDefinition.getQualifiedName());
}
/**
@@ -423,10 +404,6 @@
return this.defaultValues.getSupportedItems();
}
- private String getDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
- }
-
/**
* {@inheritDoc}
*
@@ -452,10 +429,6 @@
return this.attributes.getOnParentVersion().asJcrValue();
}
- private String getPrefixEndDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_END_PREFIX_DELIMITER);
- }
-
/**
* {@inheritDoc}
*
@@ -943,12 +916,14 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+
final StringBuilder builder = new StringBuilder(NOTATION_PREFIX);
- builder.append(getPrefixEndDelimiter());
+ builder.append((NotationType.LONG == notationType) ? Utils.SPACE_STRING : Utils.EMPTY_STRING);
- final String DELIM = getDelimiter();
-
+ final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
builder.append(this.name.toCndNotation(notationType));
+
Utils.build(builder, true, DELIM, this.type.toCndNotation(notationType));
Utils.build(builder, true, DELIM, this.defaultValues.toCndNotation(notationType));
Utils.build(builder, true, DELIM, this.attributes.toCndNotation(notationType));
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/QualifiedName.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/QualifiedName.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/QualifiedName.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -7,7 +7,6 @@
*/
package org.jboss.tools.modeshape.jcr;
-import org.jboss.tools.modeshape.jcr.LocalName.Mode;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
/**
@@ -30,8 +29,8 @@
* @return the qualified name (never <code>null</code>)
*/
public static QualifiedName parse( final String qualifiedName ) {
- String qualifier = null;
- String name = null;
+ String qualifier = Utils.EMPTY_STRING;
+ String name = Utils.EMPTY_STRING;
if (!Utils.isEmpty(qualifiedName)) {
final int index = qualifiedName.indexOf(DELIM_STRING);
@@ -51,11 +50,6 @@
}
/**
- * The quotation mode for the CND notation.
- */
- private Mode mode = Mode.UNQOUTED;
-
- /**
* The part of the name that comes after the delimiter (never <code>null</code>).
*/
private final LocalName name;
@@ -220,21 +214,6 @@
}
/**
- * @param newMode the new mode (cannot be <code>null</code>)
- * @return <code>true</code> if the mode was changed
- */
- public boolean setMode( final Mode newMode ) {
- Utils.verifyIsNotNull(newMode, "newMode"); //$NON-NLS-1$
-
- if (this.mode != newMode) {
- this.mode = newMode;
- return true;
- }
-
- return false;
- }
-
- /**
* @param newQualifier the proposed new qualifier (can be <code>null</code> or empty)
* @return <code>true</code> if the qualifier part was changed
*/
@@ -257,19 +236,18 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- final String unqualifiedName = get();
-
- if (Utils.isEmpty(unqualifiedName)) {
- return Utils.EMPTY_STRING;
+ StringBuilder builder = new StringBuilder();
+
+ if (!Utils.isEmpty(this.qualifier.get())) {
+ builder.append(this.qualifier.toCndNotation(notationType));
+ builder.append(DELIM);
}
- Mode notationMode = this.mode;
-
- if ((this.mode == Mode.UNQOUTED) && unqualifiedName.contains(Utils.SPACE_STRING)) {
- notationMode = Mode.SINGLE_QUOTED;
+ if (!Utils.isEmpty(this.name.get())) {
+ builder.append(this.name.toCndNotation(notationType));
}
- return (notationMode + unqualifiedName + notationMode);
+ return builder.toString();
}
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Utils.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -20,9 +20,10 @@
public final class Utils {
/**
- * The plug-in bundle's symbolic name.
+ * A double quote character string.
*/
- public static final String PLUGIN_ID = Utils.class.getPackage().getName();
+ public static final String DOUBLE_QUOTE = "\""; //$NON-NLS-1$
+
/**
* And empty object array.
*/
@@ -39,6 +40,11 @@
public static final String[] EMPTY_STRING_ARRAY = new String[0];
/**
+ * A single quote character string.
+ */
+ public static final String SINGLE_QUOTE = "'"; //$NON-NLS-1$
+
+ /**
* A string with one space character.
*/
public static final String SPACE_STRING = " "; //$NON-NLS-1$
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/WorkspaceRegistry.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -17,7 +17,6 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.modeshape.jcr.cnd.CndImporter;
-import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
import org.osgi.framework.Bundle;
@@ -56,7 +55,7 @@
File builtInsCndFile = null;
if (Platform.isRunning()) {
- Bundle bundle = Platform.getBundle(Utils.PLUGIN_ID);
+ Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
URL url = bundle.getEntry(BUILT_INS_CND_FILE_NAME);
if (url == null) {
@@ -91,14 +90,11 @@
// register namespace mappings
for (final NamespaceMapping namespace : jsrBuiltIns.getNamespaceMappings()) {
- assert !CndValidator.validateNamespaceMapping(namespace).isError() : "Invalid namespace " + namespace; //$NON-NLS-1$
this.namespaces.add(namespace);
}
// register node type definitions
for (final NodeTypeDefinition nodeType : jsrBuiltIns.getNodeTypeDefinitions()) {
- assert !CndValidator.validateNodeTypeDefinition(nodeType, getPrefixes(), null, true).isError() : "Invalid node type definition " //$NON-NLS-1$
- + nodeType.getName();
this.nodeTypes.add(nodeType);
}
}
@@ -264,4 +260,32 @@
return uris;
}
+
+ /**
+ * @param namespaceMapping the namespace mapping being checked (cannot be <code>null</code>)
+ * @return <code>true</code> if a built-in namespace mapping
+ */
+ public boolean isBuiltIn(NamespaceMapping namespaceMapping) {
+ Utils.verifyIsNotNull(namespaceMapping, "namespaceMapping"); //$NON-NLS-1$
+ NamespaceMapping builtIn = getNamespaceMapping(namespaceMapping.getPrefix());
+ return ((builtIn != null) && builtIn.equals(namespaceMapping));
+ }
+
+ /**
+ * @param prefix the prefix being checked (cannot be <code>null</code> or empty)
+ * @return <code>true</code> if the prefix matches one of a built-in namespace mapping
+ */
+ public boolean isBuiltInNamespacePrefix(String prefix) {
+ Utils.verifyIsNotNull(prefix, "prefix"); //$NON-NLS-1$
+ return (getUri(prefix) != null);
+ }
+
+ /**
+ * @param uri the URI being checked (cannot be <code>null</code> or empty)
+ * @return <code>true</code> if the URI matches one of a built-in namespace mapping
+ */
+ public boolean isBuiltInNamespaceUri(String uri) {
+ Utils.verifyIsNotNull(uri, "uri"); //$NON-NLS-1$
+ return (getPrefix(uri) != null);
+ }
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Abstract.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Abstract.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Abstract.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -7,7 +7,6 @@
*/
package org.jboss.tools.modeshape.jcr.attributes;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
/**
* The abstract attribute used by node type definitions.
@@ -26,7 +25,7 @@
*/
@Override
protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
+ return NOTATION[NotationType.COMPACT_INDEX];
}
/**
@@ -36,7 +35,7 @@
*/
@Override
protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
+ return NOTATION[NotationType.COMPRESSED_INDEX];
}
/**
@@ -46,7 +45,7 @@
*/
@Override
protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
+ return NOTATION[NotationType.LONG_INDEX];
}
}
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Autocreated.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Autocreated.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/Autocreated.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -7,8 +7,6 @@
*/
package org.jboss.tools.modeshape.jcr.attributes;
-import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-
/**
* The autocreated attribute used by property definitions and child node definitions. When set, the property is automatically
* created when the parent node is created. It mandates that a default value is set.
@@ -27,7 +25,7 @@
*/
@Override
protected String getCompactCndNotation() {
- return NOTATION[CndElement.NotationType.COMPACT_INDEX];
+ return NOTATION[NotationType.COMPACT_INDEX];
}
/**
@@ -37,7 +35,7 @@
*/
@Override
protected String getCompressedCndNotation() {
- return NOTATION[CndElement.NotationType.COMPRESSED_INDEX];
+ return NOTATION[NotationType.COMPRESSED_INDEX];
}
/**
@@ -47,7 +45,7 @@
*/
@Override
protected String getLongCndNotation() {
- return NOTATION[CndElement.NotationType.LONG_INDEX];
+ return NOTATION[NotationType.LONG_INDEX];
}
}
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultType.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultType.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultType.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -9,8 +9,6 @@
import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
* The child node definition's default type property.
@@ -51,7 +49,7 @@
*/
@Override
protected String getCompactCndNotation() {
- return getLongCndNotation();
+ return getNotation(NotationType.COMPACT);
}
/**
@@ -61,7 +59,7 @@
*/
@Override
protected String getCompressedCndNotation() {
- return getLongCndNotation();
+ return getNotation(NotationType.COMPRESSED);
}
/**
@@ -92,8 +90,12 @@
*/
@Override
protected String getLongCndNotation() {
+ return getNotation(NotationType.LONG);
+ }
+
+ private String getNotation( final NotationType notationType ) {
if (isVariant()) {
- return getPrefix();
+ return getPrefix(notationType);
}
final String defaultType = getDefaultTypeName();
@@ -102,17 +104,12 @@
return Utils.EMPTY_STRING;
}
- return getPrefix() + defaultType;
+ return getPrefix(notationType) + defaultType;
}
- private String getPrefix() {
- final String delim = CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER);
-
- if (Utils.isEmpty(delim)) {
- return NOTATION;
- }
-
- return (NOTATION + delim);
+ private String getPrefix( final NotationType notationType ) {
+ final String delim = ((NotationType.LONG == notationType) ? Utils.SPACE_STRING : Utils.EMPTY_STRING);
+ return (Utils.isEmpty(delim) ? NOTATION : (NOTATION + delim));
}
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultValues.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultValues.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/DefaultValues.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -10,8 +10,6 @@
import java.util.Collection;
import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
*
@@ -55,11 +53,11 @@
/**
* {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#getQuoteCharacter()
+ *
+ * @see org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#getItemQuoteCharacter()
*/
@Override
- protected String getQuoteCharacter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
+ protected String getItemQuoteCharacter() {
+ return Utils.SINGLE_QUOTE;
}
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ListAttributeState.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ListAttributeState.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ListAttributeState.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -14,8 +14,8 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* @param <E> the class of the list items
@@ -23,6 +23,17 @@
public abstract class ListAttributeState<E extends Comparable> extends AttributeState {
/**
+ * The CND notation for each notation type.
+ */
+ public static final String[] ITEM_DELIM_NOTATION = new String[] { ", ", ",", "," }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ /**
+ * The CND notation for each notation type.
+ */
+ public static final String[] PREFIX_END_DELIM_NOTATION = new String[] { Utils.SPACE_STRING, Utils.EMPTY_STRING,
+ Utils.EMPTY_STRING };
+
+ /**
* A list of supported items (can be <code>null</code>).
*/
private List<E> supported;
@@ -150,17 +161,11 @@
* @return the quote character (empty, single, or double) surrounding each item of the list (cannot be <code>null</code>)
*/
protected String getItemQuoteCharacter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+ return prefStore.get(JcrPreferenceConstants.CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
}
/**
- * @return the delimiter used after the list prefix (never <code>null</code> but can be empty)
- */
- protected String getListPrefixEndDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
- }
-
- /**
* {@inheritDoc}
*
* @see org.jboss.tools.modeshape.jcr.attributes.AttributeState#getLongCndNotation()
@@ -171,10 +176,19 @@
}
/**
- * @return the quote character (empty, single, double) surrounding the elements of the list (cannot be <code>null</code>)
+ * @param notationType the notation type (cannot be <code>null</code>)
+ * @return the delimiter after the prefix (never <code>null</code> but can be empty)
*/
- protected String getQuoteCharacter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
+ protected String getPrefixEndDelimiter(NotationType notationType) {
+ if (NotationType.LONG == notationType) {
+ return PREFIX_END_DELIM_NOTATION[NotationType.LONG_INDEX];
+ }
+
+ if (NotationType.COMPRESSED == notationType) {
+ return PREFIX_END_DELIM_NOTATION[NotationType.COMPRESSED_INDEX];
+ }
+
+ return PREFIX_END_DELIM_NOTATION[NotationType.COMPACT_INDEX];
}
/**
@@ -259,6 +273,16 @@
return Utils.EMPTY_STRING;
}
+ String delimiter = null;
+
+ if (NotationType.LONG == notationType) {
+ delimiter = ITEM_DELIM_NOTATION[NotationType.LONG_INDEX];
+ } else if (NotationType.COMPRESSED == notationType) {
+ delimiter = ITEM_DELIM_NOTATION[NotationType.COMPRESSED_INDEX];
+ } else {
+ delimiter = ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX];
+ }
+
final String itemQuote = getItemQuoteCharacter();
final boolean useQuote = !Utils.isEmpty(itemQuote);
final StringBuilder builder = new StringBuilder();
@@ -281,7 +305,7 @@
}
if (itr.hasNext()) {
- builder.append(CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER));
+ builder.append(delimiter);
}
}
@@ -311,19 +335,13 @@
builder.append(getCndNotationPrefix(notationType));
}
- final String delim = getListPrefixEndDelimiter();
+ builder.append(getPrefixEndDelimiter(notationType));
- if (!Utils.isEmpty(delim)) {
- builder.append(delim);
- }
-
if (isVariant()) {
builder.append(AttributeState.VARIANT_CHAR);
} else {
// add the delimited list
- builder.append(getQuoteCharacter());
builder.append(supportedItemsCndNotation(notationType));
- builder.append(getQuoteCharacter());
}
if (!Utils.isEmpty(getCndNotationSuffix(notationType))) {
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeAttributes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeAttributes.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeAttributes.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -10,8 +10,8 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* The child node definition attribute collection.
@@ -67,10 +67,6 @@
return this.autocreated;
}
- private String getFormatDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.CHILD_NODE_ATTRIBUTES_DELIMITER);
- }
-
/**
* @return the mandatory attribute (never <code>null</code>)
*/
@@ -163,7 +159,8 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- final String DELIM = getFormatDelimiter();
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+ final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.CHILD_NODE_ATTRIBUTES_DELIMITER);
final StringBuilder builder = new StringBuilder();
boolean addDelim = Utils.build(builder, false, DELIM, this.autocreated.toCndNotation(notationType));
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeTypeAttributes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeTypeAttributes.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/NodeTypeAttributes.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -9,8 +9,8 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* Property attributes of a node type definitions.
@@ -196,7 +196,8 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- final String DELIM = CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER);
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+ final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER);
final StringBuilder builder = new StringBuilder();
boolean addDelim = Utils.build(builder, false, DELIM, this.orderable.toCndNotation(notationType));
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/PropertyAttributes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/PropertyAttributes.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/PropertyAttributes.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -9,8 +9,8 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.CndElement;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* Property attributes of a property definitions.
@@ -130,10 +130,6 @@
return this.autocreated;
}
- private String getFormatDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
- }
-
/**
* @return the mandatory attribute (never <code>null</code>)
*/
@@ -262,7 +258,8 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
- final String DELIM = getFormatDelimiter();
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+ final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER);
final StringBuilder builder = new StringBuilder();
boolean addDelim = Utils.build(builder, false, DELIM, this.autocreated.toCndNotation(notationType));
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/QueryOperators.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -67,6 +67,36 @@
/**
* {@inheritDoc}
*
+ * @see org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#getCndNotationSuffix(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
+ */
+ @Override
+ protected String getCndNotationSuffix( NotationType notationType ) {
+ return (isVariant() ? Utils.EMPTY_STRING : Utils.SINGLE_QUOTE);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#getItemQuoteCharacter()
+ */
+ @Override
+ protected String getItemQuoteCharacter() {
+ return Utils.EMPTY_STRING;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#getPrefixEndDelimiter(org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType)
+ */
+ @Override
+ protected String getPrefixEndDelimiter( NotationType notationType ) {
+ return (Utils.SPACE_STRING + (isVariant() ? Utils.EMPTY_STRING : Utils.SINGLE_QUOTE));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.lang.Object#hashCode()
*/
@Override
@@ -81,7 +111,7 @@
return super.hashCode();
}
-
+
/**
* @param operator the operator notation of the operator being removed (cannot be <code>null</code> or empty)
* @return <code>true</code> if removed
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/RequiredTypes.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/RequiredTypes.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/RequiredTypes.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -48,16 +48,6 @@
}
/**
- * {@inheritDoc}
- *
- * @see org.jboss.tools.modeshape.jcr.attributes.ListAttributeState#getListPrefixEndDelimiter()
- */
- @Override
- protected String getListPrefixEndDelimiter() {
- return Utils.EMPTY_STRING;
- }
-
- /**
* @return the collection of required types (never <code>null</code>)
*/
public String[] toArray() {
@@ -76,5 +66,4 @@
return result;
}
-
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ValueConstraints.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ValueConstraints.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/attributes/ValueConstraints.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -10,8 +10,6 @@
import java.util.List;
import org.jboss.tools.modeshape.jcr.Utils;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
/**
* The value constraints of a property definition.
@@ -40,7 +38,7 @@
*/
@Override
protected String getItemQuoteCharacter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER);
+ return Utils.SINGLE_QUOTE;
}
/**
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -149,6 +149,9 @@
} else if (tokens.matches(NodeTypeDefinition.NAME_NOTATION_PREFIX, TokenStream.ANY_VALUE,
NodeTypeDefinition.NAME_NOTATION_SUFFIX)) {
parseNodeTypeDefinition(tokens, cnd);
+ } else if (tokens.matches(NodeTypeDefinition.NAME_NOTATION_PREFIX, NodeTypeDefinition.NAME_NOTATION_SUFFIX)) {
+ // empty node type name (no problem recorded here but editor validation will have an error)
+ parseNodeTypeDefinition(tokens, cnd);
} else {
final Position position = tokens.previousPosition();
final Object[] args = new Object[] { tokens.consume(), position.getLine(), position.getColumn() };
@@ -505,6 +508,12 @@
tokens.consume(NodeTypeDefinition.NAME_NOTATION_PREFIX);
final String name = parseName(tokens);
+
+ // if empty name then suffix will be found next
+ if (NodeTypeDefinition.NAME_NOTATION_SUFFIX.equals(name)) {
+ return Utils.EMPTY_STRING; // empty node type name
+ }
+
tokens.consume(NodeTypeDefinition.NAME_NOTATION_SUFFIX);
return name;
}
Deleted: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndNotationPreferences.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -1,231 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- *
- * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
- *
- * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
- */
-package org.jboss.tools.modeshape.jcr.cnd;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.jboss.tools.modeshape.jcr.Utils;
-
-/**
- * Preferences used during constructing CND notation.
- */
-public class CndNotationPreferences {
-
- /**
- * Default preferences.
- */
- public static final CndNotationPreferences DEFAULT_PREFERENCES = new CndNotationPreferences();
-
- /**
- * The preferences (never <code>null</code>).
- */
- private final Map<Preference, String> prefs;
-
- /**
- * Constructs default preferences.
- */
- private CndNotationPreferences() {
- final Map<Preference, String> temp = new HashMap<Preference, String>();
- loadDefaults(temp);
- this.prefs = Collections.unmodifiableMap(temp);
- }
-
- /**
- * @param overrideValues the preferences whose values are being overridden (cannot be <code>null</code>)
- */
- public CndNotationPreferences( final Map<Preference, String> overrideValues ) {
- Utils.verifyIsNotNull(overrideValues, "overrideValues"); //$NON-NLS-1$
-
- final Map<Preference, String> temp = new HashMap<Preference, String>();
- loadDefaults(temp);
-
- if ((overrideValues != null) && !overrideValues.isEmpty()) {
- for (final Entry<Preference, String> entry : overrideValues.entrySet()) {
- temp.put(entry.getKey(), entry.getValue());
- }
- }
-
- this.prefs = Collections.unmodifiableMap(temp);
- }
-
- /**
- * @param pref the preference name whose value is being requested (cannot be <code>null</code>)
- * @return the preference value (never <code>null</code> but can be empty)
- */
- public String get( final Preference pref ) {
- Utils.verifyIsNotNull(pref, "pref"); //$NON-NLS-1$
- return this.prefs.get(pref);
- }
-
- private void loadDefaults( final Map<Preference, String> map ) {
- assert (map != null) : "preference map is null"; //$NON-NLS-1$
-
- map.put(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER, ", "); //$NON-NLS-1$
- map.put(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR, Utils.EMPTY_STRING);
- map.put(Preference.CHILD_NODE_DEFINITION_END_PREFIX_DELIMITER, " "); //$NON-NLS-1$
- map.put(Preference.CHILD_NODE_PROPERTY_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.DEFAULT_VALUES_QUOTE_CHARACTER, "'"); //$NON-NLS-1$
- map.put(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.ATTRIBUTE_LIST_QUOTE_CHAR, Utils.EMPTY_STRING);
- map.put(Preference.ELEMENT_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.ELEMENTS_END_DELIMITER, Utils.EMPTY_STRING);
- map.put(Preference.ELEMENTS_START_DELIMITER, "\t"); //$NON-NLS-1$
- map.put(Preference.NAMESPACE_MAPPING_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.NAMESPACE_MAPPING_SECTION_END_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.CHILD_NODE_ATTRIBUTES_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.NODE_TYPE_DEFINITION_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER, "\n"); //$NON-NLS-1$
- map.put(Preference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.PROPERTY_DEFINITION_END_PREFIX_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.REQUIRED_TYPES_END_PREFIX_DELIMITER, Utils.EMPTY_STRING);
- map.put(Preference.SUPER_TYPES_END_DELIMITER, Utils.SPACE_STRING);
- map.put(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER, "'"); //$NON-NLS-1$
- }
-
- /**
- * All preferences used during CND notation construction.
- */
- public enum Preference {
-
- /**
- * The delimiter between list items.
- */
- ATTRIBUTE_LIST_ELEMENT_DELIMITER,
-
- /**
- * The string version of the quote character (empty string, single quote, or double quote) surrounding each item in
- * attribute lists.
- */
- ATTRIBUTE_LIST_ITEM_QUOTE_CHAR,
-
- /**
- * The delimiter after the prefix to attribute lists.
- */
- ATTRIBUTE_LIST_PREFIX_END_DELIMITER,
-
- /**
- * The quote character (single or double) surrounding attribute lists.
- */
- ATTRIBUTE_LIST_QUOTE_CHAR,
-
- /**
- * The delimiter between child node definition attributes.
- */
- CHILD_NODE_ATTRIBUTES_DELIMITER,
-
- /**
- * The delimiter after the plus sign and before the child node definition name.
- */
- CHILD_NODE_DEFINITION_END_PREFIX_DELIMITER,
-
- /**
- * The delimiter between child node properties.
- */
- CHILD_NODE_PROPERTY_DELIMITER,
-
- /**
- * The delimiter after the equals sign and before the default type.
- */
- DEFAULT_TYPE_END_PREFIX_DELIMITER,
-
- /**
- * The delimiter after the equals sign and before the list of default values.
- */
- DEFAULT_VALUES_END_PREFIX_DELIMITER,
-
- /**
- * The string form of the quotation character used to surround the one or more default values. Value can be either empty,
- * the single quote, or the double quote.
- */
- DEFAULT_VALUES_QUOTE_CHARACTER,
-
- /**
- * The delimiter between CND elements.
- */
- ELEMENT_DELIMITER,
-
- /**
- * The delimiter after the last CND element.
- */
- ELEMENTS_END_DELIMITER,
-
- /**
- * The delimiter before the first CND element.
- */
- ELEMENTS_START_DELIMITER,
-
- /**
- * The delimiter between namespace mappings.
- */
- NAMESPACE_MAPPING_DELIMITER,
-
- /**
- * The delimiter after the last namespace mapping.
- */
- NAMESPACE_MAPPING_SECTION_END_DELIMITER,
-
- /**
- * The delimiter between node type definition attributes.
- */
- NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER,
-
- /**
- * The delimiter after all the node type definition attributes.
- */
- NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER,
-
- /**
- * The delimiter between node type definitions.
- */
- NODE_TYPE_DEFINITION_DELIMITER,
-
- /**
- * The delimiter after the node type definition name.
- */
- NODE_TYPE_DEFINITION_NAME_END_DELIMITER,
-
- /**
- * The delimiter after the last node type definitions.
- */
- NODE_TYPE_DEFINITION_SECTION_END_DELIMITER,
-
- /**
- * The delimiter between property definition attributes.
- */
- PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER,
-
- /**
- * The delimiter after the dash and before the property definition name.
- */
- PROPERTY_DEFINITION_END_PREFIX_DELIMITER,
-
- /**
- * The delimiter after the open paren and before the required types.
- */
- REQUIRED_TYPES_END_PREFIX_DELIMITER,
-
- /**
- * The delimiter after the last super type.
- */
- SUPER_TYPES_END_DELIMITER,
-
- /**
- * The string version of the quote character (empty string, single quote, or double quote) surrounding each item in value
- * constraints list.
- */
- VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER,
- }
-}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -14,7 +14,10 @@
import java.util.Collection;
import java.util.StringTokenizer;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
+import org.jboss.tools.modeshape.jcr.Activator;
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition;
import org.jboss.tools.modeshape.jcr.ItemDefinition;
import org.jboss.tools.modeshape.jcr.Messages;
@@ -25,6 +28,7 @@
import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.ValidationStatus;
+import org.jboss.tools.modeshape.jcr.WorkspaceRegistry;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
import org.jboss.tools.modeshape.jcr.attributes.PropertyType;
import org.jboss.tools.modeshape.jcr.attributes.QueryOperators.QueryOperator;
@@ -339,19 +343,39 @@
Utils.verifyIsNotNull(childNodeDefinition, "childNodeDefinition"); //$NON-NLS-1$
Utils.verifyIsNotNull(status, "status"); //$NON-NLS-1$
- final String defaultType = childNodeDefinition.getDefaultPrimaryTypeName();
+ String childNodeName = childNodeDefinition.getName();
+ if (Utils.isEmpty(childNodeName)) {
+ childNodeName = Messages.missingName;
+ }
+
+ final String defaultTypeName = childNodeDefinition.getDefaultPrimaryTypeName();
+
if (childNodeDefinition.getState(ChildNodeDefinition.PropertyName.DEFAULT_TYPE) == Value.IS) {
- // ERROR - Invalid default type name
+ // ERROR - Invalid default type name (cannot be empty)
validateQualifiedName(childNodeDefinition.getDefaultType().getDefaultType(), Messages.defaultTypeName,
validNamespacePrefixes, null, status);
- } else if (!Utils.isEmpty(defaultType)) {
- String childNodeName = childNodeDefinition.getName();
- if (Utils.isEmpty(childNodeName)) {
- childNodeName = Messages.missingName;
+ // ERROR - Must be equal to a required type if not a residual
+ if (!ItemDefinition.RESIDUAL_NAME.equals(childNodeName)) {
+ final String[] requiredTypes = childNodeDefinition.getRequiredPrimaryTypeNames();
+ boolean foundMatch = false;
+
+ if (!Utils.isEmpty(defaultTypeName)) {
+ for (final String requiredType : requiredTypes) {
+ if (defaultTypeName.equals(requiredType)) {
+ foundMatch = true;
+ break;
+ }
+ }
+
+ if (!foundMatch) {
+ status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.defaultTypeDoesNotMatchRequiredType,
+ childNodeName, defaultTypeName)));
+ }
+ }
}
-
+ } else if (!Utils.isEmpty(defaultTypeName)) {
// ERROR - Cannot have explicit default type when default type is marked as a variant
status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.defaultTypeExistsButMarkedAsVariant, childNodeName)));
}
@@ -407,13 +431,13 @@
isValid(defaultValue, propertyDefinition.getType(), Messages.defaultValue, status);
// make sure if NAME type the qualifier is valid
- if (!Utils.isEmpty(validNamespacePrefixes) && propertyDefinition.getType() == PropertyType.NAME) {
- QualifiedName qname = QualifiedName.parse(defaultValue);
- String qualifier = qname.getQualifier();
+ if (!Utils.isEmpty(validNamespacePrefixes) && (propertyDefinition.getType() == PropertyType.NAME)) {
+ final QualifiedName qname = QualifiedName.parse(defaultValue);
+ final String qualifier = qname.getQualifier();
boolean valid = false;
if (!Utils.isEmpty(qualifier)) {
- for (String validQualifier : validNamespacePrefixes) {
+ for (final String validQualifier : validNamespacePrefixes) {
if (validQualifier.equals(qualifier)) {
valid = true;
break;
@@ -528,7 +552,7 @@
// allow residual name
if (!ItemDefinition.RESIDUAL_NAME.equals(childNodeDefinition.getName())) {
// ERROR - Empty or invalid child node definition name
- validateQualifiedName(childNodeDefinition.getQualifiedName(), Messages.childDefinitionName, validNamespacePrefixes,
+ validateQualifiedName(childNodeDefinition.getQualifiedName(), Messages.childNodeDefinitionName, validNamespacePrefixes,
existingChildNodeNames, status);
}
}
@@ -611,17 +635,41 @@
*/
final MultiValidationStatus status = new MultiValidationStatus();
+ final String prefix = namespaceMapping.getPrefix();
+ final String uri = namespaceMapping.getUri();
// ERROR - Empty or invalid prefix
- validateLocalName(namespaceMapping.getPrefix(), Messages.namespacePrefix, status);
+ validateLocalName(prefix, Messages.namespacePrefix, status);
// ERROR - Empty or invalid URI
- final ValidationStatus uriStatus = validateUri(namespaceMapping.getUri(), Messages.namespaceUri);
+ final ValidationStatus uriStatus = validateUri(uri, Messages.namespaceUri);
if (!uriStatus.isOk()) {
status.add(uriStatus);
}
+ // ERROR - prefix matches a built-in but URI does not match
+ try {
+ if (!Utils.isEmpty(prefix) && WorkspaceRegistry.get().isBuiltInNamespacePrefix(prefix)) {
+ if (!Utils.equals(uri, WorkspaceRegistry.get().getUri(prefix))) {
+ status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidUriForBuiltInNamespacePrefix,
+ new Object[] { uri, prefix,
+ WorkspaceRegistry.get().getUri(prefix) })));
+ }
+ }
+
+ // ERROR - URI matches a built-in but prefix does not match
+ if (!Utils.isEmpty(uri) && WorkspaceRegistry.get().isBuiltInNamespaceUri(uri)) {
+ if (!Utils.equals(prefix, WorkspaceRegistry.get().getPrefix(uri))) {
+ status.add(ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPrefixForBuiltInNamespaceUri,
+ new Object[] { prefix, uri,
+ WorkspaceRegistry.get().getPrefix(uri) })));
+ }
+ }
+ } catch (final Exception e) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ }
+
return status;
}
@@ -828,16 +876,11 @@
}
}
- boolean noPropertyDefinitions = false;
- boolean noChildNodeDefinitions = false;
-
if (validateEachPropertyAndChildNode) {
{ // property definitions
final Collection<PropertyDefinition> propertyDefinitions = nodeTypeDefinition.getPropertyDefinitions();
- if (Utils.isEmpty(propertyDefinitions)) {
- noPropertyDefinitions = true;
- } else {
+ if (!Utils.isEmpty(propertyDefinitions)) {
validatePropertyDefinitions(nodeTypeDefinitionName, validNamespacePrefixes, propertyDefinitions, status);
}
}
@@ -845,23 +888,12 @@
{ // child node definitions
final Collection<ChildNodeDefinition> childNodeDefinitions = nodeTypeDefinition.getChildNodeDefinitions();
- if (Utils.isEmpty(childNodeDefinitions)) {
- noChildNodeDefinitions = true;
- } else {
+ if (!Utils.isEmpty(childNodeDefinitions)) {
validateChildNodeDefinitions(nodeTypeDefinitionName, validNamespacePrefixes, childNodeDefinitions, status);
}
}
- } else {
- noPropertyDefinitions = nodeTypeDefinition.getPropertyDefinitions().isEmpty();
- noChildNodeDefinitions = nodeTypeDefinition.getChildNodeDefinitions().isEmpty();
}
- // WARNING - No property definitions or child node definitions exist
- if (noPropertyDefinitions && noChildNodeDefinitions) {
- status.add(ValidationStatus.createWarningMessage(NLS.bind(Messages.nodeTypeDefinitionHasNoPropertyDefinitionsOrChildNodeDefinitions,
- nodeTypeDefinitionName)));
- }
-
return status;
}
@@ -953,7 +985,7 @@
* @param propertyName the property name whose path value is being validated (cannot be <code>null</code> or empty)
* @return the validation status (never <code>null</code>)
*/
- public static ValidationStatus validatePath( String path,
+ public static ValidationStatus validatePath( final String path,
String propertyName ) {
Utils.verifyIsNotNull(propertyName, "propertyName"); //$NON-NLS-1$
@@ -965,11 +997,11 @@
return ValidationStatus.createErrorMessage(NLS.bind(Messages.emptyValue, propertyName));
}
- StringTokenizer pathTokenizer = new StringTokenizer(path, "/"); //$NON-NLS-1$
+ final StringTokenizer pathTokenizer = new StringTokenizer(path, "/"); //$NON-NLS-1$
if (pathTokenizer.hasMoreTokens()) {
while (pathTokenizer.hasMoreElements()) {
- String segment = pathTokenizer.nextToken();
+ final String segment = pathTokenizer.nextToken();
if (Utils.isEmpty(segment)) {
if (pathTokenizer.hasMoreTokens()) {
@@ -978,11 +1010,11 @@
PropertyType.PATH));
}
} else {
- StringTokenizer segmentTokenizer = new StringTokenizer(segment, "[]"); //$NON-NLS-1$
+ final StringTokenizer segmentTokenizer = new StringTokenizer(segment, "[]"); //$NON-NLS-1$
if (segmentTokenizer.countTokens() == 2) {
// has SNS index
- String qualifiedName = segmentTokenizer.nextToken();
+ final String qualifiedName = segmentTokenizer.nextToken();
if (Utils.isEmpty(qualifiedName)) {
// found SNS but now qualified name
@@ -996,8 +1028,8 @@
}
// validate qualified name
- QualifiedName qname = QualifiedName.parse(qualifiedName);
- MultiValidationStatus status = validateQualifiedName(qname, propertyName, null, null);
+ final QualifiedName qname = QualifiedName.parse(qualifiedName);
+ final MultiValidationStatus status = validateQualifiedName(qname, propertyName, null, null);
// return if invalid qualified
if (status.isError()) {
@@ -1006,10 +1038,10 @@
// valid qualified name so check SNS index
if (segmentTokenizer.countTokens() == 1) {
- String snsIndex = segmentTokenizer.nextToken();
+ final String snsIndex = segmentTokenizer.nextToken();
// make sure SNS index is a number
- for (char c : snsIndex.toCharArray()) {
+ for (final char c : snsIndex.toCharArray()) {
if (!Character.isDigit(c)) {
// found invalid character
return ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidPropertyValueForType, path,
@@ -1028,8 +1060,8 @@
}
// no SNS index
- QualifiedName qname = QualifiedName.parse(segment);
- MultiValidationStatus status = validateQualifiedName(qname, propertyName, null, null);
+ final QualifiedName qname = QualifiedName.parse(segment);
+ final MultiValidationStatus status = validateQualifiedName(qname, propertyName, null, null);
// return if invalid segment
if (status.isError()) {
@@ -1040,7 +1072,7 @@
}
} else {
// only one segment
- QualifiedName qname = QualifiedName.parse(path);
+ final QualifiedName qname = QualifiedName.parse(path);
return validateQualifiedName(qname, propertyName, null, null);
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CompactNodeTypeDefinition.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -16,13 +16,15 @@
import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.tools.modeshape.jcr.ChildNodeDefinition;
+import org.jboss.tools.modeshape.jcr.ItemDefinition;
import org.jboss.tools.modeshape.jcr.NamespaceMapping;
import org.jboss.tools.modeshape.jcr.NodeTypeDefinition;
import org.jboss.tools.modeshape.jcr.PropertyDefinition;
import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.WorkspaceRegistry;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
* The <code>CompactNodeTypeDefinition</code> class represents one CND file.
@@ -239,7 +241,8 @@
final NodeTypeDefinition superTypeNodeType = getNodeTypeDefinition(superType.get());
if (superTypeNodeType == null) {
- childNodes.addAll(WorkspaceRegistry.get().getChildNodeDefinitions(nodeTypeDefinitionName, true));
+ // super type not found in CND so see if it is a built-in
+ childNodes.addAll(WorkspaceRegistry.get().getChildNodeDefinitions(superType.get(), true));
} else {
childNodes.addAll(getChildNodeDefinitions(superTypeNodeType.getName(), true));
}
@@ -249,18 +252,24 @@
return childNodes;
}
- private String getEndNamespaceMappingSectionDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NAMESPACE_MAPPING_SECTION_END_DELIMITER);
+ /**
+ * The node type definition must exist in this CND for it to return child nodes.
+ *
+ * @param nodeTypeDefinitionName the name of the node type definition whose item definitions are being requested (cannot be
+ * <code>null</code> or empty)
+ * @param includeInherited indicates if inherited item definitions should be included
+ * @return the item definitions (never <code>null</code>)
+ * @throws Exception if there is a problem obtaining the inherited item definitions
+ */
+ public Collection<ItemDefinition> getItemDefinitions( final String nodeTypeDefinitionName,
+ final boolean includeInherited ) throws Exception {
+ final List<ItemDefinition> itemDefinitions = new ArrayList<ItemDefinition>(getChildNodeDefinitions(nodeTypeDefinitionName,
+ includeInherited));
+ itemDefinitions.addAll(getPropertyDefinitions(nodeTypeDefinitionName, includeInherited));
+ Collections.sort(itemDefinitions);
+ return itemDefinitions;
}
- private String getEndNodeTypeDefinitionSectionDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER);
- }
-
- private String getNamespaceMappingDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NAMESPACE_MAPPING_DELIMITER);
- }
-
/**
* @return the namespace mappings (never <code>null</code>)
*/
@@ -307,10 +316,6 @@
return null;
}
- private String getNodeTypeDefinitionDelimiter() {
- return CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.NODE_TYPE_DEFINITION_DELIMITER);
- }
-
/**
* @return the node type definitions (never <code>null</code>)
*/
@@ -349,7 +354,8 @@
final NodeTypeDefinition superTypeNodeType = getNodeTypeDefinition(superType.get());
if (superTypeNodeType == null) {
- properties.addAll(WorkspaceRegistry.get().getPropertyDefinitions(nodeTypeDefinitionName, true));
+ // super type not found in CND so see if it is a built-in
+ properties.addAll(WorkspaceRegistry.get().getPropertyDefinitions(superType.get(), true));
} else {
properties.addAll(getPropertyDefinitions(superTypeNodeType.getName(), true));
}
@@ -455,12 +461,13 @@
*/
@Override
public String toCndNotation( final NotationType notationType ) {
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
final StringBuilder builder = new StringBuilder();
boolean addDelim = false;
{ // namespace mappings
if (!Utils.isEmpty(this.namespaceMappings)) {
- final String DELIM = getNamespaceMappingDelimiter();
+ final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.NAMESPACE_MAPPING_DELIMITER);
for (final NamespaceMapping namespaceMapping : this.namespaceMappings) {
if (Utils.build(builder, addDelim, DELIM, namespaceMapping.toCndNotation(notationType))) {
@@ -468,13 +475,13 @@
}
}
- builder.append(getEndNamespaceMappingSectionDelimiter());
+ builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NAMESPACE_MAPPING_SECTION_END_DELIMITER));
}
}
{ // node type definitions
if (!Utils.isEmpty(this.nodeTypeDefinitions)) {
- final String DELIM = getNodeTypeDefinitionDelimiter();
+ final String DELIM = prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_DELIMITER);
for (final NodeTypeDefinition nodeTypeDefinition : this.nodeTypeDefinitions) {
if (Utils.build(builder, addDelim, DELIM, nodeTypeDefinition.toCndNotation(notationType))) {
@@ -482,7 +489,7 @@
}
}
- builder.append(getEndNodeTypeDefinitionSectionDelimiter());
+ builder.append(prefStore.get(JcrPreferenceConstants.CndPreference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER));
}
}
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-04-09 21:36:05 UTC (rev 40101)
@@ -10,10 +10,12 @@
# individual contributors.
#
-childDefinitionName = child node definition name
+childNodeDefinitionName = child node definition name
cndHasNoNamespacesOrNodeTypeDefinitions = CND has no namespace mappings or node type definitions.
# 0 = child node definition name
defaultTypeExistsButMarkedAsVariant = Child node definition "{0}" has default type marked as a variant but has a default type.
+# 0 = child node definition name, 1 = default type name
+defaultTypeDoesNotMatchRequiredType = Child noded definition "{0}" has a default type of "{1}" that does not match a required type.
defaultTypeName = default type name
defaultValue = default value
# 0 = property definition name
@@ -71,10 +73,14 @@
invalidQualifierForDefaultValue = Property definition "{0}" has a default value of "{1}" that does not have a valid qualifier.
# 0 = invalid query operator
invalidQueryOperator = Expected a valid query operator ('=', '<>', '<', '<=', '>', '>=', or 'LIKE'), but was "{0}" for property definition "{1}."
+# 0 = invalid prefix, 1 = built-in namespace mapping URI
+invalidPrefixForBuiltInNamespaceUri = A prefix of "{0}" is invalid for a namespace mapping URI of "{1}." The prefix should be "{2}."
# 0 = property value, 1 = property type, 2 = property definition name
invalidPropertyValueForType = The value "{0}" is not valid for a "{1}" property type in property "{2}."
# 0 = URI value
invalidUri = "{0}" is not a valid URI.
+# 0 = invalid URI, 1 = built-in namespace mapping prefix
+invalidUriForBuiltInNamespacePrefix = A URI of "{0}" is invalid for a namespace mapping prefix of "{1}." The URI should be "{2}."
# 0 = path to CND file
jsrBuiltInsCndFileNotFound = The JSR built-ins CND file "{0}" could not be found in workspace.
# 0 = path to CND file
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.jcr.preference;
+
+/**
+ * The ModeShape JCR preferences.
+ */
+public interface JcrPreferenceConstants {
+
+ /**
+ * An interface for all JCR preferences.
+ */
+ interface Preference {
+
+ /**
+ * @return the preference identifier (never <code>null</code> or empty)
+ */
+ String getId();
+ }
+
+ /**
+ * CND notation preferences.
+ */
+ enum CndPreference implements Preference {
+
+ /**
+ * The format used when writing out the CND (i.e, long, compressed, or compact.
+ */
+ NOTATION_TYPE,
+
+ /**
+ * The quote character used when quotes are being used (single, double, or empty).
+ */
+ QUOTE_CHAR,
+
+ /**
+ * The string version of the quote character (empty string, single quote, or double quote) surrounding each item in
+ * attribute lists.
+ */
+ ATTRIBUTE_LIST_ITEM_QUOTE_CHAR,
+
+ /**
+ * The delimiter between child node definition attributes.
+ */
+ CHILD_NODE_ATTRIBUTES_DELIMITER,
+
+ /**
+ * The delimiter between child node properties.
+ */
+ CHILD_NODE_PROPERTY_DELIMITER,
+
+ /**
+ * The delimiter between CND elements.
+ */
+ ELEMENT_DELIMITER,
+
+ /**
+ * The delimiter after the last CND element.
+ */
+ ELEMENTS_END_DELIMITER,
+
+ /**
+ * The delimiter before the first CND element.
+ */
+ ELEMENTS_START_DELIMITER,
+
+ /**
+ * The delimiter between namespace mappings.
+ */
+ NAMESPACE_MAPPING_DELIMITER,
+
+ /**
+ * The delimiter after the last namespace mapping.
+ */
+ NAMESPACE_MAPPING_SECTION_END_DELIMITER,
+
+ /**
+ * The delimiter between node type definition attributes.
+ */
+ NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER,
+
+ /**
+ * The delimiter after all the node type definition attributes.
+ */
+ NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER,
+
+ /**
+ * The delimiter between node type definitions.
+ */
+ NODE_TYPE_DEFINITION_DELIMITER,
+
+ /**
+ * The delimiter after the node type definition name.
+ */
+ NODE_TYPE_DEFINITION_NAME_END_DELIMITER,
+
+ /**
+ * The delimiter after the last node type definitions.
+ */
+ NODE_TYPE_DEFINITION_SECTION_END_DELIMITER,
+
+ /**
+ * The delimiter between property definition attributes.
+ */
+ PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER,
+
+ /**
+ * The delimiter after the last super type.
+ */
+ SUPER_TYPES_END_DELIMITER;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants.Preference#getId()
+ */
+ @Override
+ public String getId() {
+ return (getClass().getPackage().getName() + '.' + toString().toLowerCase());
+ }
+ }
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceConstants.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.jcr.preference;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.jboss.tools.modeshape.jcr.Activator;
+import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants.CndPreference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants.Preference;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * The <code>JcrPreferenceStore</code> can be used to access the ModeShape JCR plugin preference store. Can be used when the Eclipse
+ * platform is running or not.
+ */
+public final class JcrPreferenceStore extends AbstractPreferenceInitializer {
+
+ private static JcrPreferenceStore _store;
+
+ /**
+ * @param listener the listener being registered (cannot be <code>null</code>)
+ */
+ public static void addPreferenceChangeListener( final IPreferenceChangeListener listener ) {
+ Utils.verifyIsNotNull(listener, "listener"); //$NON-NLS-1$
+ get().prefs.addPreferenceChangeListener(listener);
+ }
+
+ /**
+ * @return the shared preference store (never <code>null</code>)
+ */
+ public static JcrPreferenceStore get() {
+ if (_store == null) {
+ _store = new JcrPreferenceStore();
+ }
+
+ return _store;
+ }
+
+ /**
+ * @param listener the listener being unregistered (cannot be <code>null</code>)
+ */
+ public static void removePreferenceChangeListener( final IPreferenceChangeListener listener ) {
+ Utils.verifyIsNotNull(listener, "listener"); //$NON-NLS-1$
+ get().prefs.removePreferenceChangeListener(listener);
+ }
+
+ private final boolean eclipse;
+ private final IEclipsePreferences prefs;
+ private final Map<String, String> testDefaultPrefs;
+ private final Map<String, String> testPrefs;
+
+ /**
+ * <strong>Only should be called by the Eclipse platform when initializing default preferences. Use the {@link #get()} method to
+ * access an instance of this store.</strong>
+ */
+ public JcrPreferenceStore() {
+ if (Platform.isRunning()) {
+ this.eclipse = true;
+ this.prefs = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ this.testDefaultPrefs = null;
+ this.testPrefs = null;
+ } else {
+ this.eclipse = false;
+ this.prefs = null;
+ this.testDefaultPrefs = new HashMap<String, String>();
+ this.testPrefs = new HashMap<String, String>();
+ initializeTestDefaultPreferences();
+ }
+ }
+
+ /**
+ * @param pref the preference whose current value is being requested (cannot be <code>null</code>)
+ * @return the value or <code>null</code> if there is no default value
+ */
+ public String get( final Preference pref ) {
+ Utils.verifyIsNotNull(pref, "pref"); //$NON-NLS-1$
+
+ if (this.eclipse) {
+ final String value = this.prefs.get(pref.getId(), null);
+
+ if (value == null) {
+ return getDefault(pref);
+ }
+
+ return value;
+ }
+
+ // test mode
+ String value = this.testPrefs.get(pref.getId());
+
+ if (value == null) {
+ value = this.testDefaultPrefs.get(pref.getId());
+ }
+
+ return value;
+ }
+
+ /**
+ * @param pref the preference whose current value is being requested (cannot be <code>null</code>)
+ * @return the value or <code>null</code> if there is no default value
+ */
+ public String getDefault( final Preference pref ) {
+ if (this.eclipse) {
+ return DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID).get(pref.getId(), null);
+ }
+
+ // test mode
+ return this.testDefaultPrefs.get(pref.getId());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ final IEclipsePreferences prefs = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ prefs.put(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR.getId(), Utils.EMPTY_STRING);
+ prefs.put(CndPreference.CHILD_NODE_ATTRIBUTES_DELIMITER.getId(), Utils.SPACE_STRING);
+ prefs.put(CndPreference.CHILD_NODE_PROPERTY_DELIMITER.getId(), Utils.SPACE_STRING);
+ prefs.put(CndPreference.ELEMENT_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ prefs.put(CndPreference.ELEMENTS_END_DELIMITER.getId(), Utils.EMPTY_STRING);
+ prefs.put(CndPreference.ELEMENTS_START_DELIMITER.getId(), "\t"); //$NON-NLS-1$
+ prefs.put(CndPreference.NAMESPACE_MAPPING_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ prefs.put(CndPreference.NAMESPACE_MAPPING_SECTION_END_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ prefs.put(CndPreference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER.getId(), Utils.SPACE_STRING);
+ prefs.put(CndPreference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ prefs.put(CndPreference.NODE_TYPE_DEFINITION_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ prefs.put(CndPreference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER.getId(), Utils.SPACE_STRING);
+ prefs.put(CndPreference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ prefs.put(CndPreference.NOTATION_TYPE.getId(), CndElement.NotationType.LONG.toString());
+ prefs.put(CndPreference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER.getId(), Utils.SPACE_STRING);
+ prefs.put(CndPreference.QUOTE_CHAR.getId(), Utils.EMPTY_STRING);
+ prefs.put(CndPreference.SUPER_TYPES_END_DELIMITER.getId(), Utils.SPACE_STRING);
+ }
+
+ /**
+ * Must be kept in-sync with loading the Eclipse preference store.
+ */
+ private void initializeTestDefaultPreferences() {
+ this.testDefaultPrefs.put(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR.getId(), Utils.EMPTY_STRING);
+ this.testDefaultPrefs.put(CndPreference.CHILD_NODE_ATTRIBUTES_DELIMITER.getId(), Utils.SPACE_STRING);
+ this.testDefaultPrefs.put(CndPreference.CHILD_NODE_PROPERTY_DELIMITER.getId(), Utils.SPACE_STRING);
+ this.testDefaultPrefs.put(CndPreference.ELEMENT_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ this.testDefaultPrefs.put(CndPreference.ELEMENTS_END_DELIMITER.getId(), Utils.EMPTY_STRING);
+ this.testDefaultPrefs.put(CndPreference.ELEMENTS_START_DELIMITER.getId(), "\t"); //$NON-NLS-1$
+ this.testDefaultPrefs.put(CndPreference.NAMESPACE_MAPPING_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ this.testDefaultPrefs.put(CndPreference.NAMESPACE_MAPPING_SECTION_END_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ this.testDefaultPrefs.put(CndPreference.NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER.getId(), Utils.SPACE_STRING);
+ this.testDefaultPrefs.put(CndPreference.NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ this.testDefaultPrefs.put(CndPreference.NODE_TYPE_DEFINITION_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ this.testDefaultPrefs.put(CndPreference.NODE_TYPE_DEFINITION_NAME_END_DELIMITER.getId(), Utils.SPACE_STRING);
+ this.testDefaultPrefs.put(CndPreference.NODE_TYPE_DEFINITION_SECTION_END_DELIMITER.getId(), "\n"); //$NON-NLS-1$
+ this.testDefaultPrefs.put(CndPreference.NOTATION_TYPE.getId(), CndElement.NotationType.LONG.toString());
+ this.testDefaultPrefs.put(CndPreference.PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER.getId(), Utils.SPACE_STRING);
+ this.testDefaultPrefs.put(CndPreference.QUOTE_CHAR.getId(), Utils.EMPTY_STRING);
+ this.testDefaultPrefs.put(CndPreference.SUPER_TYPES_END_DELIMITER.getId(), Utils.SPACE_STRING);
+ }
+
+ /**
+ * @param pref the preference whose value is being set (cannot be <code>null</code>)
+ * @param newValue the new value (can be <code>null</code> or empty)
+ */
+ public void set( final Preference pref,
+ final String newValue ) {
+ Utils.verifyIsNotNull(pref, "pref"); //$NON-NLS-1$
+
+ if (this.eclipse) {
+ this.prefs.put(pref.getId(), newValue);
+
+ // save
+ try {
+ this.prefs.flush();
+ } catch (final BackingStoreException e) {
+ Activator.get().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, null, e));
+ }
+ } else {
+ // test mode
+ this.testPrefs.put(pref.getId(), newValue);
+ }
+ }
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/preference/JcrPreferenceStore.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF 2012-04-09 21:36:05 UTC (rev 40101)
@@ -17,3 +17,6 @@
org.eclipse.ui.ide,
org.jboss.tools.modeshape.client;bundle-version="1.1.0"
Bundle-Activator: org.jboss.tools.modeshape.jcr.ui.Activator
+Export-Package: org.jboss.tools.modeshape.jcr.ui,
+ org.jboss.tools.modeshape.jcr.ui.cnd,
+ org.jboss.tools.modeshape.jcr.ui.preferences
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/bundle.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/bundle.properties 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/bundle.properties 2012-04-09 21:36:05 UTC (rev 40101)
@@ -12,4 +12,5 @@
bundleName = ModeShape JCR UI Plug-in
bundleVendor = JBoss by Red Hat
cndEditor.name = CND
+cndPreferencePage.name = CND Notation
modeShapeCategory.name = ModeShape
\ No newline at end of file
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml 2012-04-09 21:36:05 UTC (rev 40101)
@@ -24,6 +24,17 @@
</editor>
</extension>
+<!-- CND Preference Page -->
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ name="%cndPreferencePage.name"
+ category="modeShapePreferencePage"
+ class="org.jboss.tools.modeshape.jcr.ui.preferences.CndPreferencePage"
+ id="org.jboss.tools.modeshape.jcr.ui.jcrPreferencePage">
+ </page>
+ </extension>
+
<!-- New wizards
<extension
point="org.eclipse.ui.newWizards">
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/ChildNodeDialog.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -10,6 +10,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -32,8 +33,6 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
@@ -48,7 +47,6 @@
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.ui.forms.FormDialog;
import org.eclipse.ui.forms.IManagedForm;
@@ -80,6 +78,7 @@
private IAction addRequiredType;
private Button btnOk;
+ private CCombo cbxDefaultType;
private ChildNodeDefinition childNodeBeingEdited;
private final ErrorMessage defaultTypeError;
private IAction deleteRequiredType;
@@ -222,10 +221,11 @@
this.nameEditor = new QualifiedNameEditor(leftContainer,
SWT.NONE,
toolkit,
- Messages.propertyDefinitionName,
+ Messages.childNodeDefinitionName,
this.existingNamespacePrefixes,
this.childNodeBeingEdited.getQualifiedName());
((GridData)this.nameEditor.getLayoutData()).horizontalSpan = 2;
+ this.nameEditor.setAllowsResidualName(true);
this.nameEditor.addListener(SWT.Modify, new Listener() {
/**
@@ -243,35 +243,43 @@
}
{ // default type
- toolkit.createLabel(leftContainer, CndMessages.childNodeDefaultTypeLabel);
- final Text txtDefaultType = toolkit.createText(leftContainer, Utils.EMPTY_STRING, Styles.TEXT_STYLE);
- txtDefaultType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- txtDefaultType.setToolTipText(CndMessages.childNodeDefaultTypeToolTip);
+ final Composite defaultTypeContainer = toolkit.createComposite(leftContainer);
+ defaultTypeContainer.setLayout(new GridLayout(2, false));
+ defaultTypeContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ ((GridData)defaultTypeContainer.getLayoutData()).horizontalSpan = 2;
+ toolkit.paintBordersFor(defaultTypeContainer);
- if (isEditMode()) {
- String currentValue = this.childNodeBeingEdited.getDefaultPrimaryTypeName();
+ final Label lblDefaultType = toolkit.createLabel(defaultTypeContainer, CndMessages.childNodeDefaultTypeLabel,
+ SWT.NONE);
+ lblDefaultType.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
- if (currentValue == null) {
- currentValue = Utils.EMPTY_STRING;
- }
+ this.cbxDefaultType = new CCombo(defaultTypeContainer, Styles.COMBO_STYLE);
+ this.cbxDefaultType.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ ((GridData)this.cbxDefaultType.getLayoutData()).heightHint = this.cbxDefaultType.getItemHeight() + 4;
+ this.cbxDefaultType.setToolTipText(CndMessages.childNodeDefaultTypeToolTip);
+ toolkit.adapt(this.cbxDefaultType, true, false);
- txtDefaultType.setText(currentValue);
- }
+ this.cbxDefaultType.addSelectionListener(new SelectionAdapter() {
- txtDefaultType.addModifyListener(new ModifyListener() {
-
/**
* {@inheritDoc}
*
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
- public void modifyText( final ModifyEvent e ) {
- handleDefaultTypeChanged(((Text)e.widget).getText());
+ public void widgetSelected( final SelectionEvent e ) {
+ String newDefaultType = ((CCombo)e.widget).getText();
+
+ if (CndMessages.notAssignedItemChoice.equals(newDefaultType)) {
+ newDefaultType = Utils.EMPTY_STRING;
+ }
+
+ handleDefaultTypeChanged(newDefaultType);
}
});
- this.defaultTypeError.setControl(txtDefaultType);
+ refreshDefaultTypes(); // populate default type choices
+ this.defaultTypeError.setControl(this.cbxDefaultType);
}
{ // attributes
@@ -739,6 +747,7 @@
} else if (PropertyName.REQUIRED_TYPES.toString().equals(propName)) {
validateRequiredTypes();
this.requiredTypesViewer.refresh();
+ validateDefaultType();
}
updateState();
@@ -769,6 +778,39 @@
return (this.originalChildNode != null);
}
+ private void refreshDefaultTypes() {
+ // set default type choices if they have changed
+ final String[] temp = this.childNodeBeingEdited.getRequiredPrimaryTypeNames();
+ final String[] currentRequiredTypes = new String[temp.length + 1];
+ currentRequiredTypes[0] = CndMessages.notAssignedItemChoice;
+
+ if (temp.length != 0) {
+ System.arraycopy(temp, 0, currentRequiredTypes, 1, temp.length);
+ }
+
+ if ((this.cbxDefaultType.getItemCount() != currentRequiredTypes.length)
+ || !Arrays.asList(currentRequiredTypes).containsAll(Arrays.asList(this.cbxDefaultType.getItems()))) {
+ this.cbxDefaultType.setItems(currentRequiredTypes);
+ }
+
+ // select the current default type
+ final String defaultTypeName = this.childNodeBeingEdited.getDefaultPrimaryTypeName();
+
+ if (Utils.isEmpty(defaultTypeName)) {
+ this.cbxDefaultType.select(0); // select no default type assigned
+ } else {
+ final int index = this.cbxDefaultType.indexOf(defaultTypeName);
+
+ if (index == -1) {
+ // not a valid primary item but add and select
+ this.cbxDefaultType.add(defaultTypeName);
+ this.cbxDefaultType.select(this.cbxDefaultType.getItemCount() - 1);
+ } else {
+ this.cbxDefaultType.select(index);
+ }
+ }
+ }
+
private void updateMessage( final ValidationStatus status,
final ErrorMessage errorMsg ) {
JcrUiUtils.setMessage(status, errorMsg);
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -28,6 +28,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IMessageProvider;
@@ -61,6 +63,8 @@
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
import org.jboss.tools.modeshape.jcr.cnd.CndImporter;
import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
import org.jboss.tools.modeshape.jcr.ui.Activator;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants;
import org.jboss.tools.modeshape.jcr.ui.JcrUiConstants.Images;
@@ -71,8 +75,8 @@
/**
*
*/
-public final class CndEditor extends SharedHeaderFormEditor implements IPersistableEditor, IResourceChangeListener,
- PropertyChangeListener {
+public final class CndEditor extends SharedHeaderFormEditor implements IPersistableEditor, IPreferenceChangeListener,
+ IResourceChangeListener, PropertyChangeListener {
private CompactNodeTypeDefinition cndBeingEdited;
@@ -95,6 +99,7 @@
*/
public CndEditor() {
this.formsPage = new CndFormsEditorPage(this);
+ JcrPreferenceStore.addPreferenceChangeListener(this);
}
/**
@@ -168,33 +173,6 @@
}
}
- private void createCnd() throws Exception {
- final CndImporter importer = new CndImporter();
- final List<Throwable> errors = new ArrayList<Throwable>();
- this.originalCnd = importer.importFrom(getFile().getContents(), errors, getFile().getName());
-
- // check for parse errors
- if (!errors.isEmpty()) {
- final Throwable t = errors.iterator().next();
-
- if (t.getCause() == null) {
- throw new RuntimeException(t);
- }
-
- throw new RuntimeException(t.getCause());
- }
-
- // unhook lstening to current CND being edited
- if (this.cndBeingEdited != null) {
- this.cndBeingEdited.removeListener(this);
- }
-
- // copy over CND
- this.cndBeingEdited = CompactNodeTypeDefinition.copy(this.originalCnd);
- this.cndBeingEdited.addListener(this);
- this.formsPage.handleCndReloaded();
- }
-
//
// private void contributeToMenu( IMenuManager menuMgr ) {
// menuMgr.add(this.updateRegisteryAction);
@@ -226,6 +204,33 @@
// this.showRegistryViewAction = new ShowModelExtensionRegistryViewAction();
// }
+ private void createCnd() throws Exception {
+ final CndImporter importer = new CndImporter();
+ final List<Throwable> errors = new ArrayList<Throwable>();
+ this.originalCnd = importer.importFrom(getFile().getContents(), errors, getFile().getName());
+
+ // check for parse errors
+ if (!errors.isEmpty()) {
+ final Throwable t = errors.iterator().next();
+
+ if (t.getCause() == null) {
+ throw new RuntimeException(t);
+ }
+
+ throw new RuntimeException(t.getCause());
+ }
+
+ // unhook lstening to current CND being edited
+ if (this.cndBeingEdited != null) {
+ this.cndBeingEdited.removeListener(this);
+ }
+
+ // copy over CND
+ this.cndBeingEdited = CompactNodeTypeDefinition.copy(this.originalCnd);
+ this.cndBeingEdited.addListener(this);
+ this.formsPage.handleCndReloaded();
+ }
+
/**
* {@inheritDoc}
*
@@ -266,6 +271,7 @@
@Override
public void dispose() {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+ JcrPreferenceStore.removePreferenceChangeListener(this);
super.dispose();
}
@@ -353,6 +359,11 @@
return this.scrolledForm.getMessageManager();
}
+ private NotationType getNotationTypePreference() {
+ final String notationTypeString = JcrPreferenceStore.get().get(JcrPreferenceConstants.CndPreference.NOTATION_TYPE);
+ return NotationType.valueOf(notationTypeString);
+ }
+
private IProgressMonitor getProgressMonitor() {
final IStatusLineManager statusLineMgr = getEditorSite().getActionBars().getStatusLineManager();
return ((statusLineMgr == null) ? null : statusLineMgr.getProgressMonitor());
@@ -437,13 +448,9 @@
final IEditorInput input = getEditorInput();
try {
- final IDocument document = this.documentProvider.getDocument(input);
- document.set(getCnd().toCndNotation(NotationType.LONG)); // TODO hook this to notation type preference
+ // create the new text document
+ saveDocument(input, progressMonitor);
- this.documentProvider.aboutToChange(input);
- this.documentProvider.saveDocument(progressMonitor, input, document, true);
- this.modificationStamp = this.documentProvider.getModificationStamp(input);
-
// create new original CND that that will then be copied over to the CND being edited
createCnd();
} catch (final Exception e) {
@@ -504,6 +511,20 @@
/**
* {@inheritDoc}
*
+ * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
+ */
+ @Override
+ public void preferenceChange( final PreferenceChangeEvent event ) {
+ try {
+ saveDocument(getEditorInput(), getProgressMonitor());
+ } catch (final Exception e) {
+ Activator.getSharedInstance().getLog().log(new Status(IStatus.ERROR, JcrUiConstants.PLUGIN_ID, null, e));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
@Override
@@ -524,10 +545,8 @@
this.modificationStamp = this.documentProvider.getModificationStamp(getEditorInput());
createCnd();
-
- // this.formsPage.handleCndReloaded();
} catch (final Exception e) {
- // TODO log this
+ Activator.getSharedInstance().getLog().log(new Status(IStatus.ERROR, JcrUiConstants.PLUGIN_ID, null, e));
MessageFormDialog.openError(getShell(), CndMessages.cndEditorRefreshErrorTitle,
Activator.getSharedInstance().getImage(Images.CND_EDITOR),
CndMessages.cndEditorRefreshErrorMsg);
@@ -635,7 +654,7 @@
}
});
} catch (final Exception e) {
- // TODO log this
+ Activator.getSharedInstance().getLog().log(new Status(IStatus.ERROR, JcrUiConstants.PLUGIN_ID, null, e));
}
}
}
@@ -651,6 +670,15 @@
this.formsPage.restoreState(this.memento);
}
+ private void saveDocument( final IEditorInput input,
+ final IProgressMonitor progressMonitor ) throws Exception {
+ final IDocument document = this.documentProvider.getDocument(input);
+ document.set(getCnd().toCndNotation(getNotationTypePreference()));
+ this.documentProvider.aboutToChange(input);
+ this.documentProvider.saveDocument(progressMonitor, input, document, true);
+ this.modificationStamp = this.documentProvider.getModificationStamp(input);
+ }
+
/**
* {@inheritDoc}
*
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -245,7 +245,7 @@
this.openChildNodeDeclaringNodeType.setEnabled(false);
this.openChildNodeDeclaringNodeType.setToolTipText(CndMessages.openDeclaringNodeTypeToolTip);
this.openChildNodeDeclaringNodeType.setImageDescriptor(Activator.getSharedInstance()
- .getImageDescriptor(JcrUiConstants.Images.OPEN_DECLARING_NODE_TYPE));
+ .getImageDescriptor(JcrUiConstants.Images.OPEN_DECLARING_NODE_TYPE));
}
private void createChildNodeSection( final IManagedForm managedForm,
@@ -320,7 +320,7 @@
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
if (!Utils.equivalent(nodeTypeDefinition.getName(), childNodeDefinition.getDeclaringNodeTypeDefinitionName()
- .get())) {
+ .get())) {
return getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
}
}
@@ -341,7 +341,7 @@
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
if (!Utils.equivalent(nodeTypeDefinition.getName(), childNodeDefinition.getDeclaringNodeTypeDefinitionName()
- .get())) {
+ .get())) {
return JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
}
}
@@ -366,7 +366,7 @@
if (this.columnIndex == ChildNodeColumnIndexes.DECLARING_NODE_TYPE) {
if (!Utils.equivalent(getSelectedNodeType().getName(), childNodeDefinition.getDeclaringNodeTypeDefinitionName()
- .get())) {
+ .get())) {
return childNodeDefinition.getDeclaringNodeTypeDefinitionName().get();
}
@@ -666,7 +666,7 @@
public void widgetSelected( final SelectionEvent e ) {
String newPrimaryItem = ((CCombo)e.widget).getText();
- if (CndMessages.noPrimaryItemChoice.equals(newPrimaryItem)) {
+ if (CndMessages.notAssignedItemChoice.equals(newPrimaryItem)) {
newPrimaryItem = Utils.EMPTY_STRING;
}
@@ -1984,16 +1984,16 @@
void handleChildNodeSelected() {
// update button enablements
- boolean enable = (getSelectedNodeType() != null);
+ final boolean enable = (getSelectedNodeType() != null);
if (this.addChildNode.isEnabled() != enable) {
this.addChildNode.setEnabled(enable);
}
- boolean enableWithChildNodeSelected = (enable && (getSelectedChildNode() != null));
- boolean enableInheritedChildNode = enableWithChildNodeSelected
+ final boolean enableWithChildNodeSelected = (enable && (getSelectedChildNode() != null));
+ final boolean enableInheritedChildNode = enableWithChildNodeSelected
&& !getSelectedNodeType().hasDeclaredChildNodeDefinition(getSelectedChildNode().getName());
- boolean enableDeclaredChildNode = enableWithChildNodeSelected
+ final boolean enableDeclaredChildNode = enableWithChildNodeSelected
&& getSelectedNodeType().hasDeclaredChildNodeDefinition(getSelectedChildNode().getName());
// enable if selected child node is not inherited
@@ -2403,6 +2403,16 @@
} else if (NodeTypeDefinition.PropertyName.SUPERTYPES.toString().equals(propName)) {
validateSuperTypes();
this.superTypesViewer.refresh();
+
+ // refresh properties if showing inherited
+ if (shouldShowInheritedProperties()) {
+ this.propertyViewer.refresh();
+ }
+
+ // refresh child nodes if showing inherited
+ if (shouldShowInheritedChildNodes()) {
+ this.childNodeViewer.refresh();
+ }
}
// tell editor about node type definition change
@@ -2424,16 +2434,16 @@
void handlePropertySelected() {
// update button enablements
- boolean enable = (getSelectedNodeType() != null);
+ final boolean enable = (getSelectedNodeType() != null);
if (this.addProperty.isEnabled() != enable) {
this.addProperty.setEnabled(enable);
}
- boolean enableWithPropertySelected = (enable && (getSelectedProperty() != null));
- boolean enableInheritedProperty = enableWithPropertySelected
+ final boolean enableWithPropertySelected = (enable && (getSelectedProperty() != null));
+ final boolean enableInheritedProperty = enableWithPropertySelected
&& !getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
- boolean enableDeclaredProperty = enableWithPropertySelected
+ final boolean enableDeclaredProperty = enableWithPropertySelected
&& getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
// enable if selected property is not inherited
@@ -2458,8 +2468,8 @@
void handleSelectPropertyDeclaringNodeType() {
assert (getSelectedProperty() != null) : "handleSelectPropertyDeclaringNodeType called and no property selected"; //$NON-NLS-1$
- QualifiedName qname = getSelectedProperty().getDeclaringNodeTypeDefinitionName();
- NodeTypeDefinition nodeType = getCnd().getNodeTypeDefinition(qname.get());
+ final QualifiedName qname = getSelectedProperty().getDeclaringNodeTypeDefinitionName();
+ final NodeTypeDefinition nodeType = getCnd().getNodeTypeDefinition(qname.get());
if (nodeType == null) {
@@ -2583,27 +2593,38 @@
}
// set primary item choices if they have changed
- final List<ItemDefinition> currentItems = nodeTypeDefinition.getItemDefinitions();
+ try {
+ final Collection<ItemDefinition> currentItems = getCnd().getItemDefinitions(nodeTypeDefinition.getName(), true);
- // take out any items with residual names
- for (final ItemDefinition item : new ArrayList<ItemDefinition>(currentItems)) {
- if (ItemDefinition.RESIDUAL_NAME.equals(item.getQualifiedName().get())) {
- currentItems.remove(item);
+ // take out any items with residual names
+ for (final ItemDefinition item : new ArrayList<ItemDefinition>(currentItems)) {
+ if (ItemDefinition.RESIDUAL_NAME.equals(item.getQualifiedName().get())) {
+ currentItems.remove(item);
+ }
}
- }
- final String[] itemNames = new String[currentItems.size() + 1];
- itemNames[0] = CndMessages.noPrimaryItemChoice;
- int i = 1;
+ final String[] itemNames = new String[currentItems.size() + 1];
+ itemNames[0] = CndMessages.notAssignedItemChoice;
+ int i = 1;
- for (final ItemDefinition item : currentItems) {
- itemNames[i++] = item.getQualifiedName().get();
- }
+ for (final ItemDefinition item : currentItems) {
+ itemNames[i++] = item.getQualifiedName().get();
+ }
- // only reload primary item names if different
- if ((this.cbxPrimaryItem.getItemCount() != itemNames.length)
- || !Arrays.asList(itemNames).containsAll(Arrays.asList(this.cbxPrimaryItem.getItems()))) {
- this.cbxPrimaryItem.setItems(itemNames);
+ // only reload primary item names if different
+ if ((this.cbxPrimaryItem.getItemCount() != itemNames.length)
+ || !Arrays.asList(itemNames).containsAll(Arrays.asList(this.cbxPrimaryItem.getItems()))) {
+ this.cbxPrimaryItem.setItems(itemNames);
+ }
+ } catch (final Exception e) {
+ Activator.getSharedInstance()
+ .getLog()
+ .log(new Status(IStatus.ERROR,
+ JcrUiConstants.PLUGIN_ID,
+ NLS.bind(CndMessages.errorObtainingInheritedItemDefinitions, nodeTypeDefinition.getName()),
+ e));
+
+ this.cbxPrimaryItem.setItems(new String[] { CndMessages.notAssignedItemChoice });
}
// select the current primary item name
@@ -2858,10 +2879,10 @@
this.propertyViewer.getTable().setEnabled(enableWithNodeTypeSelected);
}
- boolean enableWithPropertySelected = (enableWithNodeTypeSelected && (getSelectedProperty() != null));
- boolean enableInheritedProperty = enableWithPropertySelected
+ final boolean enableWithPropertySelected = (enableWithNodeTypeSelected && (getSelectedProperty() != null));
+ final boolean enableInheritedProperty = enableWithPropertySelected
&& !getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
- boolean enableDeclaredProperty = enableWithPropertySelected
+ final boolean enableDeclaredProperty = enableWithPropertySelected
&& getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
// enable if selected property is not inherited
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -13,7 +13,7 @@
/**
* Localized messages used by classes in the <code>org.jboss.tools.modeshape.jcr.ui.cnd</code> package.
*/
-class CndMessages extends NLS {
+public class CndMessages extends NLS {
/**
* A name for the abstract attribute name for a radio or check button.
@@ -26,6 +26,11 @@
public static String abstractAttributeToolTip;
/**
+ * A dialog message indicating the namespace mapping is a built-in and asks the user to OK the dialog.
+ */
+ public static String acceptBuiltInNamespaceDialogMsg;
+
+ /**
* A dialog message indicating the default value has been changed and asks the user to OK the dialog. One parameter, the default
* value, is required.
*/
@@ -320,6 +325,21 @@
public static String cndMessageDialogTitle;
/**
+ * The description of the CND preference page.
+ */
+ public static String cndPrefPageDescription;
+
+ /**
+ * The message of the CND preference page.
+ */
+ public static String cndPrefPageMessage;
+
+ /**
+ * The title of the CND prefrence page.
+ */
+ public static String cndPrefPageTitle;
+
+ /**
* The column header text of the declaring node type of an item definition.
*/
public static String declaringNodeTypeHeaderText;
@@ -941,11 +961,6 @@
public static String noNameQualifierChoice;
/**
- * The text indicating the node type definition has not assigned a primary item.
- */
- public static String noPrimaryItemChoice;
-
- /**
* A name for the noQueryOrder attribute suitable for a radio or check button.
*/
public static String noQueryOrderAttribute;
@@ -956,6 +971,21 @@
public static String noQueryOrderAttributeToolTip;
/**
+ * The text indicating a choice has not been made.
+ */
+ public static String notAssignedItemChoice;
+
+ /**
+ * A label for a notation type choice control.
+ */
+ public static String notationTypeLabel;
+
+ /**
+ * A tool tip for CND notation type.
+ */
+ public static String notationTypeToolTip;
+
+ /**
* A tool tip message for the "not equals" query operator.
*/
public static String notEqualsOperatorToolTip;
@@ -974,12 +1004,12 @@
* The context menu item text for the open declaring node type action.
*/
public static String openDeclaringNodeTypeMenuText;
-
+
/**
* A tool tip message of the open declaring node type action.
*/
public static String openDeclaringNodeTypeToolTip;
-
+
/**
* A name for the orderable attribute suitable for a radio or check button.
*/
@@ -1087,6 +1117,31 @@
public static String queryOperatorsLabel;
/**
+ * Choice text for using a double quote character.
+ */
+ public static String quoteCharDoubleChoiceLabel;
+
+ /**
+ * Choice text for not using a quote character.
+ */
+ public static String quoteCharNoneChoiceLabel;
+
+ /**
+ * A label for a quote character control.
+ */
+ public static String quoteCharPolicyLabel;
+
+ /**
+ * A tool tip for a quote character choice control.
+ */
+ public static String quoteCharPolicyToolTip;
+
+ /**
+ * Choice text for using a single quote character.
+ */
+ public static String quoteCharSingleChoiceLabel;
+
+ /**
* The column header text for the required types of a child node definition.
*/
public static String requiredTypesHeaderText;
@@ -1115,7 +1170,7 @@
* A tool tip message for the show inherited properties action.
*/
public static String showInheritedPropertiesToolTip;
-
+
/**
* A label for a supertypes control.
*/
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/NamespaceMappingDialog.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -278,7 +278,15 @@
} else if (status.isInfo()) {
severity = IMessageProvider.INFORMATION;
} else {
- message = CndMessages.acceptNamespaceDialogMsg;
+ try {
+ if (WorkspaceRegistry.get().isBuiltIn(currentNamespace)) {
+ message = CndMessages.acceptBuiltInNamespaceDialogMsg;
+ } else {
+ message = CndMessages.acceptNamespaceDialogMsg;
+ }
+ } catch (Exception e) {
+ message = CndMessages.acceptNamespaceDialogMsg;
+ }
}
this.scrolledForm.setMessage(message, severity);
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/PropertyDialog.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -345,6 +345,7 @@
this.existingNamespacePrefixes,
this.propertyBeingEdited.getQualifiedName());
((GridData)this.nameEditor.getLayoutData()).horizontalSpan = 2;
+ this.nameEditor.setAllowsResidualName(true);
this.nameEditor.addListener(SWT.Modify, new Listener() {
/**
@@ -1482,7 +1483,7 @@
}
private void validateAttributes() {
- // TODO primary item
+ // nothing to do
}
private void validateDefaultValues() {
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/QualifiedNameEditor.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -23,6 +23,7 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.modeshape.jcr.ItemDefinition;
import org.jboss.tools.modeshape.jcr.QualifiedName;
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.ValidationStatus;
@@ -57,6 +58,8 @@
private String qualifier;
+ private boolean residualNameAllowed = false;
+
private ValidationStatus status;
private final FormToolkit toolkit;
@@ -189,6 +192,14 @@
}
/**
+ * @param newValue indicates if and unqualified name equal to {@link ItemDefinition#RESIDUAL_NAME} is allowed.
+ */
+ public void setAllowsResidualName(boolean newValue) {
+ this.residualNameAllowed = newValue;
+ validate();
+ }
+
+ /**
* {@inheritDoc}
*
* @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
@@ -288,9 +299,14 @@
}
private void validate() {
- final QualifiedName currentQName = new QualifiedName(this.qualifier, this.unqualifiedName);
- this.status = CndValidator.validateQualifiedName(currentQName, this.qualifiedNameType, this.validQualifiers,
- this.existingQNames);
+ if (ItemDefinition.RESIDUAL_NAME.equals(this.unqualifiedName) && this.residualNameAllowed) {
+ this.status = ValidationStatus.OK_STATUS;
+ } else {
+ final QualifiedName currentQName = new QualifiedName(this.qualifier, this.unqualifiedName);
+ this.status = CndValidator.validateQualifiedName(currentQName, this.qualifiedNameType, this.validQualifiers,
+ this.existingQNames);
+ }
+
final Event e = new Event();
e.widget = this;
e.type = SWT.Modify;
Modified: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-09 21:36:05 UTC (rev 40101)
@@ -6,6 +6,7 @@
abstractAttribute = Abstract
abstractAttributeToolTip = Indicates if the node type definition cannot be instantiated
+acceptBuiltInNamespaceDialogMsg = Select OK to accept the built-in namespace mapping.
acceptDefaultValueDialogMsg = Select OK to accept the changes to the "{0}" default value.
acceptNamespaceDialogMsg = Select OK to accept the changes to the namespace mapping.
acceptQualifiedNameDialogMsg = Select OK to accept the changes to the "{0}" qualified name.
@@ -68,6 +69,9 @@
cndMessageDialogMessageAreaMessage = The {0} CND has {1} error(s), {2} warnings, and {3} information messages.
cndMessageDialogMessageAreaTitle = Message Summary
cndMessageDialogTitle = CND Validation Messages
+cndPrefPageDescription = Settings that determine how CND files are formatted.
+cndPrefPageMessage = CND Notation
+cndPrefPageTitle = CND Notation
declaringNodeTypeHeaderText = Declaring Node Type
declaringNodeTypeToolTip = The node type definition that defines the property or child node
defaultTypeHeaderText = Default Type
@@ -194,9 +198,11 @@
noFullTextAttribute = Not Full Text Searchable
noFullTextAttributeToolTip = Indicates if the property does not support full text search
noNameQualifierChoice = <no qualifier>
-noPrimaryItemChoice = <not assigned>
noQueryOrderAttribute = Not Query Orderable
noQueryOrderAttributeToolTip = Indicates if query results of this property cannot be ordered
+notAssignedItemChoice = <not assigned>
+notationTypeLabel = Notation Type:
+notationTypeToolTip = The notation type is used when saving a CND file.
notEqualsOperatorToolTip = Indicates if the property supports the "not equals" query operation
onParentVersionLabel = On Parent Version:
onParentVersionToolTip = Indicates what happens to the child node/property when the parent is created
@@ -223,6 +229,11 @@
queryableAttribute = Queryable
queryableAttributeToolTip = Indicates if the child node definition supports siblings of the same name
queryOperatorsLabel = Supported Query Operators:
+quoteCharDoubleChoiceLabel = Use double quote
+quoteCharNoneChoiceLabel = Do not use quote characters
+quoteCharPolicyLabel = Quote Policy:
+quoteCharPolicyToolTip = The quote character policy determines if CND string values are surrounded by quotes.
+quoteCharSingleChoiceLabel = Use single quote
requiredTypesHeaderText = Required Types
requiredTypesLabel = Required Types:
sameNamedSiblingsAttribute = Same Named Siblings
@@ -245,4 +256,3 @@
valueConstraintsToolTip = The value constraints of a property are used to limit the allowed values
valueConstraintToolTip = A value constraint is used to limit the allowed values of a property
valueEditorDialogTitle = Value Editor
-
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java (rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -0,0 +1,263 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.jboss.tools.modeshape.jcr.ui.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.modeshape.jcr.cnd.CndElement;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants.CndPreference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
+import org.jboss.tools.modeshape.jcr.ui.JcrUiUtils;
+import org.jboss.tools.modeshape.jcr.ui.cnd.CndMessages;
+
+/**
+ *
+ */
+public final class CndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ private static String[] QUOTE_CHAR_LABELS = new String[] { CndMessages.quoteCharNoneChoiceLabel,
+ CndMessages.quoteCharSingleChoiceLabel, CndMessages.quoteCharDoubleChoiceLabel };
+
+ /**
+ * The editor used to choose the notation type for the CND format.
+ */
+ private Combo cbxNotationType;
+//
+// /**
+// * The editor used to choose the quote character.
+// */
+// private Combo cbxQuoteChar;
+
+ private String notationType;
+//
+// private String quoteString;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents( final Composite parent ) {
+ final Composite panel = new Composite(parent, SWT.NONE);
+ panel.setLayout(new GridLayout(2, false));
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ { // notation type editor
+ final Label lbl = new Label(panel, SWT.NONE);
+ lbl.setText(CndMessages.notationTypeLabel);
+
+ this.cbxNotationType = new Combo(panel, SWT.NONE);
+ this.cbxNotationType.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ this.cbxNotationType.setItems(new String[] { CndElement.NotationType.LONG.toString(),
+ CndElement.NotationType.COMPRESSED.toString(), CndElement.NotationType.COMPACT.toString() });
+ this.cbxNotationType.setToolTipText(CndMessages.notationTypeToolTip);
+
+ // set current value
+ this.notationType = JcrPreferenceStore.get().get(CndPreference.NOTATION_TYPE);
+
+ if (this.notationType == null) {
+ this.notationType = CndElement.NotationType.LONG.toString();
+ }
+
+ this.cbxNotationType.setText(this.notationType);
+
+ // add selection listener
+ this.cbxNotationType.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ handleNotationTypeChanged();
+ }
+ });
+ }
+
+ { // quote chars
+// final Label lbl = new Label(panel, SWT.NONE);
+// lbl.setText(CndMessages.quoteCharPolicyLabel);
+//
+// this.cbxQuoteChar = new Combo(panel, SWT.NONE);
+// this.cbxQuoteChar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+// this.cbxQuoteChar.setItems(QUOTE_CHAR_LABELS);
+// this.cbxQuoteChar.setToolTipText(CndMessages.quoteCharPolicyToolTip);
+//
+// // set current value
+// this.quoteString = JcrPreferenceStore.get().get(CndPreference.QUOTE_CHAR);
+//
+// if (Utils.DOUBLE_QUOTE.equals(this.quoteString)) {
+// this.cbxQuoteChar.setText(CndMessages.quoteCharDoubleChoiceLabel);
+// } else if (Utils.SINGLE_QUOTE.equals(this.quoteString)) {
+// this.cbxQuoteChar.setText(CndMessages.quoteCharSingleChoiceLabel);
+// } else {
+// this.cbxQuoteChar.setText(CndMessages.quoteCharNoneChoiceLabel);
+// }
+//
+// // add selection listener
+// this.cbxQuoteChar.addSelectionListener(new SelectionAdapter() {
+//
+// /**
+// * {@inheritDoc}
+// *
+// * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+// */
+// @Override
+// public void widgetSelected( final SelectionEvent e ) {
+// handleQuotationCharacterChanged();
+// }
+// });
+ }
+
+ return panel;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ return CndMessages.cndPrefPageDescription;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return JcrUiUtils.getCndEditorImage();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return CndMessages.cndPrefPageMessage;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#getPreferenceStore()
+ */
+ @Override
+ public IPreferenceStore getPreferenceStore() {
+ return null;
+ }
+//
+// private String getQuoteStringFromSelection() {
+// final String quoteSelection = this.cbxQuoteChar.getText();
+//
+// if (CndMessages.quoteCharNoneChoiceLabel.equals(quoteSelection)) {
+// return Utils.EMPTY_STRING;
+// }
+//
+// if (CndMessages.quoteCharSingleChoiceLabel.equals(quoteSelection)) {
+// return Utils.SINGLE_QUOTE;
+// }
+//
+// return Utils.DOUBLE_QUOTE;
+// }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.DialogPage#getTitle()
+ */
+ @Override
+ public String getTitle() {
+ return CndMessages.cndPrefPageTitle;
+ }
+
+ void handleNotationTypeChanged() {
+ this.notationType = this.cbxNotationType.getText();
+ }
+//
+// void handleQuotationCharacterChanged() {
+// this.quoteString = getQuoteStringFromSelection();
+// }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+ */
+ @Override
+ public void init( final IWorkbench workbench ) {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+ */
+ @Override
+ protected void performDefaults() {
+ final JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+
+ { // notation type
+ String defaultNotationType = prefStore.getDefault(CndPreference.NOTATION_TYPE);
+
+ if (defaultNotationType == null) {
+ defaultNotationType = CndElement.NotationType.LONG.toString();
+ }
+
+ this.notationType = defaultNotationType;
+ this.cbxNotationType.setText(defaultNotationType);
+ }
+
+ { // quote character
+// final String quoteSelection = prefStore.getDefault(CndPreference.QUOTE_CHAR);
+//
+// if (Utils.EMPTY_STRING.equals(quoteSelection)) {
+// this.cbxQuoteChar.setText(CndMessages.quoteCharNoneChoiceLabel);
+// } else if (Utils.SINGLE_QUOTE.equals(quoteSelection)) {
+// this.cbxQuoteChar.setText(CndMessages.quoteCharSingleChoiceLabel);
+// } else {
+// this.cbxQuoteChar.setText(CndMessages.quoteCharDoubleChoiceLabel);
+// }
+ }
+
+ super.performDefaults();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.preference.PreferencePage#performOk()
+ */
+ @Override
+ public boolean performOk() {
+ JcrPreferenceStore.get().set(CndPreference.NOTATION_TYPE, this.notationType);
+// JcrPreferenceStore.get().set(CndPreference.QUOTE_CHAR, this.quoteString);
+ return super.performOk();
+ }
+}
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/preferences/CndPreferencePage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndImporterTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -467,6 +467,16 @@
}
@Test
+ public void shouldParseEmptyNodeType() {
+ final String content = "[]"; //$NON-NLS-1$
+ this.cnd = this.importer.importFrom(content, this.problems, "string"); //$NON-NLS-1$
+
+ if (!this.problems.isEmpty()) {
+ printProblems();
+ }
+ }
+
+ @Test
public void shouldImportCndThatUsesAllFeatures() throws RepositoryException {
// this.importer.setDebug(true);
final String content = "<ex = 'http://namespace.com/ns'>\n" //$NON-NLS-1$
@@ -905,18 +915,6 @@
}
@Test(expected = ParsingException.class)
- public void shouldReportErrorIfTheNodeTypeNameIsBlank() {
- final String content = "<ns = 'http://namespace.com/ns'> [ ] abstract"; //$NON-NLS-1$
- this.importer.parse(content);
- }
-
- @Test(expected = ParsingException.class)
- public void shouldReportErrorIfTheNodeTypeNameIsEmpty() {
- final String content = "<ns = 'http://namespace.com/ns'> [] abstract"; //$NON-NLS-1$
- this.importer.parse(content);
- }
-
- @Test(expected = ParsingException.class)
public void shouldReportErrorIfTheNodeTypeNameIsNotFollowedByClosingBracket() {
final String content = "<ns = 'http://namespace.com/ns'> [ abstract"; //$NON-NLS-1$
this.importer.parse(content);
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -90,6 +90,15 @@
}
@Test
+ public void defaultTypeNameShoudMatchRequiredType() {
+ this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ this.childNodeDefinition.addRequiredType(Constants.QUALIFIED_NAME1.get());
+ this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.QUALIFIED_NAME2.get());
+ assertTrue(CndValidator.validateDefaultType(this.childNodeDefinition, Constants.Helper.getDefaultNamespacePrefixes())
+ .isError());
+ }
+
+ @Test
public void defaultTypeNameWithNonMatchingQualifierShouldBeAnError() {
this.childNodeDefinition.setName(Constants.QUALIFIED_NAME1.get());
this.childNodeDefinition.setDefaultPrimaryTypeName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
@@ -233,12 +242,6 @@
}
@Test
- public void nodeTypeDefinitionWithoutPropertiesAndChildNodesShouldBeAWarning() {
- this.nodeTypeDefinition.setName("name"); //$NON-NLS-1$
- assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition, null, null, false).isWarning());
- }
-
- @Test
public void nodeTypeNameWithNonMatchingQualifierShouldBeAnError() {
this.nodeTypeDefinition.setName(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
assertTrue(CndValidator.validateName(this.nodeTypeDefinition, Constants.Helper.getDefaultNamespacePrefixes(), null)
@@ -307,6 +310,14 @@
}
@Test
+ public void residualChildNodeDoesNotNeedDefaultType() {
+ this.childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
+ this.childNodeDefinition.addRequiredType(Constants.QUALIFIED_NAME1.get());
+ assertFalse(CndValidator.validateDefaultType(this.childNodeDefinition, Constants.Helper.getDefaultNamespacePrefixes())
+ .isError());
+ }
+
+ @Test
public void shouldAllowChildNodeDefinitionsWithResidualNames() {
this.childNodeDefinition.setName(ItemDefinition.RESIDUAL_NAME);
assertTrue(CndValidator.validateName(this.childNodeDefinition, null, null).isOk());
@@ -343,6 +354,20 @@
}
@Test
+ public void shouldNotAllowBuiltInPrefixWithIncorrectUri() {
+ this.namespaceMapping.setPrefix(Constants.BuiltInNamespaces.JCR.getPrefix());
+ this.namespaceMapping.setUri("foo"); //$NON-NLS-1$
+ assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ }
+
+ @Test
+ public void shouldNotAllowBuiltInUriWithIncorrectPrefix() {
+ this.namespaceMapping.setPrefix("foo"); //$NON-NLS-1$
+ this.namespaceMapping.setUri(Constants.BuiltInNamespaces.JCR.getUri());
+ assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ }
+
+ @Test
public void shouldNotAllowChildNodeDefinitionsWithSameName() {
this.nodeTypeDefinition.setName("nodeName"); //$NON-NLS-1$
this.childNodeDefinition.setName("name"); //$NON-NLS-1$
@@ -394,16 +419,6 @@
}
@Test
- public void superTypeNameWithNonMatchingQualifierShouldBeAnError() {
- this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
- this.nodeTypeDefinition.addSuperType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
- assertTrue(CndValidator.validateSuperTypes(this.nodeTypeDefinition.getName(),
- Constants.Helper.getDefaultNamespacePrefixes(),
- this.nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES),
- this.nodeTypeDefinition.getSupertypes()).isError());
- }
-
- @Test
public void shouldValidatePathsWithNoErrors() {
final String PROP_NAME = "testProperty"; //$NON-NLS-1$
assertFalse(CndValidator.validatePath("A", PROP_NAME).isError()); //$NON-NLS-1$
@@ -422,4 +437,14 @@
assertFalse(CndValidator.validatePath("/A/B/C[1]/././D[2]", PROP_NAME).isError()); //$NON-NLS-1$
assertFalse(CndValidator.validatePath("/A/B/C[1]/../D[2]/./E/..", PROP_NAME).isError()); //$NON-NLS-1$
}
+
+ @Test
+ public void superTypeNameWithNonMatchingQualifierShouldBeAnError() {
+ this.nodeTypeDefinition.setName(Constants.QUALIFIED_NAME1.get());
+ this.nodeTypeDefinition.addSuperType(Constants.NAME_WITH_NON_DEFAULT_QUALIFIER.get());
+ assertTrue(CndValidator.validateSuperTypes(this.nodeTypeDefinition.getName(),
+ Constants.Helper.getDefaultNamespacePrefixes(),
+ this.nodeTypeDefinition.getState(NodeTypeDefinition.PropertyName.SUPERTYPES),
+ this.nodeTypeDefinition.getSupertypes()).isError());
+ }
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -14,12 +14,14 @@
import org.jboss.tools.modeshape.jcr.NamespaceMapping;
import org.jboss.tools.modeshape.jcr.QualifiedName;
+import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.attributes.Abstract;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState;
import org.jboss.tools.modeshape.jcr.attributes.AttributeState.Value;
import org.jboss.tools.modeshape.jcr.attributes.Autocreated;
import org.jboss.tools.modeshape.jcr.attributes.DefaultType;
import org.jboss.tools.modeshape.jcr.attributes.DefaultValues;
+import org.jboss.tools.modeshape.jcr.attributes.ListAttributeState;
import org.jboss.tools.modeshape.jcr.attributes.Mandatory;
import org.jboss.tools.modeshape.jcr.attributes.Mixin;
import org.jboss.tools.modeshape.jcr.attributes.Multiple;
@@ -36,13 +38,44 @@
import org.jboss.tools.modeshape.jcr.attributes.SuperTypes;
import org.jboss.tools.modeshape.jcr.attributes.ValueConstraints;
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
-import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants.CndPreference;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
/**
*
*/
public interface Constants {
+ JcrPreferenceStore prefStore = JcrPreferenceStore.get();
+
+ interface Preferences {
+ // String ATTRIBUTE_LIST_ELEMENT_DELIMITER = ", "; //$NON-NLS-1$
+ // String ATTRIBUTE_LIST_ITEM_QUOTE_CHAR = Utils.EMPTY_STRING;
+ String CHILD_NODE_DEFINITION_END_PREFIX_DELIMITER = " "; //$NON-NLS-1$
+ String CHILD_NODE_PROPERTY_DELIMITER = Utils.SPACE_STRING;
+ String DEFAULT_VALUES_END_PREFIX_DELIMITER = Utils.SPACE_STRING;
+ String DEFAULT_VALUES_QUOTE_CHARACTER = "'"; //$NON-NLS-1$
+ String DEFAULT_TYPE_END_PREFIX_DELIMITER = Utils.SPACE_STRING;
+ String ATTRIBUTE_LIST_PREFIX_END_DELIMITER = Utils.SPACE_STRING;
+ // String ATTRIBUTE_LIST_QUOTE_CHAR = Utils.EMPTY_STRING;
+ String ELEMENT_DELIMITER = "\n"; //$NON-NLS-1$
+ String ELEMENTS_END_DELIMITER = Utils.EMPTY_STRING;
+ String ELEMENTS_START_DELIMITER = "\t"; //$NON-NLS-1$
+ String NAMESPACE_MAPPING_DELIMITER = "\n"; //$NON-NLS-1$
+ String NAMESPACE_MAPPING_SECTION_END_DELIMITER = "\n"; //$NON-NLS-1$
+ String CHILD_NODE_ATTRIBUTES_DELIMITER = Utils.SPACE_STRING;
+ String NODE_TYPE_DEFINITION_ATTRIBUTES_DELIMITER = Utils.SPACE_STRING;
+ String NODE_TYPE_DEFINITION_ATTRIBUTES_END_DELIMITER = "\n"; //$NON-NLS-1$
+ String NODE_TYPE_DEFINITION_DELIMITER = "\n"; //$NON-NLS-1$
+ String NODE_TYPE_DEFINITION_NAME_END_DELIMITER = Utils.SPACE_STRING;
+ String NODE_TYPE_DEFINITION_SECTION_END_DELIMITER = "\n"; //$NON-NLS-1$
+ String PROPERTY_DEFINITION_ATTRIBUTES_DELIMITER = Utils.SPACE_STRING;
+ String PROPERTY_DEFINITION_END_PREFIX_DELIMITER = Utils.SPACE_STRING;
+ String REQUIRED_TYPES_END_PREFIX_DELIMITER = Utils.EMPTY_STRING;
+ String SUPER_TYPES_END_DELIMITER = Utils.SPACE_STRING;
+ // String VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER = "'"; //$NON-NLS-1$
+ }
+
String NAMESPACE_PREFIX1 = "NAMESPACE_PREFIX1"; //$NON-NLS-1$
String NAMESPACE_PREFIX2 = "NAMESPACE_PREFIX2"; //$NON-NLS-1$
String NAMESPACE_PREFIX3 = "NAMESPACE_PREFIX3"; //$NON-NLS-1$
@@ -85,11 +118,11 @@
String AUTOCREATED_VARIANT_COMPRESSED_FORM = Autocreated.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
String AUTOCREATED_VARIANT_LONG_FORM = Autocreated.NOTATION[NotationType.LONG_INDEX] + VARIANT;
- String DEFAULT_TYPE_VARIANT_FORM = DefaultType.NOTATION
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER) + VARIANT;
+ String DEFAULT_TYPE_VARIANT_FORM = DefaultType.NOTATION + Preferences.DEFAULT_TYPE_END_PREFIX_DELIMITER + VARIANT;
+ String DEFAULT_TYPE_VARIANT_SHORT_FORM = DefaultType.NOTATION + VARIANT;
String DEFAULT_TYPE = "jcr:data"; //$NON-NLS-1$
- String DEFAULT_TYPE_TYPE_FORM = DefaultType.NOTATION
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_TYPE_END_PREFIX_DELIMITER) + DEFAULT_TYPE;
+ String DEFAULT_TYPE_TYPE_FORM = DefaultType.NOTATION + Preferences.DEFAULT_TYPE_END_PREFIX_DELIMITER + DEFAULT_TYPE;
+ String DEFAULT_TYPE_TYPE_SHORT_FORM = DefaultType.NOTATION + DEFAULT_TYPE;
String MANDATORY_VARIANT_COMPACT_FORM = Mandatory.NOTATION[NotationType.COMPACT_INDEX] + VARIANT;
String MANDATORY_VARIANT_COMPRESSED_FORM = Mandatory.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
@@ -127,12 +160,9 @@
String PROTECTED_VARIANT_COMPRESSED_FORM = Protected.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
String PROTECTED_VARIANT_LONG_FORM = Protected.NOTATION[NotationType.LONG_INDEX] + VARIANT;
- String QUERY_OPS_COMPACT_FORM = QueryOperators.NOTATION[NotationType.COMPACT_INDEX]
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
- String QUERY_OPS_COMPRESSED_FORM = QueryOperators.NOTATION[NotationType.COMPRESSED_INDEX]
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
- String QUERY_OPS_LONG_FORM = QueryOperators.NOTATION[NotationType.LONG_INDEX]
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER);
+ String QUERY_OPS_COMPACT_FORM = QueryOperators.NOTATION[NotationType.COMPACT_INDEX] + Utils.SPACE_STRING;
+ String QUERY_OPS_COMPRESSED_FORM = QueryOperators.NOTATION[NotationType.COMPRESSED_INDEX] + Utils.SPACE_STRING;
+ String QUERY_OPS_LONG_FORM = QueryOperators.NOTATION[NotationType.LONG_INDEX] + Utils.SPACE_STRING;
String QUERY_OPS_VARIANT_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + VARIANT;
String QUERY_OPS_VARIANT_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM + VARIANT;
String QUERY_OPS_VARIANT_LONG_FORM = QUERY_OPS_LONG_FORM + VARIANT;
@@ -142,42 +172,26 @@
QueryOperator OPERATOR_THREE = QueryOperator.LESS_THAN;
QueryOperator[] DEFAULT_OPERATORS = new QueryOperator[] { OPERATOR_ONE, OPERATOR_TWO, OPERATOR_THREE };
- String QUERY_OPS_ONE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + OPERATOR_ONE.toCndNotation(NotationType.COMPACT)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
- String QUERY_OPS_ONE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ String QUERY_OPS_ONE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + Utils.SINGLE_QUOTE
+ + OPERATOR_ONE.toCndNotation(NotationType.COMPACT) + Utils.SINGLE_QUOTE;
+ String QUERY_OPS_ONE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM + Utils.SINGLE_QUOTE
+ + OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED) + Utils.SINGLE_QUOTE;
+ String QUERY_OPS_ONE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM + Utils.SINGLE_QUOTE
+ + OPERATOR_ONE.toCndNotation(NotationType.LONG) + Utils.SINGLE_QUOTE;
+ String QUERY_OPS_THREE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM + Utils.SINGLE_QUOTE
+ + OPERATOR_ONE.toCndNotation(NotationType.COMPACT) + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX]
+ + OPERATOR_TWO.toCndNotation(NotationType.COMPACT) + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX]
+ + OPERATOR_THREE.toCndNotation(NotationType.COMPACT) + Utils.SINGLE_QUOTE;
+ String QUERY_OPS_THREE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM + Utils.SINGLE_QUOTE
+ OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
- String QUERY_OPS_ONE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + OPERATOR_ONE.toCndNotation(NotationType.LONG)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
- String QUERY_OPS_THREE_OPERATOR_COMPACT_FORM = QUERY_OPS_COMPACT_FORM
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + OPERATOR_ONE.toCndNotation(NotationType.COMPACT)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + OPERATOR_TWO.toCndNotation(NotationType.COMPACT)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + OPERATOR_THREE.toCndNotation(NotationType.COMPACT)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
- String QUERY_OPS_THREE_OPERATOR_COMPRESSED_FORM = QUERY_OPS_COMPRESSED_FORM
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + OPERATOR_ONE.toCndNotation(NotationType.COMPRESSED)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPRESSED_INDEX]
+ OPERATOR_TWO.toCndNotation(NotationType.COMPRESSED)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + OPERATOR_THREE.toCndNotation(NotationType.COMPRESSED)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
- String QUERY_OPS_THREE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + OPERATOR_ONE.toCndNotation(NotationType.LONG)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + OPERATOR_TWO.toCndNotation(NotationType.LONG)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + OPERATOR_THREE.toCndNotation(NotationType.LONG)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPRESSED_INDEX]
+ + OPERATOR_THREE.toCndNotation(NotationType.COMPRESSED) + Utils.SINGLE_QUOTE;
+ String QUERY_OPS_THREE_OPERATOR_LONG_FORM = QUERY_OPS_LONG_FORM + Utils.SINGLE_QUOTE
+ + OPERATOR_ONE.toCndNotation(NotationType.LONG) + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX]
+ + OPERATOR_TWO.toCndNotation(NotationType.LONG) + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX]
+ + OPERATOR_THREE.toCndNotation(NotationType.LONG) + Utils.SINGLE_QUOTE;
String SAME_NAME_SIBLINGS_VARIANT_COMPACT_FORM = SameNameSiblings.NOTATION[NotationType.COMPACT_INDEX] + VARIANT;
String SAME_NAME_SIBLINGS_VARIANT_COMPRESSED_FORM = SameNameSiblings.NOTATION[NotationType.COMPRESSED_INDEX] + VARIANT;
@@ -186,76 +200,75 @@
String ITEM_ONE = "item1"; //$NON-NLS-1$
String ITEM_TWO = "item2"; //$NON-NLS-1$
String ITEM_THREE = "item3"; //$NON-NLS-1$
- String ONE_ITEM_SINGLE_QUOTED_FORM = CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
- + ITEM_ONE + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
- String THREE_ITEM_SINGLE_QUOTED_FORM = CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
- + ITEM_ONE + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER) + ITEM_TWO
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER) + ITEM_THREE
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
+ String ONE_ITEM_SINGLE_QUOTED_FORM = prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_ONE
+ + prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
+ String THREE_ITEM_SINGLE_QUOTED_FORM = prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_ONE
+ + prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX]
+ + prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_TWO
+ + prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX]
+ + prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_THREE
+ + prefStore.get(CndPreference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR);
- String DEFAULT_VALUES_VARIANT = DefaultValues.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER) + VARIANT;
- String DEFAULT_VALUES_ONE_ITEM_FORM = DefaultValues.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_ONE
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
- String DEFAULT_VALUES_THREE_ITEM_FORM = DefaultValues.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_END_PREFIX_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_ONE
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_TWO
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR) + ITEM_THREE
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ITEM_QUOTE_CHAR)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.DEFAULT_VALUES_QUOTE_CHARACTER);
+ String DEFAULT_VALUES_VARIANT = DefaultValues.NOTATION_PREFIX + Preferences.DEFAULT_VALUES_END_PREFIX_DELIMITER + VARIANT;
+ String DEFAULT_VALUES_SHORT_VARIANT = DefaultValues.NOTATION_PREFIX + VARIANT;
+ String DEFAULT_VALUES_ONE_ITEM_FORM = DefaultValues.NOTATION_PREFIX + Preferences.DEFAULT_VALUES_END_PREFIX_DELIMITER
+ + Utils.SINGLE_QUOTE + ITEM_ONE + Utils.SINGLE_QUOTE;
+ String DEFAULT_VALUES_ONE_ITEM_SHORT_FORM = DefaultValues.NOTATION_PREFIX + Utils.SINGLE_QUOTE + ITEM_ONE + Utils.SINGLE_QUOTE;
+ String DEFAULT_VALUES_THREE_ITEM_FORM = DefaultValues.NOTATION_PREFIX + Preferences.DEFAULT_VALUES_END_PREFIX_DELIMITER
+ + Utils.SINGLE_QUOTE + ITEM_ONE + Utils.SINGLE_QUOTE + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX]
+ + Utils.SINGLE_QUOTE + ITEM_TWO + Utils.SINGLE_QUOTE + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX]
+ + Utils.SINGLE_QUOTE + ITEM_THREE + Utils.SINGLE_QUOTE;
+ String DEFAULT_VALUES_THREE_ITEM_SHORT_FORM = DefaultValues.NOTATION_PREFIX + Utils.SINGLE_QUOTE + ITEM_ONE
+ + Utils.SINGLE_QUOTE + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX] + Utils.SINGLE_QUOTE
+ + ITEM_TWO + Utils.SINGLE_QUOTE + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX]
+ + Utils.SINGLE_QUOTE + ITEM_THREE + Utils.SINGLE_QUOTE;
- String REQUIRED_TYPES_VARIANT = RequiredTypes.NOTATION_PREFIX + VARIANT + RequiredTypes.NOTATION_SUFFIX;
- String REQUIRED_TYPES_ONE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX + QUALIFIED_NAME1 + RequiredTypes.NOTATION_SUFFIX;
- String REQUIRED_TYPES_THREE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX + QUALIFIED_NAME1
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER) + QUALIFIED_NAME2
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER) + QUALIFIED_NAME3
- + RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_SHORT_VARIANT = RequiredTypes.NOTATION_PREFIX + VARIANT + RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_VARIANT = RequiredTypes.NOTATION_PREFIX + Utils.SPACE_STRING + VARIANT + RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_ONE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX + Utils.SPACE_STRING + QUALIFIED_NAME1 + RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_ONE_ITEM_SHORT_FORM = RequiredTypes.NOTATION_PREFIX + QUALIFIED_NAME1 + RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_THREE_ITEM_SHORT_FORM = RequiredTypes.NOTATION_PREFIX + QUALIFIED_NAME1
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX] + QUALIFIED_NAME2
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX] + QUALIFIED_NAME3 + RequiredTypes.NOTATION_SUFFIX;
+ String REQUIRED_TYPES_THREE_ITEM_FORM = RequiredTypes.NOTATION_PREFIX + Utils.SPACE_STRING + QUALIFIED_NAME1
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX] + QUALIFIED_NAME2
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX] + QUALIFIED_NAME3 + RequiredTypes.NOTATION_SUFFIX;
- String SUPER_TYPES_VARIANT = SuperTypes.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER) + VARIANT;
- String SUPER_TYPES_ONE_ITEM_FORM = SuperTypes.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER) + QUALIFIED_NAME1;
- String SUPER_TYPES_THREE_ITEM_FORM = SuperTypes.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER) + QUALIFIED_NAME1
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER) + QUALIFIED_NAME2
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER) + QUALIFIED_NAME3;
+ String SUPER_TYPES_VARIANT = SuperTypes.NOTATION_PREFIX + Preferences.ATTRIBUTE_LIST_PREFIX_END_DELIMITER + VARIANT;
+ String SUPER_TYPES_SHORT_VARIANT = SuperTypes.NOTATION_PREFIX + VARIANT;
+ String SUPER_TYPES_ONE_ITEM_FORM = SuperTypes.NOTATION_PREFIX + Preferences.ATTRIBUTE_LIST_PREFIX_END_DELIMITER
+ + QUALIFIED_NAME1;
+ String SUPER_TYPES_ONE_ITEM_SHORT_FORM = SuperTypes.NOTATION_PREFIX + QUALIFIED_NAME1;
+ String SUPER_TYPES_THREE_ITEM_FORM = SuperTypes.NOTATION_PREFIX + Preferences.ATTRIBUTE_LIST_PREFIX_END_DELIMITER
+ + QUALIFIED_NAME1 + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX] + QUALIFIED_NAME2
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX] + QUALIFIED_NAME3;
+ String SUPER_TYPES_THREE_ITEM_SHORT_FORM = SuperTypes.NOTATION_PREFIX + QUALIFIED_NAME1
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX] + QUALIFIED_NAME2
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX] + QUALIFIED_NAME3;
String VALUE_CONSTRAINT1 = "(19|20)\\d{2}"; //$NON-NLS-1$
String VALUE_CONSTRAINT2 = "[$]\\d{1,3}[,]?\\d{3}([.]\\d{2})?"; //$NON-NLS-1$
String VALUE_CONSTRAINT3 = "[1,5]"; //$NON-NLS-1$
- String[] DEFAULT_VALUE_CONSTRAINTS = new String[] {VALUE_CONSTRAINT1, VALUE_CONSTRAINT2, VALUE_CONSTRAINT3};
-
- String VALUE_CONSTRAINTS_VARIANT = ValueConstraints.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER) + VARIANT;
- String VALUE_CONSTRAINTS_ONE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER) + VALUE_CONSTRAINT1
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
- String VALUE_CONSTRAINTS_THREE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_PREFIX_END_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER) + VALUE_CONSTRAINT1
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER) + VALUE_CONSTRAINT2
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_ELEMENT_DELIMITER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER) + VALUE_CONSTRAINT3
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
- + CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
+ String[] DEFAULT_VALUE_CONSTRAINTS = new String[] { VALUE_CONSTRAINT1, VALUE_CONSTRAINT2, VALUE_CONSTRAINT3 };
+ String VALUE_CONSTRAINTS_VARIANT = ValueConstraints.NOTATION_PREFIX + Preferences.ATTRIBUTE_LIST_PREFIX_END_DELIMITER + VARIANT;
+ String VALUE_CONSTRAINTS_SHORT_VARIANT = ValueConstraints.NOTATION_PREFIX + VARIANT;
+ String VALUE_CONSTRAINTS_ONE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX + Preferences.ATTRIBUTE_LIST_PREFIX_END_DELIMITER
+ + Utils.SINGLE_QUOTE + VALUE_CONSTRAINT1 + Utils.SINGLE_QUOTE;
+ String VALUE_CONSTRAINTS_ONE_ITEM_SHORT_FORM = ValueConstraints.NOTATION_PREFIX + Utils.SINGLE_QUOTE + VALUE_CONSTRAINT1
+ + Utils.SINGLE_QUOTE;
+ String VALUE_CONSTRAINTS_THREE_ITEM_FORM = ValueConstraints.NOTATION_PREFIX + Preferences.ATTRIBUTE_LIST_PREFIX_END_DELIMITER
+ + Utils.SINGLE_QUOTE + VALUE_CONSTRAINT1 + Utils.SINGLE_QUOTE
+ + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX] + Utils.SINGLE_QUOTE + VALUE_CONSTRAINT2
+ + Utils.SINGLE_QUOTE + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.LONG_INDEX] + Utils.SINGLE_QUOTE
+ + VALUE_CONSTRAINT3 + Utils.SINGLE_QUOTE;
+ String VALUE_CONSTRAINTS_THREE_ITEM_SHORT_FORM = ValueConstraints.NOTATION_PREFIX + Utils.SINGLE_QUOTE + VALUE_CONSTRAINT1
+ + Utils.SINGLE_QUOTE + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX] + Utils.SINGLE_QUOTE
+ + VALUE_CONSTRAINT2 + Utils.SINGLE_QUOTE + ListAttributeState.ITEM_DELIM_NOTATION[NotationType.COMPACT_INDEX]
+ + Utils.SINGLE_QUOTE + VALUE_CONSTRAINT3 + Utils.SINGLE_QUOTE;
+
class Helper {
public static void changeValue( AttributeState attribute ) {
if (attribute.is()) {
@@ -278,7 +291,7 @@
public static String[] getDefaultQualifiedNamesAsStringArray() {
String[] names = new String[DEFAULT_QUALIFIED_NAMES.length];
int i = 0;
-
+
for (QualifiedName qname : DEFAULT_QUALIFIED_NAMES) {
names[i++] = qname.get();
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/LocalNameTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/LocalNameTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/LocalNameTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -14,6 +14,8 @@
import org.jboss.tools.modeshape.jcr.LocalName;
import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceConstants;
+import org.jboss.tools.modeshape.jcr.preference.JcrPreferenceStore;
import org.junit.Before;
import org.junit.Test;
@@ -30,29 +32,6 @@
}
@Test
- public void differentModesDifferentValuesShouldNotBeEqual() {
- final String VALUE = "value"; //$NON-NLS-1$
- this.localName.set(VALUE);
- final LocalName thatLocalName = new LocalName(VALUE + "Changed"); //$NON-NLS-1$
- thatLocalName.setMode(LocalName.Mode.DOUBLE_QUOTED);
- assertFalse(this.localName.equals(thatLocalName));
- }
-
- @Test
- public void differentModesSameValuesShouldBeEqual() {
- final String VALUE = "value"; //$NON-NLS-1$
- this.localName.set(VALUE);
- final LocalName thatLocalName = new LocalName(VALUE);
- thatLocalName.setMode(LocalName.Mode.DOUBLE_QUOTED);
- assertTrue(this.localName.equals(thatLocalName));
- }
-
- @Test
- public void initialModeShouldBeUnquoted() {
- assertTrue(this.localName.isUnquoted());
- }
-
- @Test
public void initialValueShouldBeCorrectWhenSet() {
final String INITIAL_VALUE = "initialValue"; //$NON-NLS-1$
this.localName = new LocalName(INITIAL_VALUE);
@@ -60,8 +39,8 @@
}
@Test
- public void initialValueShouldBeNull() {
- assertNull(this.localName.get());
+ public void initialValueShouldBeEmpty() {
+ assertEquals(Utils.EMPTY_STRING, this.localName.get());
}
@Test
@@ -84,7 +63,7 @@
public void shouldHaveCorrectDoubleQuotedCndNotation() {
final String VALUE = "value"; //$NON-NLS-1$
this.localName.set(VALUE);
- this.localName.setMode(LocalName.Mode.DOUBLE_QUOTED);
+ JcrPreferenceStore.get().set(JcrPreferenceConstants.CndPreference.QUOTE_CHAR, Utils.DOUBLE_QUOTE);
assertEquals('"' + VALUE + '"', this.localName.toCndNotation(null));
}
@@ -92,13 +71,14 @@
public void shouldHaveCorrectSingleQuotedCndNotation() {
final String VALUE = "value"; //$NON-NLS-1$
this.localName.set(VALUE);
- this.localName.setMode(LocalName.Mode.SINGLE_QUOTED);
+ JcrPreferenceStore.get().set(JcrPreferenceConstants.CndPreference.QUOTE_CHAR, Utils.SINGLE_QUOTE);
assertEquals('\'' + VALUE + '\'', this.localName.toCndNotation(null));
}
@Test
public void shouldHaveCorrectUnquotedCndNotation() {
final String VALUE = "value"; //$NON-NLS-1$
+ JcrPreferenceStore.get().set(JcrPreferenceConstants.CndPreference.QUOTE_CHAR, Utils.EMPTY_STRING);
this.localName.set(VALUE);
assertEquals(VALUE, this.localName.toCndNotation(null));
}
@@ -115,38 +95,14 @@
}
@Test
- public void shouldNotSetModeToSameValue() {
- assertFalse(this.localName.setMode(LocalName.Mode.UNQOUTED));
- }
-
- @Test
public void shouldQuoteIfContainsSpacesAndModeIsUnquoted() {
final String NEW_VALUE = "new value"; //$NON-NLS-1$
this.localName.set(NEW_VALUE);
- assertTrue(this.localName.isUnquoted());
+ JcrPreferenceStore.get().set(JcrPreferenceConstants.CndPreference.QUOTE_CHAR, Utils.EMPTY_STRING);
assertEquals('\'' + NEW_VALUE + '\'', this.localName.toCndNotation(null));
}
@Test
- public void shouldSetModeToDoubleQuoted() {
- assertTrue(this.localName.setMode(LocalName.Mode.DOUBLE_QUOTED));
- assertTrue(this.localName.isDoubleQuoted());
- }
-
- @Test
- public void shouldSetModeToSingleQuoted() {
- assertTrue(this.localName.setMode(LocalName.Mode.SINGLE_QUOTED));
- assertTrue(this.localName.isSingleQuoted());
- }
-
- @Test
- public void shouldSetModeToUnquoted() {
- this.localName.setMode(LocalName.Mode.SINGLE_QUOTED);
- assertTrue(this.localName.setMode(LocalName.Mode.UNQOUTED));
- assertTrue(this.localName.isUnquoted());
- }
-
- @Test
public void shouldSetValue() {
final String NEW_VALUE = "newValue"; //$NON-NLS-1$
this.localName.set(NEW_VALUE);
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/WorkspaceRegistryTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import org.jboss.tools.modeshape.jcr.NamespaceMapping;
import org.jboss.tools.modeshape.jcr.PropertyDefinition;
import org.jboss.tools.modeshape.jcr.WorkspaceRegistry;
import org.junit.Before;
@@ -34,6 +35,9 @@
@Test
public void jcrNamespaceShouldBeRegistered() {
+ assertTrue(this.registry.isBuiltIn(new NamespaceMapping(Constants.BuiltInNamespaces.JCR.getPrefix(),
+ Constants.BuiltInNamespaces.JCR.getUri())));
+ assertTrue(this.registry.isBuiltInNamespacePrefix(Constants.BuiltInNamespaces.JCR.getPrefix()));
assertNotNull(this.registry.getNamespaceMapping(Constants.BuiltInNamespaces.JCR.getPrefix()));
assertEquals(Constants.BuiltInNamespaces.JCR.getPrefix(), this.registry.getPrefix(Constants.BuiltInNamespaces.JCR.getUri()));
assertEquals(Constants.BuiltInNamespaces.JCR.getUri(), this.registry.getUri(Constants.BuiltInNamespaces.JCR.getPrefix()));
@@ -41,6 +45,9 @@
@Test
public void mixNamespaceShouldBeRegistered() {
+ assertTrue(this.registry.isBuiltIn(new NamespaceMapping(Constants.BuiltInNamespaces.MIX.getPrefix(),
+ Constants.BuiltInNamespaces.MIX.getUri())));
+ assertTrue(this.registry.isBuiltInNamespacePrefix(Constants.BuiltInNamespaces.MIX.getPrefix()));
assertNotNull(this.registry.getNamespaceMapping(Constants.BuiltInNamespaces.MIX.getPrefix()));
assertEquals(Constants.BuiltInNamespaces.MIX.getPrefix(), this.registry.getPrefix(Constants.BuiltInNamespaces.MIX.getUri()));
assertEquals(Constants.BuiltInNamespaces.MIX.getUri(), this.registry.getUri(Constants.BuiltInNamespaces.MIX.getPrefix()));
@@ -48,6 +55,9 @@
@Test
public void ntNamespaceShouldBeRegistered() {
+ assertTrue(this.registry.isBuiltIn(new NamespaceMapping(Constants.BuiltInNamespaces.NT.getPrefix(),
+ Constants.BuiltInNamespaces.NT.getUri())));
+ assertTrue(this.registry.isBuiltInNamespacePrefix(Constants.BuiltInNamespaces.NT.getPrefix()));
assertNotNull(this.registry.getNamespaceMapping(Constants.BuiltInNamespaces.NT.getPrefix()));
assertEquals(Constants.BuiltInNamespaces.NT.getPrefix(), this.registry.getPrefix(Constants.BuiltInNamespaces.NT.getUri()));
assertEquals(Constants.BuiltInNamespaces.NT.getUri(), this.registry.getUri(Constants.BuiltInNamespaces.NT.getPrefix()));
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultTypeTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultTypeTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultTypeTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -45,13 +45,13 @@
@Test
public void verifyCompactCndNotation() {
this.attribute.setDefaultType(DEFAULT_TYPE);
- assertEquals(DEFAULT_TYPE_TYPE_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(DEFAULT_TYPE_TYPE_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
}
@Test
public void verifyCompressedCndNotation() {
this.attribute.setDefaultType(DEFAULT_TYPE);
- assertEquals(DEFAULT_TYPE_TYPE_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(DEFAULT_TYPE_TYPE_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
}
@Test
@@ -63,13 +63,13 @@
@Test
public void verifyVariantCompactCndNotation() {
this.attribute.set(AttributeState.Value.VARIANT);
- assertEquals(DEFAULT_TYPE_VARIANT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(DEFAULT_TYPE_VARIANT_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
}
@Test
public void verifyVariantCompressedCndNotation() {
this.attribute.set(AttributeState.Value.VARIANT);
- assertEquals(DEFAULT_TYPE_VARIANT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(DEFAULT_TYPE_VARIANT_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
}
@Test
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValuesTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValuesTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/DefaultValuesTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -79,8 +79,8 @@
add(ITEM_THREE);
// tests
- assertEquals(DEFAULT_VALUES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(DEFAULT_VALUES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(DEFAULT_VALUES_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(DEFAULT_VALUES_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(DEFAULT_VALUES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -90,8 +90,8 @@
add(ITEM_ONE);
// tests
- assertEquals(DEFAULT_VALUES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(DEFAULT_VALUES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(DEFAULT_VALUES_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(DEFAULT_VALUES_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(DEFAULT_VALUES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -145,8 +145,8 @@
this.attribute.set(AttributeState.Value.VARIANT);
// tests
- assertEquals(DEFAULT_VALUES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(DEFAULT_VALUES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(DEFAULT_VALUES_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(DEFAULT_VALUES_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(DEFAULT_VALUES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/RequiredTypesTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -80,8 +80,8 @@
add(QUALIFIED_NAME3);
// tests
- assertEquals(REQUIRED_TYPES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(REQUIRED_TYPES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(REQUIRED_TYPES_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(REQUIRED_TYPES_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(REQUIRED_TYPES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -91,8 +91,8 @@
add(QUALIFIED_NAME1);
// tests
- assertEquals(REQUIRED_TYPES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(REQUIRED_TYPES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(REQUIRED_TYPES_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(REQUIRED_TYPES_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(REQUIRED_TYPES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -146,8 +146,8 @@
this.attribute.set(AttributeState.Value.VARIANT);
// tests
- assertEquals(REQUIRED_TYPES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(REQUIRED_TYPES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(REQUIRED_TYPES_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(REQUIRED_TYPES_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(REQUIRED_TYPES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/SuperTypesTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -80,8 +80,8 @@
add(QUALIFIED_NAME3);
// tests
- assertEquals(SUPER_TYPES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(SUPER_TYPES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(SUPER_TYPES_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(SUPER_TYPES_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(SUPER_TYPES_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -91,8 +91,8 @@
add(QUALIFIED_NAME1);
// tests
- assertEquals(SUPER_TYPES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(SUPER_TYPES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(SUPER_TYPES_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(SUPER_TYPES_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(SUPER_TYPES_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -146,8 +146,8 @@
this.attribute.set(AttributeState.Value.VARIANT);
// tests
- assertEquals(SUPER_TYPES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(SUPER_TYPES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(SUPER_TYPES_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(SUPER_TYPES_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(SUPER_TYPES_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
Modified: trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraintsTest.java
===================================================================
--- trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraintsTest.java 2012-04-09 17:14:21 UTC (rev 40100)
+++ trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/attributes/ValueConstraintsTest.java 2012-04-09 21:36:05 UTC (rev 40101)
@@ -79,8 +79,8 @@
add(VALUE_CONSTRAINT3);
// tests
- assertEquals(VALUE_CONSTRAINTS_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(VALUE_CONSTRAINTS_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(VALUE_CONSTRAINTS_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(VALUE_CONSTRAINTS_THREE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(VALUE_CONSTRAINTS_THREE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -90,8 +90,8 @@
add(VALUE_CONSTRAINT1);
// tests
- assertEquals(VALUE_CONSTRAINTS_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(VALUE_CONSTRAINTS_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(VALUE_CONSTRAINTS_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(VALUE_CONSTRAINTS_ONE_ITEM_SHORT_FORM, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(VALUE_CONSTRAINTS_ONE_ITEM_FORM, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
@@ -145,8 +145,8 @@
this.attribute.set(AttributeState.Value.VARIANT);
// tests
- assertEquals(VALUE_CONSTRAINTS_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
- assertEquals(VALUE_CONSTRAINTS_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
+ assertEquals(VALUE_CONSTRAINTS_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPACT));
+ assertEquals(VALUE_CONSTRAINTS_SHORT_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.COMPRESSED));
assertEquals(VALUE_CONSTRAINTS_VARIANT, this.attribute.toCndNotation(CndElement.NotationType.LONG));
}
13 years, 8 months