use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageAssignmentShoppingCart method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
initModels();
getRoleCatalogStorage().setAssignmentRequestLimit(AssignmentsUtil.loadAssignmentsLimit(new OperationResult(OPERATION_LOAD_ASSIGNMENTS_LIMIT), this));
setOutputMarkupId(true);
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
List<ITab> tabs = getTabsList();
TabbedPanel tabbedPanel = new TabbedPanel<ITab>(ID_VIEWS_TAB_PANEL, tabs) {
private static final long serialVersionUID = 1L;
@Override
public TabbedPanel<ITab> setSelectedTab(int index) {
getRoleCatalogStorage().setDefaultTabIndex(index);
return super.setSelectedTab(index);
}
};
tabbedPanel.setOutputMarkupId(true);
int defaultSelectedTabIndex = getDefaultViewTypeIndex();
if (getRoleCatalogStorage().getDefaultTabIndex() > 0 && getRoleCatalogStorage().getDefaultTabIndex() < tabs.size()) {
tabbedPanel.setSelectedTab(getRoleCatalogStorage().getDefaultTabIndex());
} else if (defaultSelectedTabIndex < tabs.size()) {
tabbedPanel.setSelectedTab(defaultSelectedTabIndex);
}
mainForm.add(tabbedPanel);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class AssignmentConflictPanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
Form container = new MidpointForm<>(ID_PANEL_CONTAINER);
container.setOutputMarkupId(true);
add(container);
Label statusIconLabel = new Label(ID_STATUS_ICON);
statusIconLabel.add(new AttributeAppender("class", new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null ? (getModelObject().isResolved() ? STATUS_FIXED : (getModelObject().isWarning() ? STATUS_WARNING : STATUS_ERROR)) : STATUS_ERROR;
}
}));
container.add(statusIconLabel);
Label existingAssignment = new Label(ID_EXISTING_ASSIGNMENT, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (getModelObject() != null) {
String name = getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment1().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment1().getAssignmentTargetObject().getOid();
return name + " " + getMessageLabel(getModelObject().getAssignment1().isOldAssignment());
}
return "";
}
});
existingAssignment.add(new AttributeAppender("style", new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null && getModelObject().getAssignment1().isResolved() ? "text-decoration: line-through;" : "";
}
}));
container.add(existingAssignment);
Label addedAssignment = new Label(ID_ADDED_ASSIGNMENT, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
if (getModelObject() != null) {
String name = getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName() != null ? getModelObject().getAssignment2().getAssignmentTargetObject().asObjectable().getName().getOrig() : getModelObject().getAssignment2().getAssignmentTargetObject().getOid();
return name + " " + getMessageLabel(getModelObject().getAssignment2().isOldAssignment());
}
return "";
}
});
addedAssignment.add(new AttributeAppender("style", new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null && getModelObject().getAssignment2().isResolved() ? "text-decoration: line-through;" : "";
}
}));
container.add(addedAssignment);
IModel<String> removeButtonTitleModel = new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject().getAssignment1().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
}
};
AjaxSubmitButton removeButton = new AjaxSubmitButton(ID_REMOVE_BUTTON, removeButtonTitleModel) {
@Override
public void onSubmit(AjaxRequestTarget target) {
AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment1(), target);
}
};
removeButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject() != null;
}
@Override
public boolean isEnabled() {
return !getModelObject().getAssignment2().isResolved();
}
});
container.add(removeButton);
IModel<String> unselectButtonTitleModel = new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject().getAssignment2().isResolved() ? createStringResource("AssignmentConflictPanel.undoAction").getString() : createStringResource("AssignmentConflictPanel.removeButton").getString();
}
};
AjaxSubmitButton unselectButton = new AjaxSubmitButton(ID_UNSELECT_BUTTON, unselectButtonTitleModel) {
@Override
public void onSubmit(AjaxRequestTarget target) {
AssignmentConflictPanel.this.removeAssignmentPerformed(getModelObject().getAssignment2(), target);
}
};
unselectButton.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return getModelObject() != null;
}
@Override
public boolean isEnabled() {
return !getModelObject().getAssignment1().isResolved();
}
});
container.add(unselectButton);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class DashboardSearchPanel method initLayout.
protected void initLayout() {
final Form<?> searchForm = new MidpointForm<>(ID_SEARCH_FORM);
add(searchForm);
searchForm.setOutputMarkupId(true);
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_USERS_ALL_URL, AuthorizationConstants.AUTZ_UI_USERS_URL)) {
searchTypes.put(SearchType.USERS, createStringResource("PageDashboard.search.users"));
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_RESOURCES_ALL_URL, AuthorizationConstants.AUTZ_UI_RESOURCES_URL)) {
searchTypes.put(SearchType.RESOURCES, createStringResource("PageDashboard.search.resources"));
}
if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_TASKS_ALL_URL, AuthorizationConstants.AUTZ_UI_TASKS_URL)) {
searchTypes.put(SearchType.TASKS, createStringResource("PageDashboard.search.tasks"));
}
for (SearchType type : SearchType.values()) {
if (searchTypes.containsKey(type)) {
selectedSearchType = type;
break;
}
}
TextField<String> searchInput = new TextField<>(ID_SEARCH_INPUT, Model.of(""));
searchInput.add(new VisibleBehaviour(() -> !searchTypes.isEmpty()));
searchInput.setOutputMarkupId(true);
searchInput.setOutputMarkupPlaceholderTag(true);
searchForm.add(searchInput);
final AjaxSubmitLink searchButton = new AjaxSubmitLink(ID_SEARCH_BUTTON) {
@Override
protected void onSubmit(AjaxRequestTarget target) {
performSearch(getSearchText());
}
};
searchButton.setOutputMarkupId(true);
searchButton.setOutputMarkupPlaceholderTag(true);
Label searchButtonLabel = new Label("searchButtonLabel", (IModel<Object>) () -> searchTypes.get(selectedSearchType).getObject());
searchButtonLabel.setOutputMarkupId(true);
searchButton.add(searchButtonLabel);
searchForm.add(searchButton);
searchForm.setDefaultButton(searchButton);
ListView<SearchType> li = new ListView<>(ID_SEARCH_TYPES, new ListModel<>(new ArrayList<>(searchTypes.keySet()))) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<SearchType> item) {
final AjaxLink<String> searchTypeLink = new AjaxLink<>(ID_SEARCH_TYPE_ITEM) {
private static final long serialVersionUID = 1L;
@Override
public IModel<String> getBody() {
return searchTypes.get(item.getModelObject());
}
@Override
public void onClick(AjaxRequestTarget target) {
selectedSearchType = item.getModelObject();
target.add(DashboardSearchPanel.this.get(createComponentPath(ID_SEARCH_FORM, ID_SEARCH_BUTTON)));
}
};
searchTypeLink.setOutputMarkupId(true);
item.add(searchTypeLink);
}
};
li.setOutputMarkupId(true);
searchForm.add(li);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class LimitationsEditorDialog method initLayout.
public void initLayout(WebMarkupContainer content) {
Form<?> form = new MidpointForm<>(ID_MAIN_FORM);
form.setOutputMarkupId(true);
content.add(form);
ListView<PropertyLimitationsTypeDto> repeater = new ListView<PropertyLimitationsTypeDto>(ID_REPEATER, model) {
@Override
protected void populateItem(final ListItem<PropertyLimitationsTypeDto> item) {
WebMarkupContainer linkContainer = new WebMarkupContainer(ID_LIMITATIONS_LINK);
linkContainer.setOutputMarkupId(true);
linkContainer.add(new AttributeModifier("href", createCollapseItemId(item, true)));
item.add(linkContainer);
Label linkLabel = new Label(ID_LIMITATIONS_LABEL, createLimitationsLabelModel(item));
linkContainer.add(linkLabel);
AjaxLink<Void> delete = new AjaxLink<Void>(ID_LIMITATION_DELETE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteLimitationPerformed(target, item);
}
};
delete.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
linkContainer.add(delete);
WebMarkupContainer limitationBody = new WebMarkupContainer(ID_BODY);
limitationBody.setOutputMarkupId(true);
limitationBody.setMarkupId(createCollapseItemId(item, false).getObject());
if (changeState != ChangeState.SKIP) {
limitationBody.add(new AttributeModifier("class", (IModel<String>) () -> {
if (changeState == ChangeState.FIRST && item.getIndex() == 0) {
return "panel-collapse collapse in";
} else if (changeState == ChangeState.LAST && item.getIndex() == (getModelObject().size() - 1)) {
return "panel-collapse collapse in";
} else {
return "panel-collapse collapse";
}
}));
}
limitationBody.add(WebComponentUtil.enabledIfFalse(readOnlyModel));
item.add(limitationBody);
initLimitationBody(limitationBody, item);
}
};
repeater.setOutputMarkupId(true);
form.add(repeater);
initButtons(form);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class Wizard method initLayout.
protected void initLayout() {
Form form = new MidpointForm(ID_FORM);
add(form);
IModel<List<WizardStepDto>> stepsModel = new LoadableModel<List<WizardStepDto>>() {
@Override
protected List<WizardStepDto> load() {
return loadSteps();
}
};
WizardSteps steps = new WizardSteps(ID_STEPS, stepsModel) {
@Override
public IWizardStep getActiveStep() {
if (Wizard.this.getModel() != null && Wizard.this.getModel().getObject() != null) {
return Wizard.this.getModel().getObject().getActiveStep();
}
return null;
}
@Override
public void changeStepPerformed(AjaxRequestTarget target, WizardStepDto dto) {
changeStep(target, dto);
}
};
steps.setOutputMarkupId(true);
steps.setVisible(hasMoreThanOneStep());
form.add(steps);
WebMarkupContainer header = new WebMarkupContainer(ID_HEADER);
form.add(header);
WebMarkupContainer view = new WebMarkupContainer(ID_VIEW);
form.add(view);
WizardIssuesPanel issuesPanel = new WizardIssuesPanel(ID_ISSUES, issuesModel);
issuesPanel.setOutputMarkupId(true);
form.add(issuesPanel);
WizardButtonBar buttons = new WizardButtonBar(ID_BUTTONS, this);
buttons.setOutputMarkupId(true);
form.add(buttons);
WebMarkupContainer autoSaveNote = new WebMarkupContainer(ID_AUTO_SAVE_NOTE);
autoSaveNote.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
return !wizardPage.isConfigurationOnly() && !wizardPage.isReadOnly();
}
});
form.add(autoSaveNote);
WebMarkupContainer readOnlyNote = new WebMarkupContainer(ID_READ_ONLY_NOTE);
readOnlyNote.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
return wizardPage.isReadOnly();
}
});
form.add(readOnlyNote);
readOnlyNote.add(new AjaxFallbackLink<String>(ID_READ_ONLY_SWITCH) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(Optional<AjaxRequestTarget> optionalTarget) {
PageResourceWizard wizardPage = (PageResourceWizard) getPageBase();
// e.g. to switch configuration models to read-write
wizardPage.resetModels();
wizardPage.setReadOnly(false);
optionalTarget.get().add(wizardPage);
}
});
IWizardModel wizard = getWizardModel();
wizard.addListener(this);
wizard.reset();
}
Aggregations