use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.
the class PrismHeaderPanel method initLayout.
private void initLayout(final IModel model) {
VisibleEnableBehaviour buttonsVisibleBehaviour = new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return PrismHeaderPanel.this.isButtonsVisible();
}
};
ToggleIconButton showMetadataButton = new ToggleIconButton(ID_SHOW_METADATA, GuiStyleConstants.CLASS_ICON_SHOW_METADATA, GuiStyleConstants.CLASS_ICON_SHOW_METADATA) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ObjectWrapper objectWrapper = getObjectWrapper(model);
objectWrapper.setShowMetadata(!objectWrapper.isShowMetadata());
onButtonClick(target);
}
@Override
public boolean isOn() {
return getObjectWrapper(model).isShowMetadata();
}
};
showMetadataButton.add(new AttributeModifier("title", getObjectWrapper(model) == null ? "" : (getObjectWrapper(model).isShowMetadata() ? createStringResource("PrismObjectPanel.hideMetadata") : createStringResource("PrismObjectPanel.showMetadata"))));
showMetadataButton.add(buttonsVisibleBehaviour);
add(showMetadataButton);
ToggleIconButton showEmptyFieldsButton = new ToggleIconButton(ID_SHOW_EMPTY_FIELDS, GuiStyleConstants.CLASS_ICON_SHOW_EMPTY_FIELDS, GuiStyleConstants.CLASS_ICON_NOT_SHOW_EMPTY_FIELDS) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ObjectWrapper objectWrapper = getObjectWrapper(model);
objectWrapper.setShowEmpty(!objectWrapper.isShowEmpty());
onButtonClick(target);
}
@Override
public boolean isOn() {
return getObjectWrapper(model).isShowEmpty();
}
};
showEmptyFieldsButton.setMarkupId(ID_SHOW_EMPTY_FIELDS);
showEmptyFieldsButton.add(buttonsVisibleBehaviour);
add(showEmptyFieldsButton);
ToggleIconButton sortPropertiesButton = new ToggleIconButton(ID_SORT_PROPERTIES, GuiStyleConstants.CLASS_ICON_SORT_ALPHA_ASC, GuiStyleConstants.CLASS_ICON_SORT_AMOUNT_ASC) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ObjectWrapper objectWrapper = getObjectWrapper(model);
objectWrapper.setSorted(!objectWrapper.isSorted());
objectWrapper.sort((PageBase) getPage());
onButtonClick(target);
}
@Override
public boolean isOn() {
return getObjectWrapper(model).isSorted();
}
};
sortPropertiesButton.add(buttonsVisibleBehaviour);
add(sortPropertiesButton);
IModel<String> headerLabelModel = new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
Object wrapper = model.getObject();
String displayName = null;
if (wrapper instanceof ContainerWrapper) {
displayName = ((ContainerWrapper) wrapper).getDisplayName();
} else if (wrapper instanceof ObjectWrapper) {
// HACK HACK HACK
// If we would display label for the object itself, display label for main container instead
// the "object label" is actually displayed in front of main container
ContainerWrapper mainContainerWrapper = ((ObjectWrapper) wrapper).findMainContainerWrapper();
if (mainContainerWrapper != null) {
displayName = mainContainerWrapper.getDisplayName();
} else {
// e.g. resource wizard needs this
displayName = ((ObjectWrapper) wrapper).getDisplayName();
}
}
return getString(displayName, null, displayName);
}
};
add(new Label(ID_LABEL, headerLabelModel));
}
use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.
the class CheckTableHeader method initLayout.
private void initLayout() {
AjaxCheckBox check = new AjaxCheckBox(ID_CHECK, new PropertyModel<Boolean>(getModel(), ObjectWrapper.F_SELECTED)) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
};
add(check);
Label icon = new Label(ID_ICON);
icon.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return "check-table-header-icon " + createAccountIcon();
}
}));
add(icon);
Label trigger = new Label(ID_TRIGGER);
trigger.add(AttributeModifier.replace("title", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return createTriggerTooltip();
}
}));
trigger.add(new TooltipBehavior());
trigger.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return hasTriggers();
}
});
add(trigger);
BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("CheckTableHeader.label.error"), new Model<>(BootstrapLabel.State.DANGER));
status.add(createFetchErrorVisibleBehaviour());
add(status);
AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
onShowMorePerformed(target);
}
};
showMore.add(createFetchErrorVisibleBehaviour());
add(showMore);
AjaxLink link = new AjaxLink(ID_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
onClickPerformed(target);
}
};
add(link);
Label name = new Label(ID_NAME, new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getDisplayName();
}
});
link.add(name);
Label description = new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getDescription();
}
});
add(description);
ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
onClickPerformed(target);
}
@Override
public boolean isOn() {
return !CheckTableHeader.this.getModelObject().isMinimalized();
}
};
add(expandButton);
}
use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.
the class DelegationEditorPanel method initHeaderRow.
@Override
protected void initHeaderRow() {
if (delegatedToMe) {
privilegesListModel = new LoadableModel<List<AssignmentsPreviewDto>>(false) {
@Override
protected List<AssignmentsPreviewDto> load() {
return DelegationEditorPanel.this.getModelObject().getPrivilegeLimitationList();
}
};
}
AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
};
selected.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(selected);
Label arrowIcon = new Label(ID_ARROW_ICON);
headerRow.add(arrowIcon);
WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
headerRow.add(typeImage);
AjaxLink name = new AjaxLink(ID_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
};
headerRow.add(name);
Label nameLabel;
if (delegatedToMe) {
OperationResult result = new OperationResult(OPERATION_GET_TARGET_REF_NAME);
Task task = pageBase.createSimpleTask(OPERATION_GET_TARGET_REF_NAME);
nameLabel = new Label(ID_NAME_LABEL, WebModelServiceUtils.resolveReferenceName(getModelObject().getTargetRef(), pageBase, task, result));
} else {
nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
}
nameLabel.setOutputMarkupId(true);
name.add(nameLabel);
AssignmentEditorDto dto = getModelObject();
dto.getTargetRef();
WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
if (delegatedToMe) {
delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(((PageUser) pageBase).getObjectWrapper().getObject())));
} else {
if (getModelObject().getDelegationOwner() != null) {
delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject())));
}
}
headerRow.add(delegatedToTypeImage);
AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
};
headerRow.add(delegatedToName);
Label delegatedToNameLabel;
if (delegatedToMe) {
delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
} else {
delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, getUserDisplayName());
}
delegatedToNameLabel.setOutputMarkupId(true);
delegatedToName.add(delegatedToNameLabel);
ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
@Override
public boolean isOn() {
return !DelegationEditorPanel.this.getModelObject().isMinimized();
}
};
headerRow.add(expandButton);
}
use of com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton in project midpoint by Evolveum.
the class AssignmentEditorPanel method initHeaderRow.
protected void initHeaderRow() {
AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
// do we want to update something?
}
};
selected.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(selected);
WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
headerRow.add(typeImage);
Label errorIcon = new Label(ID_ERROR_ICON);
errorIcon.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isTargetValid();
}
});
headerRow.add(errorIcon);
AjaxLink name = new AjaxLink(ID_NAME) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
};
headerRow.add(name);
AjaxLink errorLink = new AjaxLink(ID_BUTTON_SHOW_MORE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showErrorPerformed(target);
}
};
errorLink.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return !isTargetValid();
}
});
headerRow.add(errorLink);
Label nameLabel = new Label(ID_NAME_LABEL, createAssignmentNameLabelModel(false));
nameLabel.setOutputMarkupId(true);
name.add(nameLabel);
Label activation = new Label(ID_ACTIVATION, createActivationModel());
headerRow.add(activation);
ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
nameClickPerformed(target);
}
@Override
public boolean isOn() {
return !AssignmentEditorPanel.this.getModelObject().isMinimized();
}
};
expandButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModel().getObject().isSimpleView();
}
});
headerRow.add(expandButton);
}
Aggregations