From eaa734092518cdeb8ff80d62f27412f2bea50a49 Mon Sep 17 00:00:00 2001 From: Erik Suta Date: Wed, 17 Dec 2014 11:41:01 +0100 Subject: [PATCH] Reworking QName editor and working with association and attribute references in RW. --- .../web/component/input/QNameEditorPanel.html | 10 +-- .../web/component/input/QNameEditorPanel.java | 62 +++++++++---- .../input/QNameEditorPanel.properties | 16 +++- .../ResourceAssociationEditor.html | 22 +---- .../ResourceAssociationEditor.java | 86 +------------------ .../ResourceAttributeEditor.java | 4 +- 6 files changed, 73 insertions(+), 127 deletions(-) diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.html b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.html index d9e98ae3a96..ce0523e78fa 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.html +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.html @@ -20,18 +20,18 @@
- - + +
- +
- - + +
diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.java index 14dcb411c09..4254d1848ff 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.java @@ -18,6 +18,7 @@ import com.evolveum.midpoint.web.component.util.SimplePanel; import com.evolveum.midpoint.web.util.InfoTooltipBehavior; +import org.apache.wicket.behavior.AttributeAppender; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.DropDownChoice; import org.apache.wicket.markup.html.form.TextField; @@ -33,13 +34,23 @@ * */ public class QNameEditorPanel extends SimplePanel{ - private static final String ID_ATTRIBUTE = "attribute"; + private static final String ID_LOCAL_PART = "localPart"; private static final String ID_NAMESPACE = "namespace"; - private static final String ID_T_ATTRIBUTE = "attributeTooltip"; + private static final String ID_LOCAL_PART_LABEL = "localPartLabel"; + private static final String ID_NAMESPACE_LABEL = "namespaceLabel"; + private static final String ID_T_LOCAL_PART = "localPartTooltip"; private static final String ID_T_NAMESPACE = "namespaceTooltip"; public QNameEditorPanel(String id, IModel model){ + this(id, model, "QNameEditor.label.localPart", "QNameEditor.tooltip.localPart", + "QNameEditor.label.namespace", "QNameEditor.tooltip.namespace"); + } + + public QNameEditorPanel(String id, IModel model, String localPartLabelKey, String localPartTooltipKey, + String namespaceLabelKey, String namespaceTooltipKey){ super(id, model); + + initLayout(localPartLabelKey, localPartTooltipKey, namespaceLabelKey, namespaceTooltipKey); } @Override @@ -54,14 +65,24 @@ public IModel getModel() { return model; } - @Override - protected void initLayout(){ + protected void initLayout(String localPartLabelKey, String localPartTooltipKey, + String namespaceLabelKey, String namespaceTooltipKey){ - TextField attribute = new TextField<>(ID_ATTRIBUTE, new PropertyModel(getModel(), "localPart")); - attribute.setOutputMarkupId(true); - attribute.setOutputMarkupPlaceholderTag(true); - attribute.setRequired(true); - add(attribute); + Label localPartLabel = new Label(ID_LOCAL_PART_LABEL, getString(localPartLabelKey)); + localPartLabel.setOutputMarkupId(true); + localPartLabel.setOutputMarkupPlaceholderTag(true); + add(localPartLabel); + + Label namespaceLabel = new Label(ID_NAMESPACE_LABEL, getString(namespaceLabelKey)); + namespaceLabel.setOutputMarkupId(true); + namespaceLabel.setOutputMarkupPlaceholderTag(true); + add(namespaceLabel); + + TextField localPart = new TextField<>(ID_LOCAL_PART, new PropertyModel(getModel(), "localPart")); + localPart.setOutputMarkupId(true); + localPart.setOutputMarkupPlaceholderTag(true); + localPart.setRequired(isLocalPartRequired()); + add(localPart); DropDownChoice namespace = new DropDownChoice<>(ID_NAMESPACE, new PropertyModel(getModel(), "namespaceURI"), prepareNamespaceList()); @@ -71,17 +92,23 @@ protected void initLayout(){ namespace.setRequired(true); add(namespace); - Label attrTooltip = new Label(ID_T_ATTRIBUTE); - attrTooltip.add(new InfoTooltipBehavior()); - attrTooltip.setOutputMarkupPlaceholderTag(true); - add(attrTooltip); + Label localPartTooltip = new Label(ID_T_LOCAL_PART); + localPartTooltip.add(new AttributeAppender("data-original-title", getString(localPartTooltipKey))); + localPartTooltip.add(new InfoTooltipBehavior()); + localPartTooltip.setOutputMarkupPlaceholderTag(true); + add(localPartTooltip); Label namespaceTooltip = new Label(ID_T_NAMESPACE); + namespaceTooltip.add(new AttributeAppender("data-original-title", getString(namespaceTooltipKey))); namespaceTooltip.add(new InfoTooltipBehavior()); namespaceTooltip.setOutputMarkupPlaceholderTag(true); add(namespaceTooltip); } + /** + * Override to provide custom list of namespaces + * for QName editor + * */ protected List prepareNamespaceList(){ List list = new ArrayList<>(); @@ -93,7 +120,10 @@ protected List prepareNamespaceList(){ return list; } -// public boolean isRequired(){ -// return false; -// } + /** + * Should localPart of QName be required? + * */ + public boolean isLocalPartRequired(){ + return false; + } } diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.properties b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.properties index e1bd5038b71..88d0fee56d5 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.properties +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/input/QNameEditorPanel.properties @@ -14,5 +14,17 @@ # limitations under the License. # -QNameEditor.label.attribute=Ref. attribute -QNameEditor.label.namespace=Ref. namespace +QNameEditor.label.localPart=Local part name +QNameEditor.label.namespace=Namespace +QNameEditor.tooltip.localPart=Local part of QName +QNameEditor.tooltip.namespace=Namespace of QName + +SchemaHandlingStep.attribute.label.attributeName=Attribute name +SchemaHandlingStep.attribute.label.attributeNamespace=Attribute namespace +SchemaHandlingStep.attribute.tooltip.attributeLocalPart=TODO: SchemaHandlingStep.attribute.tooltip.attributeLocalPart +SchemaHandlingStep.attribute.tooltip.attributeNamespace=TODO: SchemaHandlingStep.attribute.tooltip.attributeNamespace + +SchemaHandlingStep.association.label.associationName=Association name +SchemaHandlingStep.association.label.associationNamespace=Association namespace +SchemaHandlingStep.association.tooltip.associationLocalPart=TODO: SchemaHandlingStep.association.tooltip.associationLocalPart +SchemaHandlingStep.association.tooltip.associationNamespace=TODO: SchemaHandlingStep.association.tooltip.associationNamespace \ No newline at end of file diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.html b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.html index a726fb6ff92..db165e1b0a3 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.html +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.html @@ -115,27 +115,7 @@

-
-
- - -
-
- -
-
- -
- -
-
- - -
-
- -
-
+
diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.java index 6f98175d5eb..582e740fe09 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAssociationEditor.java @@ -29,7 +29,6 @@ import com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextPanel; import com.evolveum.midpoint.web.component.input.QNameEditorPanel; import com.evolveum.midpoint.web.component.util.SimplePanel; -import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour; import com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.LimitationsEditorDialog; import com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.modal.MappingEditorDialog; import com.evolveum.midpoint.web.component.wizard.resource.dto.MappingTypeDto; @@ -39,10 +38,8 @@ import com.evolveum.midpoint.xml.ns._public.common.common_3.*; import org.apache.wicket.RestartResponseException; import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.form.*; import org.apache.wicket.model.AbstractReadOnlyModel; @@ -71,10 +68,7 @@ public class ResourceAssociationEditor extends SimplePanel resource; private ResourceObjectTypeDefinitionType objectType; - private boolean nonSchemaRefValueAllowed = false; public ResourceAssociationEditor(String id, IModel model, ResourceObjectTypeDefinitionType objectType, PrismObject resource){ @@ -205,78 +196,13 @@ public String getIdValue(QName object, int index) { new PropertyModel(getModel(), "explicitReferentialIntegrity")); add(explicitRefIntegrity); - QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_NON_SCHEMA_REF_PANEL, new PropertyModel(getModel(), "ref")); - + QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_ASSOCIATION_ATTRIBUTE_PANEL, new PropertyModel(getModel(), "ref"), + "SchemaHandlingStep.association.label.associationName", "SchemaHandlingStep.association.tooltip.associationLocalPart", + "SchemaHandlingStep.association.label.associationNamespace", "SchemaHandlingStep.association.tooltip.associationNamespace"); nonSchemaRefPanel.setOutputMarkupId(true); nonSchemaRefPanel.setOutputMarkupPlaceholderTag(true); - nonSchemaRefPanel.add(new VisibleEnableBehaviour(){ - - @Override - public boolean isVisible() { - return nonSchemaRefValueAllowed; - } - }); add(nonSchemaRefPanel); - WebMarkupContainer schemaRefPanel = new WebMarkupContainer(ID_SCHEMA_REF_PANEL); - schemaRefPanel.setOutputMarkupId(true); - schemaRefPanel.setOutputMarkupPlaceholderTag(true); - schemaRefPanel.add(new VisibleEnableBehaviour(){ - - @Override - public boolean isVisible() { - return !nonSchemaRefValueAllowed; - } - }); - add(schemaRefPanel); - - Label refTooltip = new Label(ID_T_REF); - refTooltip.add(new InfoTooltipBehavior()); - refTooltip.setOutputMarkupId(true); - refTooltip.setOutputMarkupId(true); - schemaRefPanel.add(refTooltip); - - DropDownChoice refSelect = new DropDownChoice<>(ID_REFERENCE_SELECT, new PropertyModel(getModel(), "ref"), - new AbstractReadOnlyModel>() { - - @Override - public List getObject() { - return loadObjectReferences(true); - } - }, new IChoiceRenderer() { - - @Override - public Object getDisplayValue(QName object) { - return prepareReferenceDisplayValue(object); - } - - @Override - public String getIdValue(QName object, int index) { - return Integer.toString(index); - } - }); - refSelect.setOutputMarkupId(true); - refSelect.setOutputMarkupPlaceholderTag(true); - refSelect.add(new VisibleEnableBehaviour(){ - - @Override - public boolean isVisible() { - return !nonSchemaRefValueAllowed; - } - - }); - schemaRefPanel.add(refSelect); - - CheckBox allowNonSchema = new CheckBox(ID_REFERENCE_ALLOW, new PropertyModel(this, "nonSchemaRefValueAllowed")); - allowNonSchema.add(new AjaxFormComponentUpdatingBehavior("onchange") { - - @Override - protected void onUpdate(AjaxRequestTarget target) { - target.add(get(ID_SCHEMA_REF_PANEL), get(ID_NON_SCHEMA_REF_PANEL)); - } - }); - add(allowNonSchema); - TextField displayName = new TextField<>(ID_DISPLAY_NAME, new PropertyModel(getModel(), "displayName")); add(displayName); @@ -417,10 +343,6 @@ protected void editPerformed(AjaxRequestTarget target, MappingType object){ integrityTooltip.add(new InfoTooltipBehavior()); add(integrityTooltip); - Label allowTooltip = new Label(ID_T_ALLOW); - allowTooltip.add(new InfoTooltipBehavior()); - add(allowTooltip); - Label limitationsTooltip = new Label(ID_T_LIMITATIONS); limitationsTooltip.add(new InfoTooltipBehavior()); add(limitationsTooltip); diff --git a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAttributeEditor.java b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAttributeEditor.java index 5499742634f..084e4e49dc8 100644 --- a/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAttributeEditor.java +++ b/gui/admin-gui/src/main/java/com/evolveum/midpoint/web/component/wizard/resource/component/schemahandling/ResourceAttributeEditor.java @@ -122,7 +122,9 @@ public String getObject() { }); add(label); - QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_NON_SCHEMA_REF_PANEL, new PropertyModel(getModel(), "ref")); + QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_NON_SCHEMA_REF_PANEL, new PropertyModel(getModel(), "ref"), + "SchemaHandlingStep.attribute.label.attributeName", "SchemaHandlingStep.attribute.tooltip.attributeLocalPart", + "SchemaHandlingStep.attribute.label.attributeNamespace", "SchemaHandlingStep.attribute.tooltip.attributeNamespace"); nonSchemaRefPanel.setOutputMarkupId(true); nonSchemaRefPanel.setOutputMarkupPlaceholderTag(true);