Example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setInitialWidth

List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setInitialWidth

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow setInitialWidth.

Prototype

public ModalWindow setInitialWidth(final int initialWidth) 

Source Link

Document

Sets the initial width of the window.

Usage

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.CacheListPanel.java

License:Apache License

public CacheListPanel(final String id, final Behavior updater, final Component[] updateList) {
    super(id);/*from   ww  w  .  j a  v  a 2  s. c om*/

    final ModalWindow modal1;
    add(modal1 = new ModalWindow("modal1"));
    modal1.setInitialWidth(1000);
    //      modal1.setCookieName("modal-1");
    modal1.setPageCreator(new ModalWindow.PageCreator() {
        private static final long serialVersionUID = 1L;

        public Page createPage() {
            return new CacheDetailsPage(hostname);
        }
    });

    this.updateList = updateList;
    final WebMarkupContainer container = new WebMarkupContainer("listpanel");
    container.setOutputMarkupId(true);
    add(container);
    servers = createServerListView(updater, modal1);
    servers.setOutputMarkupId(true);
    container.setOutputMarkupId(true);
    container.add(servers);

    add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) {
        private static final long serialVersionUID = 1L;
        int serverCount = 0;

        @Override
        protected final void onTimer(final AjaxRequestTarget target) {
            //            target.add(getComponent());
            final int size = CacheState.getCacheStates().size();
            if (serverCount != size) {
                serverCount = size;
                servers.setList(getServerList());
                target.add(container);
                if (updateList != null) {
                    for (Component c : updateList) {
                        target.add(c);
                    }
                }
                //               target.add(graph);
            }
        }
    });
}

From source file:com.comcast.cdn.traffic_control.traffic_monitor.wicket.components.DsListPanel.java

License:Apache License

public DsListPanel(final String id, final Behavior updater, final Component[] updateList) {
    super(id);//ww w.  java 2s. c  o m

    final ModalWindow modal1;
    add(modal1 = new ModalWindow("modal2"));
    modal1.setInitialWidth(1000);
    //      modal1.setCookieName("modal-1");
    modal1.setPageCreator(new ModalWindow.PageCreator() {
        private static final long serialVersionUID = 1L;

        public Page createPage() {
            return new DsDetailsPage(dsId);
        }
    });

    this.updateList = updateList;
    final WebMarkupContainer container = new WebMarkupContainer("listpanel");
    container.setOutputMarkupId(true);
    add(container);
    servers = createDsListView(updater, modal1);
    servers.setOutputMarkupId(true);
    container.setOutputMarkupId(true);
    container.add(servers);

    add(new AbstractAjaxTimerBehavior(Duration.seconds(1)) {
        private static final long serialVersionUID = 1L;
        int serverCount = 0;

        @Override
        protected final void onTimer(final AjaxRequestTarget target) {
            final int size = DsState.getDsStates().size();
            if (serverCount != size) {
                serverCount = size;
                servers.setList(getDsList());
                target.add(container);
                if (updateList != null) {
                    for (Component c : updateList) {
                        target.add(c);
                    }
                }
            }
        }
    });
}

From source file:com.cubeia.backoffice.web.user.UserList.java

License:Open Source License

