Author: elvisisking
Date: 2012-03-15 11:55:37 -0400 (Thu, 15 Mar 2012)
New Revision: 39542
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.classpath
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.project
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.jdt.core.prefs
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.pde.core.prefs
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/bundle.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/build.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/cnd-editor-16x.png
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/delete-16x.gif
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/edit-16x.png
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/new-16x.gif
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/pom.xml
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/Activator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiUtils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/UiConstants.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/
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/CndEditorPage.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/cndMessages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.classpath
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.project
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.jdt.core.prefs
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.pde.core.prefs
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/OSGI-INF/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/OSGI-INF/l10n/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/OSGI-INF/l10n/bundle.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/build.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/delete-16x.gif
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/edit-16x.png
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.gif
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/pom.xml
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/Activator.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/ErrorMessage.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageFormDialog.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/graphics/
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/graphics/GraphicsUtils.java
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/
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/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/messages.properties
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/
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
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. First version of CND GUI
editor. The editor is not complete. The dialogs to add/edit property definitions, child
node definitions, namespace mappings, and node type definitions have not been implemented
yet. Also, some event handling within the editor still needs implementing.
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-03-15
15:40:34 UTC (rev 39541)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/Messages.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -53,8 +53,8 @@
public static String duplicateChildNodeDefinitionName;
/**
- * A message indicating a property definition has duplicate default values.
Parameters for the duplicate value and the property
- * definition name are required.
+ * A message indicating a property definition has duplicate default values. Two
parameters, the property definition name and the
+ * duplicate value, are required.
*/
public static String duplicateDefaultValue;
@@ -187,17 +187,18 @@
public static String invalidGetStateRequest;
/**
- * A message indicating an invalid query operator CND notation was found. One
parameter, the invalid value, is required.
- */
- public static String invalidQueryOperator;
-
- /**
* A message indicating an invalid property valid was found. The parameters of
invalid property value, property type, and
* property definition name are required.
*/
public static String invalidPropertyValueForType;
/**
+ * A message indicating an invalid query operator CND notation was found. Two
parameters, the invalid value and the property
+ * definition name, are required.
+ */
+ public static String invalidQueryOperator;
+
+ /**
* A message indicating an invalid URI was found. One parameter, the invalid URI, is
required.
*/
public static String invalidUri;
@@ -230,6 +231,12 @@
public static String multipleKeywordNotValidInJcr2CndFormat;
/**
+ * A message indicating the qualifier of a qualified name is not a namespace mapping
prefix in the CND. Two parameters, the
+ * name/type of the qualified name and the qualifier, are required.
+ */
+ public static String nameQualifierNotFound;
+
+ /**
* A message used for the namespace prefix attribute.
*/
public static String namespacePrefix;
@@ -251,14 +258,14 @@
public static String nodeTypeDefinitionName;
/**
- * A message indicating no errors, warnings, or info validation messages were found.
+ * A message indicating a <code>null</code> was found. One parameter, a
string identifying the object, is required.
*/
- public static String okValidationMsg;
+ public static String objectIsNull;
/**
- * A message indicating a <code>null</code> was found. One parameter, a
string identifying the object, is required.
+ * A message indicating no errors, warnings, or info validation messages were found.
*/
- public static String objectIsNull;
+ public static String okValidationMsg;
/**
* A message indicating a node type definition has a primary item but has been marked
as a variant. One parameter, the node type
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-03-15
15:40:34 UTC (rev 39541)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndImporter.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -704,7 +704,8 @@
if (operator != null) {
operators.add(operatorValue);
} else {
- throw new ParsingException(tokens.previousPosition(),
NLS.bind(Messages.invalidQueryOperator, operator));
+ throw new ParsingException(tokens.previousPosition(),
NLS.bind(Messages.invalidQueryOperator, operator,
+
propDefn.getName()));
}
}
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-03-15
15:40:34 UTC (rev 39541)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/cnd/CndValidator.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -763,7 +763,7 @@
for (final String operator : queryOperators) {
// ERROR - Invalid query operator
- validateQueryOperator(operator, status);
+ validateQueryOperator(operator, propertyDefinitionName, status);
if (!Utils.isEmpty(operator)) {
// ERROR - Duplicate query operator
@@ -866,7 +866,7 @@
* @return the status (never <code>null</code>)
*/
public static MultiValidationStatus validateQualifiedName( final QualifiedName
qname,
- String propertyName ) {
+ final String propertyName
) {
Utils.verifyIsNotNull(qname, "qname"); //$NON-NLS-1$
final MultiValidationStatus status = new MultiValidationStatus();
@@ -887,7 +887,7 @@
final String unqualifiedName = qname.getUnqualifiedName();
if (Utils.isEmpty(unqualifiedName)) {
-
status.add(ValidationStatus.createErrorMessage(Messages.emptyUnqualifiedName));
+
status.add(ValidationStatus.createErrorMessage(Messages.emptyUnqualifiedName));
} else {
final ValidationStatus nameStatus = validateLocalName(unqualifiedName,
propertyName);
@@ -903,11 +903,50 @@
/**
* @param qname the qualified name being validated (cannot be
<code>null</code>)
* @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
+ * @return the status (never <code>null</code>)
+ */
+ public static MultiValidationStatus validateQualifiedName( final QualifiedName
qname,
+ final String
propertyName,
+ final List<String>
validNamespacePrefixes ) {
+ final MultiValidationStatus status = new MultiValidationStatus();
+ validateQualifiedName(qname, propertyName, validNamespacePrefixes, status);
+ return status;
+ }
+
+ /**
+ * @param qname the qualified name being validated (cannot be
<code>null</code>)
+ * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
+ * @param validNamespacePrefixes a collection of namespace prefixes that the
qualified name must match (can be <code>null</code>
+ * or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateQualifiedName( final QualifiedName qname,
- String propertyName,
+ final String propertyName,
+ final List<String>
validNamespacePrefixes,
final MultiValidationStatus status ) {
+ validateQualifiedName(qname, propertyName, status);
+
+ if (!Utils.isEmpty(validNamespacePrefixes)) {
+ final String qualifier = qname.getQualifier();
+
+ if (!Utils.isEmpty(qualifier) &&
!validNamespacePrefixes.contains(qualifier)) {
+ final ValidationStatus newStatus =
ValidationStatus.createErrorMessage(NLS.bind(Messages.nameQualifierNotFound,
+
propertyName, qualifier));
+ status.add(newStatus);
+ }
+ }
+ }
+
+ /**
+ * @param qname the qualified name being validated (cannot be
<code>null</code>)
+ * @param propertyName the name to use to identify the qualified name (cannot be
<code>null</code> empty)
+ * @param status the status to add the new status to (never
<code>null</code>)
+ */
+ public static void validateQualifiedName( final QualifiedName qname,
+ final String propertyName,
+ final MultiValidationStatus status ) {
final MultiValidationStatus newStatus = validateQualifiedName(qname,
propertyName);
if (!newStatus.isOk()) {
@@ -917,15 +956,20 @@
/**
* @param operator the query operator being validated (can be
<code>null</code> or empty)
+ * @param propertyDefinitionName the name of the property definition the query
operator belongs to (cannot be <code>null</code>
+ * or empty)
* @return the status (never <code>null</code>)
*/
- public static ValidationStatus validateQueryOperator( final String operator ) {
- Utils.verifyIsNotEmpty(operator, "operator"); //$NON-NLS-1$
+ public static ValidationStatus validateQueryOperator( final String operator,
+ final String
propertyDefinitionName ) {
+ if (Utils.isEmpty(operator)) {
+ return ValidationStatus.createErrorMessage(Messages.emptyQueryOperator);
+ }
try {
QueryOperator.find(operator);
} catch (final Exception e) {
- return ValidationStatus.createErrorMessage(Messages.invalidQueryOperator);
+ return
ValidationStatus.createErrorMessage(NLS.bind(Messages.invalidQueryOperator, operator,
propertyDefinitionName));
}
return ValidationStatus.OK_STATUS;
@@ -933,11 +977,14 @@
/**
* @param operator the query operator being validated (can be
<code>null</code> or empty)
+ * @param propertyDefinitionName the name of the property definition the query
operator belongs to (cannot be <code>null</code>
+ * or empty)
* @param status the status to add the new status to (never
<code>null</code>)
*/
public static void validateQueryOperator( final String operator,
+ final String propertyDefinitionName,
final MultiValidationStatus status ) {
- final ValidationStatus newStatus = validateQueryOperator(operator);
+ final ValidationStatus newStatus = validateQueryOperator(operator,
propertyDefinitionName);
if (!newStatus.isOk()) {
status.add(newStatus);
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-03-15
15:40:34 UTC (rev 39541)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr/src/org/jboss/tools/modeshape/jcr/messages.properties 2012-03-15
15:55:37 UTC (rev 39542)
@@ -66,7 +66,7 @@
# 0 = property definition name
invalidGetStateRequest = The "getState" method cannot be used for property
"{0}."
# 0 = invalid query operator
-invalidQueryOperator = Expected a valid query operator ('=', '<>',
'<', '<=', '>', '>=', or 'LIKE'), but
was "{0}."
+invalidQueryOperator = Expected a valid query operator ('=', '<>',
'<', '<=', '>', '>=', or 'LIKE'), but
was "{0}" for property definition "{1}."
# 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
@@ -78,8 +78,10 @@
missingName = <missing name>
# 0 = property definition name
multipleDefaultValuesForSingleValuedProperty = The single-valued property definition
"{0}" cannot have multiple default values.
-# = CND line number, 1 = CND column number
+# 0 = CND line number, 1 = CND column number
multipleKeywordNotValidInJcr2CndFormat = The 'MULTIPLE' attribute at line {0},
column {1} is no longer valid in the JCR 2.0 CND format. Use 'SNS' instead.
+# 0 = type of qualified name, 1 = qualifier
+nameQualifierNotFound = The "{0}" qualified name has a qualifier of
"{1}" that does not match any namespace prefixes in the CND.
namespacePrefix = namespace prefix
namespaceUri = namespace URI
# 0 = node type definition name
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui
___________________________________________________________________
Added: svn:ignore
+ bin
target
build
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.classpath
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.classpath
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.classpath 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.project
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.project
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.project 2012-03-15 15:55:37
UTC (rev 39542)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.modeshape.jcr.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.jdt.core.prefs 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,22 @@
+#Fri Mar 02 10:24:18 CST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.source=1.6
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.pde.core.prefs
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.pde.core.prefs
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.pde.core.prefs 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,4 @@
+#Thu Mar 01 11:32:21 CST 2012
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/.settings/org.eclipse.pde.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: 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
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.jboss.tools.modeshape.jcr.ui;singleton:=true
+Bundle-Version: 1.1.0.qualifier
+Bundle-Vendor: %bundleVendor
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.jboss.tools.modeshape.jcr,
+ org.jboss.tools.modeshape.ui,
+ org.eclipse.ui.forms,
+ org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.ui.editors,
+ org.eclipse.jface.text,
+ org.eclipse.ui.ide,
+ org.jboss.tools.modeshape.client;bundle-version="1.1.0"
+Bundle-Activator: org.jboss.tools.modeshape.jcr.ui.Activator
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/bundle.properties 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,15 @@
+#
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership.
+#
+# This software is made available by Red Hat, Inc. under the terms of the
+# Eclipse Public License v1.0 which accompanies this distribution and is
+# available at
http://www.eclipse.org/legal/epl-v10.html.
+#
+# See the AUTHORS.txt file in the distribution for a full listing of
+# individual contributors.
+#
+bundleName = ModeShape JCR UI Plug-in
+bundleVendor = JBoss by Red Hat
+cndEditor.name = CND
+modeShapeCategory.name = ModeShape
\ No newline at end of file
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/OSGI-INF/l10n/bundle.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/build.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/build.properties
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/build.properties 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,19 @@
+#
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership.
+#
+# This software is made available by Red Hat, Inc. under the terms of the
+# Eclipse Public License v1.0 which accompanies this distribution and is
+# available at
http://www.eclipse.org/legal/epl-v10.html.
+#
+# See the AUTHORS.txt file in the distribution for a full listing of
+# individual contributors.
+#
+bin.includes = META-INF/,\
+ OSGI-INF/,\
+ icons/,\
+ .,\
+ plugin.xml
+jars.compile.order = .
+source.. = src/
+output.. = bin/
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/build.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/cnd-editor-16x.png
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/cnd-editor-16x.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/delete-16x.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/delete-16x.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/edit-16x.png
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/edit-16x.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/new-16x.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/new-16x.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<!--
+ - See the COPYRIGHT.txt file distributed with this work for information
+ - regarding copyright ownership.
+ -
+ - This software is made available by Red Hat, Inc. under the terms of the
+ - Eclipse Public License v1.0 which accompanies this distribution and is
+ - available at
http://www.eclipse.org/legal/epl-v10.html.
+ -
+ - See the AUTHORS.txt file in the distribution for a full listing of
+ - individual contributors.
+-->
+<plugin>
+ <extension
+ point="org.eclipse.ui.editors">
+ <editor
+ class="org.jboss.tools.modeshape.jcr.ui.cnd.CndEditor"
+ default="true"
+ extensions="cnd"
+ id="org.jboss.tools.modeshape.jcr.ui.cndEditor"
+ icon="icons/cnd-editor-16x.png"
+ name="%cndEditor.name">
+ </editor>
+ </extension>
+
+<!-- New wizards
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ name="%modeShapeCategory.name"
+ id="org.modeshape">
+ </category>
+ <wizard
+ name="%newCndWizard.name"
+ icon="icons/new-cnd-wiz.png"
+ category="org.modeshape"
+ class="org.jboss.tools.modeshape.jcr.ui.cnd.NewCndWizard"
+ id="newCndWizard">
+ <description>
+ %newCndWizard.description
+ </description>
+ </wizard>
+ </extension>
+ -->
+ <!--
+ <extension
+ id="cndMarker"
+ name="%cndMarker.name"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.core.resources.problemmarker" />
+ <persistent value="true" />
+ </extension>
+-->
+<!--
+ <extension
+ id="cndBuilder"
+ name="%cndBuilder.name"
+ point="org.eclipse.core.resources.builders">
+ <builder
+ callOnEmptyDelta="false"
+ hasNature="true"
+ isConfigurable="false"
+ supportsConfigurations="false">
+ <run
+ class="org.jboss.tools.modeshape.jcr.ui.cnd.CndBuilder">
+ <parameter name="optimize" value="true"/>
+ <parameter name="comment"
value="%cndBuilder.name"/>
+ </run>
+ </builder>
+ </extension>
+-->
+</plugin>
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/plugin.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/pom.xml
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/pom.xml
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/pom.xml 2012-03-15 15:55:37
UTC (rev 39542)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.modeshape</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.modeshape.plugins</groupId>
+ <artifactId>org.jboss.tools.modeshape.jcr.ui</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/Activator.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/Activator.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/Activator.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,63 @@
+/*
+ * 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;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.modeshape.ui.graphics.GraphicsUtils;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The <code>org.jboss.tools.modeshape.jcr.ui</code> UI Plug-in class.
+ */
+public class Activator extends AbstractUIPlugin {
+
+ private static Activator _sharedInstance;
+
+ /**
+ * @return the shared instance (<code>null</code> if the Eclipse platform
is not running)
+ */
+ public static Activator getSharedInstance() {
+ return _sharedInstance;
+ }
+
+ /**
+ * Retrieves the requested image from the image registry. If the image does not exist
in the registry it will be created and
+ * registered.
+ *
+ * @param pathToImage the path to the image file relative to the specified
plug-in's folder (can be <code>null</code>)
+ * @return the requested image or a standard "missing image" image (never
<code>null</code>)
+ */
+ public final Image getImage( final String pathToImage ) {
+ return GraphicsUtils.getImage(this, pathToImage);
+ }
+
+ /**
+ * Retrieves the requested image descriptor from the image registry. If the image
does not exist in the registry it will be
+ * created and registered.
+ *
+ * @param pathToImage the path to the image file relative to the specified
plug-in's folder (can be <code>null</code>)
+ * @return the requested image descriptor or a standard "missing image"
image descriptor (never <code>null</code>)
+ */
+ public final ImageDescriptor getImageDescriptor( final String pathToImage ) {
+ getImage(pathToImage); // this creates entry in registry if necessary
+ return getImageRegistry().getDescriptor(pathToImage);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start( BundleContext context ) throws Exception {
+ super.start(context);
+ _sharedInstance = this;
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/Activator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiUtils.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiUtils.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiUtils.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import org.jboss.tools.modeshape.jcr.ValidationStatus;
+import org.jboss.tools.modeshape.ui.forms.ErrorMessage;
+
+/**
+ *
+ */
+public class JcrUiUtils {
+
+ /**
+ * @param status the status being used to set the message (cannot be
<code>null</code>)
+ * @param message the message being set (cannot be <code>null</code>)
+ */
+ public static void setMessage( ValidationStatus status,
+ ErrorMessage message ) {
+ // TODO need to figure out how to get all the MultiValidationStatus errors to
display
+ if (status.isError()) {
+ message.setErrorMessage(status.getMessage());
+ } else if (status.isWarning()) {
+ message.setWarningMessage(status.getMessage());
+ } else if (status.isInfo()) {
+ message.setInformationMessage(status.getMessage());
+ } else if (status.isOk()) {
+ message.setOkMessage(status.getMessage());
+ } else {
+ assert false : "Unexpected status type"; //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Don't allow construction.
+ */
+ private JcrUiUtils() {
+ // nothing to do
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/UiConstants.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/UiConstants.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/UiConstants.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+/**
+ * Constants used within the <code>org.jboss.tools.modeshape.jcr.ui</code>
plug-in.
+ */
+public interface UiConstants {
+
+ /**
+ * The plug-in bundle's symbolic name.
+ */
+ String PLUGIN_ID = UiConstants.class.getPackage().getName();
+
+ /**
+ * The identifiers for the CND editor-related parts.
+ */
+ interface EditorIds {
+
+ /**
+ * The extension ID for the CND editor part.
+ */
+ String CND_EDITOR = PLUGIN_ID + ".cndEditor"; //$NON-NLS-1$
+
+ /**
+ * The ID of the CND editor's forms editor page.
+ */
+ String CND_FORMS_PAGE = CND_EDITOR + ".formsPage"; //$NON-NLS-1$
+
+ /**
+ * The ID of the CND editor's text editor page.
+ */
+ String CND_SOURCE_PAGE = CND_EDITOR + ".sourcePage"; //$NON-NLS-1$
+ }
+
+ /**
+ * The image paths.
+ */
+ interface Images {
+
+ /**
+ * The relative path from the plugin folder to the icons folder.
+ */
+ String ICONS_FOLDER = "icons/"; //$NON-NLS-1$
+
+ /**
+ * The relative path from the plugin folder to the icon used for the CND editor.
+ */
+ String CND_EDITOR = ICONS_FOLDER + "cnd-editor-16x.png"; //$NON-NLS-1$
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/UiConstants.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,637 @@
+/*
+ * 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.cnd;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourceAttributes;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IStatusLineManager;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableEditor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.FileDocumentProvider;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.IMessageManager;
+import org.eclipse.ui.forms.editor.SharedHeaderFormEditor;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.jboss.tools.modeshape.jcr.cnd.CndImporter;
+import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
+import org.jboss.tools.modeshape.jcr.ui.Activator;
+import org.jboss.tools.modeshape.jcr.ui.UiConstants;
+import org.jboss.tools.modeshape.jcr.ui.UiConstants.Images;
+import org.jboss.tools.modeshape.ui.UiMessages;
+import org.jboss.tools.modeshape.ui.forms.MessageFormDialog;
+
+/**
+ *
+ */
+public final class CndEditor extends SharedHeaderFormEditor implements
IPersistableEditor, IResourceChangeListener,
+ PropertyChangeListener {
+
+ /**
+ * The memento key for the index of the selected editor.
+ */
+ private static final String SELECTED_PAGE = "SELECTED_PAGE"; //$NON-NLS-1$
+
+ private boolean dirty = false;
+ private boolean readOnly = false;
+
+ private IMemento memento;
+
+ private final FileDocumentProvider documentProvider = new FileDocumentProvider();
+ private long modificationStamp = 0;
+ private Listener refreshListener;
+
+ private CompactNodeTypeDefinition originalCnd;
+ private CompactNodeTypeDefinition cndBeingEdited;
+
+ private ScrolledForm scrolledForm;
+
+ private final CndEditorPage formsPage;
+// private final CndEditorPage sourcePage;
+
+ /**
+ * Constructs a CND editor.
+ */
+ public CndEditor() {
+ this.formsPage = new CndFormsEditorPage(this);
+ }
+
+ /**
+ * Allow inner classes access to this instance.
+ *
+ * @return this instance
+ */
+ CndEditor accessThis() {
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+ */
+ @Override
+ protected void addPages() {
+ try {
+ addPage(0, this.formsPage); // Page 0: Forms Editor Page
+
+ TextEditor sourceEditor = new TextEditor() {
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#isEditable()
+ */
+ @Override
+ public boolean isEditable() {
+ return false;
+ }
+ };
+
+ // add text editor and set editor tab title
+ addPage(1, sourceEditor, getEditorInput());
+ setPageText((getPageCount() - 1), CndMessages.cndEditorSourcePageTitle);
+
+ // handle when CND changed outside of this editor
+ this.refreshListener = new Listener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
+ */
+ @Override
+ public void handleEvent( final Event event ) {
+ refreshCnd();
+ }
+ };
+
+ // hook activation listener
+ getContainer().addListener(SWT.Activate, this.refreshListener);
+
+ // restore state
+ int selectedPageNum = 0;
+
+ if (this.memento != null) {
+ final int value = this.memento.getInteger(SELECTED_PAGE);
+
+ if (value != -1) {
+ selectedPageNum = value;
+ }
+ }
+
+ setActivePage(selectedPageNum);
+ } catch (final PartInitException e) {
+ // this will open a "Could not open editor" page with exception
details
+ throw new RuntimeException(CndMessages.errorOpeningCndEditor, e);
+ }
+ }
+
+ //
+ // private void contributeToMenu( IMenuManager menuMgr ) {
+ // menuMgr.add(this.updateRegisteryAction);
+ // menuMgr.add(this.showRegistryViewAction);
+ // menuMgr.update(true);
+ // }
+ //
+ // private void contributeToToolBar( IToolBarManager toolBarMgr ) {
+ // toolBarMgr.add(this.updateRegisteryAction);
+ // toolBarMgr.add(this.showRegistryViewAction);
+ // toolBarMgr.update(true);
+ // }
+ //
+ // private void createActions() {
+ // this.updateRegisteryAction = new Action(CndMessages.updateMedInRegistryActionText,
SWT.FLAT) {
+ // @Override
+ // public void run() {
+ // IEditorInput editorInput = getEditorInput();
+ //
+ // if (editorInput instanceof IFileEditorInput) {
+ // IFile medFile = ((IFileEditorInput)editorInput).getFile();
+ // RegistryDeploymentValidator.deploy(medFile);
+ // }
+ // }
+ // };
+ //
this.updateRegisteryAction.setImageDescriptor(Activator.getDefault().getImageDescriptor(REGISTERY_MED_UPDATE_ACTION));
+ //
this.updateRegisteryAction.setToolTipText(CndMessages.updateMedInRegistryActionToolTip);
+ //
+ // this.showRegistryViewAction = new ShowModelExtensionRegistryViewAction();
+ // }
+
+ private void createCnd() throws Exception {
+ // TODO implement createCnd
+ CndImporter importer = new CndImporter();
+ List<Throwable> errors = new ArrayList<Throwable>();
+ this.cndBeingEdited = importer.importFrom(getFile().getContents(), errors,
getFile().getName());
+ // TODO implement
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createHeaderContents( final IManagedForm headerForm ) {
+ this.scrolledForm = headerForm.getForm();
+
this.scrolledForm.setImage(Activator.getSharedInstance().getImage(UiConstants.Images.CND_EDITOR));
+ this.scrolledForm.setText(CndMessages.cndEditorTitle);
+
+ final Form form = this.scrolledForm.getForm();
+ getToolkit().decorateFormHeading(form);
+ //
+ // createActions();
+ // contributeToToolBar(form.getToolBarManager());
+ // contributeToMenu(form.getMenuManager());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void doSave( final IProgressMonitor monitor ) {
+ internalSave(monitor);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ @Override
+ public void doSaveAs() {
+ // TODO implement doSaveAs
+ final IProgressMonitor progressMonitor = getProgressMonitor();
+ // SaveAsDialog dialog = new SaveAsDialog(getShell());
+ // dialog.setOriginalFile(getFile());
+ // dialog.create();
+ //
+ // // dialog was canceled
+ // if (dialog.open() == Window.CANCEL) {
+ // if (progressMonitor != null) {
+ // progressMonitor.setCanceled(true);
+ // }
+ //
+ // return;
+ // }
+ //
+ // // dialog OK'd
+ // IPath filePath = dialog.getResult();
+ //
+ // // make sure that file has the right extension
+ // if (!ExtensionConstants.MED_EXTENSION.equals(filePath.getFileExtension())) {
+ // filePath = filePath.addFileExtension(ExtensionConstants.MED_EXTENSION);
+ // }
+ //
+ // IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ // IFile file = workspace.getRoot().getFile(filePath);
+ //
+ // try {
+ // // create set new editor input file
+ // InputStream emptyStream = new ByteArrayInputStream(new byte[0]);
+ // file.create(emptyStream, true, progressMonitor);
+ // setInput(new FileEditorInput(file));
+ //
+ // // save MED in new file
+ // internalSave(progressMonitor);
+ // } catch (Exception e) {
+ // IStatus status = null;
+ //
+ // if (!(e instanceof CoreException)) {
+ // status = new Status(IStatus.ERROR, UiConstants.PLUGIN_ID,
e.getLocalizedMessage());
+ // } else {
+ // status = ((CoreException)e).getStatus();
+ // }
+ //
+ // ErrorDialog.openError(getShell(), UiMessages.errorDialogTitle,
CndMessages.cndEditorSaveError, status);
+ // }
+ }
+
+ /**
+ * @return the CND being edited (never <code>null</code>)
+ */
+ CompactNodeTypeDefinition getCnd() {
+ return this.cndBeingEdited;
+ }
+
+ /**
+ * @return the *.cnd resource (never <code>null</code>)
+ */
+ protected IFile getFile() {
+ return ((IFileEditorInput)getEditorInput()).getFile();
+ }
+
+ /**
+ * @return the form editor's message manager (never
<code>null</code>)
+ */
+ IMessageManager getMessageManager() {
+ return this.scrolledForm.getMessageManager();
+ }
+
+ private IProgressMonitor getProgressMonitor() {
+ final IStatusLineManager statusLineMgr =
getEditorSite().getActionBars().getStatusLineManager();
+ return ((statusLineMgr == null) ? null : statusLineMgr.getProgressMonitor());
+ }
+
+ /**
+ * @return the editor's shell (never <code>null</code>)
+ */
+ Shell getShell() {
+ return getEditorSite().getShell();
+ }
+//
+// /**
+// * Handler for page change listener.
+// */
+// void handlePageChanged() {
+// final FormPage page = (FormPage)getSelectedPage();
+// this.scrolledForm.setText(page.getTitle());
+// page.setFocus();
+// }
+
+ /**
+ * Registers an editor activation listener.
+ */
+ private void hookRefreshListener() {
+ getContainer().addListener(SWT.Activate, this.refreshListener);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite,
org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init( final IEditorSite site,
+ final IEditorInput input ) throws PartInitException {
+ super.init(site, input);
+ assert (input instanceof IFileEditorInput) : "MED Editor input is not a
file"; //$NON-NLS-1$
+
+ try {
+ createCnd();
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+ } catch (final Exception e) {
+ throw new PartInitException(CndMessages.errorOpeningCndEditor, e);
+ }
+ }
+
+ private void internalSave( final IProgressMonitor progressMonitor ) {
+ final IEditorInput input = getEditorInput();
+
+ try {
+ // TODO need a CND writer
+ // ModelExtensionDefinitionWriter writer = new
ModelExtensionDefinitionWriter();
+ // String medAsString = writer.writeAsText(this.cndBeingEdited);
+ // IDocument document = this.documentProvider.getDocument(input);
+ // document.set(medAsString);
+ //
+ // 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) {
+ IStatus status = null;
+
+ if (!(e instanceof CoreException)) {
+ status = new Status(IStatus.ERROR, UiConstants.PLUGIN_ID,
e.getLocalizedMessage());
+ } else {
+ status = ((CoreException)e).getStatus();
+ }
+
+ if ((status == null) || (status.getSeverity() != IStatus.CANCEL)) {
+ ErrorDialog.openError(getShell(), UiMessages.errorDialogTitle,
CndMessages.cndEditorSaveError, status);
+ }
+ } finally {
+ this.documentProvider.changed(input);
+
+ // update dirty flag
+ refreshDirtyState();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#isDirty()
+ */
+ @Override
+ public boolean isDirty() {
+ return this.dirty;
+ }
+
+ /**
+ * @return <code>true</code> if the file is readonly
+ */
+ public boolean isReadOnly() {
+ return this.readOnly;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ return true;
+ }
+
+ /**
+ * @return <code>true</code> if editor is synchronized with file system
+ */
+ boolean isSynchronized() {
+ final long currentModifiedStamp =
this.documentProvider.getModificationStamp(getEditorInput());
+ return (this.modificationStamp == currentModifiedStamp);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange( final PropertyChangeEvent e ) {
+ refreshDirtyState();
+ this.formsPage.handlePropertyChanged(e);
+// this.sourcePage.handlePropertyChanged(e);
+ }
+
+ void refreshCnd() {
+ if (!isSynchronized()) {
+ unhookRefreshListener();
+
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.cndChangedOnFileSystemDialogTitle,
+
Activator.getSharedInstance().getImage(Images.CND_EDITOR),
+
NLS.bind(CndMessages.cndChangedOnFileSystemDialogMsg, getFile().getName()))) {
+ try {
+ getFile().refreshLocal(IResource.DEPTH_ONE, null);
+ this.modificationStamp =
this.documentProvider.getModificationStamp(getEditorInput());
+
+ createCnd();
+
+ this.formsPage.handleCndReloaded();
+// this.sourcePage.handleCndReloaded();
+ } catch (final Exception e) {
+ // TODO log this
+ MessageFormDialog.openError(getShell(),
CndMessages.cndEditorRefreshErrorTitle,
+
Activator.getSharedInstance().getImage(Images.CND_EDITOR),
+ CndMessages.cndEditorRefreshErrorMsg);
+ }
+ }
+
+ hookRefreshListener();
+ }
+ }
+
+ /**
+ * Refreshes the editor's dirty state by comparing the MED being edited with the
original MED.
+ */
+ protected void refreshDirtyState() {
+ final boolean newValue = !this.originalCnd.equals(this.cndBeingEdited);
+
+ if (isDirty() != newValue) {
+ this.dirty = newValue;
+ getHeaderForm().dirtyStateChanged();
+ }
+ }
+
+ /**
+ * Checks the *.mxd file permissions and notifies the editor's pages if the
permissions have changed.
+ */
+ private void refreshReadOnlyState() {
+ final ResourceAttributes attributes = getFile().getResourceAttributes();
+ final boolean newValue = ((attributes == null) ? true :
attributes.isReadOnly());
+
+ if (isReadOnly() != newValue) {
+ this.readOnly = newValue;
+
+ this.formsPage.setResourceReadOnly(this.readOnly);
+ this.formsPage.getManagedForm().refresh();
+//
+// this.sourcePage.setResourceReadOnly(this.readOnly);
+// this.sourcePage.getManagedForm().refresh();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
+ @Override
+ public void resourceChanged( final IResourceChangeEvent event ) {
+ final int type = event.getType();
+
+ if (type == IResourceChangeEvent.POST_CHANGE) {
+ final IResourceDelta delta = event.getDelta();
+
+ if (delta == null) {
+ return;
+ }
+
+ try {
+ delta.accept(new IResourceDeltaVisitor() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
+ */
+ @Override
+ public boolean visit( final IResourceDelta delta ) {
+ if (delta.getResource().equals(getFile())) {
+ // MXD file has been deleted so close editor
+ if ((delta.getKind() & IResourceDelta.REMOVED) != 0) {
+ if (!getShell().isDisposed()) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+
getEditorSite().getPage().closeEditor(accessThis(), false);
+ }
+ });
+ }
+ } else if ((delta.getKind() == IResourceDelta.CHANGED)
+ && ((delta.getFlags() &
org.eclipse.core.resources.IResourceDelta.CONTENT) != 0)) {
+ if (!getShell().isDisposed()) {
+ getShell().getDisplay().asyncExec(new Runnable() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ refreshCnd();
+ }
+ });
+ }
+ }
+
+ return false; // stop visiting
+ }
+
+ return true; // keep visiting
+ }
+ });
+ } catch (final Exception e) {
+ // TODO log this
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.IPersistableEditor#restoreState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void restoreState( final IMemento memento ) {
+ this.memento = memento;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void saveState( final IMemento memento ) {
+ final int selectedPageNum = getActivePage();
+ memento.putInteger(SELECTED_PAGE, selectedPageNum);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ super.setFocus();
+ refreshCnd();
+ refreshReadOnlyState();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.part.EditorPart#setInput(org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ protected void setInput( final IEditorInput input ) {
+ if (getEditorInput() != null) {
+ // unhook previous document provider
+ this.documentProvider.disconnect(getEditorInput());
+ }
+
+ if (input instanceof IFileEditorInput) {
+ super.setInput(input);
+
+ try {
+ // hook new document provider
+ this.documentProvider.connect(input);
+ this.modificationStamp =
this.documentProvider.getModificationStamp(input);
+ final IAnnotationModel model =
this.documentProvider.getAnnotationModel(input);
+ model.connect(this.documentProvider.getDocument(input));
+
+ // set editor tab text
+ setPartName(getEditorInput().getName());
+ } catch (final Exception e) {
+ throw new RuntimeException(CndMessages.errorOpeningCndEditor, e);
+ }
+ } else {
+ throw new RuntimeException(CndMessages.cndEditorInputNotAFile);
+ }
+ }
+
+ /**
+ * Unregisters the editor activation listener.
+ */
+ private void unhookRefreshListener() {
+ if (!getContainer().isDisposed()) {
+ getContainer().removeListener(SWT.Activate, this.refreshListener);
+ }
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditorPage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditorPage.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditorPage.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,165 @@
+/*
+ * 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.cnd;
+
+import java.beans.PropertyChangeEvent;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.IMessageManager;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.modeshape.jcr.cnd.CompactNodeTypeDefinition;
+import org.jboss.tools.modeshape.ui.forms.ErrorMessage;
+
+/**
+ *
+ */
+public abstract class CndEditorPage extends FormPage {
+
+ /**
+ * @param cndEditor the CND editor (cannot be <code>null</code>)
+ * @param id the unique page identifier (cannot be <code>null</code>)
+ * @param title the page part title (cannot be <code>null</code>)
+ */
+ protected CndEditorPage( final CndEditor cndEditor,
+ final String id,
+ final String title ) {
+ super(cndEditor, id, title);
+ }
+
+ /**
+ * @param body the parent UI control where all other controls should be added (never
<code>null</code>)
+ * @param toolkit the form toolkit to use when creating form controls (never
<code>null</code>)
+ */
+ protected abstract void createBody( Composite body,
+ FormToolkit toolkit );
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected final void createFormContent( final IManagedForm managedForm ) {
+ final Composite body = managedForm.getForm().getBody();
+ body.setLayout(new GridLayout());
+ body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ createBody(body, managedForm.getToolkit());
+ setResourceReadOnly(isReadonly());
+ updateAllMessages();
+ }
+
+ /**
+ * @param c the form control that will be revealed in the MED editor client area
(cannot be <code>null</code>)
+ */
+ protected void ensureVisible( final Control c ) {
+ FormToolkit.ensureVisible(c);
+ }
+
+ /**
+ * @return the CND being modified by the GUI (never <code>null</code>)
+ */
+ protected CompactNodeTypeDefinition getCnd() {
+ return getCndEditor().getCnd();
+ }
+
+ /**
+ * @return the CND editor that this page belongs to (never
<code>null</code>)
+ */
+ protected CndEditor getCndEditor() {
+ return (CndEditor)getEditor();
+ }
+
+ /**
+ * @return the resource being edited (never <code>null</code>)
+ */
+ protected IFile getFile() {
+ return getCndEditor().getFile();
+ }
+
+ /**
+ * @return the part site's shell (never <code>null</code>)
+ */
+ protected Shell getShell() {
+ return getSite().getShell();
+ }
+
+ /**
+ * The CND was changed outside of the editor. Page must reload CND content.
+ */
+ public abstract void handleCndReloaded();
+
+ /**
+ * @param e the property change event being handled (never
<code>null</code>)
+ */
+ protected abstract void handlePropertyChanged( PropertyChangeEvent e );
+
+ /**
+ * @return <code>true</code> if the editor is readonly
+ */
+ protected boolean isReadonly() {
+ return getCndEditor().isReadOnly();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.editor.FormPage#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ super.setFocus();
+
+ // check for null as this method gets called before controls are constructed
+ if (getManagedForm() != null) {
+ getManagedForm().refresh();
+ }
+ }
+
+ /**
+ * @param readOnly the new readonly state of the editor
+ */
+ protected abstract void setResourceReadOnly( boolean readOnly );
+
+ /**
+ * Updates/refreshes all page header error messages.
+ */
+ protected abstract void updateAllMessages();
+
+ /**
+ * @param errorMessage the message being updated in the {@link IMessageManager
message manager} (never <code>null</code>)
+ */
+ protected void updateMessage( final ErrorMessage errorMessage ) {
+ assert (errorMessage != null) : "errorMessage is null"; //$NON-NLS-1$
+ final IMessageManager msgMgr = ((CndEditor)getEditor()).getMessageManager();
+
+ if (errorMessage.isOk()) {
+ if (errorMessage.getControl() == null) {
+ msgMgr.removeMessage(errorMessage.getKey());
+ } else {
+ msgMgr.removeMessage(errorMessage.getKey(), errorMessage.getControl());
+ }
+ } else {
+ if (errorMessage.getControl() == null) {
+ msgMgr.addMessage(errorMessage.getKey(), errorMessage.getMessage(),
errorMessage.getData(),
+ errorMessage.getMessageType());
+ } else {
+ msgMgr.addMessage(errorMessage.getKey(), errorMessage.getMessage(),
errorMessage.getData(),
+ errorMessage.getMessageType(),
errorMessage.getControl());
+ }
+ }
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndEditorPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,2194 @@
+/*
+ * 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.cnd;
+
+import static org.jboss.tools.modeshape.jcr.ui.UiConstants.EditorIds.CND_FORMS_PAGE;
+
+import java.beans.PropertyChangeEvent;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.custom.SashForm;
+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;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.ui.forms.IFormColors;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.jboss.tools.modeshape.jcr.Messages;
+import org.jboss.tools.modeshape.jcr.MultiValidationStatus;
+import org.jboss.tools.modeshape.jcr.Utils;
+import org.jboss.tools.modeshape.jcr.cnd.ChildNodeDefinition;
+import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
+import org.jboss.tools.modeshape.jcr.cnd.CndValidator;
+import org.jboss.tools.modeshape.jcr.cnd.NamespaceMapping;
+import org.jboss.tools.modeshape.jcr.cnd.NodeTypeDefinition;
+import org.jboss.tools.modeshape.jcr.cnd.NodeTypeDefinition.PropertyName;
+import org.jboss.tools.modeshape.jcr.cnd.PropertyDefinition;
+import org.jboss.tools.modeshape.jcr.cnd.QualifiedName;
+import org.jboss.tools.modeshape.jcr.ui.JcrUiUtils;
+import org.jboss.tools.modeshape.ui.Activator;
+import org.jboss.tools.modeshape.ui.UiConstants;
+import org.jboss.tools.modeshape.ui.UiUtils;
+import org.jboss.tools.modeshape.ui.forms.ErrorMessage;
+import org.jboss.tools.modeshape.ui.forms.FormUtils;
+import org.jboss.tools.modeshape.ui.forms.FormUtils.Styles;
+import org.jboss.tools.modeshape.ui.forms.MessageFormDialog;
+
+/**
+ * The GUI part of the CND editor.
+ */
+class CndFormsEditorPage extends CndEditorPage {
+
+ private IAction addChildNode;
+ private IAction addNamespace;
+ private IAction addNodeType;
+
+ private IAction addProperty;
+ private IAction addSuperType;
+ // node type attributes
+ private Button btnAbstract;
+
+ private Button btnMixin;
+ private Button btnOrderable;
+ private Button btnQueryable;
+
+ // node type details
+ private CCombo cbxNamePrefix;
+ private Section childNodeSection;
+ private final ErrorMessage childNodesError;
+
+ private TableViewer childNodeViewer;
+ private IAction deleteChildNode;
+ private IAction deleteNamespace;
+
+ private IAction deleteNodeType;
+ private IAction deleteProperty;
+ private IAction deleteSuperType;
+ private Section detailsSection;
+ private IAction editChildNode;
+
+ private IAction editNamespace;
+ private IAction editNodeType;
+ private IAction editProperty;
+
+ private IAction editSuperType;
+ private final ErrorMessage namespacesError;
+ private TableViewer namespaceViewer;
+ private final ErrorMessage nodeTypeNameError;
+ private String nodeTypeNameFilterPattern;
+ private final ErrorMessage nodeTypeNamePrefixError;
+ private final ErrorMessage nodeTypesError;
+
+ private TableViewer nodeTypeViewer;
+
+ private final ErrorMessage propertiesError;
+ private Section propertiesSection;
+ private TableViewer propertyViewer;
+ private final ErrorMessage superTypesError;
+
+ private TableViewer superTypesViewer;
+ private Text txtName;
+
+ /**
+ * @param cndEditor the CND editor this page belongs to (cannot be
<code>null</code>)
+ */
+ protected CndFormsEditorPage( final CndEditor cndEditor ) {
+ super(cndEditor, CND_FORMS_PAGE, CndMessages.cndEditorFormsPageTitle);
+
+ // construct form messages
+ this.childNodesError = new ErrorMessage();
+ this.namespacesError = new ErrorMessage();
+ this.nodeTypesError = new ErrorMessage();
+ this.nodeTypeNameError = new ErrorMessage();
+ this.nodeTypeNamePrefixError = new ErrorMessage();
+ this.propertiesError = new ErrorMessage();
+ this.superTypesError = new ErrorMessage();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.ui.cnd.CndEditorPage#createBody(org.eclipse.swt.widgets.Composite,
+ * org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ protected void createBody( final Composite body,
+ final FormToolkit toolkit ) {
+ // top is namespaces
+ createNamespaceSection(getManagedForm(), toolkit, body);
+
+ // bottom is node types
+ createNodeTypeSection(getManagedForm(), toolkit, body);
+
+ // fill GUI with CND
+ populateUi();
+ }
+
+ private void createChildNodeActions() {
+ this.addChildNode = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleAddChildNode();
+ }
+ };
+ this.addChildNode.setEnabled(false);
+ this.addChildNode.setToolTipText(CndMessages.addChildNodeToolTip);
+
this.addChildNode.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
+
+ this.deleteChildNode = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleDeleteChildNode();
+ }
+ };
+ this.deleteChildNode.setEnabled(false);
+ this.deleteChildNode.setToolTipText(CndMessages.deleteChildNodeToolTip);
+
this.deleteChildNode.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
+
+ this.editChildNode = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleEditChildNode();
+ }
+ };
+ this.editChildNode.setEnabled(false);
+ this.editChildNode.setToolTipText(CndMessages.editChildNodeToolTip);
+
this.editChildNode.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
+ }
+
+ private void createChildNodeSection( final IManagedForm managedForm,
+ final FormToolkit toolkit,
+ final Composite parent ) {
+ this.childNodeSection = FormUtils.createSection(managedForm, toolkit, parent,
CndMessages.cndEditorChildNodeSectionTitle,
+
CndMessages.cndEditorChildNodeSectionDescription, Styles.SECTION_STYLE
+ &
~ExpandableComposite.EXPANDED, true);
+ toolkit.paintBordersFor(this.childNodeSection);
+
+ // create actions
+ createChildNodeActions();
+
+ // create toolbar
+ FormUtils.createSectionToolBar(this.childNodeSection, toolkit, new IAction[] {
this.addChildNode, this.editChildNode,
+ this.deleteChildNode });
+
+ // create viewer
+ final Composite container = toolkit.createComposite(this.childNodeSection);
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ this.childNodeSection.setClient(container);
+ toolkit.paintBordersFor(container);
+
+ final Table table = FormUtils.createTable(toolkit, container);
+ ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
+
+ createChildNodeViewer(table);
+ this.childNodesError.setControl(table);
+ }
+
+ private void createChildNodeViewer( final Table childNodeTable ) {
+ // create custom label provider for child node definitions
+ class ChildNodeLabelProvider extends ColumnLabelProvider {
+
+ private final int columnIndex;
+
+ public ChildNodeLabelProvider( final int columnIndex ) {
+ this.columnIndex = columnIndex;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( final Object element ) {
+ final ChildNodeDefinition childNodeDefinition =
(ChildNodeDefinition)element;
+
+ if (this.columnIndex == ChildNodeColumnIndexes.NAME) {
+ return childNodeDefinition.getName();
+ }
+
+ final NotationType notationType = NotationType.LONG;
+
+ if (this.columnIndex == ChildNodeColumnIndexes.DEFAULT_TYPE) {
+ return
childNodeDefinition.getDefaultType().toCndNotation(notationType);
+ }
+
+ if (this.columnIndex == ChildNodeColumnIndexes.REQUIRED_TYPES) {
+ return
childNodeDefinition.getRequiredTypesCndNotation(notationType);
+ }
+
+ assert (this.columnIndex == ChildNodeColumnIndexes.ATTRIBUTES) :
"Unexpected child node column index"; //$NON-NLS-1$
+ return childNodeDefinition.getAttributesCndNotation(notationType);
+ }
+ }
+
+ this.childNodeViewer = new TableViewer(childNodeTable);
+ this.childNodeViewer.setContentProvider(new IStructuredContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( final Object inputElement ) {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition == null) {
+ return Utils.EMPTY_OBJECT_ARRAY;
+ }
+
+ return nodeTypeDefinition.getChildNodeDefinitions().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( final Viewer viewer,
+ final Object oldInput,
+ final Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ // open edit child node on double click
+ this.childNodeViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ public void doubleClick( final DoubleClickEvent event ) {
+ handleEditChildNode();
+ }
+ });
+
+ // add selection listener
+ this.childNodeViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ @Override
+ public void selectionChanged( final SelectionChangedEvent event ) {
+ handleChildNodeSelected();
+ }
+ });
+
+ { // create name column
+ final TableViewerColumn nameColumn = new
TableViewerColumn(this.childNodeViewer, SWT.LEFT);
+ UiUtils.configureColumn(nameColumn, new
ChildNodeLabelProvider(ChildNodeColumnIndexes.NAME),
+ CndMessages.nameHeaderText,
CndMessages.childNodeNameToolTip, false, true);
+ }
+
+ { // create type column
+ final TableViewerColumn typeColumn = new
TableViewerColumn(this.childNodeViewer, SWT.LEFT);
+ UiUtils.configureColumn(typeColumn, new
ChildNodeLabelProvider(ChildNodeColumnIndexes.REQUIRED_TYPES),
+ CndMessages.requiredTypesHeaderText,
CndMessages.childNodeRequiredTypesToolTip, false, true);
+ }
+
+ { // create default values column
+ final TableViewerColumn defaultValuesColumn = new
TableViewerColumn(this.childNodeViewer, SWT.LEFT);
+ UiUtils.configureColumn(defaultValuesColumn, new
ChildNodeLabelProvider(ChildNodeColumnIndexes.DEFAULT_TYPE),
+ CndMessages.defaultTypeHeaderText,
CndMessages.childNodeDefaultTypeToolTip, false, true);
+ }
+
+ { // create attributes column
+ final TableViewerColumn attributesColumn = new
TableViewerColumn(this.childNodeViewer, SWT.LEFT);
+ UiUtils.configureColumn(attributesColumn, new
ChildNodeLabelProvider(ChildNodeColumnIndexes.ATTRIBUTES),
+ CndMessages.attributesHeaderText,
CndMessages.childNodeAttributesToolTip, false, true);
+ }
+
+ // this will sort by child node name
+ this.childNodeViewer.setSorter(new ViewerSorter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ViewerComparator#sort(org.eclipse.jface.viewers.Viewer,
java.lang.Object[])
+ */
+ @Override
+ public void sort( final Viewer viewer,
+ final Object[] elements ) {
+ Arrays.sort(elements);
+ }
+ });
+ }
+
+ private void createDetailsSection( final IManagedForm managedForm,
+ final FormToolkit toolkit,
+ final Composite parent ) {
+ // create section
+ this.detailsSection = FormUtils.createSection(managedForm, toolkit, parent,
CndMessages.cndEditorDetailsSectionTitle,
+
CndMessages.cndEditorDetailsSectionDescription, Styles.SECTION_STYLE
+ &
~ExpandableComposite.TWISTIE & ~ExpandableComposite.EXPANDED, false);
+ toolkit.paintBordersFor(this.detailsSection);
+
+ // create contents
+ final Composite detailsContainer = toolkit.createComposite(this.detailsSection);
+ detailsContainer.setLayout(new GridLayout(2, true));
+ detailsContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ this.detailsSection.setClient(detailsContainer);
+ toolkit.paintBordersFor(detailsContainer);
+
+ { // left-side of details section
+ final Composite leftContainer = toolkit.createComposite(detailsContainer);
+ leftContainer.setLayout(new GridLayout(2, false));
+ leftContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false));
+ toolkit.paintBordersFor(leftContainer);
+
+ { // name qualifier
+ toolkit.createLabel(leftContainer, CndMessages.namespaceLabel);
+ this.cbxNamePrefix = new CCombo(leftContainer, Styles.COMBO_STYLE);
+ toolkit.adapt(this.cbxNamePrefix, true, false);
+ this.nodeTypeNamePrefixError.setControl(this.cbxNamePrefix);
+ this.cbxNamePrefix.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false));
+ ((GridData)this.cbxNamePrefix.getLayoutData()).heightHint =
this.cbxNamePrefix.getItemHeight() + 4;
+
+ this.cbxNamePrefix.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleNameQualifierChanged(((CCombo)e.widget).getText());
+ }
+ });
+ }
+
+ { // name
+ toolkit.createLabel(leftContainer, CndMessages.nameLabel);
+ this.txtName = toolkit.createText(leftContainer, Utils.EMPTY_STRING,
Styles.TEXT_STYLE);
+ this.txtName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,
false));
+ this.txtName.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleNodeTypeNameChanged(((Text)e.widget).getText());
+ }
+ });
+
+ this.nodeTypeNameError.setControl(this.txtName);
+ }
+
+ { // attributes
+ final Group attributesContainer = new Group(leftContainer,
SWT.SHADOW_NONE);
+ attributesContainer.setText(CndMessages.attributesHeaderText);
+ attributesContainer.setLayout(new GridLayout(2, true));
+ attributesContainer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,
true, false));
+ ((GridData)attributesContainer.getLayoutData()).horizontalSpan = 2;
+ toolkit.adapt(attributesContainer);
+ //
attributesContainer.setBackground(toolkit.getColors().getColor(IFormColors.H_HOVER_LIGHT));
+ toolkit.paintBordersFor(attributesContainer);
+
+ this.btnAbstract = toolkit.createButton(attributesContainer,
CndMessages.abstractAttribute, SWT.CHECK);
+ this.btnAbstract.setBackground(attributesContainer.getBackground());
+ this.btnAbstract.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ handleAbstractChanged(((Button)e.widget).getSelection());
+ }
+ });
+ this.btnAbstract.setToolTipText(CndMessages.abstractAttributeToolTip);
+
+ this.btnMixin = toolkit.createButton(attributesContainer,
CndMessages.mixinAttribute, SWT.CHECK);
+ this.btnMixin.setBackground(attributesContainer.getBackground());
+ this.btnMixin.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ handleMixinChanged(((Button)e.widget).getSelection());
+ }
+ });
+ this.btnMixin.setToolTipText(CndMessages.mixinAttributeToolTip);
+
+ this.btnOrderable = toolkit.createButton(attributesContainer,
CndMessages.orderableAttribute, SWT.CHECK);
+ this.btnOrderable.setBackground(attributesContainer.getBackground());
+ this.btnOrderable.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ handleOrderableChanged(((Button)e.widget).getSelection());
+ }
+ });
+ this.btnOrderable.setToolTipText(CndMessages.orderableAttributeToolTip);
+
+ this.btnQueryable = toolkit.createButton(attributesContainer,
CndMessages.queryableAttribute, SWT.CHECK);
+ this.btnQueryable.setBackground(attributesContainer.getBackground());
+ this.btnQueryable.addSelectionListener(new SelectionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected( final SelectionEvent e ) {
+ handleQueryableChanged(((Button)e.widget).getSelection());
+ }
+ });
+ this.btnQueryable.setToolTipText(CndMessages.queryableAttributeToolTip);
+
+ // fill with data from CND
+ refreshNameControls(true); // fill control with data from CND
+ refreshAttributeControls();
+ }
+ }
+
+ { // right-side of details section (supertypes)
+ final Composite rightContainer = toolkit.createComposite(detailsContainer);
+ rightContainer.setLayout(new GridLayout(2, false));
+ rightContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ toolkit.paintBordersFor(rightContainer);
+
+ final Label label = toolkit.createLabel(rightContainer,
CndMessages.supertypesLabel);
+ label.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));
+ ((GridData)label.getLayoutData()).horizontalSpan = 2;
+
+ final Table table = FormUtils.createTable(toolkit, rightContainer);
+ table.setHeaderVisible(false);
+ table.setLinesVisible(false);
+ ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 2;
+ this.superTypesError.setControl(table);
+
+ createSuperTypesActions();
+ createSuperTypesViewer(table);
+
+ // add toolbar buttons (add, edit, delete)
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT |
SWT.VERTICAL);
+ final ToolBar toolBar = toolBarManager.createControl(rightContainer);
+
+ toolkit.adapt(toolBar);
+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+ toolBarManager.add(this.addSuperType);
+ toolBarManager.add(this.editSuperType);
+ toolBarManager.add(this.deleteSuperType);
+ toolBarManager.update(true);
+
+ // fill with data from CND
+ refreshSuperTypes();
+ }
+ }
+
+ private void createNamespaceActions() {
+ this.addNamespace = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleAddNamespace();
+ }
+ };
+ this.addNamespace.setToolTipText(CndMessages.addNamespaceToolTip);
+
this.addNamespace.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
+
+ this.deleteNamespace = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleDeleteNamespace();
+ }
+ };
+ this.deleteNamespace.setEnabled(false);
+ this.deleteNamespace.setToolTipText(CndMessages.deleteNamespaceToolTip);
+
this.deleteNamespace.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
+
+ this.editNamespace = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleEditNamespace();
+ }
+ };
+ this.editNamespace.setEnabled(false);
+ this.editNamespace.setToolTipText(CndMessages.editNamespaceToolTip);
+
this.editNamespace.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
+ }
+
+ private void createNamespaceSection( final IManagedForm managedForm,
+ final FormToolkit toolkit,
+ final Composite parent ) {
+ // create section
+ final Section section = FormUtils.createSection(managedForm, toolkit, parent,
CndMessages.cndEditorNamespacesSectionTitle,
+
CndMessages.cndEditorNamespacesSectionDescription, Styles.SECTION_STYLE
+ &
~ExpandableComposite.EXPANDED, true);
+ toolkit.paintBordersFor(section);
+
+ // create actions
+ createNamespaceActions();
+
+ // create toolbar
+ FormUtils.createSectionToolBar(section, toolkit, new IAction[] {
this.addNamespace, this.editNamespace,
+ this.deleteNamespace });
+
+ // create viewer
+ final Composite container = toolkit.createComposite(section);
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ section.setClient(container);
+ toolkit.paintBordersFor(container);
+
+ final Table table = FormUtils.createTable(toolkit, container);
+ ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
+
+ createNamespaceViewer(table);
+ this.namespacesError.setControl(table);
+ }
+
+ private void createNamespaceViewer( final Table namespaceTable ) {
+ // create custom label provider for namespace mappings
+ class NamespaceLabelProvider extends ColumnLabelProvider {
+
+ private final int columnIndex;
+
+ public NamespaceLabelProvider( final int columnIndex ) {
+ this.columnIndex = columnIndex;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( final Object element ) {
+ final NamespaceMapping namespaceMapping = (NamespaceMapping)element;
+
+ if (this.columnIndex == NamespaceColumnIndexes.PREFIX) {
+ return namespaceMapping.getPrefix();
+ }
+
+ return namespaceMapping.getUri();
+ }
+ }
+
+ this.namespaceViewer = new TableViewer(namespaceTable);
+ this.namespaceViewer.setContentProvider(new IStructuredContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( final Object inputElement ) {
+ return getCnd().getNamespaceMappings().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( final Viewer viewer,
+ final Object oldInput,
+ final Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ // open edit namespace on double click
+ this.namespaceViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ public void doubleClick( final DoubleClickEvent event ) {
+ handleEditNamespace();
+ }
+ });
+
+ // add selection listener
+ this.namespaceViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ @Override
+ public void selectionChanged( final SelectionChangedEvent event ) {
+ handleNamespaceSelected();
+ }
+ });
+
+ { // create prefix column
+ final TableViewerColumn prefixColumn = new
TableViewerColumn(this.namespaceViewer, SWT.LEFT);
+ UiUtils.configureColumn(prefixColumn, new
NamespaceLabelProvider(NamespaceColumnIndexes.PREFIX),
+ CndMessages.namespacePrefixHeaderText,
CndMessages.namespacePrefixToolTip, false, true);
+ }
+
+ { // create URI column
+ final TableViewerColumn uriColumn = new
TableViewerColumn(this.namespaceViewer, SWT.LEFT);
+ UiUtils.configureColumn(uriColumn, new
NamespaceLabelProvider(NamespaceColumnIndexes.URI),
+ CndMessages.namespaceUriHeaderText,
CndMessages.namespaceUriToolTip, false, true);
+ }
+
+ // this will sort by prefix
+ this.namespaceViewer.setSorter(new ViewerSorter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ViewerComparator#sort(org.eclipse.jface.viewers.Viewer,
java.lang.Object[])
+ */
+ @Override
+ public void sort( final Viewer viewer,
+ final Object[] elements ) {
+ Arrays.sort(elements);
+ }
+ });
+ }
+
+ private void createNodeTypeActions() {
+ this.addNodeType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleAddNodeType();
+ }
+ };
+ this.addNodeType.setToolTipText(CndMessages.addNodeTypeToolTip);
+
this.addNodeType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
+
+ this.deleteNodeType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleDeleteNodeType();
+ }
+ };
+ this.deleteNodeType.setEnabled(false);
+ this.deleteNodeType.setToolTipText(CndMessages.deleteNodeTypeToolTip);
+
this.deleteNodeType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
+
+ this.editNodeType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleEditNodeType();
+ }
+ };
+ this.editNodeType.setEnabled(false);
+ this.editNodeType.setToolTipText(CndMessages.editNodeTypeToolTip);
+
this.editNodeType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
+ }
+
+ @SuppressWarnings("unused")
+ private void createNodeTypeSection( final IManagedForm managedForm,
+ final FormToolkit toolkit,
+ final Composite parent ) {
+ // create section
+ final Section section = FormUtils.createSection(managedForm, toolkit, parent,
CndMessages.cndEditorNodeTypeSectionTitle,
+
CndMessages.cndEditorNodeTypeSectionDescription, Styles.SECTION_STYLE
+ &
~ExpandableComposite.TWISTIE, false);
+ toolkit.paintBordersFor(section);
+
+ // create actions
+ createNodeTypeActions();
+
+ // create toolbar
+ FormUtils.createSectionToolBar(section, toolkit, new IAction[] {
this.addNodeType, this.editNodeType, this.deleteNodeType });
+
+ // splitter has node type table on left and node type detail, properties, and
child nodes on right
+ final SashForm splitter = new SashForm(section, SWT.HORIZONTAL);
+ toolkit.adapt(splitter);
+ splitter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ splitter.setBackground(toolkit.getColors().getColor(IFormColors.SEPARATOR));
+ section.setClient(splitter);
+
+ // left side is node type name filter and node type name table
+ final Composite leftContainer = toolkit.createComposite(splitter);
+ leftContainer.setLayout(new GridLayout());
+ leftContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ toolkit.paintBordersFor(leftContainer);
+
+ FILTER: {
+ final Text txtFilter = toolkit.createText(leftContainer, Utils.EMPTY_STRING,
Styles.TEXT_STYLE | SWT.SEARCH
+ | SWT.ICON_CANCEL);
+ txtFilter.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ txtFilter.setMessage(CndMessages.nodeTypeNamePatternMessage);
+ txtFilter.setFont(JFaceResources.getDialogFont());
+ txtFilter.addModifyListener(new ModifyListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText( final ModifyEvent e ) {
+ handleNodeTypeNameFilterModified(txtFilter.getText());
+ }
+ });
+ }
+
+ VIEWER: {
+ final Composite viewerContainer = toolkit.createComposite(leftContainer);
+ viewerContainer.setLayout(new GridLayout());
+ viewerContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ toolkit.paintBordersFor(viewerContainer);
+
+ final Table table = FormUtils.createTable(toolkit, viewerContainer);
+ table.setLinesVisible(false);
+
+ createNodeTypeViewer(table);
+ this.nodeTypesError.setControl(table);
+ }
+
+ RIGHT_SIDE: {
+ final Composite container = toolkit.createComposite(splitter);
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ toolkit.paintBordersFor(container);
+
+ DETAILS: {
+ createDetailsSection(managedForm, toolkit, container);
+ }
+
+ PROPERTIES: {
+ createPropertySection(managedForm, toolkit, container);
+ }
+
+ CHILD_NODES: {
+ createChildNodeSection(managedForm, toolkit, container);
+ }
+ }
+
+ splitter.setWeights(new int[] { 20, 80 });
+ }
+
+ private void createNodeTypeViewer( final Table nodeTypeTable ) {
+ // create custom label provider for node type definitions
+ class NodeTypeLabelProvider extends ColumnLabelProvider {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( final Object element ) {
+ final NodeTypeDefinition nodeTypeDefinition =
(NodeTypeDefinition)element;
+ return nodeTypeDefinition.getName();
+ }
+ }
+
+ this.nodeTypeViewer = new TableViewer(nodeTypeTable);
+ this.nodeTypeViewer.setContentProvider(new IStructuredContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( final Object inputElement ) {
+ return getCnd().getNodeTypeDefinitions().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( final Viewer viewer,
+ final Object oldInput,
+ final Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ // open edit namespace on double click
+ this.nodeTypeViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ public void doubleClick( final DoubleClickEvent event ) {
+ handleEditNodeType();
+ }
+ });
+
+ // add selection listener
+ this.nodeTypeViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ @Override
+ public void selectionChanged( final SelectionChangedEvent event ) {
+ handleNodeTypeSelected();
+ }
+ });
+
+ { // create name column
+ final TableViewerColumn nameColumn = new
TableViewerColumn(this.nodeTypeViewer, SWT.LEFT);
+ UiUtils.configureColumn(nameColumn, new NodeTypeLabelProvider(),
CndMessages.nodeTypeNameHeaderText,
+ CndMessages.nodeTypeNameToolTip, false, true);
+ }
+
+ // sort by name
+ this.nodeTypeViewer.setSorter(new ViewerSorter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ViewerComparator#sort(org.eclipse.jface.viewers.Viewer,
java.lang.Object[])
+ */
+ @Override
+ public void sort( final Viewer viewer,
+ final Object[] elements ) {
+ Arrays.sort(elements);
+ }
+ });
+
+ // add name filter
+ this.nodeTypeViewer.addFilter(new ViewerFilter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public boolean select( final Viewer viewer,
+ final Object parentElement,
+ final Object element ) {
+ final String pattern = getNodeTypeNameFilterPattern();
+
+ // no pattern don't filter any out
+ if (Utils.isEmpty(pattern)) {
+ return true;
+ }
+
+ final NodeTypeDefinition nodeTypeDefinition =
(NodeTypeDefinition)element;
+ final String name = nodeTypeDefinition.getName();
+
+ // filter out node type without names if there is a pattern
+ if (Utils.isEmpty(name)) {
+ return false;
+ }
+
+ return name.contains(pattern);
+ }
+ });
+ }
+
+ private void createPropertyActions() {
+ this.addProperty = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleAddProperty();
+ }
+ };
+ this.addProperty.setEnabled(false);
+ this.addProperty.setToolTipText(CndMessages.addPropertyToolTip);
+
this.addProperty.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
+
+ this.deleteProperty = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleDeleteProperty();
+ }
+ };
+ this.deleteProperty.setEnabled(false);
+ this.deleteProperty.setToolTipText(CndMessages.deletePropertyToolTip);
+
this.deleteProperty.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
+
+ this.editProperty = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleEditProperty();
+ }
+ };
+ this.editProperty.setEnabled(false);
+ this.editProperty.setToolTipText(CndMessages.editPropertyToolTip);
+
this.editProperty.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
+ }
+
+ private void createPropertySection( final IManagedForm managedForm,
+ final FormToolkit toolkit,
+ final Composite parent ) {
+ // create section
+ this.propertiesSection = FormUtils.createSection(managedForm, toolkit, parent,
CndMessages.cndEditorPropertySectionTitle,
+
CndMessages.cndEditorPropertySectionDescription, Styles.SECTION_STYLE
+ &
~ExpandableComposite.EXPANDED, true);
+ toolkit.paintBordersFor(this.propertiesSection);
+
+ // create actions
+ createPropertyActions();
+
+ // create toolbar
+ FormUtils.createSectionToolBar(this.propertiesSection, toolkit, new IAction[] {
this.addProperty, this.editProperty,
+ this.deleteProperty });
+
+ // create viewer
+ final Composite container = toolkit.createComposite(this.propertiesSection);
+ container.setLayout(new GridLayout());
+ container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ this.propertiesSection.setClient(container);
+ toolkit.paintBordersFor(container);
+
+ final Table table = FormUtils.createTable(toolkit, container);
+ ((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
+
+ createPropertyViewer(table);
+ this.propertiesError.setControl(table);
+ }
+
+ private void createPropertyViewer( final Table propertyTable ) {
+ // create custom label provider for property definitions
+ class PropertyLabelProvider extends ColumnLabelProvider {
+
+ private final int columnIndex;
+
+ public PropertyLabelProvider( final int columnIndex ) {
+ this.columnIndex = columnIndex;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText( final Object element ) {
+ final PropertyDefinition propertyDefinition =
(PropertyDefinition)element;
+
+ if (this.columnIndex == PropertyColumnIndexes.NAME) {
+ return propertyDefinition.getName();
+ }
+
+ final NotationType notationType = NotationType.LONG;
+
+ if (this.columnIndex == PropertyColumnIndexes.TYPE) {
+ return propertyDefinition.getType().toCndNotation(notationType);
+ }
+
+ if (this.columnIndex == PropertyColumnIndexes.ATTRIBUTES) {
+ return propertyDefinition.getAttributesCndNotation(notationType);
+ }
+
+ if (this.columnIndex == PropertyColumnIndexes.DEFAULT_VALUES) {
+ return
propertyDefinition.getType().toCndNotation(NotationType.LONG);
+ }
+
+ assert (this.columnIndex == PropertyColumnIndexes.CONSTRAINTS) :
"Unexpected property column index"; //$NON-NLS-1$
+ return propertyDefinition.getValueConstraintsCndNotation(notationType);
+ }
+ }
+
+ this.propertyViewer = new TableViewer(propertyTable);
+ this.propertyViewer.setContentProvider(new IStructuredContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( final Object inputElement ) {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition == null) {
+ return Utils.EMPTY_OBJECT_ARRAY;
+ }
+
+ return nodeTypeDefinition.getPropertyDefinitions().toArray();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( final Viewer viewer,
+ final Object oldInput,
+ final Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ // open edit property on double click
+ this.propertyViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ public void doubleClick( final DoubleClickEvent event ) {
+ handleEditProperty();
+ }
+ });
+
+ // add selection listener
+ this.propertyViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ @Override
+ public void selectionChanged( final SelectionChangedEvent event ) {
+ handlePropertySelected();
+ }
+ });
+
+ { // create name column
+ final TableViewerColumn nameColumn = new
TableViewerColumn(this.propertyViewer, SWT.LEFT);
+ UiUtils.configureColumn(nameColumn, new
PropertyLabelProvider(PropertyColumnIndexes.NAME), CndMessages.nameHeaderText,
+ CndMessages.propertyNameToolTip, false, true);
+ }
+
+ { // create type column
+ final TableViewerColumn typeColumn = new
TableViewerColumn(this.propertyViewer, SWT.LEFT);
+ UiUtils.configureColumn(typeColumn, new
PropertyLabelProvider(PropertyColumnIndexes.TYPE), CndMessages.typeHeaderText,
+ CndMessages.propertyTypeToolTip, false, true);
+ }
+
+ { // create default values column
+ final TableViewerColumn defaultValuesColumn = new
TableViewerColumn(this.propertyViewer, SWT.LEFT);
+ UiUtils.configureColumn(defaultValuesColumn, new
PropertyLabelProvider(PropertyColumnIndexes.DEFAULT_VALUES),
+ CndMessages.defaultValuesHeaderText,
CndMessages.propertyDefaultValuesToolTip, false, true);
+ }
+
+ { // create attributes column
+ final TableViewerColumn attributesColumn = new
TableViewerColumn(this.propertyViewer, SWT.LEFT);
+ UiUtils.configureColumn(attributesColumn, new
PropertyLabelProvider(PropertyColumnIndexes.ATTRIBUTES),
+ CndMessages.attributesHeaderText,
CndMessages.propertyAttributesToolTip, false, true);
+ }
+
+ { // create value constraints column
+ final TableViewerColumn constraintsColumn = new
TableViewerColumn(this.propertyViewer, SWT.LEFT);
+ UiUtils.configureColumn(constraintsColumn, new
PropertyLabelProvider(PropertyColumnIndexes.CONSTRAINTS),
+ CndMessages.valueConstraintsHeaderText,
CndMessages.propertyValueConstraintsToolTip, false,
+ true);
+ }
+
+ // this will sort by property name
+ this.propertyViewer.setSorter(new ViewerSorter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ViewerComparator#sort(org.eclipse.jface.viewers.Viewer,
java.lang.Object[])
+ */
+ @Override
+ public void sort( final Viewer viewer,
+ final Object[] elements ) {
+ Arrays.sort(elements);
+ }
+ });
+ }
+
+ private void createSuperTypesActions() {
+ this.addSuperType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleAddSuperType();
+ }
+ };
+ this.addSuperType.setEnabled(false);
+ this.addSuperType.setToolTipText(CndMessages.addSuperTypeToolTip);
+
this.addSuperType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.NEW_16X));
+
+ this.deleteSuperType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleDeleteSuperType();
+ }
+ };
+ this.deleteSuperType.setEnabled(false);
+ this.deleteSuperType.setToolTipText(CndMessages.deleteSuperTypeToolTip);
+
this.deleteSuperType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.DELETE_16X));
+
+ this.editSuperType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleEditSuperType();
+ }
+ };
+ this.editSuperType.setEnabled(false);
+ this.editSuperType.setToolTipText(CndMessages.editSuperTypeToolTip);
+
this.editSuperType.setImageDescriptor(Activator.getSharedInstance().getImageDescriptor(UiConstants.Images.EDIT_16X));
+ }
+
+ private void createSuperTypesViewer( final Table superTypesTable ) {
+ this.superTypesViewer = new TableViewer(superTypesTable);
+ this.superTypesViewer.setLabelProvider(new LabelProvider());
+ this.superTypesViewer.setContentProvider(new IStructuredContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // nothing to do
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements( final Object inputElement ) {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition == null) {
+ return Utils.EMPTY_OBJECT_ARRAY;
+ }
+
+ return nodeTypeDefinition.getDeclaredSupertypeNames();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
java.lang.Object,
+ * java.lang.Object)
+ */
+ @Override
+ public void inputChanged( final Viewer viewer,
+ final Object oldInput,
+ final Object newInput ) {
+ // nothing to do
+ }
+ });
+
+ this.superTypesViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ public void doubleClick( final DoubleClickEvent event ) {
+ handleEditSuperType();
+ }
+ });
+
+ this.superTypesViewer.addSelectionChangedListener(new ISelectionChangedListener()
{
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ @Override
+ public void selectionChanged( final SelectionChangedEvent event ) {
+ handleSuperTypeSelected();
+ }
+ });
+ }
+
+ /**
+ * @return the name filter pattern (can be <code>null</code>)
+ */
+ String getNodeTypeNameFilterPattern() {
+ return this.nodeTypeNameFilterPattern;
+ }
+
+ /**
+ * @return the selected child node definition or <code>null</code> if the
viewer has an empty selection
+ */
+ private ChildNodeDefinition getSelectedChildNode() {
+ final IStructuredSelection selection =
(IStructuredSelection)this.childNodeViewer.getSelection();
+
+ if (selection.isEmpty()) {
+ return null;
+ }
+
+ assert (selection.size() == 1) : "child node viewer should not allow
multiple selections"; //$NON-NLS-1$
+ assert (selection.getFirstElement() instanceof ChildNodeDefinition) :
"selection was not a ChildNodeDefinition"; //$NON-NLS-1$
+ return (ChildNodeDefinition)selection.getFirstElement();
+ }
+
+ /**
+ * @return the selected namespace mapping or <code>null</code> if the
viewer has an empty selection
+ */
+ private NamespaceMapping getSelectedNamespace() {
+ final IStructuredSelection selection =
(IStructuredSelection)this.namespaceViewer.getSelection();
+
+ if (selection.isEmpty()) {
+ return null;
+ }
+
+ assert (selection.size() == 1) : "child node viewer should not allow
multiple selections"; //$NON-NLS-1$
+ assert (selection.getFirstElement() instanceof NamespaceMapping) :
"selection was not a NamespaceMapping"; //$NON-NLS-1$
+ return (NamespaceMapping)selection.getFirstElement();
+ }
+
+ /**
+ * @return the selected node type definition or <code>null</code> if the
viewer has an empty selection
+ */
+ NodeTypeDefinition getSelectedNodeType() {
+ final IStructuredSelection selection =
(IStructuredSelection)this.nodeTypeViewer.getSelection();
+
+ if (selection.isEmpty()) {
+ return null;
+ }
+
+ assert (selection.size() == 1) : "node type viewer should not allow multiple
selections"; //$NON-NLS-1$
+ assert (selection.getFirstElement() instanceof NodeTypeDefinition) :
"selection was not a NodeTypeDefinition"; //$NON-NLS-1$
+ return (NodeTypeDefinition)selection.getFirstElement();
+ }
+
+ /**
+ * @return the selected property definition or <code>null</code> if the
viewer has an empty selection
+ */
+ private PropertyDefinition getSelectedProperty() {
+ final IStructuredSelection selection =
(IStructuredSelection)this.propertyViewer.getSelection();
+
+ if (selection.isEmpty()) {
+ return null;
+ }
+
+ assert (selection.size() == 1) : "property viewer should not allow multiple
selections"; //$NON-NLS-1$
+ assert (selection.getFirstElement() instanceof PropertyDefinition) :
"selection was not a PropertyDefinition"; //$NON-NLS-1$
+ return (PropertyDefinition)selection.getFirstElement();
+ }
+
+ /**
+ * @return the selected super type or <code>null</code> if the viewer has
an empty selection
+ */
+ private String getSelectedSuperType() {
+ final IStructuredSelection selection =
(IStructuredSelection)this.superTypesViewer.getSelection();
+
+ if (selection.isEmpty()) {
+ return null;
+ }
+
+ assert (selection.size() == 1) : "super types viewer should not allow
multiple selections"; //$NON-NLS-1$
+ assert (selection.getFirstElement() instanceof String) : "selection was not
a string"; //$NON-NLS-1$
+ return (String)selection.getFirstElement();
+ }
+
+ void handleAbstractChanged( final boolean newValue ) {
+ getSelectedNodeType().setAbstract(newValue);
+ }
+
+ void handleAddChildNode() {
+ // TODO handleAddChildNode
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleAddNamespace() {
+ // TODO handleAddNamespace
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleAddNodeType() {
+ // TODO handleAddNodeType
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleAddProperty() {
+ // TODO handleAddProperty
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleAddSuperType() {
+ // TODO handleAddSuperType
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleChildNodeSelected() {
+ // update button enablements
+ boolean enable = (getSelectedNodeType() != null);
+
+ if (this.addChildNode.isEnabled() != enable) {
+ this.addChildNode.setEnabled(enable);
+ }
+
+ enable = (getSelectedChildNode() != null);
+
+ if (this.editChildNode.isEnabled() != enable) {
+ this.editChildNode.setEnabled(enable);
+ }
+
+ if (this.deleteChildNode.isEnabled() != enable) {
+ this.deleteChildNode.setEnabled(enable);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.ui.cnd.CndEditorPage#handleCndReloaded()
+ */
+ @Override
+ public void handleCndReloaded() {
+ // make sure GUI has been constructed before refreshing
+ if (this.propertyViewer != null) {
+ refreshNameControls(true);
+ refreshAttributeControls();
+ refreshSuperTypes();
+ refreshPropertyViewer();
+ refreshChildNodeViewer();
+ }
+ }
+
+ void handleDeleteChildNode() {
+ assert (getSelectedNodeType() != null) : "Delete child node button is
enabled and there is no node type selected"; //$NON-NLS-1$
+ assert (getSelectedChildNode() != null) : "Delete child node button is
enabled and there is no child node selected"; //$NON-NLS-1$
+
+ final ChildNodeDefinition childNodeDefinition = getSelectedChildNode();
+ final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
+
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
+ String name = childNodeDefinition.getName();
+
+ if (Utils.isEmpty(name)) {
+ name = Messages.missingName;
+ }
+
+ // show confirmation dialog
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteChildNodeDialogTitle, image,
+
NLS.bind(CndMessages.deleteChildNodeDialogMessage, name))) {
+ getSelectedNodeType().removeChildNodeDefinition(childNodeDefinition);
+ }
+ }
+
+ void handleDeleteNamespace() {
+ assert (getSelectedNamespace() != null) : "Delete namespace button is
enabled and there is no namespace selected"; //$NON-NLS-1$
+
+ final NamespaceMapping namespaceMapping = getSelectedNamespace();
+ final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
+
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
+ String prefix = namespaceMapping.getPrefix();
+
+ if (Utils.isEmpty(prefix)) {
+ prefix = CndMessages.missingValue;
+ }
+
+ // show confirmation dialog
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteNamespaceDialogTitle, image,
+
NLS.bind(CndMessages.deleteNamespaceDialogMessage, prefix))) {
+ getCnd().removeNamespaceMapping(namespaceMapping);
+ }
+ }
+
+ void handleDeleteNodeType() {
+ assert (getSelectedNodeType() != null) : "Delete node type button is enabled
and there is no node type selected"; //$NON-NLS-1$
+
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+ final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
+
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
+ String name = nodeTypeDefinition.getName();
+
+ if (Utils.isEmpty(name)) {
+ name = Messages.missingName;
+ }
+
+ // show confirmation dialog
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteNodeTypeDialogTitle, image,
+
NLS.bind(CndMessages.deleteNodeTypeDialogMessage, name))) {
+ getCnd().removeNodeTypeDefinition(nodeTypeDefinition);
+ }
+ }
+
+ void handleDeleteProperty() {
+ assert (getSelectedNodeType() != null) : "Delete property button is enabled
and there is no node type selected"; //$NON-NLS-1$
+ assert (getSelectedProperty() != null) : "Delete property button is enabled
and there is no property selected"; //$NON-NLS-1$
+
+ final PropertyDefinition propertyDefinition = getSelectedProperty();
+ final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
+
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
+ String name = propertyDefinition.getName();
+
+ if (Utils.isEmpty(name)) {
+ name = Messages.missingName;
+ }
+
+ // show confirmation dialog
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deletePropertyDialogTitle, image,
+
NLS.bind(CndMessages.deletePropertyDialogMessage, name))) {
+ getSelectedNodeType().removePropertyDefinition(propertyDefinition);
+ }
+ }
+
+ void handleDeleteSuperType() {
+ assert (getSelectedNodeType() != null) : "Delete super type button is
enabled and there is no node type selected"; //$NON-NLS-1$
+ assert (getSelectedSuperType() != null) : "Delete super type button is
enabled and there is no super type selected"; //$NON-NLS-1$
+
+ String superTypeName = getSelectedSuperType();
+ final Image image =
org.jboss.tools.modeshape.jcr.ui.Activator.getSharedInstance()
+
.getImage(org.jboss.tools.modeshape.jcr.ui.UiConstants.Images.CND_EDITOR);
+
+ if (Utils.isEmpty(superTypeName)) {
+ superTypeName = Messages.missingName;
+ }
+
+ // show confirmation dialog
+ if (MessageFormDialog.openQuestion(getShell(),
CndMessages.deleteSuperTypeDialogTitle, image,
+
NLS.bind(CndMessages.deleteSuperTypeDialogMessage, superTypeName))) {
+ getSelectedNodeType().removeSuperType(superTypeName);
+ }
+ }
+
+ void handleEditChildNode() {
+ // TODO handleEditChildNode
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleEditNamespace() {
+ // TODO handleEditNamespace
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleEditNodeType() {
+ // TODO handleEditNodeType
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleEditProperty() {
+ // TODO handleEditProperty
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleEditSuperType() {
+ // TODO handleEditSuperType
+ MessageFormDialog.openInfo(getShell(), "Not Implemented Yet", null,
"method has not be implemented");
+ }
+
+ void handleMixinChanged( final boolean newValue ) {
+ getSelectedNodeType().setMixin(newValue);
+ }
+
+ /**
+ * @param newQualifier the new node type definition qualifier/prefix (can be
<code>null</code> or empty
+ */
+ protected void handleNameQualifierChanged( String newQualifier ) {
+ if (!Utils.isEmpty(newQualifier) && (getSelectedNodeType() != null)) {
+ final String name = this.txtName.getText();
+
+ // if prefix indicates no qualifier should be used just use the name
otherwise use prefix and name
+ if (CndMessages.noNameQualifierChoice.equals(newQualifier)) {
+ newQualifier = Utils.EMPTY_STRING;
+ }
+
+ final String newName = new QualifiedName(newQualifier, name).get();
+ getSelectedNodeType().setName(newName);
+ }
+ }
+
+ void handleNamespaceSelected() {
+ // update button enablements
+ final boolean enable = (getSelectedNamespace() != null);
+
+ // this.addNamespace is always enabled
+
+ if (this.editNamespace.isEnabled() != enable) {
+ this.editNamespace.setEnabled(enable);
+ }
+
+ if (this.deleteNamespace.isEnabled() != enable) {
+ this.deleteNamespace.setEnabled(enable);
+ }
+ }
+
+ void handleNodeTypeNameChanged( final String newNodeTypeName ) {
+ if (getSelectedNodeType() != null) {
+ String qualifier = this.cbxNamePrefix.getText();
+
+ // if prefix indicates no qualifier should be used just use the name
otherwise use prefix and name
+ if (CndMessages.noNameQualifierChoice.equals(qualifier)) {
+ qualifier = Utils.EMPTY_STRING;
+ }
+
+ final String newName = new QualifiedName(qualifier, newNodeTypeName).get();
+ getSelectedNodeType().setName(newName);
+ }
+ }
+
+ void handleNodeTypeNameFilterModified( final String namePattern ) {
+ this.nodeTypeNameFilterPattern = namePattern;
+ this.nodeTypeViewer.refresh();
+ }
+
+ void handleNodeTypeSelected() {
+ updateEnabledState();
+
+ // update section descriptions
+ if (getSelectedNodeType() == null) {
+
this.detailsSection.setDescription(CndMessages.cndEditorDetailsSectionDescription);
+
this.propertiesSection.setDescription(CndMessages.cndEditorChildNodeSectionDescription);
+
this.childNodeSection.setDescription(CndMessages.cndEditorPropertySectionDescription);
+ } else {
+ String name = getSelectedNodeType().getName();
+
+ if (Utils.isEmpty(name)) {
+ name = Messages.missingName;
+ }
+
+
this.detailsSection.setDescription(NLS.bind(CndMessages.cndEditorChildNodeSectionDescriptionWithNodeTypeName,
name));
+
this.propertiesSection.setDescription(NLS.bind(CndMessages.cndEditorChildNodeSectionDescriptionWithNodeTypeName,
name));
+
this.childNodeSection.setDescription(NLS.bind(CndMessages.cndEditorPropertySectionDescriptionWithNodeTypeName,
name));
+ }
+
+ // update button enablements
+ final boolean enable = (getSelectedNodeType() != null);
+
+ // this.addNodeType always enabled
+
+ if (this.editNodeType.isEnabled() != enable) {
+ this.editNodeType.setEnabled(enable);
+ }
+
+ if (this.deleteNodeType.isEnabled() != enable) {
+ this.deleteNodeType.setEnabled(enable);
+ }
+
+ // populate details section
+ refreshNameControls(false);
+ refreshAttributeControls();
+ refreshSuperTypes();
+ refreshPropertyViewer();
+ refreshChildNodeViewer();
+ }
+
+ void handleOrderableChanged( final boolean newValue ) {
+ getSelectedNodeType().setOrderableChildNodes(newValue);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.ui.cnd.CndEditorPage#handlePropertyChanged(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ protected void handlePropertyChanged( final PropertyChangeEvent e ) {
+ // return if GUI hasn't been constructed yet
+ if (this.childNodeViewer == null) {
+ return;
+ }
+
+ // TODO implement handlePropertyChanged
+ final String propName = e.getPropertyName();
+
+ if (NodeTypeDefinition.PropertyName.ABSTRACT.toString().equals(propName)) {
+
+ } else if
(NodeTypeDefinition.PropertyName.CHILD_NODES.toString().equals(propName)) {
+
+ } else if (NodeTypeDefinition.PropertyName.MIXIN.toString().equals(propName)) {
+
+ } else if (NodeTypeDefinition.PropertyName.NAME.toString().equals(propName)) {
+
+ } else if (NodeTypeDefinition.PropertyName.ORDERABLE.toString().equals(propName))
{
+
+ } else if
(NodeTypeDefinition.PropertyName.PRIMARY_ITEM.toString().equals(propName)) {
+ // TODO primary item has not been code for in this class yet
+ } else if
(NodeTypeDefinition.PropertyName.PROPERTY_DEFINITIONS.toString().equals(propName)) {
+
+ } else if (NodeTypeDefinition.PropertyName.QUERYABLE.toString().equals(propName))
{
+
+ } else if
(NodeTypeDefinition.PropertyName.SUPERTYPES.toString().equals(propName)) {
+
+ }
+ }
+
+ void handlePropertySelected() {
+ // update button enablements
+ boolean enable = (getSelectedNodeType() != null);
+
+ if (this.addProperty.isEnabled() != enable) {
+ this.addProperty.setEnabled(enable);
+ }
+
+ enable = (getSelectedProperty() != null);
+
+ if (this.editProperty.isEnabled() != enable) {
+ this.editProperty.setEnabled(enable);
+ }
+
+ if (this.deleteProperty.isEnabled() != enable) {
+ this.deleteProperty.setEnabled(enable);
+ }
+ }
+
+ void handleQueryableChanged( final boolean newValue ) {
+ getSelectedNodeType().setQueryable(newValue);
+ }
+
+ void handleSuperTypeSelected() {
+ // update button enablements
+ boolean enable = (getSelectedNodeType() != null);
+
+ if (this.addSuperType.isEnabled() != enable) {
+ this.addSuperType.setEnabled(enable);
+ }
+
+ enable = (getSelectedSuperType() != null);
+
+ if (this.editSuperType.isEnabled() != enable) {
+ this.editSuperType.setEnabled(enable);
+ }
+
+ if (this.deleteSuperType.isEnabled() != enable) {
+ this.deleteSuperType.setEnabled(enable);
+ }
+ }
+
+ private void populateUi() {
+ this.namespaceViewer.setInput(this);
+ this.nodeTypeViewer.setInput(this);
+
+ // size columns to the data
+ UiUtils.pack(this.namespaceViewer, this.nodeTypeViewer);
+
+ if (this.nodeTypeViewer.getTable().getItemCount() != 0) {
+ this.nodeTypeViewer.getTable().select(0);
+ final Event e = new Event();
+ e.widget = this.nodeTypeViewer.getTable();
+ this.nodeTypeViewer.getTable().notifyListeners(SWT.Selection, e);
+ }
+ }
+
+ private void refreshAttributeControls() {
+ boolean notConcrete = false;
+ boolean mixin = false;
+ boolean orderable = false;
+ boolean queryable = false;
+
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition != null) {
+ if (nodeTypeDefinition.isAbstract()) {
+ notConcrete = true;
+ }
+ if (nodeTypeDefinition.isMixin()) {
+ mixin = true;
+ }
+ if (nodeTypeDefinition.hasOrderableChildNodes()) {
+ orderable = true;
+ }
+ if (nodeTypeDefinition.isQueryable()) {
+ queryable = true;
+ }
+ }
+
+ if (this.btnAbstract.getSelection() != notConcrete) {
+ this.btnAbstract.setSelection(notConcrete);
+ }
+
+ if (this.btnMixin.getSelection() != mixin) {
+ this.btnMixin.setSelection(mixin);
+ }
+
+ if (this.btnOrderable.getSelection() != orderable) {
+ this.btnOrderable.setSelection(orderable);
+ }
+
+ if (this.btnQueryable.getSelection() != queryable) {
+ this.btnQueryable.setSelection(queryable);
+ }
+ }
+
+ private void refreshChildNodeViewer() {
+ if (this.childNodeViewer != null) {
+ this.childNodeViewer.setInput(this);
+ UiUtils.pack(this.childNodeViewer);
+ validateChildNodeDefinitions();
+ }
+ }
+
+ private void refreshNameControls( final boolean loadNamespaces ) {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if ((nodeTypeDefinition == null) || Utils.isEmpty(nodeTypeDefinition.getName()))
{
+ this.cbxNamePrefix.removeAll();
+ this.txtName.setText(Utils.EMPTY_STRING);
+ } else {
+ // load qualifiers with namespace prefixes
+ if (loadNamespaces) {
+ final List<NamespaceMapping> namespaceMappings =
getCnd().getNamespaceMappings();
+ final List<String> prefixes = new
ArrayList<String>(namespaceMappings.size() + 1); // add one for empty qualifier
+ prefixes.add(CndMessages.noNameQualifierChoice);
+
+ for (final NamespaceMapping namespaceMapping : namespaceMappings) {
+ prefixes.add(namespaceMapping.getPrefix());
+ }
+
+ // set qualifier choices if they have changed
+ final String[] currentItems = this.cbxNamePrefix.getItems();
+
+ // only reload qualifiers if different
+ if ((prefixes.size() != currentItems.length) ||
!prefixes.containsAll(Arrays.asList(currentItems))) {
+ this.cbxNamePrefix.setItems(prefixes.toArray(new
String[prefixes.size()]));
+ }
+ }
+
+ // load name
+ final String name = nodeTypeDefinition.getName();
+ final QualifiedName qname = QualifiedName.parse(name);
+
+ // set qualifier
+ final String qualifier = ((qname.getQualifier() == null) ? Utils.EMPTY_STRING
: qname.getQualifier());
+
+ if (!Utils.isEmpty(qualifier)) {
+ int index = this.cbxNamePrefix.indexOf(qualifier);
+
+ if (index == -1) {
+ index = this.cbxNamePrefix.getItemCount();
+ this.cbxNamePrefix.add(qualifier);
+ this.cbxNamePrefix.select(index);
+ } else if (this.cbxNamePrefix.getSelectionIndex() != index) { // only
select if currently not selected
+ this.cbxNamePrefix.select(index);
+ }
+ }
+
+ // set unqualified name
+ final String unqualifiedName = ((qname.getUnqualifiedName() == null) ?
Utils.EMPTY_STRING : qname.getUnqualifiedName());
+
+ // only set text field if different
+ if (!this.txtName.getText().equals(unqualifiedName)) {
+ this.txtName.setText(unqualifiedName);
+ }
+ }
+ }
+
+ private void refreshPropertyViewer() {
+ if (this.propertyViewer != null) {
+ this.propertyViewer.setInput(this);
+ UiUtils.pack(this.propertyViewer);
+ validateProperties();
+ }
+ }
+
+ private void refreshSuperTypes() {
+ if (this.superTypesViewer != null) {
+ this.superTypesViewer.setInput(this);
+ UiUtils.pack(this.superTypesViewer);
+ validateSuperTypes();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.jboss.tools.modeshape.jcr.ui.cnd.CndEditorPage#setResourceReadOnly(boolean)
+ */
+ @Override
+ protected void setResourceReadOnly( final boolean readOnly ) {
+ updateEnabledState();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.tools.modeshape.jcr.ui.cnd.CndEditorPage#updateAllMessages()
+ */
+ @Override
+ protected void updateAllMessages() {
+ validateChildNodeDefinitions();
+ validateNamespaces();
+ validateNodeTypes();
+ validateProperties();
+ }
+
+ private void updateEnabledState() {
+ // return if GUI hasn't been constructed yet
+ if (this.nodeTypeViewer == null) {
+ return;
+ }
+
+ boolean enable = !getCndEditor().isReadOnly();
+
+ { // namespaces section
+ if (this.addNamespace.isEnabled() != enable) {
+ this.addNamespace.setEnabled(enable);
+ }
+
+ if (this.editNamespace.isEnabled() != enable) {
+ this.editNamespace.setEnabled(enable);
+ }
+
+ if (this.deleteNamespace.isEnabled() != enable) {
+ this.deleteNamespace.setEnabled(enable);
+ }
+
+ if (this.namespaceViewer.getTable().isEnabled() != enable) {
+ this.namespaceViewer.getTable().setEnabled(enable);
+ }
+ }
+
+ { // nodetypes section
+ if (this.addNodeType.isEnabled() != enable) {
+ this.addNodeType.setEnabled(enable);
+ }
+
+ if (this.editNodeType.isEnabled() != enable) {
+ this.editNodeType.setEnabled(enable);
+ }
+
+ if (this.deleteNodeType.isEnabled() != enable) {
+ this.deleteNodeType.setEnabled(enable);
+ }
+
+ if (this.nodeTypeViewer.getTable().isEnabled() != enable) {
+ this.nodeTypeViewer.getTable().setEnabled(enable);
+ }
+ }
+
+ enable = (enable && (getSelectedNodeType() != null));
+
+ { // details section
+ if (this.cbxNamePrefix.isEnabled() != enable) {
+ this.cbxNamePrefix.setEnabled(enable);
+ }
+
+ if (this.txtName.isEnabled() != enable) {
+ this.txtName.setEnabled(enable);
+ }
+
+ if (this.btnAbstract.isEnabled() != enable) {
+ this.btnAbstract.setEnabled(enable);
+ }
+
+ if (this.btnMixin.isEnabled() != enable) {
+ this.btnMixin.setEnabled(enable);
+ }
+
+ if (this.btnOrderable.isEnabled() != enable) {
+ this.btnOrderable.setEnabled(enable);
+ }
+
+ if (this.btnQueryable.isEnabled() != enable) {
+ this.btnQueryable.setEnabled(enable);
+ }
+
+ if (this.superTypesViewer.getTable().isEnabled() != enable) {
+ this.superTypesViewer.getTable().setEnabled(enable);
+ }
+ }
+
+ { // properties section
+ if (this.addProperty.isEnabled() != enable) {
+ this.addProperty.setEnabled(enable);
+ }
+
+ if (this.editProperty.isEnabled() != enable) {
+ this.editProperty.setEnabled(enable);
+ }
+
+ if (this.deleteProperty.isEnabled() != enable) {
+ this.deleteProperty.setEnabled(enable);
+ }
+
+ if (this.propertyViewer.getTable().isEnabled() != enable) {
+ this.propertyViewer.getTable().setEnabled(enable);
+ }
+ }
+
+ { // child nodes section
+ if (this.addChildNode.isEnabled() != enable) {
+ this.addChildNode.setEnabled(enable);
+ }
+
+ if (this.editChildNode.isEnabled() != enable) {
+ this.editChildNode.setEnabled(enable);
+ }
+
+ if (this.deleteChildNode.isEnabled() != enable) {
+ this.deleteChildNode.setEnabled(enable);
+ }
+
+ if (this.childNodeViewer.getTable().isEnabled() != enable) {
+ this.childNodeViewer.getTable().setEnabled(enable);
+ }
+ }
+ }
+
+ private void validateChildNodeDefinitions() {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition == null) {
+ this.nodeTypesError.setOkMessage(null);
+ } else {
+ //
CndValidator.validateChildNodeDefinitions(nodeTypeDefinition.getChildNodeDefinitions());
+ }
+ }
+
+ private void validateNamespaces() {
+ final MultiValidationStatus status =
CndValidator.validateNamespaceMappings(getCnd().getNamespaceMappings());
+ JcrUiUtils.setMessage(status, this.namespacesError);
+ }
+
+ private void validateNodeTypes() {
+ final MultiValidationStatus status =
CndValidator.validateNodeTypeDefinitions(getCnd().getNodeTypeDefinitions());
+ JcrUiUtils.setMessage(status, this.nodeTypesError);
+ }
+
+ private void validateProperties() {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition == null) {
+ this.propertiesError.setOkMessage(null);
+ } else {
+ final MultiValidationStatus status =
CndValidator.validatePropertyDefinitions(nodeTypeDefinition.getName(),
+
nodeTypeDefinition.getPropertyDefinitions());
+ JcrUiUtils.setMessage(status, this.propertiesError);
+ }
+ }
+
+ private void validateSuperTypes() {
+ final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
+
+ if (nodeTypeDefinition == null) {
+ this.superTypesError.setOkMessage(null);
+ } else {
+ String nodeTypeName = nodeTypeDefinition.getName();
+
+ if (Utils.isEmpty(nodeTypeName)) {
+ nodeTypeName = Messages.missingName;
+ }
+
+ final MultiValidationStatus status =
CndValidator.validateSuperTypes(nodeTypeName,
+
nodeTypeDefinition.getState(PropertyName.SUPERTYPES),
+
nodeTypeDefinition.getDeclaredSupertypeNames());
+ JcrUiUtils.setMessage(status, this.superTypesError);
+ }
+ }
+
+ interface ChildNodeColumnIndexes {
+ int ATTRIBUTES = 3;
+ int DEFAULT_TYPE = 2;
+ int NAME = 0;
+ int REQUIRED_TYPES = 1;
+ }
+
+ interface NamespaceColumnIndexes {
+ int PREFIX = 0;
+ int URI = 1;
+ }
+
+ interface PropertyColumnIndexes {
+ int ATTRIBUTES = 3;
+ int CONSTRAINTS = 4;
+ int DEFAULT_VALUES = 2;
+ int NAME = 0;
+ int TYPE = 1;
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,449 @@
+/*
+ * 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.cnd;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Localized messages used by classes in the
<code>org.jboss.tools.modeshape.jcr.ui.cnd</code> package.
+ */
+class CndMessages extends NLS {
+
+ /**
+ * The abstract attribute name suitable for a radio or check button.
+ */
+ public static String abstractAttribute;
+
+ /**
+ * The tool tip message of the node type definition's abstract attribute.
+ */
+ public static String abstractAttributeToolTip;
+
+ /**
+ * The tool tip message of the add child node definition action.
+ */
+ public static String addChildNodeToolTip;
+
+ /**
+ * The tool tip message of the add namespace mapping action.
+ */
+ public static String addNamespaceToolTip;
+
+ /**
+ * The tool tip message of the add node type definition action.
+ */
+ public static String addNodeTypeToolTip;
+
+ /**
+ * The tool tip message of the add property definition action.
+ */
+ public static String addPropertyToolTip;
+
+ /**
+ * The tool tip message of the add property definition action.
+ */
+ public static String addSuperTypeToolTip;
+
+ /**
+ * The column header text for attributes.
+ */
+ public static String attributesHeaderText;
+
+ /**
+ * The tool tip for the attributes of a child node definition.
+ */
+ public static String childNodeAttributesToolTip;
+
+ /**
+ * The tool tip text for the default type of a child node definition.
+ */
+ public static String childNodeDefaultTypeToolTip;
+
+ /**
+ * The tool tip for a child node definition name.
+ */
+ public static String childNodeNameToolTip;
+
+ /**
+ * The tool tip text for the required types of a child node definition.
+ */
+ public static String childNodeRequiredTypesToolTip;
+
+ /**
+ * The title of the dialog shown within the CND editor when the editor notices that
the CND file has been changed outside the
+ * editor.
+ */
+ public static String cndChangedOnFileSystemDialogTitle;
+
+ /**
+ * The message of the dialog shown within the CND editor when the editor notices that
the CND file has been changed outside the
+ * editor. One parameter, the file name, is expected.
+ */
+ public static String cndChangedOnFileSystemDialogMsg;
+
+ /**
+ * The description of the child node definition section in the CND editor's form
page.
+ */
+ public static String cndEditorChildNodeSectionDescription;
+
+ /**
+ * The description of the child node definition section in the CND editor's form
page. One parameter, the node type definition
+ * name, is required.
+ */
+ public static String cndEditorChildNodeSectionDescriptionWithNodeTypeName;
+
+ /**
+ * The title of the child node definition section in the CND editor's form page.
+ */
+ public static String cndEditorChildNodeSectionTitle;
+
+ /**
+ * The description of the details section in the CND editor's form page.
+ */
+ public static String cndEditorDetailsSectionDescription;
+
+ /**
+ * The description of the details section in the CND editor's form page. One
parameter, the node type definition name, is
+ * required.
+ */
+ public static String cndEditorDetailsSectionDescriptionWithNodeTypeName;
+
+ /**
+ * The title of the node type definition's details section in the CND
editor's form page.
+ */
+ public static String cndEditorDetailsSectionTitle;
+
+ /**
+ * The title of the forms page of the CND editor.
+ */
+ public static String cndEditorFormsPageTitle;
+
+ /**
+ * The message of the dialog shown when an input to the CND editor was not a file.
+ */
+ public static String cndEditorInputNotAFile;
+
+ /**
+ * The description of the namespace mappings section in the CND editor's form
page.
+ */
+ public static String cndEditorNamespacesSectionDescription;
+
+ /**
+ * The title of the namespace mappings section in the CND editor's form page.
+ */
+ public static String cndEditorNamespacesSectionTitle;
+
+ /**
+ * The description of the namespace mappings section in the CND editor's form
page.
+ */
+ public static String cndEditorNodeTypeSectionDescription;
+
+ /**
+ * The title of the namespace mappings section in the CND editor's form page.
+ */
+ public static String cndEditorNodeTypeSectionTitle;
+
+ /**
+ * The description of the property definition section in the CND editor's form
page.
+ */
+ public static String cndEditorPropertySectionDescription;
+
+ /**
+ * The description of the property definition section in the CND editor's form
page. One parameter, the node type definition
+ * name, is required.
+ */
+ public static String cndEditorPropertySectionDescriptionWithNodeTypeName;
+
+ /**
+ * The title of the property definition section in the CND editor's form page.
+ */
+ public static String cndEditorPropertySectionTitle;
+
+ /**
+ * The title of the dialog shown when refreshing the CND editor with the CND file
from the file system fails.
+ */
+ public static String cndEditorRefreshErrorTitle;
+
+ /**
+ * The message of the dialog shown when refreshing the CND editor with the CND file
from the file system fails.
+ */
+ public static String cndEditorRefreshErrorMsg;
+
+ /**
+ * The message of an error dialog shown when saving the CND editor fails.
+ */
+ public static String cndEditorSaveError;
+
+ /**
+ * The title of the source page of the CND editor.
+ */
+ public static String cndEditorSourcePageTitle;
+
+ /**
+ * The title of the CND editor.
+ */
+ public static String cndEditorTitle;
+
+ /**
+ * The column header text of the default type of a child node definition.
+ */
+ public static String defaultTypeHeaderText;
+
+ /**
+ * The column header text of the default values of a property definition.
+ */
+ public static String defaultValuesHeaderText;
+
+ /**
+ * The question message of the dialog for deleting a child node definition. One
parameter, the child node definition name, is
+ * required.
+ */
+ public static String deleteChildNodeDialogMessage;
+
+ /**
+ * The title of the dialog for deleting a child node definition.
+ */
+ public static String deleteChildNodeDialogTitle;
+
+ /**
+ * The tool tip message of the delete child node definition action.
+ */
+ public static String deleteChildNodeToolTip;
+
+ /**
+ * The question message of the dialog for deleting a namespace mapping. One
parameter, the namespace prefix, is required.
+ */
+ public static String deleteNamespaceDialogMessage;
+
+ /**
+ * The title of the dialog for deleting a namespace mapping.
+ */
+ public static String deleteNamespaceDialogTitle;
+
+ /**
+ * The tool tip message of the delete namespace mapping action.
+ */
+ public static String deleteNamespaceToolTip;
+
+ /**
+ * The question message of the dialog for deleting a node type definition. One
parameter, the node type definition name, is
+ * required.
+ */
+ public static String deleteNodeTypeDialogMessage;
+
+ /**
+ * The title of the dialog for deleting a node type definition.
+ */
+ public static String deleteNodeTypeDialogTitle;
+
+ /**
+ * The tool tip message of the delete node type definition action.
+ */
+ public static String deleteNodeTypeToolTip;
+
+ /**
+ * The question message of the dialog for deleting a property definition. One
parameter, the property definition name, is
+ * required.
+ */
+ public static String deletePropertyDialogMessage;
+
+ /**
+ * The title of the dialog for deleting a property definition.
+ */
+ public static String deletePropertyDialogTitle;
+
+ /**
+ * The tool tip message of the delete property definition action.
+ */
+ public static String deletePropertyToolTip;
+
+ /**
+ * The question message of the dialog for deleting a super type. One parameter, the
super type name, is required.
+ */
+ public static String deleteSuperTypeDialogMessage;
+
+ /**
+ * The title of the dialog for deleting a super type.
+ */
+ public static String deleteSuperTypeDialogTitle;
+
+ /**
+ * The tool tip message of the delete super type action.
+ */
+ public static String deleteSuperTypeToolTip;
+
+ /**
+ * The tool tip message of the edit child node definition action.
+ */
+ public static String editChildNodeToolTip;
+
+ /**
+ * The tool tip message of the edit namespace mapping action.
+ */
+ public static String editNamespaceToolTip;
+
+ /**
+ * The tool tip message of the edit node type definition action.
+ */
+ public static String editNodeTypeToolTip;
+
+ /**
+ * The tool tip message of the edit property definition action.
+ */
+ public static String editPropertyToolTip;
+
+ /**
+ * The tool tip message of the edit super type action.
+ */
+ public static String editSuperTypeToolTip;
+
+ /**
+ * The error message when the CND editor could not be opened.
+ */
+ public static String errorOpeningCndEditor;
+
+ /**
+ * A message indicating there is no value.
+ */
+ public static String missingValue;
+
+ /**
+ * The mixin attribute name suitable for a radio or check button.
+ */
+ public static String mixinAttribute;
+
+ /**
+ * The tool tip message of the node type definition's mixin attribute.
+ */
+ public static String mixinAttributeToolTip;
+
+ /**
+ * The column header text for a generic name property or attribute.
+ */
+ public static String nameHeaderText;
+
+ /**
+ * A label for a generic name control.
+ */
+ public static String nameLabel;
+
+ /**
+ * A label for a namespace mapping control.
+ */
+ public static String namespaceLabel;
+
+ /**
+ * The column header text for a namespace prefix.
+ */
+ public static String namespacePrefixHeaderText;
+
+ /**
+ * The tool tip for a namespace prefix.
+ */
+ public static String namespacePrefixToolTip;
+
+ /**
+ * The column header text for a namespace URI.
+ */
+ public static String namespaceUriHeaderText;
+
+ /**
+ * The tool tip for a namespace URI.
+ */
+ public static String namespaceUriToolTip;
+
+ /**
+ * The message displayed in the node type name pattern filter when the pattern is
empty.
+ */
+ public static String nodeTypeNamePatternMessage;
+
+ /**
+ * The column header text for the node type definition name.
+ */
+ public static String nodeTypeNameHeaderText;
+
+ /**
+ * The tool tip for a node type definition name.
+ */
+ public static String nodeTypeNameToolTip;
+
+ /**
+ * The text indicating the qualified name does not have a qualifier.
+ */
+ public static String noNameQualifierChoice;
+
+ /**
+ * The orderable attribute name suitable for a radio or check button.
+ */
+ public static String orderableAttribute;
+
+ /**
+ * The tool tip message of the node type definition's orderable attribute.
+ */
+ public static String orderableAttributeToolTip;
+
+ /**
+ * The tool tip for the attributes of a property definition.
+ */
+ public static String propertyAttributesToolTip;
+
+ /**
+ * The tool tip for the default values of a property definition.
+ */
+ public static String propertyDefaultValuesToolTip;
+
+ /**
+ * The tool tip for a property definition name.
+ */
+ public static String propertyNameToolTip;
+
+ /**
+ * The tool tip for the data type of a property definition.
+ */
+ public static String propertyTypeToolTip;
+
+ /**
+ * The tool tip for the value constraints of a property definition.
+ */
+ public static String propertyValueConstraintsToolTip;
+
+ /**
+ * The queryable attribute name suitable for a radio or check button.
+ */
+ public static String queryableAttribute;
+
+ /**
+ * The tool tip message of the node type definition's queryable attribute.
+ */
+ public static String queryableAttributeToolTip;
+
+ /**
+ * The column header text for the required types of a child node definition.
+ */
+ public static String requiredTypesHeaderText;
+
+ /**
+ * A label for a supertypes control.
+ */
+ public static String supertypesLabel;
+
+ /**
+ * The column header text for a type.
+ */
+ public static String typeHeaderText;
+
+ /**
+ * The column header text for the value constraints of a property definition.
+ */
+ public static String valueConstraintsHeaderText;
+
+ static {
+
NLS.initializeMessages("org.jboss.tools.modeshape.jcr.ui.cnd.cndMessages",
CndMessages.class); //$NON-NLS-1$
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,102 @@
+# 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.
+
+abstractAttribute = Abstract
+abstractAttributeToolTip = Indicates if the node type definition cannot be instantiated
+addChildNodeToolTip = Add a child node definition
+addNamespaceToolTip = Add a namespace mapping
+addNodeTypeToolTip = Add a node type definition
+addPropertyToolTip = Add a property definition
+addSuperTypeToolTip = Add a super type
+attributesHeaderText = Attributes
+propertyAttributesToolTip = The attributes of a property definition (autocreated,
mandatory, multiple, nofulltext, noqueryorder, abstract, opv, queryops)
+childNodeAttributesToolTip = The attributes of a child node definition (autocreated,
mandatory, abstract, opv, sns)
+childNodeDefaultTypeToolTip = The default type of a child node definition
+childNodeNameToolTip = The name of a child node definition
+childNodeRequiredTypesToolTip = The required types of a child node definition
+cndChangedOnFileSystemDialogTitle = CND File Changed
+# 0 = file name
+cndChangedOnFileSystemDialogMsg = The CND file "{0}" was changed on the file
system. Do you want to load the changes into the CND editor?
+cndEditorChildNodeSectionDescription = Manage the child node definitions
+# 0 = node type definition name
+cndEditorChildNodeSectionDescriptionWithNodeTypeName = Manage the child node definitions
for the "{0}" node type definition
+cndEditorChildNodeSectionTitle = Child Nodes
+cndEditorDetailsSectionDescription = Details of the node type definition
+# 0 = node type definition name
+cndEditorDetailsSectionDescriptionWithNodeTypeName = Details of the "{0}" node
type definition
+cndEditorDetailsSectionTitle = Details
+cndEditorFormsPageTitle = Forms
+cndEditorInputNotAFile = CND Editor input was not a file.
+cndEditorNamespacesSectionDescription = Manage the namespace mappings
+cndEditorNamespacesSectionTitle = Namespaces
+cndEditorNodeTypeSectionDescription = Manage the node types and their defined property
definitions and child node definitions
+cndEditorNodeTypeSectionTitle = Node Types
+cndEditorPropertySectionDescription = Manage the property definitions
+# 0 = node type definition name
+cndEditorPropertySectionDescriptionWithNodeTypeName = Manage the property definitions for
the "{0}" node type definition
+cndEditorPropertySectionTitle = Properties
+cndEditorRefreshErrorTitle = Unable to refresh the CND editor
+cndEditorRefreshErrorMsg = The CND editor could not be reloaded. Close and reopen. See
log for details.
+cndEditorSaveError = Error saving the model extension definition editor.
+cndEditorSourcePageTitle = Source
+cndEditorTitle = JCR Compact Node Definition
+defaultTypeHeaderText = Default Type
+defaultValuesHeaderText = Default Values
+# 0 = child node definition name
+deleteChildNodeDialogMessage = Are you sure you want to delete the "{0}" child
node definition?
+deleteChildNodeDialogTitle = Delete Child Node
+deleteChildNodeToolTip = Delete the selected child node definition
+# 0 = namespace mapping prefix
+deleteNamespaceDialogMessage = Are you sure you want to delete the namespace mapping with
prefix "{0}"?
+deleteNamespaceDialogTitle = Delete Namespace
+deleteNamespaceToolTip = Delete the selected namespace mapping
+# 0 = node type definition name
+deleteNodeTypeDialogMessage = Are you sure you want to delete the "{0}" node
type definition?
+deleteNodeTypeDialogTitle = Delete Node Type
+deleteNodeTypeToolTip = Delete the selected node type definition
+# 0 = property definition name
+deletePropertyDialogMessage = Are you sure you want to delete the "{0}"
property definition?
+deletePropertyDialogTitle = Delete Property
+deletePropertyToolTip = Delete the selected property definition
+# 0 = supertype name
+deleteSuperTypeDialogMessage = Are you sure you want to delete the "{0}" super
type?
+deleteSuperTypeDialogTitle = Delete Super Type
+deleteSuperTypeToolTip = Delete the selected super type
+editChildNodeToolTip = Edit the selected child node definition
+editNamespaceToolTip = Edit the selected namespace mapping
+editNodeTypeToolTip = Edit the selected node type definition
+editPropertyToolTip = Edit the selected property definition
+editSuperTypeToolTip = Edit the selected super type
+errorOpeningCndEditor = There was a problem creating the CND editor.
+missingValue = <missing>
+mixinAttribute = Mixin
+mixinAttributeToolTip = Indicates if the node type definition is a mixin and not a
primary node type
+nameLabel = Name:
+nameHeaderText = Name
+namespaceLabel = Namespace:
+namespacePrefixHeaderText = Prefix
+namespacePrefixToolTip = The prefix of the namespace mapping
+namespaceUriHeaderText = URI
+namespaceUriToolTip = The URI of the namespace mapping
+nodeTypeNamePatternMessage = enter name pattern
+nodeTypeNameHeaderText = Node Type Name
+nodeTypeNameToolTip = The name of the node type definition
+noNameQualifierChoice = <no qualifier>
+orderableAttribute = Orderable
+orderableAttributeToolTip = Indicates if the node type definition's are ordered
+propertyAttributesToolTip = The attributes of a property definition (autocreated,
mandatory, multiple, nofulltext, noqueryorder, abstract, opv, queryops)
+propertyDefaultValuesToolTip = The default values of a property definition
+propertyNameToolTip = The name or identifier of the property definition
+propertyTypeToolTip = The data type of the property definition
+propertyValueConstraintsToolTip = The value constraints of a property definition
+queryableAttribute = Queryable
+queryableAttributeToolTip = Indicates if the node type can be queried
+supertypesLabel = Supertypes:
+requiredTypesHeaderText = Required Types
+typeHeaderText = Type
+valueConstraintsHeaderText = Value Constraints
+
+
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui
___________________________________________________________________
Added: svn:ignore
+ bin
target
build
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.classpath
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.classpath
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.classpath 2012-03-15 15:55:37
UTC (rev 39542)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.classpath
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.project
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.project
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.project 2012-03-15 15:55:37 UTC
(rev 39542)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.modeshape.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.project
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.jdt.core.prefs 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,22 @@
+#Fri Mar 02 10:45:36 CST 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.doc.comment.support=enabled
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadoc=error
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
+org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
+org.eclipse.jdt.core.compiler.problem.missingJavadocComments=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=protected
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag
+org.eclipse.jdt.core.compiler.problem.missingJavadocTags=error
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=protected
+org.eclipse.jdt.core.compiler.source=1.6
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.jdt.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.pde.core.prefs
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.pde.core.prefs
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.pde.core.prefs 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,4 @@
+#Thu Mar 01 11:05:40 CST 2012
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/.settings/org.eclipse.pde.core.prefs
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %bundleName
+Bundle-SymbolicName: org.jboss.tools.modeshape.ui;singleton:=true
+Bundle-Version: 1.1.0.qualifier
+Bundle-Vendor: %bundleVendor
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.eclipse.jface,
+ org.eclipse.ui.forms,
+ org.eclipse.osgi,
+ org.eclipse.ui,
+ org.eclipse.core.runtime
+Export-Package: org.jboss.tools.modeshape.ui,
+ org.jboss.tools.modeshape.ui.forms,
+ org.jboss.tools.modeshape.ui.graphics
+Bundle-Activator: org.jboss.tools.modeshape.ui.Activator
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/META-INF/MANIFEST.MF
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/OSGI-INF/l10n/bundle.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/OSGI-INF/l10n/bundle.properties
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/OSGI-INF/l10n/bundle.properties 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,13 @@
+#
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership.
+#
+# This software is made available by Red Hat, Inc. under the terms of the
+# Eclipse Public License v1.0 which accompanies this distribution and is
+# available at
http://www.eclipse.org/legal/epl-v10.html.
+#
+# See the AUTHORS.txt file in the distribution for a full listing of
+# individual contributors.
+#
+bundleName = ModeShape Tools Eclipse UI Plug-in
+bundleVendor = JBoss by Red Hat
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/OSGI-INF/l10n/bundle.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/build.properties
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/build.properties
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/build.properties 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,19 @@
+#
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership.
+#
+# This software is made available by Red Hat, Inc. under the terms of the
+# Eclipse Public License v1.0 which accompanies this distribution and is
+# available at
http://www.eclipse.org/legal/epl-v10.html.
+#
+# See the AUTHORS.txt file in the distribution for a full listing of
+# individual contributors.
+#
+bin.includes = META-INF/,\
+ .,\
+ icons/,\
+ OSGI-INF/
+jars.compile.order = .
+source.. = src/
+output.. = bin/
+
\ No newline at end of file
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/build.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/delete-16x.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/delete-16x.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/edit-16x.png
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/edit-16x.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/icons/new-16x.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/pom.xml
===================================================================
--- trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/pom.xml
(rev 0)
+++ trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/pom.xml 2012-03-15 15:55:37 UTC
(rev 39542)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.modeshape</groupId>
+ <artifactId>plugins</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.modeshape.plugins</groupId>
+ <artifactId>org.jboss.tools.modeshape.ui</artifactId>
+ <packaging>eclipse-plugin</packaging>
+</project>
\ No newline at end of file
Property changes on: trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/pom.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/Activator.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/Activator.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/Activator.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,63 @@
+/*
+ * 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.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.modeshape.ui.graphics.GraphicsUtils;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The <code>org.jboss.tools.modeshape.jcr.ui</code> UI Plug-in class.
+ */
+public class Activator extends AbstractUIPlugin {
+
+ private static Activator _sharedInstance;
+
+ /**
+ * @return the shared instance (<code>null</code> if the Eclipse platform
is not running)
+ */
+ public static Activator getSharedInstance() {
+ return _sharedInstance;
+ }
+
+ /**
+ * Retrieves the requested image from the image registry. If the image does not exist
in the registry it will be created and
+ * registered.
+ *
+ * @param pathToImage the path to the image file relative to the specified
plug-in's folder (can be <code>null</code>)
+ * @return the requested image or a standard "missing image" image (never
<code>null</code>)
+ */
+ public final Image getImage( final String pathToImage ) {
+ return GraphicsUtils.getImage(this, pathToImage);
+ }
+
+ /**
+ * Retrieves the requested image descriptor from the image registry. If the image
does not exist in the registry it will be
+ * created and registered.
+ *
+ * @param pathToImage the path to the image file relative to the specified
plug-in's folder (can be <code>null</code>)
+ * @return the requested image descriptor or a standard "missing image"
image descriptor (never <code>null</code>)
+ */
+ public final ImageDescriptor getImageDescriptor( final String pathToImage ) {
+ getImage(pathToImage); // this creates entry in registry if necessary
+ return getImageRegistry().getDescriptor(pathToImage);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start( BundleContext context ) throws Exception {
+ super.start(context);
+ _sharedInstance = this;
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/Activator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,45 @@
+/*
+ * 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.ui;
+
+/**
+ * Constants used within the <code>org.jboss.tools.modeshape.jcr.ui</code>
plug-in.
+ */
+public interface UiConstants {
+
+ /**
+ * The plug-in bundle's symbolic name.
+ */
+ String PLUGIN_ID = UiConstants.class.getPackage().getName();
+
+ /**
+ * The image paths.
+ */
+ interface Images {
+
+ /**
+ * The relative path from the plugin folder to the icons folder.
+ */
+ String ICONS_FOLDER = "icons/"; //$NON-NLS-1$
+
+ /**
+ * The relative path from the plugin folder to the icon used for editing
objects.
+ */
+ String EDIT_16X = ICONS_FOLDER + "edit-16x.png"; //$NON-NLS-1$
+
+ /**
+ * The relative path from the plugin folder to the icon used for deleting
objects.
+ */
+ String DELETE_16X = ICONS_FOLDER + "delete-16x.gif"; //$NON-NLS-1$
+
+ /**
+ * The relative path from the plugin folder to the icon used for creating new
objects.
+ */
+ String NEW_16X = ICONS_FOLDER + "new-16x.gif"; //$NON-NLS-1$
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiConstants.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,40 @@
+/*
+ * 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.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Reusable localized messages.
+ */
+public class UiMessages extends NLS {
+
+ /**
+ * The title of a generic error message dialog.
+ */
+ public static String errorDialogTitle;
+
+ /**
+ * The title of a generic information message dialog.
+ */
+ public static String infoDialogTitle;
+
+ /**
+ * The title of a generic question message dialog.
+ */
+ public static String questionDialogTitle;
+
+ /**
+ * The title of a generic warning message dialog.
+ */
+ public static String warningDialogTitle;
+
+ static {
+ NLS.initializeMessages("org.jboss.tools.modeshape.ui.uiMessages",
UiMessages.class); //$NON-NLS-1$
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiMessages.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,77 @@
+/*
+ * 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.ui;
+
+import org.eclipse.jface.viewers.CellLabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.swt.widgets.TableColumn;
+
+/**
+ * Common constants and methods used with JBoss Tool's ModeShape Tools project.
+ */
+public final class UiUtils {
+
+ /**
+ * An empty string constant.
+ */
+ public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ /**
+ * The column will be packed using the header text.
+ *
+ * @param viewerColumn the viewer column (cannot be <code>null</code>)
+ * @param labelProvider the column label provider (cannot be
<code>null</code>
+ * @param headerText the header text (cannot be <code>null</code>)
+ * @param headerToolTip (can be <code>null</code>)
+ * @param moveable a flag indicating if the column can be moved
+ * @param resizable a flag indicating if the column can be resized
+ */
+ public static void configureColumn( final TableViewerColumn viewerColumn,
+ final CellLabelProvider labelProvider,
+ final String headerText,
+ final String headerToolTip,
+ final boolean moveable,
+ final boolean resizable ) {
+ viewerColumn.setLabelProvider(labelProvider);
+
+ // configure column
+ final TableColumn column = viewerColumn.getColumn();
+ column.setText(headerText);
+ column.setToolTipText(headerToolTip);
+ column.setMoveable(false);
+ column.setResizable(resizable);
+ column.pack();
+ }
+
+ /**
+ * @param stringBeingChecked the string being checked (can be
<code>null</code> or empty)
+ * @return <code>true</code> if <code>null</code> or empty
+ */
+ public static boolean isEmpty( final String stringBeingChecked ) {
+ return ((stringBeingChecked == null) || stringBeingChecked.isEmpty());
+ }
+
+ /**
+ * @param viewers the viewers whose columns will be packed (cannot be
<code>null</code>)
+ */
+ public static void pack( final TableViewer... viewers ) {
+ for (final TableViewer viewer : viewers) {
+ for (final TableColumn column : viewer.getTable().getColumns()) {
+ column.pack();
+ }
+ }
+ }
+
+ /**
+ * Don't allow construction.
+ */
+ private UiUtils() {
+ // nothing to do
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/UiUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/ErrorMessage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/ErrorMessage.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/ErrorMessage.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,176 @@
+/*
+ * 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.ui.forms;
+
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.forms.IMessage;
+import org.jboss.tools.modeshape.ui.UiUtils;
+
+/**
+ * An error message that can be used by forms with header message areas.
+ */
+public class ErrorMessage implements IMessage {
+
+ /**
+ * The error message (can be <code>null</code> or empty)
+ */
+ private String message;
+
+ /**
+ * The message type.
+ */
+ private int messageType = IMessageProvider.NONE;
+
+ /**
+ * The UI control where the error can be fixed.
+ */
+ private Control widget;
+
+ /**
+ * Clears the error message.
+ */
+ public void clearMessage() {
+ setErrorMessage(null);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.IMessage#getControl()
+ */
+ @Override
+ public Control getControl() {
+ return this.widget;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.IMessage#getData()
+ */
+ @Override
+ public Object getData() {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.IMessage#getKey()
+ */
+ @Override
+ public Object getKey() {
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.IMessageProvider#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return this.message;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.dialogs.IMessageProvider#getMessageType()
+ */
+ @Override
+ public int getMessageType() {
+ return this.messageType;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.ui.forms.IMessage#getPrefix()
+ */
+ @Override
+ public String getPrefix() {
+ return null;
+ }
+
+ /**
+ * @return <code>true</code> if the validation status has an error
severity
+ */
+ public boolean isError() {
+ return (this.messageType == IMessageProvider.ERROR);
+ }
+
+ /**
+ * @return <code>true</code> if the validation status has an information
severity
+ */
+ public boolean isInfo() {
+ return (this.messageType == IMessageProvider.INFORMATION);
+ }
+
+ /**
+ * @return <code>true</code> if the validation status has an OK severity
+ */
+ public boolean isOk() {
+ return (this.messageType == IMessageProvider.NONE);
+ }
+
+ /**
+ * @return <code>true</code> if the validation status has a warning
severity
+ */
+ public boolean isWarning() {
+ return (this.messageType == IMessageProvider.WARNING);
+ }
+
+ /**
+ * @param newControl the new control (can be <code>null</code>)
+ */
+ public void setControl( final Control newControl ) {
+ this.widget = newControl;
+ }
+
+ /**
+ * Also sets the message severity to an error.
+ *
+ * @param newMessage the new message (can be <code>null</code> or empty)
+ */
+ public void setErrorMessage( final String newMessage ) {
+ this.message = newMessage;
+ this.messageType = (UiUtils.isEmpty(this.message) ? IMessageProvider.NONE :
IMessageProvider.ERROR);
+ }
+
+ /**
+ * Also sets the message severity to an info.
+ *
+ * @param newMessage the new message (can be <code>null</code> or empty)
+ */
+ public void setInformationMessage( final String newMessage ) {
+ this.message = newMessage;
+ this.messageType = (UiUtils.isEmpty(this.message) ? IMessageProvider.NONE :
IMessageProvider.INFORMATION);
+ }
+
+ /**
+ * Also sets the message severity to an OK.
+ *
+ * @param newMessage the new message (can be <code>null</code> or empty)
+ */
+ public void setOkMessage( final String newMessage ) {
+ this.message = newMessage;
+ this.messageType = (UiUtils.isEmpty(this.message) ? IMessageProvider.NONE :
IMessageProvider.NONE);
+ }
+
+ /**
+ * Also sets the message severity to warning.
+ *
+ * @param newMessage the new message (can be <code>null</code> or empty)
+ */
+ public void setWarningMessage( final String newMessage ) {
+ this.message = newMessage;
+ this.messageType = (UiUtils.isEmpty(this.message) ? IMessageProvider.NONE :
IMessageProvider.WARNING);
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/ErrorMessage.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,180 @@
+/*
+ * 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.ui.forms;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.ToolBarManager;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.SectionPart;
+import org.eclipse.ui.forms.events.ExpansionAdapter;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Helper methods for constructing form widgets.
+ */
+public final class FormUtils {
+
+ /**
+ * @param managedForm the managed form that will contain the new section (cannot be
<code>null</code>)
+ * @param toolkit the toolkit used to create the form objects (cannot be
<code>null</code>)
+ * @param parent the parent container for the new section (cannot be
<code>null</code>)
+ * @param title the section title (cannot be <code>null</code>)
+ * @param description the section description (cannot be
<code>null</code> if the {@link Section description style} is used)
+ * @param style the section style
+ * @param shouldGiveUpVerticalSpaceWhenFolded indicates if vertical space should be
lost when section is folded
+ * @return the new section (never <code>null</code>)
+ */
+ public static Section createSection( final IManagedForm managedForm,
+ final FormToolkit toolkit,
+ final Composite parent,
+ final String title,
+ final String description,
+ final int style,
+ final boolean
shouldGiveUpVerticalSpaceWhenFolded ) {
+ final Section section = toolkit.createSection(parent, style);
+ section.setText(title);
+
+ if ((style & Section.DESCRIPTION) != 0) {
+ section.setDescription(description);
+ section.getDescriptionControl().setFont(JFaceResources.getBannerFont());
+ }
+
+ section.setLayoutData(new GridData(SWT.FILL,
+ SWT.FILL,
+ true,
+ ((style & ExpandableComposite.EXPANDED) ==
ExpandableComposite.EXPANDED)));
+
+ managedForm.addPart(new SectionPart(section));
+
+ if (shouldGiveUpVerticalSpaceWhenFolded) {
+ ExpansionAdapter handler = new ExpansionAdapter() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.events.ExpansionAdapter#expansionStateChanged(org.eclipse.ui.forms.events.ExpansionEvent)
+ */
+ @Override
+ public void expansionStateChanged( final ExpansionEvent e ) {
+ final GridData gridData = (GridData)section.getLayoutData();
+ gridData.grabExcessVerticalSpace = e.getState();
+ managedForm.reflow(true);
+ }
+ };
+ section.addExpansionListener(handler);
+ }
+
+ return section;
+ }
+
+ /**
+ * @param section the section whose toolbar is being created (cannot
<code>null</code>)
+ * @param toolkit the toolkit used to create the form objects (cannot be
<code>null</code>)
+ * @param actions the actions used to create the toolbar buttons from (cannot be
<code>null</code> or empty)
+ * @return the toolbar manager of the new toolbar (never
<code>null</code>)
+ */
+ public static IToolBarManager createSectionToolBar( final Section section,
+ final FormToolkit toolkit,
+ final IAction[] actions ) {
+ final ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
+ final ToolBar toolBar = toolBarManager.createControl(section);
+ toolkit.adapt(toolBar);
+ final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ toolBar.setCursor(handCursor);
+ section.setTextClient(toolBar);
+
+ // Cursor needs to be explicitly disposed
+ toolBar.addDisposeListener(new DisposeListener() {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
+ */
+ @Override
+ public void widgetDisposed( final DisposeEvent e ) {
+ if (!handCursor.isDisposed()) {
+ handCursor.dispose();
+ }
+ }
+ });
+
+ for (final IAction action : actions) {
+ toolBarManager.add(action);
+ }
+
+ toolBarManager.update(true);
+ return toolBarManager;
+ }
+
+ /**
+ * Table is created with header and lines visible using the default {@link
Styles#VIEWER_STYLE style}.
+ *
+ * @param toolkit the toolkit used to create the form objects (cannot be
<code>null</code>)
+ * @param parent the parent container for the new section (cannot be
<code>null</code>)
+ * @return the table created by the toolkit (never <code>null</code>)
+ */
+ public static Table createTable( final FormToolkit toolkit,
+ final Composite parent ) {
+ final Table table = toolkit.createTable(parent, Styles.VIEWER_STYLE);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ table.setLayoutData(new GridLayout());
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ return table;
+ }
+
+ /**
+ * Don't allow construction.
+ */
+ private FormUtils() {
+ // nothing to do
+ }
+
+ /**
+ * Default widget styles.
+ */
+ public interface Styles {
+
+ /**
+ * A default style for combo boxes.
+ */
+ int COMBO_STYLE = SWT.FLAT | SWT.READ_ONLY | SWT.BORDER;
+
+ /**
+ * A default style for sections.
+ */
+ int SECTION_STYLE = Section.DESCRIPTION | ExpandableComposite.TITLE_BAR |
ExpandableComposite.LEFT_TEXT_CLIENT_ALIGNMENT
+ | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED;
+
+ /**
+ * A default style for text fields.
+ */
+ int TEXT_STYLE = SWT.BORDER;
+
+ /**
+ * A default style for viewers.
+ */
+ int VIEWER_STYLE = SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE | SWT.BORDER;
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/FormUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageFormDialog.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageFormDialog.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageFormDialog.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,250 @@
+/*
+ * 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.ui.forms;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.FormDialog;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+import org.jboss.tools.modeshape.ui.UiMessages;
+
+/**
+ * A form-based message dialog.
+ */
+public class MessageFormDialog extends FormDialog {
+
+ private static String getMessageTitle( final Kind kind ) {
+ if (Kind.ERROR == kind) {
+ return UiMessages.errorDialogTitle;
+ }
+
+ if (Kind.INFORMATION == kind) {
+ return UiMessages.infoDialogTitle;
+ }
+
+ if (Kind.QUESTION == kind) {
+ return UiMessages.questionDialogTitle;
+ }
+
+ if (Kind.WARNING == kind) {
+ return UiMessages.warningDialogTitle;
+ }
+
+ assert false : "null or unknown dialog kind found"; //$NON-NLS-1$
+ throw new IllegalArgumentException();
+ }
+
+ private static int getMessageType( final Kind kind ) {
+ if (Kind.ERROR == kind) {
+ return IMessageProvider.ERROR;
+ }
+
+ if ((Kind.INFORMATION == kind) || (Kind.QUESTION == kind)) {
+ return IMessageProvider.INFORMATION;
+ }
+
+ if (Kind.WARNING == kind) {
+ return IMessageProvider.WARNING;
+ }
+
+ assert false : "null or unknown dialog kind found"; //$NON-NLS-1$
+ throw new IllegalArgumentException();
+ }
+
+ private static boolean open( final Kind kind,
+ final Shell parent,
+ final String msgTitle,
+ final Image titleImage,
+ final String message ) {
+ final FormDialog dialog = new MessageFormDialog(kind, parent, msgTitle,
titleImage, message);
+ dialog.create();
+ dialog.getShell().pack();
+ return (dialog.open() == Window.OK);
+ }
+
+ /**
+ * Open a dialog with the warning title.
+ *
+ * @param parent the parent (can be <code>null</code>)
+ * @param msgTitle the message area title (if <code>null</code> or empty
the message area will not have a title)
+ * @param titleImage the title image or <code>null</code>
+ * @param message the dialog message (if <code>null</code> or empty the
dialog area will not have a message)
+ * @return <code>true</code> if the dialog was OK'd
+ */
+ public static boolean openError( final Shell parent,
+ final String msgTitle,
+ final Image titleImage,
+ final String message ) {
+ return open(Kind.ERROR, parent, msgTitle, titleImage, message);
+ }
+
+ /**
+ * Open a dialog with the warning title.
+ *
+ * @param parent the parent (can be <code>null</code>)
+ * @param msgTitle the message area title (if <code>null</code> or empty
the message area will not have a title)
+ * @param titleImage the title image or <code>null</code>
+ * @param message the dialog message (if <code>null</code> or empty the
dialog area will not have a message)
+ * @return <code>true</code> if the dialog was OK'd
+ */
+ public static boolean openInfo( final Shell parent,
+ final String msgTitle,
+ final Image titleImage,
+ final String message ) {
+ return open(Kind.INFORMATION, parent, msgTitle, titleImage, message);
+ }
+
+ /**
+ * Open a dialog with the question title.
+ *
+ * @param parent the parent (can be <code>null</code>)
+ * @param msgTitle the message area title (if <code>null</code> or empty
the message area will not have a title)
+ * @param titleImage the title image or <code>null</code>
+ * @param message the dialog message (if <code>null</code> or empty the
dialog area will not have a message)
+ * @return <code>true</code> if the dialog was OK'd
+ */
+ public static boolean openQuestion( final Shell parent,
+ final String msgTitle,
+ final Image titleImage,
+ final String message ) {
+ return open(Kind.QUESTION, parent, msgTitle, titleImage, message);
+ }
+
+ /**
+ * Open a dialog with the warning title.
+ *
+ * @param parent the parent (can be <code>null</code>)
+ * @param msgTitle the message area title (if <code>null</code> or empty
the message area will not have a title)
+ * @param titleImage the title image or <code>null</code>
+ * @param message the dialog message (if <code>null</code> or empty the
dialog area will not have a message)
+ * @return <code>true</code> if the dialog was OK'd
+ */
+ public static boolean openWarning( final Shell parent,
+ final String msgTitle,
+ final Image titleImage,
+ final String message ) {
+ return open(Kind.WARNING, parent, msgTitle, titleImage, message);
+ }
+
+ private final Image titleImage;
+
+ private final String message;
+ private final String msgTitle;
+ private final Kind kind;
+
+ private MessageFormDialog( final Kind kind,
+ final Shell parent,
+ final String msgTitle,
+ final Image titleImage,
+ final String message ) {
+ super(parent);
+ this.kind = kind;
+ this.msgTitle = msgTitle;
+ this.titleImage = titleImage;
+ this.message = message;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell( final Shell newShell ) {
+ super.configureShell(newShell);
+
+ newShell.setText(getMessageTitle(this.kind));
+
+ if (this.titleImage != null) {
+ newShell.setImage(this.titleImage);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createButton(org.eclipse.swt.widgets.Composite, int,
java.lang.String, boolean)
+ */
+ @Override
+ protected Button createButton( final Composite parent,
+ final int id,
+ String label,
+ final boolean defaultButton ) {
+ if (this.kind == Kind.QUESTION) {
+ if (Window.OK == id) {
+ label = IDialogConstants.YES_LABEL;
+ } else if (Window.CANCEL == id) {
+ label = IDialogConstants.NO_LABEL;
+ }
+ }
+
+ return super.createButton(parent, id, label, defaultButton);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar( final Composite parent ) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+
+ if (this.kind == Kind.QUESTION) {
+ createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see
org.eclipse.ui.forms.FormDialog#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent( final IManagedForm managedForm ) {
+ final ScrolledForm scrolledForm = managedForm.getForm();
+ scrolledForm.setText(this.msgTitle);
+ scrolledForm.setMessage("", getMessageType(this.kind)); //$NON-NLS-1$
+
+ final FormToolkit toolkit = managedForm.getToolkit();
+ toolkit.decorateFormHeading(scrolledForm.getForm());
+
+ final Composite body = scrolledForm.getBody();
+ body.setLayout(new TableWrapLayout());
+ toolkit.createLabel(body, this.message, SWT.WRAP);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.window.Window#getShellStyle()
+ */
+ @Override
+ protected int getShellStyle() {
+ if (this.kind != Kind.QUESTION) {
+ return super.getShellStyle() | SWT.SHEET;
+ }
+ return super.getShellStyle();
+ }
+
+ private enum Kind {
+ ERROR,
+ QUESTION,
+ INFORMATION,
+ WARNING
+ }
+}
\ No newline at end of file
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/forms/MessageFormDialog.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/graphics/GraphicsUtils.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/graphics/GraphicsUtils.java
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/graphics/GraphicsUtils.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,64 @@
+/*
+ * 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.ui.graphics;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ *
+ */
+public final class GraphicsUtils {
+
+ /**
+ * @param uiPlugin the UI Plug-in instance (cannot be <code>null</code>)
+ * @param pathToImage the path to the image file relative to the specified
plug-in's folder (can be <code>null</code>)
+ * @return the new image descriptor or <code>null</code> if path does not
exist
+ */
+ private static ImageDescriptor createImageDescriptor( final AbstractUIPlugin
uiPlugin,
+ final String pathToImage ) {
+ assert (uiPlugin != null) : "UI Plugin is null"; //$NON-NLS-1$
+ assert (pathToImage != null) : "pathToImage is null"; //$NON-NLS-1$
+
+ final String pluginId = uiPlugin.getBundle().getSymbolicName();
+ return AbstractUIPlugin.imageDescriptorFromPlugin(pluginId, pathToImage);
+ }
+
+ /**
+ * @param uiPlugin the UI Plug-in instance (cannot be <code>null</code>)
+ * @param pathToImage the path to the image file relative to the specified
plug-in's folder (can be <code>null</code>)
+ * @return the requested image or a standard "missing image" image (never
<code>null</code>)
+ */
+ public static final Image getImage( final AbstractUIPlugin uiPlugin,
+ final String pathToImage ) {
+ final ImageRegistry imageRegistry = uiPlugin.getImageRegistry();
+ Image image = imageRegistry.get(pathToImage);
+
+ if (image == null) {
+ if (pathToImage != null) {
+ final ImageDescriptor newImageDescriptor =
createImageDescriptor(uiPlugin, pathToImage);
+
+ if (newImageDescriptor != null) {
+ imageRegistry.put(pathToImage, newImageDescriptor);
+ image = imageRegistry.get(pathToImage);
+ }
+ }
+ }
+
+ return ((image == null) ?
ImageDescriptor.getMissingImageDescriptor().createImage() : image);
+ }
+
+ /**
+ * Don't allow construction.
+ */
+ private GraphicsUtils() {
+ // nothing to do
+ }
+}
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/graphics/GraphicsUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties
(rev 0)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties 2012-03-15
15:55:37 UTC (rev 39542)
@@ -0,0 +1,10 @@
+# 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.
+
+errorDialogTitle = Error
+infoDialogTitle = Info
+questionDialogTitle = Question
+warningDialogTitle = Warning
\ No newline at end of file
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.ui/src/org/jboss/tools/modeshape/ui/uiMessages.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-03-15
15:40:34 UTC (rev 39541)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/CndValidatorTest.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -11,6 +11,7 @@
import org.jboss.tools.modeshape.jcr.Utils;
import org.jboss.tools.modeshape.jcr.cnd.attributes.PropertyType;
+import org.jboss.tools.modeshape.jcr.cnd.attributes.QueryOperators.QueryOperator;
import org.junit.Before;
import org.junit.Test;
@@ -24,7 +25,7 @@
private NamespaceMapping namespaceMapping;
private NodeTypeDefinition nodeTypeDefinition;
private PropertyDefinition propertyDefinition;
-
+
@Before
public void beforeEach() {
this.childNodeDefinition = new ChildNodeDefinition();
@@ -44,6 +45,13 @@
}
@Test
+ public void childNodeDefinitionWithInvalidDefaultTypeNameShouldBeAnError() {
+ this.childNodeDefinition.setName("name"); //$NON-NLS-1$
+ this.childNodeDefinition.setDefaultPrimaryTypeName("invalid:name");
//$NON-NLS-1$
+
assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition).isError());
+ }
+
+ @Test
public void childNodeDefinitionWithInvalidNameShouldBeAnError() {
this.childNodeDefinition.setName("invalid/name"); //$NON-NLS-1$
assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition).isError());
@@ -57,73 +65,99 @@
}
@Test
- public void childNodeDefinitionWithInvalidDefaultTypeNameShouldBeAnError() {
- this.childNodeDefinition.setName("name"); //$NON-NLS-1$
- this.childNodeDefinition.setDefaultPrimaryTypeName("invalid:name");
//$NON-NLS-1$
-
assertTrue(CndValidator.validateChildNodeDefinition(this.childNodeDefinition).isError());
+ public void cndWithoutNamespaceMappingsAndNodeTypeDefintionsShouldBeAWarning() {
+ assertTrue(CndValidator.validateCnd(this.cnd).isWarning());
}
@Test
- public void propertyDefinitionWithEmptyNameShouldNotBeValid() {
- this.propertyDefinition.setName(null);
-
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
-
- this.propertyDefinition.setName(Utils.EMPTY_STRING);
-
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
+ public void emptyNamespaceMappingPrefixShouldBeAnError() {
+
assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
}
@Test
- public void propertyDefinitionWithInvalidNameShouldBeAnError() {
- this.propertyDefinition.setName("invalid/name"); //$NON-NLS-1$
-
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
+ public void emptyNamespaceMappingUriShouldBeAnError() {
+ this.namespaceMapping.setUri("uri"); //$NON-NLS-1$
+
assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
}
@Test
- public void
propertyDefinitionWithMultipleDefaultValuesButSingleValuedShouldBeAnError() {
- this.propertyDefinition.setName("name"); //$NON-NLS-1$
- this.propertyDefinition.addDefaultValue("defaultValue1");
//$NON-NLS-1$
- this.propertyDefinition.addDefaultValue("defaultValue2");
//$NON-NLS-1$
+ public void emptyQualifiedNameQualifierShouldBeValid() {
-
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
+
assertTrue(CndValidator.validateQualifiedName(Constants.NAME_WITH_EMPTY_QUALIFIER,
"propertyName", //$NON-NLS-1$
+
Constants.Helper.getDefaultQualifiers()).isOk());
}
@Test
- public void propertyDefinitionWithInvalidDefaultValueShouldBeAnError() {
- this.propertyDefinition.setName("name"); //$NON-NLS-1$
- this.propertyDefinition.setType(PropertyType.LONG);
- this.propertyDefinition.addDefaultValue("notALongValue");
//$NON-NLS-1$
+ public void emptyQueryOperatorShouldBeAnError() {
+ assertTrue(CndValidator.validateQueryOperator(Utils.EMPTY_STRING,
"propName").isError()); //$NON-NLS-1$
+ }
-
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
+ @Test
+ public void invalidQualifiedNameQualifierShouldBeAnError() {
+ final QualifiedName qname = new QualifiedName(Constants.QUALIFIER1 +
"Changed", Constants.UNQUALIFIED_NAME1); //$NON-NLS-1$
+ assertTrue(CndValidator.validateQualifiedName(qname, "propertyName",
Constants.Helper.getDefaultQualifiers()).isError()); //$NON-NLS-1$
}
@Test
- public void nodeTypeDefinitionWithEmptyNameShouldAnError() {
- this.nodeTypeDefinition.setName(null);
-
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isError());
+ public void invalidQueryOperatorShouldBeAnError() {
+ assertTrue(CndValidator.validateQueryOperator("a",
"propName").isError()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
- this.nodeTypeDefinition.setName(Utils.EMPTY_STRING);
-
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isError());
+ @Test
+ public void localNameEqualToParentShouldBeAnError() {
+ this.childNodeDefinition.setName(".."); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
}
@Test
- public void nodeTypeDefinitionWithInvalidNameShouldBeAnError() {
- this.nodeTypeDefinition.setName("invalid/name"); //$NON-NLS-1$
-
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isError());
+ public void localNameEqualToSelfShouldBeAnError() {
+ this.childNodeDefinition.setName("."); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
}
@Test
- public void nodeTypeDefinitionWithoutPropertiesAndChildNodesShouldBeAWarning() {
- this.nodeTypeDefinition.setName("name"); //$NON-NLS-1$
-
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isWarning());
+ public void localNameWithInvalidCharactersShouldBeAnError() {
+ this.childNodeDefinition.setName("name/"); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+
+ this.childNodeDefinition.setName("name:"); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+
+ this.childNodeDefinition.setName("name["); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+
+ this.childNodeDefinition.setName("name]"); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+
+ this.childNodeDefinition.setName("name|"); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+
+ this.childNodeDefinition.setName("name*"); //$NON-NLS-1$
+ assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
}
@Test
+ public void nodeTypeDefinitionWithDuplicateChildNodeNamesShouldBeAnError() {
+ this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+
+ final String NAME = "name"; //$NON-NLS-1$
+ this.childNodeDefinition.setName(NAME);
+ final ChildNodeDefinition child2 = new ChildNodeDefinition();
+ child2.setName(NAME);
+
+ this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
+ this.nodeTypeDefinition.addChildNodeDefinition(child2);
+
+
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isError());
+ }
+
+ @Test
public void nodeTypeDefinitionWithDuplicatePropertyNamesShouldBeAnError() {
this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
final String NAME = "name"; //$NON-NLS-1$
this.propertyDefinition.setName(NAME);
- PropertyDefinition prop2 = new PropertyDefinition();
+ final PropertyDefinition prop2 = new PropertyDefinition();
prop2.setName(NAME);
this.nodeTypeDefinition.addPropertyDefinition(this.propertyDefinition);
@@ -133,17 +167,17 @@
}
@Test
- public void nodeTypeDefinitionWithDuplicateChildNodeNamesShouldBeAnError() {
- this.nodeTypeDefinition.setName("nodeTypeName"); //$NON-NLS-1$
+ public void nodeTypeDefinitionWithEmptyNameShouldAnError() {
+ this.nodeTypeDefinition.setName(null);
+
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isError());
- final String NAME = "name"; //$NON-NLS-1$
- this.childNodeDefinition.setName(NAME);
- ChildNodeDefinition child2 = new ChildNodeDefinition();
- child2.setName(NAME);
+ this.nodeTypeDefinition.setName(Utils.EMPTY_STRING);
+
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isError());
+ }
- this.nodeTypeDefinition.addChildNodeDefinition(this.childNodeDefinition);
- this.nodeTypeDefinition.addChildNodeDefinition(child2);
-
+ @Test
+ public void nodeTypeDefinitionWithInvalidNameShouldBeAnError() {
+ this.nodeTypeDefinition.setName("invalid/name"); //$NON-NLS-1$
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isError());
}
@@ -164,51 +198,53 @@
}
@Test
- public void cndWithoutNamespaceMappingsAndNodeTypeDefintionsShouldBeAWarning() {
- assertTrue(CndValidator.validateCnd(this.cnd).isWarning());
+ public void nodeTypeDefinitionWithoutPropertiesAndChildNodesShouldBeAWarning() {
+ this.nodeTypeDefinition.setName("name"); //$NON-NLS-1$
+
assertTrue(CndValidator.validateNodeTypeDefinition(this.nodeTypeDefinition).isWarning());
}
@Test
- public void localNameEqualToSelfShouldBeAnError() {
- this.childNodeDefinition.setName("."); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+ public void nullQueryOperatorShouldBeAnError() {
+ assertTrue(CndValidator.validateQueryOperator(null,
"propName").isError()); //$NON-NLS-1$
}
@Test
- public void localNameEqualToParentShouldBeAnError() {
- this.childNodeDefinition.setName(".."); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+ public void propertyDefinitionWithEmptyNameShouldNotBeValid() {
+ this.propertyDefinition.setName(null);
+
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
+
+ this.propertyDefinition.setName(Utils.EMPTY_STRING);
+
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
}
@Test
- public void localNameWithInvalidCharactersShouldBeAnError() {
- this.childNodeDefinition.setName("name/"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+ public void propertyDefinitionWithInvalidDefaultValueShouldBeAnError() {
+ this.propertyDefinition.setName("name"); //$NON-NLS-1$
+ this.propertyDefinition.setType(PropertyType.LONG);
+ this.propertyDefinition.addDefaultValue("notALongValue");
//$NON-NLS-1$
- this.childNodeDefinition.setName("name:"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
+ }
- this.childNodeDefinition.setName("name["); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
-
- this.childNodeDefinition.setName("name]"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
-
- this.childNodeDefinition.setName("name|"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
-
- this.childNodeDefinition.setName("name*"); //$NON-NLS-1$
- assertTrue(CndValidator.validateLocalName(this.childNodeDefinition.getName(),
"name").isError()); //$NON-NLS-1$
+ @Test
+ public void propertyDefinitionWithInvalidNameShouldBeAnError() {
+ this.propertyDefinition.setName("invalid/name"); //$NON-NLS-1$
+
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
}
@Test
- public void emptyNamespaceMappingPrefixShouldBeAnError() {
-
assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ public void
propertyDefinitionWithMultipleDefaultValuesButSingleValuedShouldBeAnError() {
+ this.propertyDefinition.setName("name"); //$NON-NLS-1$
+ this.propertyDefinition.addDefaultValue("defaultValue1");
//$NON-NLS-1$
+ this.propertyDefinition.addDefaultValue("defaultValue2");
//$NON-NLS-1$
+
+
assertTrue(CndValidator.validatePropertyDefinition(this.propertyDefinition).isError());
}
@Test
- public void emptyNamespaceMappingUriShouldBeAnError() {
- this.namespaceMapping.setUri("uri"); //$NON-NLS-1$
-
assertTrue(CndValidator.validateNamespaceMapping(this.namespaceMapping).isError());
+ public void shouldValidateAllQueryOperators() {
+ for (final QueryOperator operator : QueryOperator.values()) {
+ assertTrue(CndValidator.validateQueryOperator(operator.toString(),
"propName").isOk()); //$NON-NLS-1$
+ }
}
}
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-03-15
15:40:34 UTC (rev 39541)
+++
trunk/modeshape/tests/org.jboss.tools.modeshape.jcr.test/src/org/jboss/tools/modeshape/jcr/cnd/Constants.java 2012-03-15
15:55:37 UTC (rev 39542)
@@ -7,6 +7,9 @@
*/
package org.jboss.tools.modeshape.jcr.cnd;
+import java.util.ArrayList;
+import java.util.List;
+
import org.jboss.tools.modeshape.jcr.cnd.CndElement.NotationType;
import org.jboss.tools.modeshape.jcr.cnd.CndNotationPreferences.Preference;
import org.jboss.tools.modeshape.jcr.cnd.attributes.Abstract;
@@ -45,6 +48,7 @@
QualifiedName QUALIFIED_NAME1 = new QualifiedName(QUALIFIER1, UNQUALIFIED_NAME1);
QualifiedName QUALIFIED_NAME2 = new QualifiedName(QUALIFIER2, UNQUALIFIED_NAME2);
QualifiedName QUALIFIED_NAME3 = new QualifiedName(QUALIFIER3, UNQUALIFIED_NAME3);
+ QualifiedName NAME_WITH_EMPTY_QUALIFIER = new QualifiedName(null,
UNQUALIFIED_NAME1);
String VARIANT = AttributeState.VARIANT_STRING;
@@ -218,4 +222,14 @@
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+ ITEM_THREE
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.VALUE_CONSTRAINTS_ITEM_QUOTE_CHARACTER)
+
CndNotationPreferences.DEFAULT_PREFERENCES.get(Preference.ATTRIBUTE_LIST_QUOTE_CHAR);
+
+ class Helper {
+ public static List<String> getDefaultQualifiers() {
+ List<String> qualifiers = new ArrayList<String>();
+ qualifiers.add(QUALIFIER1);
+ qualifiers.add(QUALIFIER2);
+ qualifiers.add(QUALIFIER3);
+ return qualifiers;
+ }
+ }
}