use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.
the class SceneItemLinePanel method initLayout.
private void initLayout() {
WebMarkupContainer nameCell = new WebMarkupContainer(ID_NAME_CONTAINER);
nameCell.add(new AttributeModifier("rowspan", new PropertyModel<Integer>(getModel(), SceneItemLineDto.F_NUMBER_OF_LINES)));
Label label = new Label(ID_NAME, createStringResource("${name}", getModel()));
nameCell.add(label);
nameCell.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isFirst();
}
});
add(nameCell);
WebMarkupContainer oldValueCell = new WebMarkupContainer(ID_OLD_VALUE_CONTAINER);
oldValueCell.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isNullEstimatedOldValues() || getModelObject().isDelta();
}
});
Component sivp;
if (getModelObject().isNullEstimatedOldValues()) {
sivp = new Label(ID_OLD_VALUE, createStringResource("SceneItemLinePanel.unknownLabel"));
} else {
sivp = new SceneItemValuePanel(ID_OLD_VALUE, new PropertyModel<>(getModel(), SceneItemLineDto.F_OLD_VALUE));
}
sivp.setRenderBodyOnly(true);
oldValueCell.add(sivp);
ImagePanel oldValueImagePanel = new ImagePanel(ID_OLD_VALUE_IMAGE, Model.of(GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER), createStringResource("SceneItemLinePanel.removedValue"));
oldValueImagePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getOldValue() != null && getModelObject().getOldValue().getSourceValue() != null && !getModelObject().isNullEstimatedOldValues();
}
});
oldValueCell.add(oldValueImagePanel);
add(oldValueCell);
IModel<String> newValueIconModel;
IModel<String> newValueTitleModel;
if (getModelObject().isNullEstimatedOldValues()) {
if (getModelObject().isAdd()) {
newValueIconModel = Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS);
newValueTitleModel = createStringResource("SceneItemLinePanel.addedValue");
} else if (getModelObject().isDelete()) {
newValueIconModel = Model.of(GuiStyleConstants.CLASS_MINUS_CIRCLE_DANGER);
newValueTitleModel = createStringResource("SceneItemLinePanel.removedValue");
} else if (getModelObject().isReplace()) {
newValueIconModel = Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL);
newValueTitleModel = createStringResource("SceneItemLinePanel.unchangedValue");
} else {
newValueIconModel = Model.of("");
newValueTitleModel = Model.of("");
}
} else {
if (getModelObject().isDescriptive()) {
newValueIconModel = Model.of("");
newValueTitleModel = Model.of("");
} else {
newValueIconModel = !getModelObject().isDelta() && getModelObject().isDeltaScene() ? Model.of(GuiStyleConstants.CLASS_CIRCLE_FULL) : Model.of(GuiStyleConstants.CLASS_PLUS_CIRCLE_SUCCESS);
newValueTitleModel = !getModelObject().isDelta() && getModelObject().isDeltaScene() ? createStringResource("SceneItemLinePanel.unchangedValue") : createStringResource("SceneItemLinePanel.addedValue");
}
}
WebMarkupContainer newValueCell = new WebMarkupContainer(ID_NEW_VALUE_CONTAINER);
sivp = new SceneItemValuePanel(ID_NEW_VALUE, new PropertyModel<>(getModel(), SceneItemLineDto.F_NEW_VALUE));
sivp.setRenderBodyOnly(true);
newValueCell.add(sivp);
newValueCell.add(new AttributeModifier("colspan", new IModel<Integer>() {
@Override
public Integer getObject() {
return !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaScene() ? 2 : 1;
}
}));
newValueCell.add(new AttributeModifier("align", new IModel<String>() {
@Override
public String getObject() {
return !getModelObject().isDelta() && !getModelObject().isNullEstimatedOldValues() && getModelObject().isDeltaScene() ? "center" : null;
}
}));
ImagePanel newValueImagePanel = new ImagePanel(ID_NEW_VALUE_IMAGE, newValueIconModel, newValueTitleModel);
newValueImagePanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject().getNewValue() != null && getModelObject().getNewValue().getSourceValue() != null;
}
});
// newValueImagePanel.add(new AttributeAppender("style",
// !getModelObject().isDelta() && getModelObject().isDeltaScene() ?
// ""
// : "float: left; margin-right: 5px;"));
newValueCell.add(newValueImagePanel);
add(newValueCell);
}
use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.
the class ApprovalProcessExecutionInformationPanel method initLayout.
protected void initLayout() {
// TODO clean this code up!!!
ListView<ApprovalStageExecutionInformationDto> stagesList = new ListView<ApprovalStageExecutionInformationDto>(ID_STAGES, new PropertyModel<>(getModel(), ApprovalProcessExecutionInformationDto.F_STAGES)) {
@Override
protected void populateItem(ListItem<ApprovalStageExecutionInformationDto> stagesListItem) {
ApprovalProcessExecutionInformationDto process = ApprovalProcessExecutionInformationPanel.this.getModelObject();
ApprovalStageExecutionInformationDto stage = stagesListItem.getModelObject();
int stageNumber = stage.getStageNumber();
int numberOfStages = process.getNumberOfStages();
int currentStageNumber = process.getCurrentStageNumber();
WebMarkupContainer arrow = new WebMarkupContainer(ID_ARROW);
arrow.add(new VisibleBehaviour(() -> stageNumber > 1));
stagesListItem.add(arrow);
WebMarkupContainer currentStageMarker = new WebMarkupContainer(ID_CURRENT_STAGE_MARKER);
currentStageMarker.add(new VisibleBehaviour(() -> stageNumber == currentStageNumber && process.isRunning()));
stagesListItem.add(currentStageMarker);
ListView<ApproverEngagementDto> approversList = new ListView<ApproverEngagementDto>(ID_APPROVERS, new PropertyModel<>(stagesListItem.getModel(), ApprovalStageExecutionInformationDto.F_APPROVER_ENGAGEMENTS)) {
@Override
protected void populateItem(ListItem<ApproverEngagementDto> approversListItem) {
ApproverEngagementDto ae = approversListItem.getModelObject();
// original approver name
approversListItem.add(createReferencedObjectLabel(ID_APPROVER_NAME, "ApprovalProcessExecutionInformationPanel.approver", ae.getApproverRef(), true));
// outcome
WorkItemOutcomeType outcome = ae.getOutput() != null ? ApprovalUtils.fromUri(ae.getOutput().getOutcome()) : null;
ApprovalOutcomeIcon outcomeIcon;
if (outcome != null) {
switch(outcome) {
case APPROVE:
outcomeIcon = ApprovalOutcomeIcon.APPROVED;
break;
case REJECT:
outcomeIcon = ApprovalOutcomeIcon.REJECTED;
break;
// perhaps should throw AssertionError instead
default:
outcomeIcon = ApprovalOutcomeIcon.UNKNOWN;
break;
}
} else {
if (stageNumber < currentStageNumber) {
// history: do not show anything for work items with no outcome
outcomeIcon = ApprovalOutcomeIcon.EMPTY;
} else if (stageNumber == currentStageNumber) {
outcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.IN_PROGRESS : // currently open
ApprovalOutcomeIcon.CANCELLED;
} else {
outcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.FUTURE : ApprovalOutcomeIcon.CANCELLED;
}
}
ImagePanel outcomePanel = new ImagePanel(ID_OUTCOME, Model.of(outcomeIcon.getIcon()), Model.of(getString(outcomeIcon.getTitle())));
outcomePanel.add(new VisibleBehaviour(() -> outcomeIcon != ApprovalOutcomeIcon.EMPTY));
approversListItem.add(outcomePanel);
// content (incl. performer)
WebMarkupContainer approvalBoxContent = new WebMarkupContainer(ID_APPROVAL_BOX_CONTENT);
approversListItem.add(approvalBoxContent);
approvalBoxContent.setVisible(performerVisible(ae) || attorneyVisible(ae));
approvalBoxContent.add(createReferencedObjectLabel(ID_PERFORMER_NAME, "ApprovalProcessExecutionInformationPanel.performer", ae.getCompletedBy(), performerVisible(ae)));
approvalBoxContent.add(createReferencedObjectLabel(ID_ATTORNEY_NAME, "ApprovalProcessExecutionInformationPanel.attorney", ae.getAttorney(), attorneyVisible(ae)));
// junction
// or "+" for first decides? probably not
Label junctionLabel = new Label(ID_JUNCTION, stage.isFirstDecides() ? "" : " & ");
// not showing "" to save space (if aligned vertically)
junctionLabel.setVisible(!stage.isFirstDecides() && !ae.isLast());
approversListItem.add(junctionLabel);
}
};
approversList.setVisible(stage.getAutomatedCompletionReason() == null);
stagesListItem.add(approversList);
String autoCompletionKey;
if (stage.getAutomatedCompletionReason() != null) {
switch(stage.getAutomatedCompletionReason()) {
case AUTO_COMPLETION_CONDITION:
autoCompletionKey = "DecisionDto.AUTO_COMPLETION_CONDITION";
break;
case NO_ASSIGNEES_FOUND:
autoCompletionKey = "DecisionDto.NO_ASSIGNEES_FOUND";
break;
// or throw an exception?
default:
autoCompletionKey = null;
}
} else {
autoCompletionKey = null;
}
Label automatedOutcomeLabel = new Label(ID_AUTOMATED_OUTCOME, autoCompletionKey != null ? getString(autoCompletionKey) : "");
automatedOutcomeLabel.setVisible(stage.getAutomatedCompletionReason() != null);
stagesListItem.add(automatedOutcomeLabel);
stagesListItem.add(new Label(ID_STAGE_NAME, getStageNameLabel(stage, stageNumber, numberOfStages)));
ApprovalLevelOutcomeType stageOutcome = stage.getOutcome();
ApprovalOutcomeIcon stageOutcomeIcon;
if (stageOutcome != null) {
switch(stageOutcome) {
case APPROVE:
stageOutcomeIcon = ApprovalOutcomeIcon.APPROVED;
break;
case REJECT:
stageOutcomeIcon = ApprovalOutcomeIcon.REJECTED;
break;
case SKIP:
stageOutcomeIcon = ApprovalOutcomeIcon.SKIPPED;
break;
// perhaps should throw AssertionError instead
default:
stageOutcomeIcon = ApprovalOutcomeIcon.UNKNOWN;
break;
}
} else {
if (stageNumber < currentStageNumber) {
// history: do not show anything (shouldn't occur, as historical stages are filled in)
stageOutcomeIcon = ApprovalOutcomeIcon.EMPTY;
} else if (stageNumber == currentStageNumber) {
stageOutcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.IN_PROGRESS : // currently open
ApprovalOutcomeIcon.CANCELLED;
} else {
stageOutcomeIcon = process.isRunning() && stage.isReachable() ? ApprovalOutcomeIcon.FUTURE : ApprovalOutcomeIcon.CANCELLED;
}
}
ImagePanel stageOutcomePanel = new ImagePanel(ID_STAGE_OUTCOME, Model.of(stageOutcomeIcon.getIcon()), Model.of(getString(stageOutcomeIcon.getTitle())));
stageOutcomePanel.add(new VisibleBehaviour(() -> stageOutcomeIcon != ApprovalOutcomeIcon.EMPTY));
stagesListItem.add(stageOutcomePanel);
}
};
add(stagesList);
}
use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.
the class LinkedReferencePanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
IModel<DisplayType> displayModel = new ReadOnlyModel<>(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return null;
}
DisplayType displayType = GuiDisplayTypeUtil.getDisplayTypeForObject(ref.getObject(), null, getPageBase());
if (displayType == null) {
displayType = new DisplayType();
}
if (displayType.getIcon() == null) {
displayType.setIcon(WebComponentUtil.createIconType(WebComponentUtil.createDefaultBlackIcon(ref.getTargetType())));
}
return displayType;
});
ImagePanel imagePanel = new ImagePanel(ID_ICON, displayModel);
imagePanel.setOutputMarkupId(true);
add(imagePanel);
AjaxLink<PrismReferenceValue> nameLink = new AjaxLink<PrismReferenceValue>(ID_NAME, referenceModel) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
WebComponentUtil.dispatchToObjectDetailsPage(referenceModel.getObject(), LinkedReferencePanel.this, false);
}
};
nameLink.add(new EnableBehaviour(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return false;
}
return ref.getObject() != null;
}));
nameLink.setOutputMarkupId(true);
add(nameLink);
Label nameLinkText = new Label(ID_NAME_TEXT, new ReadOnlyModel<>(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return "";
}
return WebComponentUtil.getReferencedObjectDisplayNameAndName(ref.asReferencable(), false, getPageBase());
}));
nameLinkText.setOutputMarkupId(true);
nameLink.add(nameLinkText);
}
use of com.evolveum.midpoint.web.component.data.column.ImagePanel in project midpoint by Evolveum.
the class SceneItemValuePanel method initLayout.
private void initLayout() {
final VisibleEnableBehaviour visibleIfReference = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return hasValidReferenceValue(object);
}
};
final VisibleEnableBehaviour visibleIfNotReference = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneItemValue object = getModelObject();
return !hasValidReferenceValue(object);
}
};
IModel<DisplayType> displayModel = (IModel) () -> {
ObjectTypeGuiDescriptor guiDescriptor = getObjectTypeDescriptor();
String cssClass = ObjectTypeGuiDescriptor.ERROR_ICON;
String title = null;
if (guiDescriptor != null) {
cssClass = guiDescriptor.getBlackIcon();
title = createStringResource(guiDescriptor.getLocalizationKey()).getObject();
}
return GuiDisplayTypeUtil.createDisplayType(cssClass, "", title);
};
final ImagePanel icon = new ImagePanel(ID_ICON, displayModel);
icon.add(visibleIfReference);
add(icon);
final Label label = new Label(ID_LABEL, new LabelModel());
label.add(visibleIfNotReference);
add(label);
final AjaxLinkPanel link = new AjaxLinkPanel(ID_LINK, new LabelModel()) {
@Override
public void onClick(AjaxRequestTarget target) {
if (!(getModelObject().getSourceValue() instanceof PrismReferenceValue)) {
return;
}
PrismReferenceValue refValue = (PrismReferenceValue) getModelObject().getSourceValue();
if (refValue == null) {
return;
}
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue(refValue);
WebComponentUtil.dispatchToObjectDetailsPage(ort, getPageBase(), false);
}
};
link.add(visibleIfReference);
add(link);
final Label additionalText = new Label(ID_ADDITIONAL_TEXT, new IModel<String>() {
@Override
public String getObject() {
return getModelObject() != null ? getModelObject().getAdditionalText() : null;
}
});
add(additionalText);
}
Aggregations