/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters//ww w.  jav a2s.  c o m
*            Page parameters
*/
public UserList(final PageParameters parameters) {
    final Form<?> searchForm = new Form<UserList>("searchForm", new CompoundPropertyModel<UserList>(this));
    final TextField<String> idField = new TextField<String>("userId");
    searchForm.add(idField);
    final TextField<String> userNameField = new TextField<String>("name");
    searchForm.add(userNameField);
    searchForm.add(new Button("clearForm") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            super.onSubmit();
            idField.clearInput();
            userNameField.clearInput();
        }
    });
    add(searchForm);
    add(new FeedbackPanel("feedback"));

    final UsersDataProvider dataProvider = new UsersDataProvider();
    List<IColumn<User, String>> columns = new ArrayList<IColumn<User, String>>();

    columns.add(new AbstractColumn<User, String>(Model.of("User Id")) {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<User>> item, String componentId, IModel<User> model) {
            Long userId = model.getObject().getUserId();
            LabelLinkPanel panel = new LabelLinkPanel(componentId, "" + userId, UserSummary.class,
                    params(UserSummary.PARAM_USER_ID, userId));
            item.add(panel);
        }

        @Override
        public boolean isSortable() {
            return true;
        }

        @Override
        public String getSortProperty() {
            return UserOrder.ID.name();
        }
    });
    columns.add(new PropertyColumn<User, String>(Model.of("XId"), "externalUserId"));
    columns.add(
            new PropertyColumn<User, String>(Model.of("User name"), UserOrder.USER_NAME.name(), "userName"));
    columns.add(new PropertyColumn<User, String>(Model.of("Status"), UserOrder.STATUS.name(), "status"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("First name"), "userInformation.firstName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Last name"), "userInformation.lastName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Country"), UserOrder.COUNTRY.name(), "userInformation.country"));
    columns.add(new PropertyColumn<User, String>(Model.of("Ext. Username"), "attributes.externalUsername"));
    columns.add(new PropertyColumn<User, String>(Model.of("Screename"), "attributes.screenname"));

    AjaxFallbackDefaultDataTable<User, String> userTable = new AjaxFallbackDefaultDataTable<User, String>(
            "userTable", columns, dataProvider, 20);
    add(userTable);

    final ModalWindow modal = new ModalWindow("modal");
    modal.setContent(new UserReportPanel(modal.getContentId(), modal));
    modal.setTitle("Generate report");
    modal.setCookieName("modal");
    modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modal.setInitialWidth(265);
    modal.setInitialHeight(200);

    add(modal);
    add(new AjaxLink<Void>("showReportPanel") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<User> users = getUserList(getUserId(), getName(), 0, Integer.MAX_VALUE,
                    dataProvider.getSort().getProperty(), dataProvider.getSort().isAscending()).getUsers();
            HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();
            request.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE, users);
            modal.show(target);
        }
    });
}

From source file:com.cubeia.games.poker.admin.wicket.pages.user.UserList.java

License:Open Source License

/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters//from w w w.j a v a2s.  c  o  m
*            Page parameters
*/
public UserList(final PageParameters parameters) {
    super(parameters);
    final Form<?> searchForm = new Form<UserList>("searchForm", new CompoundPropertyModel<UserList>(this));
    final TextField<String> idField = new TextField<String>("userId");
    searchForm.add(idField);
    final TextField<String> userNameField = new TextField<String>("name");
    searchForm.add(userNameField);
    searchForm.add(new Button("clearForm") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onSubmit() {
            super.onSubmit();
            idField.clearInput();
            userNameField.clearInput();
        }
    });
    add(searchForm);
    add(new FeedbackPanel("feedback"));

    final UsersDataProvider dataProvider = new UsersDataProvider();
    List<IColumn<User, String>> columns = new ArrayList<IColumn<User, String>>();

    columns.add(new AbstractColumn<User, String>(Model.of("User Id")) {
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<User>> item, String componentId, IModel<User> model) {
            Long userId = model.getObject().getUserId();
            LabelLinkPanel panel = new LabelLinkPanel(componentId, "" + userId, UserSummary.class,
                    params(UserSummary.PARAM_USER_ID, userId));
            item.add(panel);
        }

        @Override
        public boolean isSortable() {
            return true;
        }

        @Override
        public String getSortProperty() {
            return UserOrder.ID.name();
        }
    });
    columns.add(new PropertyColumn<User, String>(Model.of("XId"), "externalUserId"));
    columns.add(
            new PropertyColumn<User, String>(Model.of("User name"), UserOrder.USER_NAME.name(), "userName"));
    columns.add(new PropertyColumn<User, String>(Model.of("Status"), UserOrder.STATUS.name(), "status"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("First name"), "userInformation.firstName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Last name"), "userInformation.lastName"));
    //        columns.add(new PropertyColumn<User,String>(Model.of("Country"), UserOrder.COUNTRY.name(), "userInformation.country"));
    columns.add(new PropertyColumn<User, String>(Model.of("Ext. Username"), "attributes.externalUsername"));
    columns.add(new PropertyColumn<User, String>(Model.of("Screename"), "attributes.screenname"));

    AjaxFallbackDefaultDataTable<User, String> userTable = new AjaxFallbackDefaultDataTable<User, String>(
            "userTable", columns, dataProvider, 20);
    add(userTable);

    final ModalWindow modal = new ModalWindow("modal");
    modal.setContent(new UserReportPanel(modal.getContentId(), modal));
    modal.setTitle("Generate report");
    modal.setCookieName("modal");
    modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modal.setInitialWidth(265);
    modal.setInitialHeight(200);

    add(modal);
    add(new AjaxLink<Void>("showReportPanel") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<User> users = getUserList(getUserId(), getName(), 0, Integer.MAX_VALUE,
                    dataProvider.getSort().getProperty(), dataProvider.getSort().isAscending()).getUsers();
            HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();
            request.getSession().setAttribute(ReportServlet.REPORTS_COLLECTION_DATA_SOURCE, users);
            modal.show(target);
        }
    });
}

