Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Oct 6, 2014
2 parents 02accc6 + bdd7186 commit 53a13c1
Show file tree
Hide file tree
Showing 28 changed files with 450 additions and 253 deletions.
Expand Up @@ -35,12 +35,10 @@
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.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
Expand Down Expand Up @@ -114,6 +112,7 @@ protected void onUpdate(AjaxRequestTarget target) {
});
type.setOutputMarkupId(true);
type.setOutputMarkupPlaceholderTag(true);
type.setNullValid(true);
add(type);

WebMarkupContainer languageContainer = new WebMarkupContainer(ID_LANGUAGE_CONTAINER);
Expand Down Expand Up @@ -193,10 +192,10 @@ protected void onUpdate(AjaxRequestTarget target) {
expression.setOutputMarkupId(true);
add(expression);

AjaxLink update = new AjaxLink(ID_BUTTON_UPDATE) {
AjaxSubmitLink update = new AjaxSubmitLink(ID_BUTTON_UPDATE) {

@Override
public void onClick(AjaxRequestTarget target) {
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
updateExpressionPerformed(target);
}
};
Expand Down Expand Up @@ -255,9 +254,7 @@ protected void updateExpressionPerformed(AjaxRequestTarget target){
/**
* Override this in component with ExpressionEditorPanel to provide additional functionality when expression is updated
* */
public void performExpressionHook(AjaxRequestTarget target){

}
public void performExpressionHook(AjaxRequestTarget target){}

/**
* Provide key for expression type label
Expand Down
Expand Up @@ -24,6 +24,7 @@ ExpressionEditorPanel.message.cantSerialize=Could not create JAXBElement<?> from
ExpressionEditorPanel.message.expressionSuccess=Expression has been update successfully.

policyRef.nullValid=Choose One
type.nullValid=Choose One
ExpressionEvaluatorType.LITERAL=Literal
ExpressionEvaluatorType.AS_IS=As is
ExpressionEvaluatorType.PATH=Path
Expand Down
Expand Up @@ -16,7 +16,6 @@

package com.evolveum.midpoint.web.component.input;

import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand All @@ -25,7 +24,8 @@
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
Expand All @@ -41,7 +41,7 @@ public class SearchFilterPanel<T extends SearchFilterType> extends SimplePanel<T
private static final String ID_FILTER_CLAUSE = "filterClause";
private static final String ID_BUTTON_UPDATE = "update";

private IModel<SearchFilterTypeDto> model;
protected IModel<SearchFilterTypeDto> model;

public SearchFilterPanel(String id, IModel<T> model){
super(id, model);
Expand Down Expand Up @@ -71,10 +71,10 @@ protected void initLayout(){
new PropertyModel<String>(model, SearchFilterTypeDto.F_FILTER_CLAUSE));
add(filterClause);

AjaxLink update = new AjaxLink(ID_BUTTON_UPDATE) {
AjaxSubmitLink update = new AjaxSubmitLink(ID_BUTTON_UPDATE) {

@Override
public void onClick(AjaxRequestTarget target) {
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
updateClausePerformed(target);
}
};
Expand All @@ -86,7 +86,7 @@ private void updateClausePerformed(AjaxRequestTarget target){
model.getObject().updateFilterClause(getPageBase().getPrismContext());

success(getString("SearchFilterPanel.message.expressionSuccess"));
} catch (SchemaException e){
} catch (Exception e){
LoggingUtils.logException(LOGGER, "Could not create MapXNode from provided XML filterClause.", e);
error(getString("SearchFilterPanel.message.cantSerialize"));
}
Expand All @@ -98,7 +98,5 @@ private void updateClausePerformed(AjaxRequestTarget target){
/**
* Override this in component with SearchFilterPanel to provide additional functionality when filterClause is updated
* */
public void performFilterClauseHook(AjaxRequestTarget target){
target.add();
}
public void performFilterClauseHook(AjaxRequestTarget target){}
}
Expand Up @@ -17,17 +17,14 @@
package com.evolveum.midpoint.web.component.input.dto;

import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.xnode.MapXNode;
import com.evolveum.midpoint.prism.xnode.RootXNode;
import com.evolveum.midpoint.prism.xnode.XNode;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;
import org.apache.commons.lang.StringUtils;

import javax.xml.namespace.QName;
import java.io.Serializable;

/**
Expand Down Expand Up @@ -86,6 +83,11 @@ public void updateFilterClause(PrismContext context) throws SchemaException{
RootXNode filterClauseNode = (RootXNode) context.parseToXNode(filterClause, PrismContext.LANG_XML);

filterObject.setFilterClauseXNode(filterClauseNode);
} else {
String oldDescription = filterObject.getDescription();

filterObject = new SearchFilterType();
filterObject.setDescription(oldDescription);
}
}

Expand Down
Expand Up @@ -26,6 +26,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.wizard.IWizard;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.AbstractReadOnlyModel;
Expand All @@ -49,15 +50,13 @@ public WizardStep() {

@Override
public Component getHeader(String id, Component parent, IWizard wizard) {
Label header = new Label(id, new AbstractReadOnlyModel<String>() {
return new Label(id, new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
return getTitle();
}
});

return header;
}

public PageBase getPageBase() {
Expand Down Expand Up @@ -127,8 +126,8 @@ protected IValidator<String> createObjectClassValidator(final IModel<List<QName>
return new IValidator<String>() {

@Override
public void validate(IValidatable<String> validatable) {
String value = validatable.getValue();
public void validate(IValidatable<String> validated) {
String value = validated.getValue();
List<QName> list = model.getObject();
List<String> stringList = new ArrayList<>();

Expand All @@ -138,6 +137,8 @@ public void validate(IValidatable<String> validatable) {

if(!stringList.contains(value)){
error(createStringResource("SchemaHandlingStep.message.validationError", value).getString());
AjaxRequestTarget target = getRequestCycle().find(AjaxRequestTarget.class);
target.add(getPageBase().getFeedbackPanel());
}
}
};
Expand Down
Expand Up @@ -14,4 +14,5 @@
# limitations under the License.
#

WizardStep.title=
WizardStep.title=
SchemaHandlingStep.message.validationError=Inserted objectClass value: '{0}' is not valid. Please provide valid objectClass value.
Expand Up @@ -537,39 +537,39 @@ private void dependencyEditPerformed(AjaxRequestTarget target){
new PropertyModel<List<ResourceObjectTypeDependencyType>>(model, SchemaHandlingDto.F_SELECTED + ".dependency"));
getThirdRowContainer().replaceWith(newContainer);

target.add(getThirdRowContainer());
target.add(getThirdRowContainer(), getPageBase().getFeedbackPanel());
}

private void iterationEditPerformed(AjaxRequestTarget target){
WebMarkupContainer newContainer = new ResourceIterationEditor(ID_THIRD_ROW_CONTAINER,
new PropertyModel<IterationSpecificationType>(model, SchemaHandlingDto.F_SELECTED + ".iteration"));
getThirdRowContainer().replaceWith(newContainer);

target.add(getThirdRowContainer());
target.add(getThirdRowContainer(), getPageBase().getFeedbackPanel());
}

private void protectedEditPerformed(AjaxRequestTarget target){
WebMarkupContainer newContainer = new ResourceProtectedEditor(ID_THIRD_ROW_CONTAINER,
new PropertyModel<List<ResourceObjectPatternType>>(model, SchemaHandlingDto.F_SELECTED + "._protected"));
getThirdRowContainer().replaceWith(newContainer);

target.add(getThirdRowContainer());
target.add(getThirdRowContainer(), getPageBase().getFeedbackPanel());
}

private void activationEditPerformed(AjaxRequestTarget target){
WebMarkupContainer newContainer = new ResourceActivationEditor(ID_THIRD_ROW_CONTAINER,
new PropertyModel<ResourceActivationDefinitionType>(model, SchemaHandlingDto.F_SELECTED + ".activation"));
getThirdRowContainer().replaceWith(newContainer);

target.add(getThirdRowContainer());
target.add(getThirdRowContainer(), getPageBase().getFeedbackPanel());
}

private void credentialsEditPerformed(AjaxRequestTarget target){
WebMarkupContainer newContainer = new ResourceCredentialsEditor(ID_THIRD_ROW_CONTAINER,
new PropertyModel<ResourceCredentialsDefinitionType>(model, SchemaHandlingDto.F_SELECTED + ".credentials"));
getThirdRowContainer().replaceWith(newContainer);

target.add(getThirdRowContainer());
target.add(getThirdRowContainer(), getPageBase().getFeedbackPanel());
}

private void editAttributePerformed(AjaxRequestTarget target, ResourceAttributeDefinitionType object){
Expand All @@ -592,7 +592,7 @@ private void editAssociationPerformed(AjaxRequestTarget target, ResourceObjectAs
model.getObject().getSelected(), resourceModel.getObject());
getThirdRowContainer().replaceWith(newContainer);

target.add(getThirdRowContainer());
target.add(getThirdRowContainer(), getPageBase().getFeedbackPanel());
} else {
warn(getString("SchemaHandlingStep.message.selectObjectClassAss"));
getThirdRowContainer().replaceWith(new WebMarkupContainer(ID_THIRD_ROW_CONTAINER));
Expand Down
Expand Up @@ -56,23 +56,7 @@ <h4 class="panel-title">
</dl>

<h4><wicket:message key="ResourceProtectedEditor.label.filter" /></h4>
<dl class="dl-horizontal">
<dt>
<label><wicket:message key="ResourceProtectedEditor.label.description" /></label>
</dt>
<dd>
<textarea wicket:id="filterDescription" class="form-control input-sm" rows="2"></textarea>
</dd>
</dl>

<dl class="dl-horizontal">
<dt>
<label><wicket:message key="ResourceProtectedEditor.label.filterClause" /></label>
</dt>
<dd>
<input wicket:id="filterClause" type="text" class="form-control input-sm" value=""/>
</dd>
</dl>
<div wicket:id="filterClause" />
</div>
</div>
</div>
Expand Down
Expand Up @@ -16,15 +16,16 @@

package com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling;

import com.evolveum.midpoint.web.component.input.SearchFilterPanel;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceObjectPatternType;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;
import org.apache.wicket.AttributeModifier;
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.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
Expand All @@ -51,8 +52,7 @@ private static enum ChangeState{
private static final String ID_ACCOUNT_BODY = "accountBodyContainer";
private static final String ID_NAME = "name";
private static final String ID_UID = "uid";
private static final String ID_FILTER_DESCRIPTION = "filterDescription";
private static final String ID_FILTER_CLAUSE = "filterClause";
private static final String ID_FILTER_EDITOR = "filterClause";
private static final String ID_BUTTON_ADD = "addButton";
private static final String ID_BUTTON_DELETE = "deleteAccount";

Expand Down Expand Up @@ -150,16 +150,9 @@ public String getObject() {
uid.add(prepareAjaxOnComponentTagUpdateBehavior());
accountBody.add(uid);

TextArea filterDescription = new TextArea<>(ID_FILTER_DESCRIPTION,
new PropertyModel<String>(item.getModelObject(), "filter.description"));
filterDescription.add(prepareAjaxOnComponentTagUpdateBehavior());
accountBody.add(filterDescription);

//TODO - what is this? How should we edit this?
TextField filterClause = new TextField<>(ID_FILTER_CLAUSE,
new PropertyModel<String>(item.getModelObject(), "filter.filterClauseXNode"));
filterClause.add(prepareAjaxOnComponentTagUpdateBehavior());
accountBody.add(filterClause);
SearchFilterPanel searchFilterPanel = new SearchFilterPanel<>(ID_FILTER_EDITOR,
new PropertyModel<SearchFilterType>(item.getModelObject(), "filter"));
accountBody.add(searchFilterPanel);
}
};
repeater.setOutputMarkupId(true);
Expand Down
Expand Up @@ -18,10 +18,12 @@

import com.evolveum.midpoint.web.component.input.ExpressionEditorPanel;
import com.evolveum.midpoint.web.component.input.SearchFilterPanel;
import com.evolveum.midpoint.web.component.input.dto.SearchFilterTypeDto;
import com.evolveum.midpoint.web.component.util.LoadableModel;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConditionalSearchFilterType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import com.evolveum.prism.xml.ns._public.query_3.SearchFilterType;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -103,7 +105,20 @@ public String getExpressionLabelKey() {
};
add(expressionEditor);

SearchFilterPanel filterClauseEditor = new SearchFilterPanel<>(ID_FILTER_CLAUSE_PANEL, getModel());
SearchFilterPanel filterClauseEditor = new SearchFilterPanel<ConditionalSearchFilterType>(ID_FILTER_CLAUSE_PANEL, getModel()){

@Override
public void performFilterClauseHook(AjaxRequestTarget target){
if(model != null && model.getObject() != null && ConditionalSearchFilterEditor.this.getModel() != null){
SearchFilterTypeDto dto = model.getObject();
SearchFilterType filter = dto.getFilterObject();

if(filter != null){
ConditionalSearchFilterEditor.this.getModelObject().setFilterClauseXNode(filter.getFilterClauseXNode());
}
}
}
};
add(filterClauseEditor);
}
}
Expand Up @@ -69,13 +69,15 @@ public String getObject(){
name.setOutputMarkupId(true);

AjaxLink choose = new AjaxLink(ID_LINK_CHOOSE) {

@Override
public void onClick(AjaxRequestTarget target) {
changeOptionPerformed(target);
}
};

AjaxLink remove = new AjaxLink(ID_LINK_REMOVE) {

@Override
public void onClick(AjaxRequestTarget target) {
setToDefault();
Expand All @@ -91,7 +93,7 @@ public void onClick(AjaxRequestTarget target) {
}

private void initDialog(){
ModalWindow dialog = new ChooseTypeDialog(MODAL_ID_SHOW_CHOOSE_OPTIONS, getModel().getObject().getType()){
ModalWindow dialog = new ChooseTypeDialog(MODAL_ID_SHOW_CHOOSE_OPTIONS, getObjectTypeClass()){

@Override
protected void chooseOperationPerformed(AjaxRequestTarget target, ObjectType object){
Expand Down Expand Up @@ -151,7 +153,13 @@ private void changeOptionPerformed(AjaxRequestTarget target){
}

private void setToDefault(){
getModel().setObject(new ObjectViewDto());
ObjectViewDto dto = new ObjectViewDto();
dto.setType(getObjectTypeClass());
getModel().setObject(dto);
}

private Class<T> getObjectTypeClass(){
return getModel().getObject().getType();
}

public StringResourceModel createStringResource(String resourceKey, Object... objects) {
Expand Down

0 comments on commit 53a13c1

Please sign in to comment.