Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Apr 7, 2020
2 parents 74420b8 + b7303d3 commit 1851daf
Show file tree
Hide file tree
Showing 17 changed files with 1,088 additions and 921 deletions.
Expand Up @@ -39,6 +39,6 @@ public Integer getOrder() {

@Override
protected Panel getPanel(PrismPropertyPanelContext<ExecuteScriptType> panelCtx) {
return new TextAreaPanel<>(panelCtx.getComponentId(), new ExecuteScriptModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 100);
return new TextAreaPanel<>(panelCtx.getComponentId(), new ExecuteScriptModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 20);
}
}
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.factory;

import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.ThreadContext;
import org.apache.wicket.model.IModel;

import com.evolveum.midpoint.gui.api.util.ModelServiceLocator;
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.model.scripting_3.ExecuteScriptType;

public class ObjectDeltaModel implements IModel<String> {

private static final transient Trace LOGGER = TraceManager.getTrace(ObjectDeltaModel.class);

private IModel<ObjectDeltaType> baseModel;
private ModelServiceLocator locator;

public ObjectDeltaModel(IModel<ObjectDeltaType> model, ModelServiceLocator locator) {
this.baseModel = model;
this.locator = locator;
}


@Override
public String getObject() {
try {
ObjectDeltaType value = baseModel.getObject();
if (value == null) {
return null;
}

return locator.getPrismContext().xmlSerializer().serializeRealValue(value);
} catch (Exception e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot serialize delta", e);
ThreadContext.getSession().error("Cannot serialize delta: " + e.getMessage());
}
return null;
}

@Override
public void setObject(String object) {
if (StringUtils.isBlank(object)) {
return;
}

try {
ObjectDeltaType script = locator.getPrismContext().parserFor(object).parseRealValue(ObjectDeltaType.class);
baseModel.setObject(script);
} catch (Exception e) {
// TODO handle!!!!
LoggingUtils.logUnexpectedException(LOGGER, "Cannot parse delta", e);
ThreadContext.getSession().error("Cannot parse delta: " + e.getMessage());
}
}
}
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.gui.impl.factory;

import javax.annotation.PostConstruct;

import com.evolveum.midpoint.web.component.input.TextAreaPanel;

import org.apache.wicket.markup.html.panel.Panel;
import org.springframework.stereotype.Component;

import com.evolveum.midpoint.gui.api.factory.AbstractGuiComponentFactory;
import com.evolveum.midpoint.gui.api.prism.ItemWrapper;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;

@Component
public class ObjectDeltaPanelFactory extends AbstractGuiComponentFactory<ObjectDeltaType> {

@PostConstruct
public void register() {
getRegistry().addToRegistry(this);
}

@Override
public Integer getOrder() {
return super.getOrder() - 100;
}

@Override
protected Panel getPanel(PrismPropertyPanelContext<ObjectDeltaType> panelCtx) {
return new TextAreaPanel<>(panelCtx.getComponentId(), new ObjectDeltaModel(panelCtx.getRealValueModel(), panelCtx.getPageBase()), 20);
}

@Override
public <IW extends ItemWrapper> boolean match(IW wrapper) {
return QNameUtil.match(ObjectDeltaType.COMPLEX_TYPE, wrapper.getTypeName());
}
}
Expand Up @@ -108,6 +108,7 @@ protected void populateItem(ListItem<VW> item) {
GuiComponentFactory componentFactory = getPageBase().getRegistry()
.findValuePanelFactory(ItemPanel.this.getModelObject());


Component panel = createValuePanel(item, componentFactory, getVisibilityHandler(), getEditabilityHandler());
// panel.add(getEnableBehaviourOfValuePanel(ItemPanel.this.getModelObject()));
createButtons(item);
Expand Down Expand Up @@ -230,8 +231,10 @@ protected void removeValue(VW valueToRemove, AjaxRequestTarget target) throws Sc
break;
case DELETED:
valueToRemove.setStatus(ValueStatus.NOT_CHANGED);
getModelObject().getItem().add(valueToRemove.getNewValue());
break;
case NOT_CHANGED:
getModelObject().getItem().remove(valueToRemove.getNewValue());
valueToRemove.setStatus(ValueStatus.DELETED);
break;
}
Expand All @@ -248,9 +251,9 @@ protected void removeValue(VW valueToRemove, AjaxRequestTarget target) throws Sc
private int countUsableValues(List<VW> values) {
int count = 0;
for (VW value : values) {
// if (ValueStatus.DELETED.equals(value.getStatus())) {
// continue;
// }
if (ValueStatus.DELETED.equals(value.getStatus())) {
continue;
}
if (ValueStatus.ADDED.equals(value.getStatus())) {
continue;
}
Expand Down

0 comments on commit 1851daf

Please sign in to comment.