use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.
the class InfoBoxPanel method initLayout.
private void initLayout(final IModel<InfoBoxType> model, final Class<? extends IRequestablePage> linkPage) {
WebMarkupContainer infoBox = new WebMarkupContainer(ID_INFO_BOX);
add(infoBox);
infoBox.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.BOX_BACKGROUND_COLOR)));
WebMarkupContainer infoBoxIcon = new WebMarkupContainer(ID_INFO_BOX_ICON);
infoBox.add(infoBoxIcon);
infoBoxIcon.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.ICON_BACKGROUND_COLOR)));
WebMarkupContainer image = new WebMarkupContainer(ID_IMAGE_ID);
image.add(AttributeModifier.append("class", new PropertyModel<String>(model, InfoBoxType.IMAGE_ID)));
infoBoxIcon.add(image);
Label message = new Label(ID_MESSAGE, new PropertyModel<String>(model, InfoBoxType.MESSAGE));
infoBox.add(message);
Label number = new Label(ID_NUMBER, new PropertyModel<String>(model, InfoBoxType.NUMBER));
infoBox.add(number);
WebMarkupContainer progress = new WebMarkupContainer(ID_PROGRESS);
infoBox.add(progress);
progress.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return model.getObject().getProgress() != null;
}
});
ProgressbarPanel progressBar = new ProgressbarPanel(ID_PROGRESS_BAR, new PropertyModel<Integer>(model, InfoBoxType.PROGRESS));
progress.add(progressBar);
Label description = new Label(ID_DESCRIPTION, new PropertyModel<String>(model, InfoBoxType.DESCRIPTION));
infoBox.add(description);
if (linkPage != null) {
add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
setResponsePage(linkPage);
}
});
}
}
use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.
the class ChangePasswordPanel method initColumns.
private List<IColumn<PasswordAccountDto, String>> initColumns() {
List<IColumn<PasswordAccountDto, String>> columns = new ArrayList<IColumn<PasswordAccountDto, String>>();
IColumn column = new IconColumn<PasswordAccountDto>(new Model<String>()) {
private static final long serialVersionUID = 1L;
@Override
protected IModel<String> createIconModel(final IModel<PasswordAccountDto> rowModel) {
return new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
PasswordAccountDto item = rowModel.getObject();
if (item.getCssClass() == null || item.getCssClass().trim().equals("")) {
if (item.isMidpoint()) {
item.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
} else if (item.isPasswordOutbound()) {
item.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
} else {
item.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
}
}
return item.getCssClass();
}
};
}
@Override
public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId, final IModel<PasswordAccountDto> rowModel) {
super.populateItem(item, componentId, rowModel);
final ImagePanel imagePanel = (ImagePanel) item.get(0);
final PasswordAccountDto passwordAccountDto = rowModel.getObject();
imagePanel.add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 1L;
protected void onEvent(final AjaxRequestTarget target) {
if (!passwordAccountDto.isMidpoint()) {
if (passwordAccountDto.getCssClass().equals(PROPAGATED_ACCOUNT_ICON_CSS)) {
passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
} else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS) && passwordAccountDto.isPasswordOutbound() && midpointAccountSelected) {
passwordAccountDto.setCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
} else if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
} else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
}
target.add(imagePanel);
} else {
midpointAccountSelected = !midpointAccountSelected;
if (passwordAccountDto.getCssClass().equals(SELECTED_ACCOUNT_ICON_CSS)) {
passwordAccountDto.setCssClass(DESELECTED_ACCOUNT_ICON_CSS);
updatePropagatedAccountIconsCssClass(DESELECTED_ACCOUNT_ICON_CSS);
target.add(imagePanel.findParent(SelectableDataTable.class));
} else if (passwordAccountDto.getCssClass().equals(DESELECTED_ACCOUNT_ICON_CSS)) {
passwordAccountDto.setCssClass(SELECTED_ACCOUNT_ICON_CSS);
updatePropagatedAccountIconsCssClass(PROPAGATED_ACCOUNT_ICON_CSS);
target.add(imagePanel.findParent(SelectableDataTable.class));
}
}
}
});
}
};
columns.add(column);
columns.add(new AbstractColumn<PasswordAccountDto, String>(createStringResource("ChangePasswordPanel.name")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<PasswordAccountDto>> item, String componentId, final IModel<PasswordAccountDto> rowModel) {
item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {
private static final long serialVersionUID = 1L;
@Override
public Object getObject() {
PasswordAccountDto dto = rowModel.getObject();
return dto.getDisplayName();
}
}));
}
});
column = new PropertyColumn(createStringResource("ChangePasswordPanel.resourceName"), PasswordAccountDto.F_RESOURCE_NAME);
columns.add(column);
CheckBoxColumn enabled = new CheckBoxColumn(createStringResource("ChangePasswordPanel.enabled"), PasswordAccountDto.F_ENABLED);
enabled.setEnabled(false);
columns.add(enabled);
return columns;
}
use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.
the class AbstractOrgTabPanel method initLayout.
private void initLayout() {
final IModel<List<ITab>> tabModel = new LoadableModel<List<ITab>>(false) {
private static final long serialVersionUID = 1L;
@Override
protected List<ITab> load() {
LOGGER.debug("Loading org. roots for tabs for tabbed panel.");
roots = loadOrgRoots();
final List<ITab> tabs = new ArrayList<>();
for (PrismObject<OrgType> root : roots) {
final String oid = root.getOid();
tabs.add(new AbstractTab(createTabTitle(root)) {
private static final long serialVersionUID = 1L;
private int tabId = tabs.size();
@Override
public WebMarkupContainer getPanel(String panelId) {
add(new AjaxEventBehavior("load") {
private static final long serialVersionUID = 1L;
protected void onEvent(final AjaxRequestTarget target) {
SessionStorage storage = getPageBase().getSessionStorage();
storage.getUsers().setSelectedTabId(tabId);
}
});
Panel panel = createTreePanel(panelId, new Model(oid), getPageBase());
panel.setOutputMarkupId(true);
return panel;
}
});
}
LOGGER.debug("Tab count is {}", new Object[] { tabs.size() });
return tabs;
}
};
final SessionStorage storage = getPageBase().getSessionStorage();
int selectedTab = storage.getUsers().getSelectedTabId() == -1 ? 0 : storage.getUsers().getSelectedTabId();
List<ITab> tabsList = tabModel.getObject();
if (tabsList == null || (selectedTab > tabsList.size() - 1)) {
storage.getUsers().setSelectedTabId(0);
selectedTab = 0;
}
AjaxTabbedPanel<ITab> tabbedPanel = new AjaxTabbedPanel<ITab>(ID_TABS, tabModel.getObject(), new Model<>(selectedTab), null) {
private static final long serialVersionUID = 1L;
@Override
public TabbedPanel<ITab> setSelectedTab(int index) {
changeTabPerformed(index);
return super.setSelectedTab(index);
}
};
tabbedPanel.setOutputMarkupId(true);
if (tabsList == null || tabsList.size() == 0) {
tabbedPanel.setVisible(false);
}
add(tabbedPanel);
}
use of org.apache.wicket.ajax.AjaxEventBehavior in project midpoint by Evolveum.
the class PageAuditLogDetails method initAuditLogHistoryPanel.
private void initAuditLogHistoryPanel(WebMarkupContainer eventPanel) {
AuditEventRecordProvider provider = new AuditEventRecordProvider(PageAuditLogDetails.this) {
private static final long serialVersionUID = 1L;
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(TASK_IDENTIFIER_PARAMETER, recordModel.getObject().getTaskIdentifier());
return parameters;
}
};
BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_HISTORY_PANEL, provider, initColumns(), UserProfileStorage.TableId.TASK_EVENTS_TABLE, TASK_EVENTS_TABLE_SIZE) {
@Override
protected Item<AuditEventRecordType> customizeNewRowItem(final Item<AuditEventRecordType> item, final IModel<AuditEventRecordType> rowModel) {
if (rowModel.getObject().getTimestamp().equals(recordModel.getObject().getTimestamp())) {
item.add(new AttributeAppender("style", "background-color: #eee; border-color: #d6d6d6; color: #000"));
}
item.add(new AjaxEventBehavior("click") {
private static final long serialVersionUID = 1L;
@Override
protected void onEvent(AjaxRequestTarget target) {
PageAuditLogDetails.this.rowItemClickPerformed(target, item, rowModel);
}
});
return item;
}
};
table.getFooterMenu().setVisible(false);
table.getFooterCountLabel().setVisible(false);
//TODO hidden temporarily
table.setVisible(false);
table.setOutputMarkupId(true);
table.setAdditionalBoxCssClasses("without-box-header-top-border");
eventPanel.addOrReplace(table);
}
Aggregations