use of org.apache.wicket.ajax.attributes.AjaxRequestAttributes in project midpoint by Evolveum.
the class SearchPanel method initLayout.
private void initLayout() {
moreDialogModel = new LoadableModel<MoreDialogDto>(false) {
@Override
protected MoreDialogDto load() {
MoreDialogDto dto = new MoreDialogDto();
dto.setProperties(createPropertiesList());
return dto;
}
};
Form form = new Form(ID_FORM);
add(form);
ListView items = new ListView<SearchItem>(ID_ITEMS, new PropertyModel<List<SearchItem>>(getModel(), Search.F_ITEMS)) {
@Override
protected void populateItem(ListItem<SearchItem> item) {
SearchItemPanel searchItem = new SearchItemPanel(ID_ITEM, item.getModel());
item.add(searchItem);
}
};
items.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
form.add(items);
WebMarkupContainer moreGroup = new WebMarkupContainer(ID_MORE_GROUP);
moreGroup.add(createVisibleBehaviour(SearchBoxModeType.BASIC));
form.add(moreGroup);
AjaxLink more = new AjaxLink(ID_MORE) {
@Override
public void onClick(AjaxRequestTarget target) {
Component button = SearchPanel.this.get(createComponentPath(ID_FORM, ID_MORE_GROUP, ID_MORE));
Component popover = SearchPanel.this.get(createComponentPath(ID_POPOVER));
togglePopover(target, button, popover, 14);
}
};
more.add(new VisibleEnableBehaviour() {
@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);
AjaxSubmitButton searchSimple = new AjaxSubmitButton(ID_SEARCH_SIMPLE) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(form);
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
searchPerformed(target);
}
};
searchSimple.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
return true;
}
return false;
}
@Override
public boolean isVisible() {
return SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
}
});
searchSimple.setOutputMarkupId(true);
searchContainer.add(searchSimple);
WebMarkupContainer searchDropdown = new WebMarkupContainer(ID_SEARCH_DROPDOWN);
searchDropdown.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType()) && queryPlagroundAccessible;
}
});
searchContainer.add(searchDropdown);
AjaxSubmitButton searchButtonBeforeDropdown = new AjaxSubmitButton(ID_SEARCH_BUTTON_BEFORE_DROPDOWN) {
@Override
protected void onError(AjaxRequestTarget target, Form<?> form) {
target.add(form);
}
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
searchPerformed(target);
}
};
searchButtonBeforeDropdown.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
if (SearchBoxModeType.BASIC.equals(getModelObject().getSearchType()) || SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType())) {
return true;
}
Search search = getModelObject();
PrismContext ctx = getPageBase().getPrismContext();
return search.isAdvancedQueryValid(ctx);
}
});
searchDropdown.add(searchButtonBeforeDropdown);
List<InlineMenuItem> searchItems = new ArrayList<>();
InlineMenuItem searchItem = new InlineMenuItem(createStringResource("SearchPanel.search"), new InlineMenuItemAction() {
@Override
public void onClick(AjaxRequestTarget target) {
PrismContext ctx = getPageBase().getPrismContext();
if (getModelObject().isAdvancedQueryValid(ctx)) {
searchPerformed(target);
}
}
});
searchItems.add(searchItem);
searchItem = new InlineMenuItem(createStringResource("SearchPanel.debug"), new InlineMenuItemAction() {
@Override
public void onClick(AjaxRequestTarget target) {
debugPerformed();
}
});
searchItems.add(searchItem);
ListView<InlineMenuItem> li = new ListView<InlineMenuItem>(ID_MENU_ITEM, Model.ofList(searchItems)) {
@Override
protected void populateItem(ListItem<InlineMenuItem> item) {
WebMarkupContainer menuItemBody = new MenuLinkPanel(ID_MENU_ITEM_BODY, item.getModel());
menuItemBody.setRenderBodyOnly(true);
item.add(menuItemBody);
}
};
searchDropdown.add(li);
WebMarkupContainer linksContainer = new WebMarkupContainer(ID_LINKS_CONTAINER);
linksContainer.setOutputMarkupId(true);
form.add(linksContainer);
AjaxButton advanced = new AjaxButton(ID_ADVANCED, createStringResource("SearchPanel.advanced")) {
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.ADVANCED);
}
};
advanced.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !SearchBoxModeType.ADVANCED.equals(getModelObject().getSearchType());
}
});
linksContainer.add(advanced);
AjaxButton fullTextButton = new AjaxButton(ID_FULL_TEXT, createStringResource("SearchPanel.fullText")) {
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.FULLTEXT);
}
};
fullTextButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return isFullTextSearchEnabled() && !SearchBoxModeType.FULLTEXT.equals(getModelObject().getSearchType());
}
});
linksContainer.add(fullTextButton);
AjaxButton basicSearchButton = new AjaxButton(ID_BASIC_SEARCH, createStringResource("SearchPanel.basic")) {
@Override
public void onClick(AjaxRequestTarget target) {
searchTypeUpdated(target, SearchBoxModeType.BASIC);
}
};
basicSearchButton.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !SearchBoxModeType.BASIC.equals(getModelObject().getSearchType());
}
});
linksContainer.add(basicSearchButton);
advanced.add(new AttributeAppender("style", new LoadableModel<String>() {
@Override
public String load() {
return basicSearchButton.isVisible() ? "margin-top: -20px;" : "display: table-cell; vertical-align: top;";
}
}));
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 fullTextInput = new TextField(ID_FULL_TEXT_FIELD, new PropertyModel<String>(getModel(), Search.F_FULL_TEXT));
fullTextInput.add(new AjaxFormComponentUpdatingBehavior("blur") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
}
});
fullTextInput.add(new Behavior() {
@Override
public void bind(Component component) {
super.bind(component);
component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {$('[about=\"searchSimple\"]').click();}")));
}
});
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));
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()));
advancedGroup.add(advancedCheck);
final 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.milliseconds(500), true));
}
});
advancedGroup.add(advancedArea);
Label advancedError = new Label(ID_ADVANCED_ERROR, new PropertyModel<String>(getModel(), Search.F_ADVANCED_ERROR));
advancedError.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
Search search = getModelObject();
if (!search.isShowAdvanced()) {
return false;
}
return StringUtils.isNotEmpty(search.getAdvancedError());
}
});
advancedGroup.add(advancedError);
}
use of org.apache.wicket.ajax.attributes.AjaxRequestAttributes in project midpoint by Evolveum.
the class NavigatorPanel method initFirst.
private void initFirst() {
WebMarkupContainer first = new WebMarkupContainer(ID_FIRST);
first.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return isFirstEnabled() ? "" : "disabled";
}
}));
add(first);
AjaxLink firstLink = new AjaxLink(ID_FIRST_LINK) {
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
}
@Override
public void onClick(AjaxRequestTarget target) {
firstPerformed(target);
}
};
firstLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return BooleanUtils.isTrue(showPageListingModel.getObject()) && isFirstEnabled();
}
});
first.add(firstLink);
}
use of org.apache.wicket.ajax.attributes.AjaxRequestAttributes in project midpoint by Evolveum.
the class MultiButtonPanel method initLayout.
protected void initLayout() {
RepeatingView buttons = new RepeatingView(ID_BUTTONS);
add(buttons);
for (int id = 0; id < numberOfButtons; id++) {
final int finalId = getButtonId(id);
AjaxButton button = new AjaxButton(String.valueOf(finalId), createStringResource(getCaption(finalId))) {
@Override
public void onClick(AjaxRequestTarget target) {
clickPerformed(finalId, target, MultiButtonPanel.this.getModel());
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
super.updateAjaxAttributes(attributes);
attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE);
}
@Override
public boolean isEnabled() {
return MultiButtonPanel.this.isButtonEnabled(finalId, MultiButtonPanel.this.getModel());
}
@Override
public boolean isVisible() {
return MultiButtonPanel.this.isButtonVisible(finalId, MultiButtonPanel.this.getModel());
}
};
button.add(new AttributeAppender("class", getButtonCssClass(finalId)));
button.add(new AttributeAppender("title", getButtonTitle(finalId)));
buttons.add(button);
buttons.add(new Label("label" + finalId, " "));
}
}
use of org.apache.wicket.ajax.attributes.AjaxRequestAttributes in project midpoint by Evolveum.
the class NavigatorPanel method initPrevious.
private void initPrevious() {
WebMarkupContainer previous = new WebMarkupContainer(ID_PREVIOUS);
previous.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return isPreviousEnabled() ? "" : "disabled";
}
}));
add(previous);
AjaxLink previousLink = new AjaxLink(ID_PREVIOUS_LINK) {
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
}
@Override
public void onClick(AjaxRequestTarget target) {
previousPerformed(target);
}
};
previousLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return isPreviousEnabled();
}
});
previous.add(previousLink);
}
use of org.apache.wicket.ajax.attributes.AjaxRequestAttributes in project midpoint by Evolveum.
the class NavigatorPanel method initNext.
private void initNext() {
WebMarkupContainer next = new WebMarkupContainer(ID_NEXT);
next.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return isNextEnabled() ? "" : "disabled";
}
}));
add(next);
AjaxLink nextLink = new AjaxLink(ID_NEXT_LINK) {
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
}
@Override
public void onClick(AjaxRequestTarget target) {
nextPerformed(target);
}
};
nextLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isEnabled() {
return isNextEnabled();
}
});
next.add(nextLink);
}
Aggregations