Skip to content

Commit

Permalink
show/hide improvement for task basic tab, making executeScript panel …
Browse files Browse the repository at this point in the history
…smaller, adding objectDelta panel
  • Loading branch information
katkav committed Apr 6, 2020
1 parent 0e38df9 commit 13826a1
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 1 deletion.
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 @@ -173,6 +173,29 @@ private ItemVisibility getBasicTabVisibility(ItemPath path) {
return ItemVisibility.HIDDEN;
}

// region no panel for type
if (ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_SEARCH_OPTIONS).equivalent(path)) {
return ItemVisibility.HIDDEN;
}

if (ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_EXECUTE_OPTIONS).equivalent(path)) {
return ItemVisibility.HIDDEN;
}

if (ItemPath.create(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_MODEL_EXECUTE_OPTIONS).equivalent(path)) {
return ItemVisibility.HIDDEN;
}

if (TaskType.F_RESULT.equivalent(path)) {
return ItemVisibility.HIDDEN;
}

if (TaskType.F_OTHER_HANDLERS_URI_STACK.equivalent(path)) {
return ItemVisibility.HIDDEN;
}

//end region unsupported panel for type

String taskHandler = getTask().getHandlerUri();

if (taskHandler == null) {
Expand Down
Expand Up @@ -357,6 +357,7 @@ public abstract class SchemaConstants {
public static final ItemName MODEL_EXTENSION_WORKER_THREADS = new ItemName(NS_MODEL_EXTENSION, "workerThreads");
public static final ItemName MODEL_EXTENSION_OPTION_RAW = new ItemName(NS_MODEL_EXTENSION, "optionRaw");
public static final ItemName MODEL_EXTENSION_EXECUTE_OPTIONS = new ItemName(NS_MODEL_EXTENSION, "executeOptions");
public static final ItemName MODEL_EXTENSION_MODEL_EXECUTE_OPTIONS = new ItemName(NS_MODEL_EXTENSION, "modelExecuteOptions");

public static final ItemName MODEL_EXTENSION_DIAGNOSE = new ItemName(NS_MODEL_EXTENSION, "diagnose");
public static final ItemName MODEL_EXTENSION_FIX = new ItemName(NS_MODEL_EXTENSION, "fix");
Expand Down

0 comments on commit 13826a1

Please sign in to comment.