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

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

Introduction

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

Prototype

public ModalWindow setCookieName(final String cookieName) 

Source Link

Document

Sets the name of the cookie that is used to remember window position (and size if the window is resizable).

Usage

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/*from   ww  w  . ja  v  a 2 s  . 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/*w  w  w. j ava2  s . co  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.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);/*  w w w  .j  a v a  2s  .  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.results.MailSearchResultPanel.java

License:Open Source License

public MailSearchResultPanel(String id, final SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id);//from  w  w  w. jav a 2s.  c o  m

    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    final Long recordId = new Long(doc.getFieldValue(IndexField.RECORD_ID_FIELD).toString());
    final String collectionName = dataProvider.getSimpleSearch().getCollectionName();
    RecordCollection collection = collectionServices.get(collectionName);
    Record record = recordServices.get(recordId, collection);

    final IModel subjectModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);
            String subject = record.getDisplayTitle();
            if (StringUtils.isBlank(subject)) {
                subject = getLocalizer().getString("noSubject", MailSearchResultPanel.this);
            }
            if (subject.length() > 60) {
                subject = subject.substring(0, 60) + " ...";
            }
            return subject;
        }
    };

    // List<byte[]> attachmentContents = new ArrayList<byte[]>();
    // String messageContent = null;
    // for (RawContent raw : rawContents) {
    // byte[] bytes = raw.getContent();
    // if (messageContent == null) {
    // messageContent = new String(bytes);
    // } else {
    // attachmentContents.add(bytes);
    // }
    // System.out.println("partial content :" + new String(bytes));
    // }
    // System.out.println("content 1 :" + messageContent);

    // Description du document dans extrait:
    QueryResponse response = dataProvider.getQueryResponse();
    Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
    final String recordURL = record.getUrl();
    Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL);

    ConnectorInstance connectorInstance = record.getConnectorInstance();
    IndexField defaultSearchField = collection.getDefaultSearchIndexField();

    String excerpt = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting);

    final ModalWindow detailsMailModal = new ModalWindow("detailsMailModal");
    detailsMailModal.setPageCreator(new PageCreator() {
        @Override
        public Page createPage() {
            return new BaseConstellioPage();
        }
    });
    add(detailsMailModal);
    detailsMailModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    detailsMailModal.setCookieName("detailsMailModal");

    IModel modalTitleModel = subjectModel;
    detailsMailModal.setTitle(modalTitleModel);

    final String displayURL = (String) doc.getFieldValue(collection.getUrlIndexField().getName());

    emailModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);

            List<String> attachmentNames = record.getMetaContents(MailConnectorConstants.META_ATTACHMENTNAME);
            List<String> attachmentTypes = record.getMetaContents(MailConnectorConstants.META_ATTACHMENTTYPE);
            List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS);
            List<String> flags = record.getMetaContents(MailConnectorConstants.META_FLAGS);
            List<String> froms = record.getMetaContents(MailConnectorConstants.META_SENDER);
            // FIXME Hardcoded
            List<String> contentEncoding = record.getMetaContents("Content-Encoding");

            List<String> receivedDateList = record.getMetaContents(MailConnectorConstants.META_RECEIVEDDATE);

            // FIXME voir avec Vincent : exemple qui ne marche pas jobboom car mail contient que du html
            RawContentServices rawContentServices = ConstellioSpringUtils.getRawContentServices();
            List<RawContent> rawContents = rawContentServices.getRawContents(record);
            ParsedContent parsedContents = record.getParsedContent();

            Email email;
            if (rawContents.size() != 0) {
                byte[] content = rawContents.get(0).getContent();
                String tmpFilePath = ClasspathUtils.getCollectionsRootDir() + File.separator + "tmp.eml";
                try {
                    email = MailMessageUtils.toEmail(content, tmpFilePath);
                } catch (Exception e) {
                    System.out.println("Error in reading content of mail");
                    // le contenu n'a pas bien t lu correctement
                    email = new Email();
                    email.setMessageContentText(parsedContents.getContent());
                }
            } else {
                // le contenu n'a pas bien t lu correctement
                email = new Email();
                email.setMessageContentText(parsedContents.getContent());
            }

            email.setFlags(flags);

            // email.setMessageContentHtml(messageContentHtml);
            if (!receivedDateList.isEmpty()) {
                email.setReceivedDate(receivedDateList.get(0));
            }
            email.setRecipients(recipients);
            email.setSubject((String) subjectModel.getObject());
            email.setFroms(froms);
            // email.setLanguage(language);
            if (!contentEncoding.isEmpty()) {
                email.setContentEncoding(contentEncoding.get(0));
            }
            return email;
        }
    };

    final RecordModel recordModel = new RecordModel(record);
    AjaxLink detailsMailLink = new AjaxLink("detailsMailLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            Email email = (Email) emailModel.getObject();
            detailsMailModal.setContent(new MailDetailsPanel(detailsMailModal.getContentId(), email));
            detailsMailModal.show(target);
        }

        @Override
        protected IAjaxCallDecorator getAjaxCallDecorator() {
            return new AjaxCallDecorator() {
                @Override
                public CharSequence decorateScript(CharSequence script) {
                    Record record = recordModel.getObject();
                    SimpleSearch simpleSearch = dataProvider.getSimpleSearch();
                    WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
                    HttpServletRequest httpRequest = webRequest.getHttpServletRequest();
                    return script + ";" + ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest,
                            simpleSearch, record);
                }
            };
        }
    };
    add(detailsMailLink);

    IModel recipientsLabelModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);
            List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS);
            return getLocalizer().getString("to", MailSearchResultPanel.this) + " : " + recipients;
        }
    };

    IModel receivedDateLabelModel = new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
            Record record = recordServices.get(doc);
            List<String> receivedDateList = record.getMetaContents(MailConnectorConstants.META_RECEIVEDDATE);
            String receivedDate;
            if (!receivedDateList.isEmpty()) {
                receivedDate = receivedDateList.get(0);
            } else {
                receivedDate = "";
            }
            return getLocalizer().getString("date", MailSearchResultPanel.this) + " : " + receivedDate;
        }
    };

    Label subjectLabel = new Label("subject", subjectModel);
    detailsMailLink.add(subjectLabel.setEscapeModelStrings(false));

    Label excerptLbl = new Label("messageContent", excerpt);
    add(excerptLbl.setEscapeModelStrings(false));
    add(new Label("recipient", recipientsLabelModel) {
        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                RecordCollectionServices collectionServices = ConstellioSpringUtils
                        .getRecordCollectionServices();
                RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
                RecordCollection collection = collectionServices.get(collectionName);
                Record record = recordServices.get(recordId, collection);
                List<String> recipients = record.getMetaContents(MailConnectorConstants.META_RECIPIENTS);
                visible = !recipients.isEmpty();
            }
            return visible;
        }
    });
    // add(new Label("from", getLocalizer().getString("from", this) + " : " + froms));
    add(new Label("date", receivedDateLabelModel));
    add(new WebMarkupContainer("hasAttachmentsImg") {
        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
                Record record = recordServices.get(doc);
                List<String> attachmentNames = record
                        .getMetaContents(MailConnectorConstants.META_ATTACHMENTNAME);
                visible = !attachmentNames.isEmpty();
            }
            return visible;
        }
    });

    final ReloadableEntityModel<RecordCollection> collectionModel = new ReloadableEntityModel<RecordCollection>(
            collection);
    add(new ListView("searchResultFields", new LoadableDetachableModel() {
        @Override
        protected Object load() {
            RecordCollection collection = collectionModel.getObject();
            return collection.getSearchResultFields();
        }

        /**
         * Detaches from the current request. Implement this method with custom behavior, such as
         * setting the model object to null.
         */
        protected void onDetach() {
            recordModel.detach();
            collectionModel.detach();
        }
    }) {
        @Override
        protected void populateItem(ListItem item) {
            SearchResultField searchResultField = (SearchResultField) item.getModelObject();
            IndexFieldServices indexFieldServices = ConstellioSpringUtils.getIndexFieldServices();
            Record record = recordModel.getObject();
            IndexField indexField = searchResultField.getIndexField();
            Locale locale = getLocale();
            String indexFieldTitle = indexField.getTitle(locale);
            if (StringUtils.isBlank(indexFieldTitle)) {
                indexFieldTitle = indexField.getName();
            }
            StringBuffer fieldValueSb = new StringBuffer();
            List<Object> fieldValues = indexFieldServices.extractFieldValues(record, indexField);
            Map<String, String> defaultLabelledValues = indexFieldServices.getDefaultLabelledValues(indexField,
                    locale);
            for (Object fieldValue : fieldValues) {
                if (fieldValueSb.length() > 0) {
                    fieldValueSb.append("\n");
                }
                String fieldValueLabel = indexField.getLabelledValue("" + fieldValue, locale);
                if (fieldValueLabel == null) {
                    fieldValueLabel = defaultLabelledValues.get("" + fieldValue);
                }
                if (fieldValueLabel == null) {
                    fieldValueLabel = "" + fieldValue;
                }
                fieldValueSb.append(fieldValueLabel);
            }

            item.add(new Label("indexField", indexFieldTitle));
            item.add(new MultiLineLabel("indexFieldValue", fieldValueSb.toString()));
            item.setVisible(fieldValueSb.length() > 0);
        }

        @SuppressWarnings("unchecked")
        @Override
        public boolean isVisible() {
            boolean visible = super.isVisible();
            if (visible) {
                List<SearchResultField> searchResultFields = (List<SearchResultField>) getModelObject();
                visible = !searchResultFields.isEmpty();
            }
            return visible;
        }
    });

    add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch()));
}

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