From source file:com.doculibre.constellio.wicket.panels.admin.crud.CRUDPanel.java

License:Open Source License

protected IColumn getEditLinkColumn() {
    return new HeaderlessColumn() {
        @Override/*from w w w .  ja  va 2  s .c om*/
        public void populateItem(Item cellItem, String componentId, final IModel rowItemModel) {
            Item rowItem = (Item) cellItem.findParent(Item.class);
            final int rowIndex = getFirstRowItemAbsoluteIndex() + rowItem.getIndex();
            cellItem.add(new ModalImgLinkHolder(componentId) {
                @Override
                public WebMarkupContainer newLink(String id) {
                    if (isUseModalsAddEdit()) {
                        return new AjaxLink(id) {
                            @Override
                            public void onClick(AjaxRequestTarget target) {
                                ModalWindow editModal = getModalWindow();
                                editModal.setInitialHeight(MODAL_HEIGHT);
                                editModal.setInitialWidth(MODAL_WIDTH);
                                String editMsg = getLocalizer().getString("edit", CRUDPanel.this);
                                editModal.setTitle(editMsg);

                                WebMarkupContainer editContent = createEditContent(editModal.getContentId(),
                                        rowItemModel, rowIndex);
                                editModal.setContent(editContent);
                                editModal.show(target);
                            }

                            @Override
                            public boolean isVisible() {
                                return super.isVisible() && isEditLink(rowItemModel, rowIndex);
                            }
                        };
                    } else {
                        return new Link(id) {
                            @Override
                            public void onClick() {
                                WebMarkupContainer editContent = createEditContent(CRUDPanel.this.getId(),
                                        rowItemModel, rowIndex);
                                CRUDPanel.this.replaceWith(editContent);
                            }

                            @Override
                            public boolean isVisible() {
                                return super.isVisible() && isEditLink(rowItemModel, rowIndex);
                            }
                        };
                    }
                }

                @Override
                protected Component newImg(String id) {
                    return new NonCachingImage(id,
                            new ResourceReference(BaseConstellioPage.class, "images/ico_crayon.png"));
                }
            });
        }

        @Override
        public String getCssClass() {
            return "aligncenter width50px";
        }
    };
}

From source file:com.doculibre.constellio.wicket.panels.admin.crud.SingleColumnCRUDPanel.java

License:Open Source License

@Override
protected List<IColumn> getDataColumns() {
    List<IColumn> dataColumns = new ArrayList<IColumn>();
    IColumn detailsColumn = new HeaderlessColumn() {
        @Override//from   www .  ja  va2  s . com
        public void populateItem(Item cellItem, String componentId, final IModel rowItemModel) {
            Item rowItem = (Item) cellItem.findParent(Item.class);
            final int rowIndex = getFirstRowItemAbsoluteIndex() + rowItem.getIndex();
            cellItem.add(new ModalLinkHolder(componentId) {
                @Override
                public WebMarkupContainer newLink(String id) {
                    AbstractLink link;
                    if (isUseModalsDetails()) {
                        link = new AjaxLink(id) {
                            @Override
                            public void onClick(AjaxRequestTarget target) {
                                ModalWindow detailsModal = getModalWindow();
                                detailsModal.setInitialHeight(MODAL_HEIGHT);
                                detailsModal.setInitialWidth(MODAL_WIDTH);
                                detailsModal.setTitle(getLabelModel());
                                onClickDetailsLink(rowItemModel, target, detailsModal, rowIndex);
                            }
                        };
                    } else {
                        link = new Link(id) {
                            @Override
                            public void onClick() {
                                onClickDetailsLink(rowItemModel, null, null, rowIndex);
                            }
                        };
                    }
                    link.setEnabled(isDetailsLink(rowItemModel, rowIndex));
                    return link;
                }

                @Override
                protected Component newLabel(String id, IModel labelModel) {
                    return createDetailsLabelComponent(id, rowItemModel, rowIndex);
                }
            });
        }

        @Override
        public Component getHeader(String componentId) {
            Component header = createDetailsColumnHeader(componentId);
            if (header == null) {
                header = super.getHeader(componentId);
            }
            return header;
        }
    };
    dataColumns.add(detailsColumn);
    return dataColumns;
}

