use of org.apache.wicket.markup.head.IHeaderResponse in project wicket by apache.
the class SimplePanel1 method addXXX.
private MarkupContainer addXXX(final String id, final MarkupContainer parent) {
MarkupContainer container = new WebMarkupContainer(id);
parent.add(container);
container.add(new Behavior() {
private static final long serialVersionUID = 1L;
@Override
public void renderHead(Component component, IHeaderResponse response) {
response.render(CssHeaderItem.forUrl(id + ".css"));
}
});
return container;
}
use of org.apache.wicket.markup.head.IHeaderResponse in project wicket by apache.
the class FilteringHeaderResponseTest method footerDependsOnHeadItem.
@Test
public void footerDependsOnHeadItem() throws Exception {
tester.getApplication().setHeaderResponseDecorator(new IHeaderResponseDecorator() {
@Override
public IHeaderResponse decorate(IHeaderResponse response) {
// footer (after </body>)
return new ResourceAggregator(new JavaScriptFilteredIntoFooterHeaderResponse(response, "footerJS"));
}
});
executeTest(FilteredHeaderPage.class, "FilteredHeaderPageExpected.html");
}
use of org.apache.wicket.markup.head.IHeaderResponse in project midpoint by Evolveum.
the class OrgTreePanel method initLayout.
private void initLayout(ModelServiceLocator serviceLocator) {
WebMarkupContainer treeHeader = new WebMarkupContainer(ID_TREE_HEADER);
treeHeader.setOutputMarkupId(true);
add(treeHeader);
String title = StringUtils.isEmpty(treeTitleKey) ? "TreeTablePanel.hierarchy" : treeTitleKey;
Label treeTitle = new Label(ID_TREE_TITLE, createStringResource(title));
treeHeader.add(treeTitle);
List<InlineMenuItem> actions = createTreeMenu();
DropdownButtonDto model = new DropdownButtonDto(null, "fa fa-cog", null, actions);
DropdownButtonPanel treeMenu = new DropdownButtonPanel(ID_TREE_MENU, model) {
private static final long serialVersionUID = 1L;
@Override
protected String getSpecialButtonClass() {
return "btn-default";
}
@Override
protected boolean visibleCaret() {
return false;
}
};
treeMenu.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !actions.isEmpty();
}
});
treeMenu.setOutputMarkupId(true);
treeMenu.setOutputMarkupPlaceholderTag(true);
treeHeader.add(treeMenu);
ISortableTreeProvider provider = new OrgTreeProvider(this, getModel(), preselecteOrgsList) {
@Override
protected ObjectFilter getCustomFilter() {
return OrgTreePanel.this.getCustomFilter();
}
};
WebMarkupContainer treeContainer = new WebMarkupContainer(ID_TREE_CONTAINER) {
private static final long serialVersionUID = 1L;
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
// method computes height based on document.innerHeight() -
// screen height;
Component form = OrgTreePanel.this.getParent().get("memberPanel");
if (form != null) {
// TODO fix
// response.render(OnDomReadyHeaderItem.forScript(
// "updateHeight('" + getMarkupId() + "', ['#" + form.getMarkupId() + "'], ['#"
// + OrgTreePanel.this.get(ID_TREE_HEADER).getMarkupId() + "'])"));
}
}
};
add(treeContainer);
TreeStateModel treeStateMode = new TreeStateModel(this, provider, getOrgTreeStateStorage()) {
private static final long serialVersionUID = 1L;
@Override
public Set<TreeSelectableBean<OrgType>> getExpandedItems() {
return OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
}
@Override
public Set<TreeSelectableBean<OrgType>> getCollapsedItems() {
return OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
}
@Override
public void setCollapsedItems(TreeStateSet items) {
OrgTreePanel.this.setCollapsedItems(null, getOrgTreeStateStorage());
}
};
contentPannels = new ArrayList<OrgTreeFolderContent>();
MidpointNestedTree tree = new MidpointNestedTree(ID_TREE, provider, treeStateMode) {
@Override
protected Component newContentComponent(String id, IModel<TreeSelectableBean<OrgType>> model) {
OrgTreeFolderContent contentPannel = new OrgTreeFolderContent(id, model, selectable, selected, this, getOrgTreeStateStorage()) {
@Override
protected void selectTreeItemPerformed(TreeSelectableBean<OrgType> selected, AjaxRequestTarget target) {
OrgTreePanel.this.selectTreeItemPerformed(selected, target);
}
@Override
protected IModel<Boolean> getCheckboxModel(IModel<TreeSelectableBean<OrgType>> org) {
return OrgTreePanel.this.getCheckBoxValueModel(org);
}
@Override
protected void onUpdateCheckbox(AjaxRequestTarget target) {
selected = getModel();
onOrgTreeCheckBoxSelectionPerformed(target, selected);
}
@Override
protected IModel<List<InlineMenuItem>> createInlineMenuItemsModel() {
return new ReadOnlyModel<>(() -> createTreeChildrenMenuInternal(model.getObject(), serviceLocator.getCompiledGuiProfile()));
}
};
contentPannels.add(contentPannel);
return contentPannel;
}
@Override
public void collapse(TreeSelectableBean<OrgType> collapsedItem) {
super.collapse(collapsedItem);
Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getExpandedItems(getOrgTreeStateStorage());
if (items != null && items.contains(collapsedItem)) {
items.remove(collapsedItem);
}
OrgTreePanel.this.setExpandedItems((TreeStateSet) items, getOrgTreeStateStorage());
OrgTreePanel.this.addCollapsedItem(collapsedItem, getOrgTreeStateStorage());
}
@Override
public void expand(TreeSelectableBean<OrgType> expandedItem) {
super.expand(expandedItem);
Set<TreeSelectableBean<OrgType>> items = OrgTreePanel.this.getCollapsedItems(getOrgTreeStateStorage());
if (items != null && items.contains(expandedItem)) {
items.remove(expandedItem);
}
OrgTreePanel.this.setCollapsedItems((TreeStateSet) items, getOrgTreeStateStorage());
OrgTreePanel.this.addExpandedItem(expandedItem, getOrgTreeStateStorage());
}
};
tree.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
tree.setOutputMarkupId(true);
tree.add(new WindowsTheme());
treeContainer.add(tree);
}
use of org.apache.wicket.markup.head.IHeaderResponse in project midpoint by Evolveum.
the class PageBase method createModalWindow.
protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) {
final ModalWindow modal = new ModalWindow(id);
add(modal);
modal.setResizable(false);
modal.setTitle(title);
modal.setCookieName(PageBase.class.getSimpleName() + ((int) (Math.random() * 100)));
modal.setInitialWidth(width);
modal.setWidthUnit("px");
modal.setInitialHeight(height);
modal.setHeightUnit("px");
modal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
@Override
public boolean onCloseButtonClicked(AjaxRequestTarget target) {
return true;
}
});
modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
@Override
public void onClose(AjaxRequestTarget target) {
modal.close(target);
}
});
modal.add(new AbstractDefaultAjaxBehavior() {
@Override
public void renderHead(Component component, IHeaderResponse response) {
response.render(OnDomReadyHeaderItem.forScript("Wicket.Window.unloadConfirmation = false;"));
response.render(JavaScriptHeaderItem.forScript("$(document).ready(function() {\n" + " $(document).bind('keyup', function(evt) {\n" + " if (evt.keyCode == 27) {\n" + getCallbackScript() + "\n" + " evt.preventDefault();\n" + " }\n" + " });\n" + "});", id));
}
@Override
protected void respond(AjaxRequestTarget target) {
modal.close(target);
}
});
return modal;
}
use of org.apache.wicket.markup.head.IHeaderResponse in project syncope by apache.
the class Topology method topologyNodePanel.
private TopologyNodePanel topologyNodePanel(final String id, final TopologyNode node) {
final TopologyNodePanel panel = new TopologyNodePanel(id, node);
panel.setMarkupId(String.valueOf(node.getKey()));
panel.setOutputMarkupId(true);
final List<Behavior> behaviors = new ArrayList<>();
behaviors.add(new Behavior() {
private static final long serialVersionUID = 2661717818979056044L;
@Override
public void renderHead(final Component component, final IHeaderResponse response) {
response.render(OnDomReadyHeaderItem.forScript(String.format("setPosition('%s', %d, %d)", node.getKey(), node.getX(), node.getY())));
}
});
behaviors.add(new AjaxEventBehavior(Constants.ON_CLICK) {
private static final long serialVersionUID = -9027652037484739586L;
@Override
protected String findIndicatorId() {
return StringUtils.EMPTY;
}
@Override
protected void onEvent(final AjaxRequestTarget target) {
togglePanel.toggleWithContent(target, node);
target.appendJavaScript(String.format("$('.window').removeClass(\"active-window\").addClass(\"inactive-window\"); " + "$(document.getElementById('%s'))." + "removeClass(\"inactive-window\").addClass(\"active-window\");", node.getKey()));
}
});
panel.add(behaviors.toArray(new Behavior[] {}));
return panel;
}
Aggregations