License:Open Source License

public PopupSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id);/*  ww w  . j  a v a2 s .  co m*/

    RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
    String solrServerName = dataProvider.getSimpleSearch().getCollectionName();
    RecordCollection collection = collectionServices.get(solrServerName);

    IndexField uniqueKeyField = collection.getUniqueKeyIndexField();
    IndexField defaultSearchField = collection.getDefaultSearchIndexField();
    IndexField urlField = collection.getUrlIndexField();
    IndexField titleField = collection.getTitleIndexField();

    // title
    String documentID = (String) getFieldValue(doc, uniqueKeyField.getName());

    String documentTitle = (String) getFieldValue(doc, titleField.getName());

    if (StringUtils.isBlank(documentTitle)) {
        if (urlField == null) {
            documentTitle = (String) getFieldValue(doc, uniqueKeyField.getName());
        } else {
            documentTitle = (String) getFieldValue(doc, urlField.getName());
        }
    }
    if (documentTitle.length() > 120) {
        documentTitle = documentTitle.substring(0, 120) + " ...";
    }

    // content
    RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
    Record record = recordServices.get(doc);

    RawContentServices rawContentServices = ConstellioSpringUtils.getRawContentServices();
    List<RawContent> rawContents = rawContentServices.getRawContents(record);
    StringBuilder content = new StringBuilder();
    for (RawContent raw : rawContents) {
        byte[] bytes = raw.getContent();
        content.append(new String(bytes));
    }

    String documentContent = content.toString();

    // date
    String documentLastModified = getFieldValue(doc, IndexField.LAST_MODIFIED_FIELD);

    // Description du document dans extrait:
    QueryResponse response = dataProvider.getQueryResponse();
    Map<String, Map<String, List<String>>> highlighting = response.getHighlighting();
    final String recordURL = record.getUrl();
    Map<String, List<String>> fieldsHighlighting = highlighting.get(recordURL);

    String extrait = getExcerptFromHighlight(defaultSearchField.getName(), fieldsHighlighting);

    final ModalWindow detailsDocumentModal = new ModalWindow("detailsDocumentModal");
    add(detailsDocumentModal);
    detailsDocumentModal.setCssClassName(ModalWindow.CSS_CLASS_GRAY);

    detailsDocumentModal.setContent(
            new PopupDetailsPanel(detailsDocumentModal.getContentId(), documentContent, documentLastModified));
    detailsDocumentModal.setCookieName("detailsDocumentModal");

    String modalTitle = documentTitle;
    detailsDocumentModal.setTitle(modalTitle);

    AjaxLink detailsDocumentLink = new AjaxLink("detailsDocumentLink") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            detailsDocumentModal.show(target);
        }
    };
    add(detailsDocumentLink);

    final RecordModel recordModel = new RecordModel(record);
    AttributeAppender computeClickAttributeModifier = new AttributeAppender("onclick", true,
            new LoadableDetachableModel() {
                @Override
                protected Object load() {
                    Record record = recordModel.getObject();
                    SimpleSearch simpleSearch = dataProvider.getSimpleSearch();
                    WebRequest webRequest = (WebRequest) RequestCycle.get().getRequest();
                    HttpServletRequest httpRequest = webRequest.getHttpServletRequest();
                    return ComputeSearchResultClickServlet.getCallbackJavascript(httpRequest, simpleSearch,
                            record);
                }

                @Override
                protected void onDetach() {
                    recordModel.detach();
                    super.onDetach();
                }
            }, ";") {
        @Override
        protected String newValue(String currentValue, String appendValue) {
            return appendValue + currentValue;
        }
    };
    detailsDocumentLink.add(computeClickAttributeModifier);

    Label subjectLabel = new Label("subject", documentTitle);
    detailsDocumentLink.add(subjectLabel.setEscapeModelStrings(false));

    Label extraitLbl = new Label("documentContent", extrait);
    add(extraitLbl.setEscapeModelStrings(false));
    add(new Label("date", "Date : " + documentLastModified));

    add(new ElevatePanel("elevatePanel", record, dataProvider.getSimpleSearch()));
}

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 ww . j  a v a 2  s .  co 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;
}

