use of org.apache.wicket.markup.html.WebMarkupContainer in project midpoint by Evolveum.
the class SchemaHandlingStep method iterationEditPerformed.
private void iterationEditPerformed(AjaxRequestTarget target) {
WebMarkupContainer newContainer = new ResourceIterationEditor(ID_THIRD_ROW_CONTAINER, new PropertyModel<IterationSpecificationType>(schemaHandlingDtoModel, getExpression(ResourceObjectTypeDefinitionType.F_ITERATION)), parentPage);
getThirdRowContainer().replaceWith(newContainer);
resetSelections(target);
target.add(getThirdRowContainer(), get(ID_OBJECT_TYPE_EDITOR), parentPage.getFeedbackPanel());
}
use of org.apache.wicket.markup.html.WebMarkupContainer in project midpoint by Evolveum.
the class SchemaHandlingStep method initLayout.
private void initLayout() {
final ListDataProvider<ResourceObjectTypeDefinitionTypeDto> objectTypeProvider = new ListDataProvider<>(this, new PropertyModel<List<ResourceObjectTypeDefinitionTypeDto>>(schemaHandlingDtoModel, SchemaHandlingDto.F_OBJECT_TYPE_DTO_LIST));
// first row - object types table
WebMarkupContainer objectTypesTable = new WebMarkupContainer(ID_ROWS);
objectTypesTable.setOutputMarkupId(true);
add(objectTypesTable);
// second row - object type editor
WebMarkupContainer objectTypeEditor = new WebMarkupContainer(ID_OBJECT_TYPE_EDITOR);
objectTypeEditor.setOutputMarkupId(true);
objectTypeEditor.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isAnySelected();
}
});
add(objectTypeEditor);
// third row container
WebMarkupContainer thirdRowContainer = new WebMarkupContainer(ID_THIRD_ROW_CONTAINER);
thirdRowContainer.setOutputMarkupId(true);
add(thirdRowContainer);
// ---------------------- details -----------------------
// Object type table (list)
DataView<ResourceObjectTypeDefinitionTypeDto> objectTypeDataView = new DataView<ResourceObjectTypeDefinitionTypeDto>(ID_ROW_OBJECT_TYPE, objectTypeProvider, UserProfileStorage.DEFAULT_PAGING_SIZE) {
@Override
protected void populateItem(final Item<ResourceObjectTypeDefinitionTypeDto> item) {
final ResourceObjectTypeDefinitionTypeDto objectType = item.getModelObject();
AjaxSubmitLink link = new AjaxSubmitLink(ID_LINK_OBJECT_TYPE) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
editObjectTypePerformed(target, objectType);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(parentPage.getFeedbackPanel());
}
};
item.add(link);
Label label = new Label(ID_NAME_OBJECT_TYPE, createObjectTypeDisplayModel(objectType));
label.setOutputMarkupId(true);
link.add(label);
AjaxLink delete = new AjaxLink(ID_BUTTON_DELETE_OBJECT_TYPE) {
@Override
public void onClick(AjaxRequestTarget target) {
deleteObjectTypePerformed(target, objectType);
}
};
parentPage.addEditingVisibleBehavior(delete);
link.add(delete);
item.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return isSelected(item.getModelObject()) ? "success" : null;
}
}));
}
};
objectTypesTable.add(objectTypeDataView);
NavigatorPanel navigator = new NavigatorPanel(ID_PAGING_OBJECT_TYPE, objectTypeDataView, true);
navigator.setOutputMarkupPlaceholderTag(true);
navigator.setOutputMarkupId(true);
add(navigator);
AjaxSubmitLink add = new AjaxSubmitLink(ID_BUTTON_ADD_OBJECT_TYPE) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
addObjectTypePerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(parentPage.getFeedbackPanel());
}
};
parentPage.addEditingVisibleBehavior(add);
add(add);
initObjectTypeEditor(objectTypeEditor);
}
use of org.apache.wicket.markup.html.WebMarkupContainer in project midpoint by Evolveum.
the class CapabilityStep method editCapabilityPerformed.
@SuppressWarnings("unchecked")
private void editCapabilityPerformed(final AjaxRequestTarget target, CapabilityDto<? extends CapabilityType> capability) {
dtoModel.getObject().setSelected(capability);
WebMarkupContainer config = getConfigContainer();
WebMarkupContainer newConfig;
CapabilityType capType = capability.getCapability();
if (capType instanceof ActivationCapabilityType) {
newConfig = new CapabilityActivationPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ActivationCapabilityType>) capability), parentPage) {
@Override
public IModel<List<QName>> createAttributeChoiceModel(final IChoiceRenderer<QName> renderer) {
LoadableModel<List<QName>> attributeChoiceModel = new LoadableModel<List<QName>>(false) {
@Override
protected List<QName> load() {
List<QName> choices = new ArrayList<>();
PrismObject<ResourceType> resourcePrism = resourceModel.getObject();
try {
ResourceSchema schema = RefinedResourceSchemaImpl.getResourceSchema(resourcePrism, getPageBase().getPrismContext());
if (schema != null) {
ObjectClassComplexTypeDefinition def = schema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
for (ResourceAttributeDefinition attribute : def.getAttributeDefinitions()) {
choices.add(attribute.getName());
}
}
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't load resource schema attributes.", e);
getPageBase().error("Couldn't load resource schema attributes" + e);
}
Collections.sort(choices, new Comparator<QName>() {
@Override
public int compare(QName o1, QName o2) {
String s1 = (String) renderer.getDisplayValue(o1);
String s2 = (String) renderer.getDisplayValue(o2);
return String.CASE_INSENSITIVE_ORDER.compare(s1, s2);
}
});
return choices;
}
};
parentPage.registerDependentModel(attributeChoiceModel);
return attributeChoiceModel;
}
};
} else if (capType instanceof ScriptCapabilityType) {
newConfig = new CapabilityScriptPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<ScriptCapabilityType>) capability), getTable(), parentPage);
} else if (capType instanceof CredentialsCapabilityType) {
newConfig = new CapabilityCredentialsPanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CredentialsCapabilityType>) capability), getTable(), parentPage);
} else {
newConfig = new CapabilityValuePanel(ID_CAPABILITY_CONFIG, new Model<>((CapabilityDto<CapabilityType>) capability), getTable(), parentPage);
}
// TODO other specific capabilities (paged, count, ...)
newConfig.setOutputMarkupId(true);
config.replaceWith(newConfig);
target.add(newConfig);
target.add(getTable());
}
use of org.apache.wicket.markup.html.WebMarkupContainer in project midpoint by Evolveum.
the class TaskSchedulingTabPanel method initLayoutForSchedulingTable.
private void initLayoutForSchedulingTable() {
// models
final IModel<Boolean> recurringCheckModel = new PropertyModel<>(taskDtoModel, TaskDto.F_RECURRING);
final IModel<Boolean> boundCheckModel = new PropertyModel<Boolean>(taskDtoModel, TaskDto.F_BOUND);
// behaviors
final VisibleEnableBehaviour visibleIfEditAndRunnableOrRunning = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return parentPage.isEdit() && parentPage.getTaskDto().isRunnableOrRunning();
}
};
final VisibleEnableBehaviour visibleIfRecurringAndScheduleIsAccessible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheckModel.getObject() && !boundCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && (!parentPage.getTaskDto().isRunnableOrRunning() || !boundCheckModel.getObject()) && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndNotRunningAndScheduleIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && !parentPage.getTaskDto().isRunning() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndScheduleIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
}
};
final VisibleEnableBehaviour enabledIfEditAndThreadStopIsEditable = new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_THREAD_STOP_ACTION));
}
};
// components
final WebMarkupContainer schedulingTable = new WebMarkupContainer(ID_SCHEDULING_TABLE);
schedulingTable.setOutputMarkupId(true);
add(schedulingTable);
WebMarkupContainer recurringContainer = new WebMarkupContainer(ID_RECURRING_CONTAINER);
AjaxCheckBox recurringCheck = new AjaxCheckBox(ID_RECURRING_CHECK, recurringCheckModel) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(schedulingTable);
}
};
recurringCheck.setOutputMarkupId(true);
recurringCheck.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_RECURRENCE);
}
});
recurringContainer.add(recurringCheck);
WebMarkupContainer suspendReqRecurring = new WebMarkupContainer(ID_SUSPEND_REQ_RECURRING);
suspendReqRecurring.add(visibleIfEditAndRunnableOrRunning);
recurringContainer.add(suspendReqRecurring);
recurringContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_RECURRENCE));
schedulingTable.add(recurringContainer);
final WebMarkupContainer boundContainer = new WebMarkupContainer(ID_BOUND_CONTAINER);
boundContainer.setOutputMarkupId(true);
final AjaxCheckBox bound = new AjaxCheckBox(ID_BOUND_CHECK, boundCheckModel) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(schedulingTable);
}
};
bound.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_BINDING);
}
});
boundContainer.add(bound);
WebMarkupContainer suspendReqBound = new WebMarkupContainer(ID_SUSPEND_REQ_BOUND);
suspendReqBound.add(visibleIfEditAndRunnableOrRunning);
boundContainer.add(suspendReqBound);
boundContainer.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_BINDING));
}
});
Label boundHelp = new Label(ID_BOUND_HELP);
boundHelp.add(new InfoTooltipBehavior());
boundContainer.add(boundHelp);
schedulingTable.add(boundContainer);
WebMarkupContainer intervalContainer = new WebMarkupContainer(ID_INTERVAL_CONTAINER);
intervalContainer.add(visibleIfRecurringAndScheduleIsAccessible);
intervalContainer.setOutputMarkupId(true);
schedulingTable.add(intervalContainer);
TextField<Integer> interval = new TextField<>(ID_INTERVAL, new PropertyModel<Integer>(taskDtoModel, TaskDto.F_INTERVAL));
interval.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
interval.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
intervalContainer.add(interval);
WebMarkupContainer cronContainer = new WebMarkupContainer(ID_CRON_CONTAINER);
cronContainer.add(visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible);
cronContainer.setOutputMarkupId(true);
schedulingTable.add(cronContainer);
TextField<String> cron = new TextField<>(ID_CRON, new PropertyModel<String>(taskDtoModel, TaskDto.F_CRON_SPECIFICATION));
cron.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
cron.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
cronContainer.add(cron);
Label cronHelp = new Label(ID_CRON_HELP);
cronHelp.add(new InfoTooltipBehavior());
cronContainer.add(cronHelp);
WebMarkupContainer notStartBeforeContainer = new WebMarkupContainer(ID_NOT_START_BEFORE_CONTAINER);
DateInput notStartBefore = new DateInput(ID_NOT_START_BEFORE_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_BEFORE));
notStartBefore.setOutputMarkupId(true);
notStartBefore.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
notStartBeforeContainer.add(notStartBefore);
notStartBeforeContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
schedulingTable.add(notStartBeforeContainer);
WebMarkupContainer notStartAfterContainer = new WebMarkupContainer(ID_NOT_START_AFTER_CONTAINER);
DateInput notStartAfter = new DateInput(ID_NOT_START_AFTER_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_AFTER));
notStartAfter.setOutputMarkupId(true);
notStartAfter.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
notStartAfterContainer.add(notStartAfter);
notStartAfterContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
schedulingTable.add(notStartAfterContainer);
WebMarkupContainer misfireActionContainer = new WebMarkupContainer(ID_MISFIRE_ACTION_CONTAINER);
DropDownChoice misfire = new DropDownChoice(ID_MISFIRE_ACTION, new PropertyModel<MisfireActionType>(taskDtoModel, TaskDto.F_MISFIRE_ACTION), WebComponentUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(parentPage));
misfire.add(enabledIfEditAndScheduleIsEditable);
misfireActionContainer.add(misfire);
misfireActionContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
schedulingTable.add(misfireActionContainer);
WebMarkupContainer threadStopContainer = new WebMarkupContainer(ID_THREAD_STOP_CONTAINER);
DropDownChoice threadStop = new DropDownChoice<>(ID_THREAD_STOP, new Model<ThreadStopActionType>() {
@Override
public ThreadStopActionType getObject() {
return taskDtoModel.getObject().getThreadStopActionType();
}
@Override
public void setObject(ThreadStopActionType object) {
taskDtoModel.getObject().setThreadStopActionType(object);
}
}, WebComponentUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(parentPage));
threadStop.add(enabledIfEditAndThreadStopIsEditable);
threadStopContainer.add(threadStop);
threadStopContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_THREAD_STOP_ACTION));
schedulingTable.add(threadStopContainer);
org.apache.wicket.markup.html.form.Form<?> form = parentPage.getForm();
// TODO implement more intelligently when other tabs have validators as well
for (IFormValidator validator : form.getFormValidators()) {
form.remove(validator);
}
form.add(new StartEndDateValidator(notStartBefore, notStartAfter));
form.add(new ScheduleValidator(parentPage.getTaskManager(), recurringCheck, bound, interval, cron));
}
use of org.apache.wicket.markup.html.WebMarkupContainer in project midpoint by Evolveum.
the class TaskSubtasksAndThreadsTabPanel method initLayout.
private void initLayout(final IModel<TaskDto> taskDtoModel) {
WebMarkupContainer threadsConfigurationPanel = new WebMarkupContainer(ID_THREADS_CONFIGURATION_PANEL);
add(threadsConfigurationPanel);
threadsConfigurationPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return taskDtoModel.getObject().configuresWorkerThreads();
}
});
final TextField<Integer> workerThreads = new TextField<>(ID_WORKER_THREADS, new PropertyModel<Integer>(taskDtoModel, TaskDto.F_WORKER_THREADS));
workerThreads.setOutputMarkupId(true);
workerThreads.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return parentPage.isEdit();
}
});
threadsConfigurationPanel.add(workerThreads);
VisibleEnableBehaviour hiddenWhenEditingOrNoSubtasks = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !parentPage.isEdit() && !taskDtoModel.getObject().getSubtasks().isEmpty();
}
};
Label subtasksLabel = new Label(ID_SUBTASKS_LABEL, new ResourceModel("pageTaskEdit.subtasksLabel"));
subtasksLabel.add(hiddenWhenEditingOrNoSubtasks);
add(subtasksLabel);
SubtasksPanel subtasksPanel = new SubtasksPanel(ID_SUBTASKS_PANEL, new PropertyModel<List<TaskDto>>(taskDtoModel, TaskDto.F_SUBTASKS), parentPage.getWorkflowManager().isEnabled());
subtasksPanel.add(hiddenWhenEditingOrNoSubtasks);
add(subtasksPanel);
VisibleEnableBehaviour hiddenWhenNoSubtasks = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
TaskDto taskDto = taskDtoModel.getObject();
return taskDto != null && !taskDto.getTransientSubtasks().isEmpty();
}
};
Label workerThreadsTableLabel = new Label(ID_WORKER_THREADS_TABLE_LABEL, new ResourceModel("TaskStatePanel.workerThreads"));
workerThreadsTableLabel.add(hiddenWhenNoSubtasks);
add(workerThreadsTableLabel);
List<IColumn<WorkerThreadDto, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn(createStringResourceStatic(this, "TaskStatePanel.subtaskName"), WorkerThreadDto.F_NAME));
columns.add(new EnumPropertyColumn<WorkerThreadDto>(createStringResourceStatic(this, "TaskStatePanel.subtaskState"), WorkerThreadDto.F_EXECUTION_STATUS));
columns.add(new PropertyColumn(createStringResourceStatic(this, "TaskStatePanel.subtaskObjectsProcessed"), WorkerThreadDto.F_PROGRESS));
ISortableDataProvider<WorkerThreadDto, String> threadsProvider = new ListDataProvider<>(this, new AbstractReadOnlyModel<List<WorkerThreadDto>>() {
@Override
public List<WorkerThreadDto> getObject() {
List<WorkerThreadDto> rv = new ArrayList<>();
TaskDto taskDto = taskDtoModel.getObject();
if (taskDto != null) {
for (TaskDto subtaskDto : taskDto.getTransientSubtasks()) {
rv.add(new WorkerThreadDto(subtaskDto));
}
}
return rv;
}
});
TablePanel<WorkerThreadDto> workerThreadsTablePanel = new TablePanel<>(ID_WORKER_THREADS_TABLE, threadsProvider, columns);
workerThreadsTablePanel.add(hiddenWhenNoSubtasks);
add(workerThreadsTablePanel);
}
Aggregations