use of org.apache.wicket.ajax.AjaxRequestTarget 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 org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class ScenePanel method initLayout.
private void initLayout() {
final IModel<SceneDto> model = getModel();
WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
box.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.getBoxClassOverride() != null) {
return dto.getBoxClassOverride();
}
if (dto.getChangeType() == null) {
return null;
}
switch(dto.getChangeType()) {
case ADD:
return "box-success";
case DELETE:
return "box-danger";
case MODIFY:
return "box-info";
default:
return null;
}
}
}));
add(box);
WebMarkupContainer headerPanel = new WebMarkupContainer(ID_HEADER_PANEL);
box.add(headerPanel);
headerPanel.add(new SceneButtonPanel(ID_OPTION_BUTTONS, model) {
@Override
public void minimizeOnClick(AjaxRequestTarget target) {
headerOnClickPerformed(target, model);
}
});
Label headerChangeType = new Label(ID_HEADER_CHANGE_TYPE, new ChangeTypeModel());
//headerChangeType.setRenderBodyOnly(true);
Label headerObjectType = new Label(ID_HEADER_OBJECT_TYPE, new ObjectTypeModel());
//headerObjectType.setRenderBodyOnly(true);
IModel<String> nameModel = new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return model.getObject().getName(ScenePanel.this);
}
};
Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
LinkPanel headerNameLink = new LinkPanel(ID_HEADER_NAME_LINK, nameModel) {
@Override
public void onClick(AjaxRequestTarget target) {
PrismContainerValue<?> value = getModelObject().getScene().getSourceValue();
if (value != null && value.getParent() instanceof PrismObject) {
PrismObject<? extends ObjectType> object = (PrismObject<? extends ObjectType>) value.getParent();
WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(object), getPageBase(), false);
}
}
};
Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return model.getObject().getDescription(ScenePanel.this);
}
});
Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String key = ((WrapperScene) getModelObject().getScene()).getDisplayNameKey();
Object[] parameters = ((WrapperScene) getModelObject().getScene()).getDisplayNameParameters();
return new StringResourceModel(key, this).setModel(null).setDefaultValue(key).setParameters(parameters).getObject();
}
});
headerPanel.add(headerChangeType);
headerPanel.add(headerObjectType);
headerPanel.add(headerNameLabel);
headerPanel.add(headerNameLink);
headerPanel.add(headerDescription);
headerPanel.add(headerWrapperDisplayName);
headerChangeType.add(createHeaderOnClickBehaviour(model));
headerObjectType.add(createHeaderOnClickBehaviour(model));
headerNameLabel.add(createHeaderOnClickBehaviour(model));
headerDescription.add(createHeaderOnClickBehaviour(model));
headerWrapperDisplayName.add(createHeaderOnClickBehaviour(model));
VisibleEnableBehaviour visibleIfNotWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfExistingObject = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return isExistingViewableObject();
}
};
VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObject = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return !isExistingViewableObject();
}
};
headerChangeType.add(visibleIfNotWrapper);
headerObjectType.add(visibleIfNotWrapper);
headerNameLabel.add(visibleIfNotWrapperAndNotExistingObject);
headerNameLink.add(visibleIfExistingObject);
headerDescription.add(visibleIfNotWrapper);
headerWrapperDisplayName.add(visibleIfWrapper);
WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
body.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneDto wrapper = model.getObject();
return !wrapper.isMinimized();
}
});
box.add(body);
WebMarkupContainer itemsTable = new WebMarkupContainer(ID_ITEMS_TABLE);
itemsTable.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().getItems().isEmpty();
}
});
WebMarkupContainer oldValueLabel = new WebMarkupContainer(ID_OLD_VALUE_LABEL);
oldValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(oldValueLabel);
WebMarkupContainer newValueLabel = new WebMarkupContainer(ID_NEW_VALUE_LABEL);
newValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(newValueLabel);
WebMarkupContainer valueLabel = new WebMarkupContainer(ID_VALUE_LABEL);
valueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().containsDeltaItems();
}
});
itemsTable.add(valueLabel);
ListView<SceneItemDto> items = new ListView<SceneItemDto>(ID_ITEMS, new PropertyModel<List<SceneItemDto>>(model, SceneDto.F_ITEMS)) {
@Override
protected void populateItem(ListItem<SceneItemDto> item) {
SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
panel.setRenderBodyOnly(true);
item.add(panel);
}
};
items.setReuseItems(true);
itemsTable.add(items);
body.add(itemsTable);
ListView<SceneDto> partialScenes = new ListView<SceneDto>(ID_PARTIAL_SCENES, new PropertyModel<List<SceneDto>>(model, SceneDto.F_PARTIAL_SCENES)) {
@Override
protected void populateItem(ListItem<SceneDto> item) {
ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel());
panel.setOutputMarkupPlaceholderTag(true);
item.add(panel);
}
};
partialScenes.setReuseItems(true);
body.add(partialScenes);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class ProgressPanel method initButtons.
private void initButtons(final Form progressForm, final ProgressReportingAwarePage page) {
AjaxSubmitButton abortButton = new AjaxSubmitButton(ID_ABORT, createStringResource("pageAdminFocus.button.abort")) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
progressReporter.onAbortSubmit(target);
}
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(page.getFeedbackPanel());
}
};
progressReporter.registerAbortButton(abortButton);
progressForm.add(abortButton);
AjaxSubmitButton backButton = new AjaxSubmitButton(ID_BACK, createStringResource("pageAdminFocus.button.back")) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
backPerformed(target);
}
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(page.getFeedbackPanel());
}
};
progressReporter.registerBackButton(backButton);
progressForm.add(backButton);
AjaxSubmitButton continueEditingButton = new AjaxSubmitButton(ID_CONTINUE_EDITING, createStringResource("pageAdminFocus.button.continueEditing")) {
@Override
protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
ProgressReportingAwarePage page = (ProgressReportingAwarePage) getPage();
page.continueEditing(target);
}
@Override
protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) {
target.add(page.getFeedbackPanel());
}
};
progressReporter.registerContinueEditingButton(continueEditingButton);
progressForm.add(continueEditingButton);
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class ProgressReporter method startRefreshingProgressPanel.
private void startRefreshingProgressPanel(AjaxRequestTarget target) {
if (refreshingBehavior == null) {
// i.e. refreshing behavior has not been set yet
refreshingBehavior = new AjaxSelfUpdatingTimerBehavior(Duration.milliseconds(refreshInterval)) {
@Override
protected void onPostProcessTarget(AjaxRequestTarget target) {
super.onPostProcessTarget(target);
if (progressPanel != null) {
progressPanel.invalidateCache();
}
if (asyncOperationResult != null) {
// by checking this we know that async operation has been finished
// because we set it to in-progress
asyncOperationResult.recomputeStatus();
stopRefreshingProgressPanel(target);
parentPage.finishProcessing(target, asyncOperationResult, true);
asyncOperationResult = null;
}
}
@Override
public boolean isEnabled(Component component) {
return component != null;
}
};
progressPanel.add(refreshingBehavior);
target.add(progressPanel);
}
}
use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.
the class SimpleErrorPanel method initLayout.
@Override
protected void initLayout() {
Label icon = new Label(ID_ICON);
add(icon);
Label description = new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return getDescription();
}
});
add(description);
AjaxLink link = new AjaxLink(ID_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
onShowMorePerformed(target);
}
};
add(link);
Label showMore = new Label(ID_SHOW_MORE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return createStringResource("simpleErrorPanel.label.showMore").getString();
}
});
link.add(showMore);
}
Aggregations