From source file:com.doculibre.constellio.wicket.panels.admin.indexing.AdminIndexingPanel.java

License:Open Source License

private void configurePopUp(ModalWindow modal, final String textPopUp, String titlePopUp) {
    modal.add(new OpenWindowOnLoadBehavior());
    modal.setContent(new SimpleContentPanel(modal.getContentId(), textPopUp));
    modal.setTitle(titlePopUp);//  ww w  .  jav a2s.  c  o  m
    modal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    modal.setMaskType(ModalWindow.MaskType.TRANSPARENT);
    modal.setInitialWidth(200);
    modal.setWidthUnit("px");
    modal.setResizable(false);
    modal.setUseInitialHeight(false);
    modal.setCookieName("wicket-tips/styledModal");
    modal.setPageCreator(new ModalWindow.PageCreator() {
        @Override
        public Page createPage() {
            // TODO Auto-generated method stub
            return new PopUpPage(textPopUp);
        }
    });
}

From source file:com.doculibre.constellio.wicket.panels.admin.solrConfig.SolrConfigPanel.java

License:Open Source License

private ListView getPropertiesListView(List<PropertyRow> propertyRows) {
    return new ListView("properties", propertyRows) {

        @Override//ww w.  j  av  a  2s  .c  o m
        protected void populateItem(final ListItem item) {

            final PropertyRow propertyRow = (PropertyRow) item.getModelObject();
            item.setOutputMarkupId(true);
            item.add(new Label("property",
                    new StringResourceModel(propertyRow.getMessageKey(), SolrConfigPanel.this, null)));
            IModel stateModel = new LoadableDetachableModel() {

                protected Object load() {
                    SolrConfig config = solrConfigModel.getObject();
                    boolean isSet = PropertyResolver.getValue(propertyRow.getProperty(), config) != null;
                    return new StringResourceModel(isSet ? "yes" : "no", SolrConfigPanel.this, null)
                            .getObject();
                }

            };
            item.add(new Label("state", stateModel));
            AjaxLink defaultValueLink = new AjaxLink("defaultValue") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    SolrConfig config = solrConfigModel.getObject();
                    PropertyResolver.setValue(propertyRow.getProperty(), config, null, null);
                    target.addComponent(item);
                    save();
                }

                @Override
                public boolean isVisible() {
                    SolrConfig config = solrConfigModel.getObject();
                    return PropertyResolver.getValue(propertyRow.getProperty(), config) != null;
                }
            };
            item.add(defaultValueLink);
            IModel titleLabelModel = new LoadableDetachableModel() {

                @Override
                protected Object load() {
                    boolean isServerConfig = solrConfigModel.getObject().getRecordCollection() == null;
                    String resourceKey = isServerConfig ? "defaultValue" : "defaultServerValue";
                    return new StringResourceModel(resourceKey, SolrConfigPanel.this, null).getObject();
                }
            };
            defaultValueLink.add(new Label("label", titleLabelModel));

            if (propertyRow.isModalEdit()) {
                item.add(new ModalImgLinkHolder("editComponent") {
                    @Override
                    public WebMarkupContainer newLink(String id) {
                        return new AjaxLink(id) {
                            @Override
                            public void onClick(AjaxRequestTarget target) {
                                ModalWindow editModal = getModalWindow();
                                editModal.setInitialHeight(MODAL_HEIGHT);
                                editModal.setInitialWidth(MODAL_WIDTH);
                                String editMsg = getLocalizer().getString("edit", SolrConfigPanel.this);
                                editModal.setTitle(editMsg);

                                WebMarkupContainer editContent = propertyRow
                                        .getEditLinkPanel(editModal.getContentId());
                                editModal.setContent(editContent);
                                editModal.show(target);
                                target.addComponent(item);
                            }
                        };
                    }

                    @Override
                    protected Component newImg(String id) {
                        return new NonCachingImage(id,
                                new ResourceReference(BaseConstellioPage.class, "images/ico_crayon.png"));
                    }
                });
            } else if (propertyRow.getType().equals(Boolean.class)) {
                final IModel valueModel = propertyRow.createModel();
                item.add(new CheckBoxHolder("editComponent") {

                    @Override
                    protected WebMarkupContainer newInput(String id) {
                        return new AjaxCheckBox(id, valueModel) {

                            @Override
                            protected void onUpdate(AjaxRequestTarget target) {
                                save();
                                target.addComponent(item);
                            }

                            @Override
                            public void detachModels() {
                                super.detachModels();
                                valueModel.detach();
                            }

                        };
                    }
                });
            } else {
                final IModel valueModel = propertyRow.createModel();
                item.add(new AjaxEditableLabel("editComponent", valueModel) {

                    @Override
                    protected void onSubmit(AjaxRequestTarget target) {
                        super.onSubmit(target);
                        save();
                        target.addComponent(item);
                    }

                    @Override
                    public void detachModels() {
                        super.detachModels();
                        valueModel.detach();
                    }

                });
            }

        }

    };
}

