use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class PrismOptionButtonPanel method initButtons.
private void initButtons(final IModel<ObjectWrapper> model) {
AjaxLink showEmpty = new AjaxLink("showEmptyButton") {
@Override
public void onClick(AjaxRequestTarget target) {
showEmptyOnClick(target);
}
};
add(showEmpty);
showEmpty.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().isReadonly();
}
});
Image showEmptyImg = new Image("showEmptyImg", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isShowEmpty()) {
return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyFalse.png");
}
return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyTrue.png");
}
});
showEmptyImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isShowEmpty()) {
return getString("prismOptionButtonPanel.hideEmpty");
}
return getString("prismOptionButtonPanel.showEmpty");
}
}, ""));
showEmpty.add(showEmptyImg);
AjaxLink minimize = new AjaxLink("minimizeButton") {
@Override
public void onClick(AjaxRequestTarget target) {
minimizeOnClick(target);
}
};
add(minimize);
Image minimizeImg = new Image("minimizeImg", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isMinimalized()) {
return new PackageResourceReference(PrismObjectPanel.class, "Maximize.png");
}
return new PackageResourceReference(PrismObjectPanel.class, "Minimize.png");
}
});
minimizeImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {
@Override
public Object getObject() {
ObjectWrapper wrapper = model.getObject();
if (wrapper.isMinimalized()) {
return getString("prismOptionButtonPanel.maximize");
}
return getString("prismOptionButtonPanel.minimize");
}
}, ""));
minimize.add(minimizeImg);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class PrismValuePanel method initLayout.
private void initLayout(IModel<String> labelModel, Form form, String valueCssClass, String inputCssClass) {
//container
WebMarkupContainer valueContainer = new WebMarkupContainer(ID_VALUE_CONTAINER);
valueContainer.setOutputMarkupId(true);
valueContainer.add(new AttributeModifier("class", valueCssClass));
add(valueContainer);
//feedback
FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
feedback.setOutputMarkupId(true);
add(feedback);
//input
Panel input = createInputComponent(ID_INPUT, labelModel, form);
input.add(new AttributeModifier("class", inputCssClass));
if (input instanceof InputPanel) {
initAccessBehaviour((InputPanel) input);
feedback.setFilter(new ComponentFeedbackMessageFilter(((InputPanel) input).getBaseFormComponent()));
} else if (input instanceof LockoutStatusPanel) {
feedback.setFilter(new ComponentFeedbackMessageFilter(input));
} else if (input instanceof ValueChoosePanel) {
feedback.setFilter(new ComponentFeedbackMessageFilter(input));
} else if (input instanceof AssociationValueChoicePanel) {
feedback.setFilter(new ComponentFeedbackMessageFilter(((AssociationValueChoicePanel) input).getTextComponent()));
}
valueContainer.add(input);
//buttons
AjaxLink addButton = new AjaxLink(ID_ADD_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
addValue(target);
}
};
addButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isAddButtonVisible();
}
});
valueContainer.add(addButton);
AjaxLink removeButton = new AjaxLink(ID_REMOVE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
removeValue(target);
}
};
removeButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isRemoveButtonVisible();
}
});
valueContainer.add(removeButton);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method createShadowMenu.
private List<InlineMenuItem> createShadowMenu() {
List<InlineMenuItem> items = new ArrayList<InlineMenuItem>();
PrismObjectDefinition def = getObjectWrapper().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
InlineMenuItem item;
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.addShadow"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>(1);
supportedTypes.add(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
// TODO Auto-generated method stub
FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
});
items.add(item);
items.add(new InlineMenuItem());
}
PrismPropertyDefinition prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.enable"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), true);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable"), new InlineMenuItemAction() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), false);
}
});
items.add(item);
}
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlinkProjectionPerformed(target, projectionModel, getSelectedProjections(projectionModel), ID_SHADOWS);
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlockShadowPerformed(target, projectionModel, getSelectedProjections(projectionModel));
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
items.add(new InlineMenuItem());
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteProjectionPerformed(target, projectionModel);
}
});
items.add(item);
}
return items;
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class ObjectHistoryTabPanel method initLayout.
private void initLayout(final LoadableModel<ObjectWrapper<F>> focusWrapperModel, final PageAdminObjectDetails<F> page) {
AuditSearchDto searchDto = new AuditSearchDto();
ObjectReferenceType ort = new ObjectReferenceType();
ort.setOid(focusWrapperModel.getObject().getOid());
searchDto.setTargetNames(asList(ort));
searchDto.setEventStage(AuditEventStageType.EXECUTION);
Map<String, Boolean> visibilityMap = new HashMap<>();
visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_LABEL_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_FIELD_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_LABEL_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_FIELD_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_LABEL_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_FIELD_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_COLUMN_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_COLUMN_VISIBILITY, false);
visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_COLUMN_VISIBILITY, false);
AuditLogViewerPanel panel = new AuditLogViewerPanel(ID_MAIN_PANEL, page, searchDto, visibilityMap) {
@Override
protected List<IColumn<AuditEventRecordType, String>> initColumns() {
List<IColumn<AuditEventRecordType, String>> columns = super.initColumns();
IColumn<AuditEventRecordType, String> column = new MultiButtonColumn<AuditEventRecordType>(new Model(), 2) {
private final DoubleButtonColumn.BUTTON_COLOR_CLASS[] colors = { DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS };
@Override
public String getCaption(int id) {
return "";
}
@Override
public String getButtonTitle(int id) {
switch(id) {
case 0:
return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectDataTitle").getString();
case 1:
return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectXmlTitle").getString();
}
return "";
}
@Override
public String getButtonColorCssClass(int id) {
return colors[id].toString();
}
@Override
protected String getButtonCssClass(int id) {
StringBuilder sb = new StringBuilder();
sb.append(DoubleButtonColumn.BUTTON_BASE_CLASS).append(" ");
sb.append(getButtonColorCssClass(id)).append(" ");
switch(id) {
case 0:
sb.append("fa fa-circle-o");
break;
case 1:
sb.append("fa fa-file-text-o");
break;
}
return sb.toString();
}
@Override
public void clickPerformed(int id, AjaxRequestTarget target, IModel<AuditEventRecordType> model) {
switch(id) {
case 0:
currentStateButtonClicked(target, focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE), page.getCompileTimeClass());
break;
case 1:
viewObjectXmlButtonClicked(focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), page.getCompileTimeClass(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE));
break;
}
}
};
columns.add(column);
return columns;
}
};
panel.setOutputMarkupId(true);
add(panel);
}
use of org.apache.wicket.ajax.AjaxRequestTarget 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));
}
Aggregations