use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageAccount method initLayout.
private void initLayout() {
add(new ShadowSummaryPanel(ID_SUMMARY, Model.of(accountModel.getObject().getObject().asObjectable()), WebComponentUtil.getSummaryPanelSpecification(ShadowType.class, getCompiledGuiProfile())));
WebMarkupContainer protectedMessage = new WebMarkupContainer(ID_PROTECTED_MESSAGE);
protectedMessage.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
ShadowWrapper wrapper = accountModel.getObject();
return wrapper.isProtected();
}
});
add(protectedMessage);
MidpointForm mainForm = new MidpointForm(ID_MAIN_FORM);
mainForm.setMultiPart(true);
add(mainForm);
mainForm.add(createTabsPanel(mainForm));
initButtons(mainForm);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class ConfigurationStep method initLayout.
private void initLayout() {
MidpointForm form = new MidpointForm<>(ID_MAIN, true);
form.setOutputMarkupId(true);
add(form);
form.add(WebComponentUtil.createTabPanel(ID_CONFIGURATION, parentPage, createConfigurationTabs(), null));
AjaxSubmitButton testConnection = new AjaxSubmitButton(ID_TEST_CONNECTION, createStringResource("ConfigurationStep.button.testConnection")) {
@Override
protected void onError(final AjaxRequestTarget target) {
WebComponentUtil.refreshFeedbacks(form, target);
}
@Override
protected void onSubmit(AjaxRequestTarget target) {
testConnectionPerformed(target);
}
};
testConnection.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !parentPage.isReadOnly();
}
});
add(testConnection);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class SearchPanel method initLayout.
private <S extends SearchItem, T extends Serializable> void initLayout() {
moreDialogModel = new LoadableModel<MoreDialogDto>(false) {
private static final long serialVersionUID = 1L;
@Override
protected MoreDialogDto load() {
MoreDialogDto dto = new MoreDialogDto();
dto.setProperties(createPropertiesList());
return dto;
}
@Override
public MoreDialogDto getObject() {
if (SearchPanel.this.getModelObject() != null && SearchPanel.this.getModelObject().isTypeChanged()) {
reset();
}
return super.getObject();
}
};
MidpointForm<?> form = new MidpointForm<>(ID_FORM);
add(form);
AjaxButton debug = new AjaxButton(ID_DEBUG, createStringResource("SearchPanel.debug")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
debugPerformed();
}
};
debug.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) && queryPlaygroundAccessible;
}
});
form.add(debug);
PropertyModel<ObjectCollectionSearchItem> collectionModel = new PropertyModel<>(getModel(), Search.F_COLLECTION);
SearchObjectCollectionPanel collectionPanel = new SearchObjectCollectionPanel(ID_COLLECTION_REF_PANEL, collectionModel);
form.add(collectionPanel);
collectionPanel.add(new VisibleBehaviour(() -> collectionModel != null && collectionModel.getObject() != null && getModelObject().isCollectionItemVisible()));
PropertyModel<ContainerTypeSearchItem> typeModel = new PropertyModel<>(getModel(), Search.F_TYPE);
SearchTypePanel typePanel = new SearchTypePanel(ID_TYPE_PANEL, typeModel) {
@Override
protected void searchPerformed(AjaxRequestTarget target) {
resetMoreDialogModel();
SearchPanel.this.searchPerformed(target);
}
};
form.add(typePanel);
typePanel.add(new VisibleBehaviour(() -> typeModel != null && typeModel.getObject() != null && typeModel.getObject().isVisible() && !SearchBoxModeType.OID.equals(getModelObject().getSearchType())));
ListView<SearchItem> specialItems = createSpecialItemsPanel(ID_SPECIAL_ITEMS, new PropertyModel<>(getModel(), Search.F_SPECIAL_ITEMS));
form.add(specialItems);
ListView<SearchItem> compositedItems = createSpecialItemsPanel(ID_COMPOSITED_SPECIAL_ITEMS, new PropertyModel(getModel(), Search.F_COMPOSITED_SPECIAL_ITEMS + "." + AbstractRoleCompositedSearchItem.F_SEARCH_ITEMS));
form.add(compositedItems);
ListView<S> items = new ListView<S>(ID_ITEMS, new PropertyModel<>(getModel(), Search.F_ITEMS)) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<S> item) {
AbstractSearchItemPanel searchItem;
if (item.getModelObject() instanceof FilterSearchItem) {
searchItem = new SearchFilterPanel(ID_ITEM, (IModel<FilterSearchItem>) item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected boolean canRemoveSearchItem() {
return super.canRemoveSearchItem() && SearchPanel.this.getModelObject().isCanConfigure();
}
@Override
protected void searchPerformed(AjaxRequestTarget target) {
SearchPanel.this.searchPerformed(target);
}
};
} else {
searchItem = new SearchPropertyPanel<T>(ID_ITEM, (IModel<PropertySearchItem<T>>) item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected boolean canRemoveSearchItem() {
return super.canRemoveSearchItem() && SearchPanel.this.getModelObject().isCanConfigure();
}
@Override
protected void searchPerformed(AjaxRequestTarget target) {
SearchPanel.this.searchPerformed(target);
}
};
}
item.add(searchItem);
}
};
items.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
form.add(items);
SearchSpecialItemPanel oidItem = new SearchSpecialItemPanel<String>(ID_OID_ITEM, new PropertyModel<String>(getModel(), Search.F_OID)) {
@Override
protected WebMarkupContainer initSearchItemField(String id) {
TextPanel<String> inputPanel = new TextPanel<String>(id, getModelValue());
inputPanel.getBaseFormComponent().add(AttributeAppender.append("style", "width: 220px; max-width: 400px !important;"));
return inputPanel;
}
@Override
protected IModel<String> createLabelModel() {
return getPageBase().createStringResource("SearchPanel.oid");
}
@Override
protected IModel<String> createHelpModel() {
return getPageBase().createStringResource("SearchPanel.oid.help");
}
};
oidItem.add(createVisibleBehaviour(SearchBoxModeType.OID));
form.add(oidItem);
WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP);
moreGroup.add(new VisibleBehaviour(() -> createVisibleBehaviour(SearchBoxModeType.BASIC).isVisible()));
form.add(moreGroup);
AjaxLink<Void> more = new AjaxLink<Void>(ID_MORE) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
resetMoreDialogModel();
Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER));
Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE));
togglePopover(target, button, popover, 14);
}
};
more.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
Search search = getModelObject();
return !search.getAvailableDefinitions().isEmpty();
}
});
more.setOutputMarkupId(true);
moreGroup.add(more);
WebMarkupContainer searchContainer = new WebMarkupContainer(ID_SEARCH_CONTAINER);
searchContainer.setOutputMarkupId(true);
form.add(searchContainer);
final CompositedIconBuilder builder = new CompositedIconBuilder();
builder.setBasicIcon(GuiStyleConstants.CLASS_ICON_SEARCH, IconCssStyle.IN_ROW_STYLE);
IconType plusIcon = new IconType();
plusIcon.setColor("white");
builder.appendLayerIcon(getIconLabelByModeModel(), plusIcon, LayeredIconCssStyle.BOTTOM_RIGHT_STYLE);
AjaxCompositedIconSubmitButton searchButtonBeforeDropdown = new AjaxCompositedIconSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN, builder.build(), getPageBase().createStringResource("SearchPanel.search")) {
private static final long serialVersionUID = 1L;
@Override
protected void onError(AjaxRequestTarget target) {
target.add(form);
}
@Override
protected void onSubmit(AjaxRequestTarget target) {
searchPerformed(target);
}
};
IModel<String> buttonRightPaddingModel = () -> {
boolean isLongButton = SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.AXIOM_QUERY.equals(getModelObject().getSearchType());
String style = "padding-right: " + (isLongButton ? "23" : "16") + "px;";
if (getModelObject().getAllowedSearchType().size() == 1) {
style = style + "border-top-right-radius: 3px; border-bottom-right-radius: 3px;";
}
return style;
};
searchButtonBeforeDropdown.add(AttributeAppender.append("style", buttonRightPaddingModel));
searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isEnabled() {
if (SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) || SearchBoxModeType.AXIOM_QUERY.equals(getModelObject().getSearchType())) {
Search search = getModelObject();
PrismContext ctx = getPageBase().getPrismContext();
return search.isAdvancedQueryValid(ctx);
}
return true;
}
@Override
public boolean isVisible() {
Search search = getModelObject();
if (search.getAllowedSearchType().size() == 1 && SearchBoxModeType.BASIC.equals(search.getAllowedSearchType().get(0))) {
return !search.getItems().isEmpty() || !search.getAvailableDefinitions().isEmpty();
}
return true;
}
});
searchButtonBeforeDropdown.setOutputMarkupId(true);
searchContainer.add(searchButtonBeforeDropdown);
form.setDefaultButton(searchButtonBeforeDropdown);
WebMarkupContainer dropdownButton = new WebMarkupContainer(ID_SEARCH_BUTTON_DROPDOWN);
dropdownButton.add(new VisibleBehaviour(() -> getModelObject().getAllowedSearchType().size() != 1));
searchContainer.add(dropdownButton);
List<InlineMenuItem> searchItems = new ArrayList<>();
InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.basic")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.BASIC);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(getModelObject().isAllowedSearchMode(SearchBoxModeType.BASIC));
}
};
searchItems.add(searchItem);
searchItem = new InlineMenuItem(createStringResource("SearchPanel.advanced")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.ADVANCED);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(getModelObject().isAllowedSearchMode(SearchBoxModeType.ADVANCED));
}
};
searchItems.add(searchItem);
searchItem = new InlineMenuItem(createStringResource("SearchPanel.fullText")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.FULLTEXT);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(isFullTextSearchEnabled() && getModelObject().isAllowedSearchMode(SearchBoxModeType.FULLTEXT));
}
};
searchItems.add(searchItem);
searchItem = new InlineMenuItem(createStringResource("SearchPanel.oid")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.OID);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(getModelObject().isOidSearchEnabled() && getModelObject().isAllowedSearchMode(SearchBoxModeType.OID));
}
};
searchItems.add(searchItem);
searchItem = new InlineMenuItem(createStringResource("SearchPanel.axiomQuery")) {
private static final long serialVersionUID = 1L;
@Override
public InlineMenuItemAction initAction() {
return new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.AXIOM_QUERY);
}
};
}
@Override
public IModel<Boolean> getVisible() {
return Model.of(WebModelServiceUtils.isEnableExperimentalFeature(getPageBase()) && getModelObject().isAllowedSearchMode(SearchBoxModeType.AXIOM_QUERY));
}
};
searchItems.add(searchItem);
ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<InlineMenuItem> item) {
WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel());
menuItemBody.setRenderBodyOnly(true);
item.add(menuItemBody);
menuItemBody.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return Boolean.TRUE.equals(item.getModelObject().getVisible().getObject());
}
});
}
};
searchContainer.add(li);
initPopover();
WebMarkupContainer fullTextContainer = new WebMarkupContainer(ID_FULL_TEXT_CONTAINER);
fullTextContainer.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return isFullTextSearchEnabled() && getModelObject().getSearchType().equals(SearchBoxModeType.FULLTEXT);
}
});
fullTextContainer.setOutputMarkupId(true);
form.add(fullTextContainer);
TextField<String> fullTextInput = new TextField<>(ID_FULL_TEXT_FIELD, new PropertyModel<>(getModel(), Search.F_FULL_TEXT));
fullTextInput.add(new AjaxFormComponentUpdatingBehavior("blur") {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
fullTextInput.add(WebComponentUtil.getSubmitOnEnterKeyDownBehavior("searchSimple"));
fullTextInput.setOutputMarkupId(true);
fullTextInput.add(new AttributeAppender("placeholder", createStringResource("SearchPanel.fullTextSearch")));
fullTextInput.add(createVisibleBehaviour(SearchBoxModeType.FULLTEXT));
fullTextContainer.add(fullTextInput);
WebMarkupContainer advancedGroup = new WebMarkupContainer(ID_ADVANCED_GROUP);
advancedGroup.add(createVisibleBehaviour(SearchBoxModeType.ADVANCED, SearchBoxModeType.AXIOM_QUERY));
advancedGroup.add(AttributeAppender.append("class", createAdvancedGroupStyle()));
advancedGroup.setOutputMarkupId(true);
form.add(advancedGroup);
Label advancedCheck = new Label(ID_ADVANCED_CHECK);
advancedCheck.add(AttributeAppender.append("class", createAdvancedGroupLabelStyle()));
advancedCheck.setOutputMarkupId(true);
advancedGroup.add(advancedCheck);
TextArea<?> advancedArea = new TextArea<>(ID_ADVANCED_AREA, new PropertyModel<>(getModel(), Search.F_ADVANCED_QUERY));
advancedArea.add(new AjaxFormComponentUpdatingBehavior("keyup") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateAdvancedArea(advancedArea, target);
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setThrottlingSettings(new ThrottlingSettings(ID_ADVANCED_AREA, Duration.ofMillis(500), true));
}
});
advancedArea.add(AttributeAppender.append("placeholder", getPageBase().createStringResource("SearchPanel.insertFilterXml")));
advancedArea.add(createVisibleBehaviour(SearchBoxModeType.ADVANCED));
advancedGroup.add(advancedArea);
TextField<String> queryDslField = new TextField<>(ID_AXIOM_QUERY_FIELD, new PropertyModel<>(getModel(), Search.F_DSL_QUERY));
queryDslField.add(new AjaxFormComponentUpdatingBehavior("keyup") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateQueryDSLArea(advancedCheck, advancedGroup, target);
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setThrottlingSettings(new ThrottlingSettings(ID_AXIOM_QUERY_FIELD, Duration.ofMillis(500), true));
attributes.setChannel(new AjaxChannel("Drop", AjaxChannel.Type.DROP));
}
});
queryDslField.add(AttributeAppender.append("placeholder", getPageBase().createStringResource("SearchPanel.insertAxiomQuery")));
queryDslField.add(createVisibleBehaviour(SearchBoxModeType.AXIOM_QUERY));
advancedGroup.add(queryDslField);
WebMarkupContainer advancedErrorGroup = new WebMarkupContainer(ID_ADVANCED_ERROR_GROUP);
advancedErrorGroup.setOutputMarkupId(true);
advancedGroup.add(advancedErrorGroup);
Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR));
advancedError.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
Search search = getModelObject();
if (!search.isShowAdvanced()) {
return false;
}
return StringUtils.isNotEmpty(search.getAdvancedError());
}
});
advancedErrorGroup.add(advancedError);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class SearchFormPanel method initLayout.
protected void initLayout() {
final Form searchForm = new MidpointForm(ID_SEARCH_FORM);
add(searchForm);
searchForm.setOutputMarkupId(true);
SearchPanel<C> search = new SearchPanel<>(ID_SEARCH, getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void searchPerformed(AjaxRequestTarget target) {
SearchFormPanel.this.searchPerformed(target);
}
@Override
protected void saveSearch(Search search, AjaxRequestTarget target) {
SearchFormPanel.this.saveSearch(search, target);
}
};
searchForm.add(search);
}
use of com.evolveum.midpoint.web.component.form.MidpointForm in project midpoint by Evolveum.
the class PageCreatedReports method initLayout.
private void initLayout() {
Form mainForm = new MidpointForm(ID_MAIN_FORM);
add(mainForm);
MainObjectListPanel<ReportDataType> table = new MainObjectListPanel<ReportDataType>(ID_TABLE, ReportDataType.class) {
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ReportDataType object) {
}
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_CREATED_REPORTS_PANEL;
}
@Override
protected ISelectableDataProvider<ReportDataType, SelectableBean<ReportDataType>> createProvider() {
return createSelectableBeanObjectDataProvider(() -> appendTypeFilter(), (sortParam) -> PageCreatedReports.this.createCustomOrdering(sortParam));
}
// @Override
// protected ObjectQuery getCustomizeContentQuery() {
// return appendTypeFilter();
// }
//
// @Override
// protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
// return PageCreatedReports.this.createCustomOrdering(sortParam);
// }
// @Override
// protected ISelectableDataProvider<ReportDataType, SelectableBean<ReportDataType>> createProvider() {
// PageStorage storage = getObjectListPanel().getPageStorage();
// SelectableBeanObjectDataProvider<ReportDataType> provider = new SelectableBeanObjectDataProvider<ReportDataType>(
// getPageBase(), getSearchModel(), null) {
// private static final long serialVersionUID = 1L;
//
// @Override
// protected PageStorage getPageStorage() {
// return storage;
// }
//
// @NotNull
// @Override
// protected List<ObjectOrdering> createObjectOrderings(SortParam<String> sortParam) {
// return PageCreatedReports.this.createCustomOrdering(sortParam);
// }
//
// @Override
// protected ObjectQuery getCustomizeContentQuery() {
// return appendTypeFilter();
// }
// };
// provider.setCompiledObjectCollectionView(getObjectCollectionView());
// provider.setOptions(createOptions());
// return provider;
// }
@Override
protected List<InlineMenuItem> createInlineMenu() {
return initInlineMenu();
}
@Override
protected boolean isCreateNewObjectEnabled() {
return false;
}
@Override
protected boolean isObjectDetailsEnabled(IModel<SelectableBean<ReportDataType>> rowModel) {
return false;
}
@Override
protected List<IColumn<SelectableBean<ReportDataType>, String>> createDefaultColumns() {
return PageCreatedReports.this.initColumns();
}
};
table.setOutputMarkupId(true);
mainForm.add(table);
String reportName = reportTypeMal.get(getReportType());
List<String> values = new ArrayList<>(reportTypeMal.values());
DropDownChoicePanel<String> reportTypeSelect = new DropDownChoicePanel<>(ID_REPORT_TYPE_SELECT, Model.of(reportName), Model.ofList(values), StringChoiceRenderer.simple(), true);
reportTypeSelect.getBaseFormComponent().add(new OnChangeAjaxBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
table.refreshTable(target);
}
});
reportTypeSelect.setOutputMarkupId(true);
mainForm.add(reportTypeSelect);
ajaxDownloadBehavior = new AjaxDownloadBehaviorFromStream() {
private static final long serialVersionUID = 1L;
@Override
protected InputStream initStream() {
return createReport();
}
@Override
public String getFileName() {
return getReportFileName();
}
};
mainForm.add(ajaxDownloadBehavior);
}
Aggregations