From source file:com.doculibre.constellio.wicket.panels.results.tagging.SearchResultTaggingPanel.java

License:Open Source License

public SearchResultTaggingPanel(String id, final SolrDocument doc, final IDataProvider dataProviderParam) {
    super(id);//from   w w w  .j av a2  s  .c om

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    final SimpleSearch simpleSearch;
    if (dataProviderParam instanceof FacetsDataProvider) {
        FacetsDataProvider dataProvider = (FacetsDataProvider) dataProviderParam;
        simpleSearch = dataProvider.getSimpleSearch();
    } else {
        SearchResultsDataProvider dataProvider = (SearchResultsDataProvider) dataProviderParam;
        simpleSearch = dataProvider.getSimpleSearch();
    }

    String collectionName = simpleSearch.getCollectionName();
    RecordCollection collection = collectionServices.get(collectionName);
    if (!collection.isOpenSearch()) {
        RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
        Record record = recordServices.get(doc);
        recordModel = new RecordModel(record);

        final ModalWindow taggingModal = new ModalWindow("taggingModal");
        taggingModal.setTitle(new StringResourceModel("tags", this, null));
        taggingModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        taggingModal.setInitialWidth(800);
        taggingModal.setInitialHeight(450);
        taggingModal.setCloseButtonCallback(new CloseButtonCallback() {
            @Override
            public boolean onCloseButtonClicked(AjaxRequestTarget target) {
                target.addComponent(SearchResultTaggingPanel.this);
                return true;
            }
        });
        add(taggingModal);

        IModel thesaurusListModel = new LoadableDetachableModel() {
            @Override
            protected Object load() {
                List<Thesaurus> thesaurusList = new ArrayList<Thesaurus>();
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                String collectionName = simpleSearch.getCollectionName();
                RecordCollection collection = collectionServices.get(collectionName);
                thesaurusList.add(null);// free text tags
                if (collection.getThesaurus() != null) {
                    thesaurusList.add(collection.getThesaurus());
                }
                return thesaurusList;
            }
        };

        add(new ListView("taggingLinks", thesaurusListModel) {
            @Override
            protected void populateItem(ListItem item) {
                Thesaurus thesaurus = (Thesaurus) item.getModelObject();
                final ReloadableEntityModel<Thesaurus> thesaurusModel = new ReloadableEntityModel<Thesaurus>(
                        thesaurus);
                final String thesaurusName;
                if (thesaurus == null) {
                    thesaurusName = getLocalizer().getString("tags", this);
                } else {
                    thesaurusName = getLocalizer().getString("thesaurus", this);
                }

                AjaxLink link = new AjaxLink("taggingLink") {
                    @Override
                    public void onClick(AjaxRequestTarget target) {
                        Thesaurus thesaurus = thesaurusModel.getObject();
                        SearchResultEditTaggingPanel editTaggingPanel = new SearchResultEditTaggingPanel(
                                taggingModal.getContentId(), doc, dataProviderParam, thesaurus);
                        taggingModal.setContent(editTaggingPanel);
                        taggingModal.show(target);
                    }

                    @Override
                    public boolean isEnabled() {
                        boolean enabled = super.isEnabled();
                        if (enabled) {
                            Record record = recordModel.getObject();
                            if (record != null) {
                                ConstellioUser user = ConstellioSession.get().getUser();
                                if (user != null) {
                                    RecordCollection collection = record.getConnectorInstance()
                                            .getRecordCollection();
                                    enabled = user.hasCollaborationPermission(collection);
                                } else {
                                    enabled = false;
                                }
                            } else {
                                enabled = false;
                            }
                        }
                        return enabled;
                    }

                    @Override
                    public void detachModels() {
                        thesaurusModel.detach();
                        super.detachModels();
                    }
                };
                item.add(link);
                link.add(new Label("thesaurusName", thesaurusName));

                final IModel tagsModel = new LoadableDetachableModel() {
                    @Override
                    protected Object load() {
                        Record record = recordModel.getObject();
                        Thesaurus thesaurus = thesaurusModel.getObject();
                        return new ArrayList<RecordTag>(record.getIncludedRecordTags(thesaurus));
                    }
                };
                item.add(new ListView("tags", tagsModel) {
                    @SuppressWarnings("unchecked")
                    @Override
                    protected void populateItem(ListItem item) {
                        RecordTag recordTag = (RecordTag) item.getModelObject();
                        final RecordTagModel recordTagModel = new RecordTagModel(recordTag);
                        Link addTagLink = new Link("addTagLink") {
                            @Override
                            public void onClick() {
                                RecordTag recordTag = recordTagModel.getObject();
                                SimpleSearch clone = simpleSearch.clone();
                                clone.getTags().add(recordTag.getName(getLocale()));

                                PageFactoryPlugin pageFactoryPlugin = PluginFactory
                                        .getPlugin(PageFactoryPlugin.class);
                                if (StringUtils.isNotBlank(clone.getLuceneQuery())) {
                                    // ConstellioSession.get().addSearchHistory(clone);
                                    setResponsePage(pageFactoryPlugin.getSearchResultsPage(),
                                            SearchResultsPage.getParameters(clone));
                                } else {
                                    SimpleSearch newSearch = new SimpleSearch();
                                    newSearch.setCollectionName(simpleSearch.getCollectionName());
                                    newSearch.setSingleSearchLocale(simpleSearch.getSingleSearchLocale());
                                    setResponsePage(pageFactoryPlugin.getSearchFormPage(),
                                            SearchFormPage.getParameters(newSearch));
                                }
                            }

                            @Override
                            public void detachModels() {
                                recordTagModel.detach();
                                super.detachModels();
                            }
                        };
                        item.add(addTagLink);
                        List<RecordTag> recordTags = (List<RecordTag>) tagsModel.getObject();
                        String tag = recordTag.getName(getLocale());
                        if (item.getIndex() < recordTags.size() - 1) {
                            tag += ";";
                        }
                        addTagLink.add(new Label("tag", tag));
                        addTagLink.setEnabled(false);
                    }
                });
                item.add(new WebMarkupContainer("noTags") {
                    @SuppressWarnings("unchecked")
                    @Override
                    public boolean isVisible() {
                        List<RecordTag> recordTags = (List<RecordTag>) tagsModel.getObject();
                        return super.isVisible() && recordTags.isEmpty();
                    }
                });
            }
        });

    } else {
        setVisible(false);
    }
}

From source file:com.evolveum.midpoint.gui.api.page.PageBase.java

License:Apache License

protected ModalWindow createModalWindow(final String id, IModel<String> title, int width, int height) {
    final ModalWindow modal = new ModalWindow(id);
    add(modal);//from  w  w w . j a  v  a  2  s.  c o  m

    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;
}