use of org.apache.syncope.client.console.wicket.markup.html.form.ImageModalPanel in project syncope by apache.
the class WorkflowDirectoryPanel method getActions.
@Override
public ActionsPanel<WorkflowDefinitionTO> getActions(final IModel<WorkflowDefinitionTO> model) {
final ActionsPanel<WorkflowDefinitionTO> panel = super.getActions(model);
panel.add(new ActionLink<WorkflowDefinitionTO>() {
private static final long serialVersionUID = -184018732772021627L;
@Override
public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
final IModel<String> wfDefinition = new Model<>();
try {
wfDefinition.setObject(IOUtils.toString(restClient.getDefinition(MediaType.APPLICATION_XML_TYPE, model.getObject().getKey())));
} catch (IOException e) {
LOG.error("Could not get workflow definition", e);
}
utility.header(Model.of(model.getObject().getKey()));
utility.setContent(new XMLEditorPanel(utility, wfDefinition, false, pageRef) {
private static final long serialVersionUID = -7688359318035249200L;
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
if (StringUtils.isNotBlank(wfDefinition.getObject())) {
try {
restClient.setDefinition(MediaType.APPLICATION_XML_TYPE, model.getObject().getKey(), wfDefinition.getObject());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
utility.show(false);
utility.close(target);
} catch (SyncopeClientException e) {
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}
});
utility.show(target);
target.add(utility);
}
}, ActionLink.ActionType.EDIT, StandardEntitlement.WORKFLOW_DEF_SET);
panel.add(new ActionLink<WorkflowDefinitionTO>() {
private static final long serialVersionUID = 3109256773218160485L;
@Override
public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
modal.header(Model.of(model.getObject().getKey()));
modal.setContent(new ImageModalPanel<>(modal, restClient.getDiagram(model.getObject().getKey()), pageRef));
modal.show(target);
target.add(modal);
}
}, ActionLink.ActionType.VIEW, StandardEntitlement.WORKFLOW_DEF_GET);
panel.add(new ActionLink<WorkflowDefinitionTO>() {
private static final long serialVersionUID = -184018732772021627L;
@Override
public Class<? extends Page> getPageClass() {
return ModelerPopupPage.class;
}
@Override
public PageParameters getPageParameters() {
PageParameters parameters = new PageParameters();
if (modelerCtx != null) {
parameters.add(Constants.MODELER_CONTEXT, modelerCtx);
}
parameters.add(Constants.MODEL_ID_PARAM, model.getObject().getModelId());
return parameters;
}
@Override
protected boolean statusCondition(final WorkflowDefinitionTO modelObject) {
return modelerCtx != null;
}
@Override
public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
// do nothing
}
}, ActionLink.ActionType.WORKFLOW_MODELER, StandardEntitlement.WORKFLOW_DEF_SET);
panel.add(new ActionLink<WorkflowDefinitionTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
protected boolean statusCondition(final WorkflowDefinitionTO modelObject) {
return !modelObject.isMain();
}
@Override
public void onClick(final AjaxRequestTarget target, final WorkflowDefinitionTO ignore) {
try {
restClient.deleteDefinition(model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting workflow definition {}", model.getObject().getName(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.WORKFLOW_DEF_DELETE, true);
return panel;
}
Aggregations