From source file:com.evolveum.midpoint.web.component.util.SimplePanel.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  ww. ja  va2  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;
}

From source file:com.evolveum.midpoint.web.page.admin.configuration.component.ObjectSelectionPage.java

License:Apache License

public static <T extends ObjectType> void prepareDialog(ModalWindow dialog,
        ObjectSelectionPanel.Context context, final Component callingComponent, String titleResourceKey,
        final String idToRefresh) {
    dialog.setPageCreator(new ObjectSelectionPage.PageCreator(dialog, context));
    dialog.setInitialWidth(800);/*from   w  w w  .  j a va2s.  com*/
    dialog.setInitialHeight(500);
    dialog.setTitle(PageBase.createStringResourceStatic(callingComponent, titleResourceKey));
    dialog.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        // We are not able to refresh targets residing in the parent page
        // from inside the modal window -> so we have to do it in this
        // context, when the modal window is being closed.
        public void onClose(AjaxRequestTarget target) {
            target.add(callingComponent.get(idToRefresh));
        }
    });
    dialog.showUnloadConfirmation(false);
    dialog.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    dialog.setCookieName(ObjectSelectionPanel.class.getSimpleName() + ((int) (Math.random() * 100)));
    dialog.setWidthUnit("px");
}

From source file:com.evolveum.midpoint.web.page.PageTemplate.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 ww  .j a  v  a 2  s .c  o m*/

    modal.setResizable(false);
    modal.setTitle(title);
    modal.setCookieName(PageTemplate.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;
}

From source file:com.socialsite.course.NewCoursePanel.java

License:Open Source License

public NewCoursePanel(String id) {
    super(id);//from   w ww.  j  a  v  a2s  .co m
    final ModalWindow courseModal;
    add(courseModal = new ModalWindow("coursemodal"));

    courseModal.setContent(new NewCourseModal(courseModal.getContentId()));
    courseModal.setTitle("Create new Course");
    courseModal.setCookieName("coursemodal");

    courseModal.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public boolean onCloseButtonClicked(AjaxRequestTarget target) {
            return true;
        }
    });

    courseModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        public void onClose(AjaxRequestTarget target) {

        }
    });

    add(new AjaxLink<Void>("newcourse") {
        /**
         * 
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            courseModal.show(target);
        }
    });
}