Author: elvisisking
Date: 2012-04-04 12:11:17 -0400 (Wed, 04 Apr 2012)
New Revision: 40039
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/open-declaring-node-type-16x.gif
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.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
Log:
JBIDE-10702 Editor for JCR Compact Node Definition (CND) files. Added an action to the
properties table and to the child nodes table that opens (selects) the selected item
definition's declaring node type in the editor.
Added:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/open-declaring-node-type-16x.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/icons/open-declaring-node-type-16x.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.java 2012-04-04
14:58:29 UTC (rev 40038)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/JcrUiConstants.java 2012-04-04
16:11:17 UTC (rev 40039)
@@ -7,7 +7,6 @@
*/
package org.jboss.tools.modeshape.jcr.ui;
-
/**
* Constants used within the <code>org.jboss.tools.modeshape.jcr.ui</code>
plug-in.
*/
@@ -71,6 +70,12 @@
String CND_EDITOR = ICONS_FOLDER + "cnd-editor-16x.png"; //$NON-NLS-1$
/**
+ * The relative path from the plugin folder to the icon used to select the
declaring node type definition of an inherited
+ * property definition or child node definition.
+ */
+ String OPEN_DECLARING_NODE_TYPE = ICONS_FOLDER +
"open-declaring-node-type-16x.gif"; //$NON-NLS-1$
+
+ /**
* The relative path from the plugin folder to the icon used to show inherited
properties and child nodes.
*/
String SHOW_INHERITED = ICONS_FOLDER + "show-inherited-16x.gif";
//$NON-NLS-1$
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-04
14:58:29 UTC (rev 40038)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndFormsEditorPage.java 2012-04-04
16:11:17 UTC (rev 40039)
@@ -126,6 +126,8 @@
private String nodeTypeNameFilterPattern;
private Section nodeTypeSection;
private TableViewer nodeTypeViewer;
+ private IAction openChildNodeDeclaringNodeType;
+ private IAction openPropertyDeclaringNodeType;
private Section propertiesSection;
private TableViewer propertyViewer;
private NodeTypeDefinition selectedNodeType; // needed for property changes (can be
null)
@@ -227,6 +229,23 @@
this.showInheritedChildNodes.setToolTipText(CndMessages.showInheritedChildNodesToolTip);
this.showInheritedChildNodes.setImageDescriptor(Activator.getSharedInstance()
.getImageDescriptor(JcrUiConstants.Images.SHOW_INHERITED));
+
+ this.openChildNodeDeclaringNodeType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleSelectPropertyDeclaringNodeType();
+ }
+ };
+ this.openChildNodeDeclaringNodeType.setEnabled(false);
+
this.openChildNodeDeclaringNodeType.setToolTipText(CndMessages.openDeclaringNodeTypeToolTip);
+
this.openChildNodeDeclaringNodeType.setImageDescriptor(Activator.getSharedInstance()
+
.getImageDescriptor(JcrUiConstants.Images.OPEN_DECLARING_NODE_TYPE));
}
private void createChildNodeSection( final IManagedForm managedForm,
@@ -262,7 +281,7 @@
// create toolbar
FormUtils.createToolBar(container, toolkit, new IAction[] { this.addChildNode,
this.editChildNode, this.deleteChildNode,
- this.showInheritedChildNodes });
+ this.showInheritedChildNodes, this.openChildNodeDeclaringNodeType });
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
@@ -272,6 +291,7 @@
menuManager.add(new DelegateAction(CndMessages.addChildNodeMenuText,
this.addChildNode));
menuManager.add(new DelegateAction(CndMessages.editChildNodeMenuText,
this.editChildNode));
menuManager.add(new DelegateAction(CndMessages.deleteChildNodeMenuText,
this.deleteChildNode));
+ menuManager.add(new DelegateAction(CndMessages.openDeclaringNodeTypeMenuText,
this.openChildNodeDeclaringNodeType));
table.setMenu(menuManager.createContextMenu(table));
createChildNodeViewer(table);
@@ -299,7 +319,7 @@
if (shouldShowInheritedChildNodes()) {
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if (Utils.equivalent(nodeTypeDefinition.getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
+ if (!Utils.equivalent(nodeTypeDefinition.getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
.get())) {
return
getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
}
@@ -320,7 +340,7 @@
if (shouldShowInheritedChildNodes()) {
final NodeTypeDefinition nodeTypeDefinition = getSelectedNodeType();
- if (Utils.equivalent(nodeTypeDefinition.getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
+ if (!Utils.equivalent(nodeTypeDefinition.getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
.get())) {
return
JFaceResources.getFontRegistry().getItalic(JFaceResources.TEXT_FONT);
}
@@ -345,7 +365,7 @@
final NotationType notationType = NotationType.LONG;
if (this.columnIndex == ChildNodeColumnIndexes.DECLARING_NODE_TYPE) {
- if (Utils.equivalent(getSelectedNodeType().getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
+ if (!Utils.equivalent(getSelectedNodeType().getName(),
childNodeDefinition.getDeclaringNodeTypeDefinitionName()
.get())) {
return
childNodeDefinition.getDeclaringNodeTypeDefinitionName().get();
}
@@ -560,7 +580,6 @@
toolkit.paintBordersFor(attributesContainer);
this.btnAbstract = toolkit.createButton(attributesContainer,
CndMessages.abstractAttribute, SWT.CHECK);
- this.btnAbstract.setBackground(attributesContainer.getBackground());
this.btnAbstract.addSelectionListener(new SelectionAdapter() {
/**
@@ -576,7 +595,6 @@
this.btnAbstract.setToolTipText(CndMessages.abstractAttributeToolTip);
this.btnMixin = toolkit.createButton(attributesContainer,
CndMessages.mixinAttribute, SWT.CHECK);
- this.btnMixin.setBackground(attributesContainer.getBackground());
this.btnMixin.addSelectionListener(new SelectionAdapter() {
/**
@@ -592,7 +610,6 @@
this.btnMixin.setToolTipText(CndMessages.mixinAttributeToolTip);
this.btnOrderable = toolkit.createButton(attributesContainer,
CndMessages.orderableAttribute, SWT.CHECK);
- this.btnOrderable.setBackground(attributesContainer.getBackground());
this.btnOrderable.addSelectionListener(new SelectionAdapter() {
/**
@@ -608,7 +625,6 @@
this.btnOrderable.setToolTipText(CndMessages.orderableAttributeToolTip);
this.btnQueryable = toolkit.createButton(attributesContainer,
CndMessages.queryableAttribute, SWT.CHECK);
- this.btnQueryable.setBackground(attributesContainer.getBackground());
this.btnQueryable.addSelectionListener(new SelectionAdapter() {
/**
@@ -1237,6 +1253,23 @@
this.showInheritedProperties.setToolTipText(CndMessages.showInheritedPropertiesToolTip);
this.showInheritedProperties.setImageDescriptor(Activator.getSharedInstance()
.getImageDescriptor(JcrUiConstants.Images.SHOW_INHERITED));
+
+ this.openPropertyDeclaringNodeType = new Action(Utils.EMPTY_STRING) {
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ handleSelectPropertyDeclaringNodeType();
+ }
+ };
+ this.openPropertyDeclaringNodeType.setEnabled(false);
+
this.openPropertyDeclaringNodeType.setToolTipText(CndMessages.openDeclaringNodeTypeToolTip);
+
this.openPropertyDeclaringNodeType.setImageDescriptor(Activator.getSharedInstance()
+
.getImageDescriptor(JcrUiConstants.Images.OPEN_DECLARING_NODE_TYPE));
}
private void createPropertySection( final IManagedForm managedForm,
@@ -1272,7 +1305,7 @@
// create toolbar
FormUtils.createToolBar(container, toolkit, new IAction[] { this.addProperty,
this.editProperty, this.deleteProperty,
- this.showInheritedProperties });
+ this.showInheritedProperties, this.openPropertyDeclaringNodeType });
final Table table = FormUtils.createTable(toolkit, container);
((GridData)table.getLayoutData()).heightHint = table.getItemHeight() * 5;
@@ -1282,6 +1315,7 @@
menuManager.add(new DelegateAction(CndMessages.addPropertyMenuText,
this.addProperty));
menuManager.add(new DelegateAction(CndMessages.editPropertyMenuText,
this.editProperty));
menuManager.add(new DelegateAction(CndMessages.deletePropertyMenuText,
this.deleteProperty));
+ menuManager.add(new DelegateAction(CndMessages.openDeclaringNodeTypeMenuText,
this.openPropertyDeclaringNodeType));
table.setMenu(menuManager.createContextMenu(table));
createPropertyViewer(table);
@@ -1956,19 +1990,25 @@
this.addChildNode.setEnabled(enable);
}
- enable = (getSelectedChildNode() != null);
+ boolean enableWithChildNodeSelected = (enable && (getSelectedChildNode()
!= null));
+ boolean enableInheritedChildNode = enableWithChildNodeSelected
+ &&
!getSelectedNodeType().hasDeclaredChildNodeDefinition(getSelectedChildNode().getName());
+ boolean enableDeclaredChildNode = enableWithChildNodeSelected
+ &&
getSelectedNodeType().hasDeclaredChildNodeDefinition(getSelectedChildNode().getName());
- // disable if selected child node is inherited
- if (enable && shouldShowInheritedChildNodes()) {
- enable =
getSelectedNodeType().hasDeclaredChildNodeDefinition(getSelectedChildNode().getName());
+ // enable if selected child node is not inherited
+ if (this.editChildNode.isEnabled() != enableDeclaredChildNode) {
+ this.editChildNode.setEnabled(enableDeclaredChildNode);
}
- if (this.editChildNode.isEnabled() != enable) {
- this.editChildNode.setEnabled(enable);
+ // enable if selected child node is not inherited
+ if (this.deleteChildNode.isEnabled() != enableDeclaredChildNode) {
+ this.deleteChildNode.setEnabled(enableDeclaredChildNode);
}
- if (this.deleteChildNode.isEnabled() != enable) {
- this.deleteChildNode.setEnabled(enable);
+ // enable if selected child node is inherited
+ if (this.openChildNodeDeclaringNodeType.isEnabled() != enableInheritedChildNode)
{
+ this.openChildNodeDeclaringNodeType.setEnabled(enableInheritedChildNode);
}
}
@@ -2390,19 +2430,25 @@
this.addProperty.setEnabled(enable);
}
- enable = (getSelectedProperty() != null);
+ boolean enableWithPropertySelected = (enable && (getSelectedProperty() !=
null));
+ boolean enableInheritedProperty = enableWithPropertySelected
+ &&
!getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
+ boolean enableDeclaredProperty = enableWithPropertySelected
+ &&
getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
- // disable if selected property is inherited
- if (enable && shouldShowInheritedProperties()) {
- enable =
getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
+ // enable if selected property is not inherited
+ if (this.editProperty.isEnabled() != enableDeclaredProperty) {
+ this.editProperty.setEnabled(enableDeclaredProperty);
}
- if (this.editProperty.isEnabled() != enable) {
- this.editProperty.setEnabled(enable);
+ // enable if selected property is not inherited
+ if (this.deleteProperty.isEnabled() != enableDeclaredProperty) {
+ this.deleteProperty.setEnabled(enableDeclaredProperty);
}
- if (this.deleteProperty.isEnabled() != enable) {
- this.deleteProperty.setEnabled(enable);
+ // enable if selected property is inherited
+ if (this.openPropertyDeclaringNodeType.isEnabled() != enableInheritedProperty) {
+ this.openPropertyDeclaringNodeType.setEnabled(enableInheritedProperty);
}
}
@@ -2410,6 +2456,18 @@
getSelectedNodeType().setQueryable(newValue);
}
+ void handleSelectPropertyDeclaringNodeType() {
+ assert (getSelectedProperty() != null) :
"handleSelectPropertyDeclaringNodeType called and no property selected";
//$NON-NLS-1$
+ QualifiedName qname =
getSelectedProperty().getDeclaringNodeTypeDefinitionName();
+ NodeTypeDefinition nodeType = getCnd().getNodeTypeDefinition(qname.get());
+
+ if (nodeType == null) {
+
+ } else {
+ this.nodeTypeViewer.setSelection(new StructuredSelection(nodeType));
+ }
+ }
+
void handleShowInheritedChildNodesChanged() {
refreshChildNodeViewer();
}
@@ -2800,19 +2858,25 @@
this.propertyViewer.getTable().setEnabled(enableWithNodeTypeSelected);
}
- boolean enable = (enableWithNodeTypeSelected &&
(getSelectedProperty() != null));
+ boolean enableWithPropertySelected = (enableWithNodeTypeSelected &&
(getSelectedProperty() != null));
+ boolean enableInheritedProperty = enableWithPropertySelected
+ &&
!getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
+ boolean enableDeclaredProperty = enableWithPropertySelected
+ &&
getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
- // disable if selected property is inherited
- if (enable && shouldShowInheritedProperties()) {
- enable =
getSelectedNodeType().hasDeclaredPropertyDefinition(getSelectedProperty().getName());
+ // enable if selected property is not inherited
+ if (this.editProperty.isEnabled() != enableDeclaredProperty) {
+ this.editProperty.setEnabled(enableDeclaredProperty);
}
- if (this.editProperty.isEnabled() != enable) {
- this.editProperty.setEnabled(enable);
+ // enable if selected property is not inherited
+ if (this.deleteProperty.isEnabled() != enableDeclaredProperty) {
+ this.deleteProperty.setEnabled(enableDeclaredProperty);
}
- if (this.deleteProperty.isEnabled() != enable) {
- this.deleteProperty.setEnabled(enable);
+ // enable if selected property is inherited
+ if (this.openPropertyDeclaringNodeType.isEnabled() !=
enableInheritedProperty) {
+ this.openPropertyDeclaringNodeType.setEnabled(enableInheritedProperty);
}
}
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-04
14:58:29 UTC (rev 40038)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/CndMessages.java 2012-04-04
16:11:17 UTC (rev 40039)
@@ -971,6 +971,16 @@
public static String onParentVersionToolTip;
/**
+ * The context menu item text for the open declaring node type action.
+ */
+ public static String openDeclaringNodeTypeMenuText;
+
+ /**
+ * A tool tip message of the open declaring node type action.
+ */
+ public static String openDeclaringNodeTypeToolTip;
+
+ /**
* A name for the orderable attribute suitable for a radio or check button.
*/
public static String orderableAttribute;
Modified:
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties
===================================================================
---
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-04
14:58:29 UTC (rev 40038)
+++
trunk/modeshape/plugins/org.jboss.tools.modeshape.jcr.ui/src/org/jboss/tools/modeshape/jcr/ui/cnd/cndMessages.properties 2012-04-04
16:11:17 UTC (rev 40039)
@@ -200,6 +200,8 @@
notEqualsOperatorToolTip = Indicates if the property supports the "not equals"
query operation
onParentVersionLabel = On Parent Version:
onParentVersionToolTip = Indicates what happens to the child node/property when the
parent is created
+openDeclaringNodeTypeMenuText = Open Declaring Node Type
+openDeclaringNodeTypeToolTip = Open the declaring node type in the editor if that node
type is in the CND being edited
orderableAttribute = Orderable
orderableAttributeToolTip = Indicates if the node type definition's are ordered
primaryItemLabel = Primary Item: