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

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

Introduction

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

Prototype

public ModalWindow setMinimalHeight(final int minimalHeight) 

Source Link

Document

Sets the minimal height of window.

Usage

From source file:org.dcm4chee.web.war.tc.TCResultPanel.java

License:LGPL

@SuppressWarnings("serial")
public TCResultPanel(final String id, final TCListModel model, final IModel<Boolean> trainingModeModel) {
    super(id, model != null ? model : new TCListModel());

    setOutputMarkupId(true);/*from w ww .j  a  v  a  2s .c om*/

    stPermHelper = StudyPermissionHelper.get();

    initWebviewerLinkProvider();

    add(msgWin);
    final ModalWindow modalWindow = new ModalWindow("modal-window");
    add(modalWindow);

    final ModalWindow forumWindow = new ModalWindow("forum-window");
    add(forumWindow);

    final TCStudyListPage studyPage = new TCStudyListPage();
    final ModalWindow studyWindow = new ModalWindow("study-window");
    studyWindow.setPageCreator(new ModalWindow.PageCreator() {
        private static final long serialVersionUID = 1L;

        public Page createPage() {
            return studyPage;
        }
    });

    add(studyWindow);

    tclistProvider = new SortableTCListProvider((TCListModel) getDefaultModel());

    final TCAttributeVisibilityStrategy attrVisibilityStrategy = new TCAttributeVisibilityStrategy(
            trainingModeModel);

    final DataView<TCModel> dataView = new DataView<TCModel>("row", tclistProvider) {

        private final StudyListLocal dao = (StudyListLocal) JNDIUtils.lookup(StudyListLocal.JNDI_NAME);

        private final Map<String, List<String>> studyActions = new HashMap<String, List<String>>();

        @Override
        protected void populateItem(final Item<TCModel> item) {
            final TCModel tc = item.getModelObject();

            final StringBuilder jsStopEventPropagationInline = new StringBuilder(
                    "var event=arguments[0] || window.event; if (event.stopPropagation) {event.stopPropagation();} else {event.cancelBubble=True;};");

            item.setOutputMarkupId(true);
            item.add(new TCMultiLineLabel("title", new AbstractReadOnlyModel<String>() {
                public String getObject() {
                    if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.Title)) {
                        return TCUtilities.getLocalizedString("tc.case.text") + " " + tc.getId();
                    }
                    return tc.getTitle();
                }
            }, new AutoClampSettings(40)));
            item.add(new TCMultiLineLabel("abstract", new AbstractReadOnlyModel<String>() {
                public String getObject() {
                    if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.Abstract)) {
                        return TCUtilities.getLocalizedString("tc.obfuscation.text");
                    }
                    return tc.getAbstract();
                }
            }, new AutoClampSettings(40)));
            item.add(new TCMultiLineLabel("author", new AbstractReadOnlyModel<String>() {
                public String getObject() {
                    if (!attrVisibilityStrategy.isAttributeVisible(TCAttribute.AuthorName)) {
                        return TCUtilities.getLocalizedString("tc.obfuscation.text");
                    }
                    return tc.getAuthor();
                }
            }, new AutoClampSettings(40)));
            item.add(new Label("date", new Model<Date>(tc.getCreationDate())) {

                private static final long serialVersionUID = 1L;

                @Override
                public IConverter getConverter(Class<?> type) {
                    return new DateConverter() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public DateFormat getDateFormat(Locale locale) {
                            if (locale == null) {
                                locale = Locale.getDefault();
                            }

                            return DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
                        }
                    };
                }
            });

            final String stuid = tc.getStudyInstanceUID();
            if (dao != null && !studyActions.containsKey(stuid)) {
                studyActions.put(stuid, dao.findStudyPermissionActions(stuid, stPermHelper.getDicomRoles()));
            }

            item.add(Webviewer.getLink(tc, webviewerLinkProviders, stPermHelper,
                    new TooltipBehaviour("tc.result.table.", "webviewer"), modalWindow,
                    new WebviewerLinkClickedCallback() {
                        public void linkClicked(AjaxRequestTarget target) {
                            TCAuditLog.logTFImagesViewed(tc);
                        }
                    }).add(new SecurityBehavior(TCPanel.getModuleName() + ":webviewerInstanceLink")));

            final Component viewLink = new IndicatingAjaxLink<String>("tc-view") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    selectTC(item, tc, target);
                    openTC(tc, false, target);
                }

                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("ondblclick", jsStopEventPropagationInline);
                }

                @Override
                protected IAjaxCallDecorator getAjaxCallDecorator() {
                    try {
                        return TCPanel.getMaskingBehaviour().getAjaxCallDecorator();
                    } catch (Exception e) {
                        log.error("Failed to get IAjaxCallDecorator: ", e);
                    }
                    return null;
                }
            }.add(new Image("tcViewImg", ImageManager.IMAGE_COMMON_DICOM_DETAILS)
                    .add(new ImageSizeBehaviour("vertical-align: middle;")))
                    .add(new TooltipBehaviour("tc.result.table.", "view")).setOutputMarkupId(true);

            final Component editLink = new IndicatingAjaxLink<String>("tc-edit") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    selectTC(item, tc, target);
                    openTC(tc, true, target);
                }

                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("ondblclick", jsStopEventPropagationInline);
                }

                @Override
                protected IAjaxCallDecorator getAjaxCallDecorator() {
                    try {
                        return TCPanel.getMaskingBehaviour().getAjaxCallDecorator();
                    } catch (Exception e) {
                        log.error("Failed to get IAjaxCallDecorator: ", e);
                    }
                    return null;
                }
            }.add(new Image("tcEditImg", ImageManager.IMAGE_COMMON_DICOM_EDIT)
                    .add(new ImageSizeBehaviour("vertical-align: middle;")))
                    .add(new TooltipBehaviour("tc.result.table.", "edit"))
                    .add(new SecurityBehavior(TCPanel.getModuleName() + ":editTC")).setOutputMarkupId(true);

            final Component studyLink = new IndicatingAjaxLink<String>("tc-study") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    selectTC(item, tc, target);
                    try {
                        TCObject tcObject = TCObject.create(tc);
                        List<TCReferencedStudy> refStudies = tcObject.getReferencedStudies();
                        if (refStudies != null && !refStudies.isEmpty()) {
                            if (refStudies.size() == 1) {
                                studyPage.setStudyInstanceUID(refStudies.get(0).getStudyUID());
                            } else {
                                studyPage.setPatientIdAndIssuer(tc.getPatientId(), tc.getIssuerOfPatientId());
                            }
                        }
                        if (studyPage.getStudyInstanceUID() != null || studyPage.getPatientId() != null) {
                            studyPage.getStudyViewPort().clear();
                            studyWindow
                                    .setTitle(new StringResourceModel("tc.result.studywindow.title", this, null,
                                            new Object[] { maskNull(cutAtISOControl(tc.getTitle(), 40), "?"),
                                                    maskNull(cutAtISOControl(tc.getAbstract(), 25), "?"),
                                                    maskNull(cutAtISOControl(tc.getAuthor(), 20), "?"),
                                                    maskNull(tc.getCreationDate(), tc.getCreatedTime()) }));
                            studyWindow.setInitialWidth(1200);
                            studyWindow.setInitialHeight(600);
                            studyWindow.setMinimalWidth(800);
                            studyWindow.setMinimalHeight(400);
                            if (studyWindow.isShown()) {
                                log.warn("###### StudyView is already shown ???!!!");
                                try {
                                    Field showField = ModalWindow.class.getDeclaredField("shown");
                                    showField.setAccessible(true);
                                    showField.set(studyWindow, false);
                                } catch (Exception e) {
                                    log.error("Failed to reset shown Field from ModalWindow!");
                                }
                                log.info("###### studyWindow.isShown():" + studyWindow.isShown());
                            }
                            studyWindow.show(target);
                        } else {
                            log.warn("Showing TC referenced studies discarded: No referened study found!");
                            msgWin.setInfoMessage(getString("tc.result.studywindow.noStudies"));
                            msgWin.show(target);
                        }
                    } catch (Exception e) {
                        msgWin.setErrorMessage(getString("tc.result.studywindow.failed"));
                        msgWin.show(target);
                        log.error("Unable to show TC referenced studies!", e);
                    }
                }

                @Override
                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("ondblclick", jsStopEventPropagationInline);
                }

                @Override
                protected IAjaxCallDecorator getAjaxCallDecorator() {
                    try {
                        return TCPanel.getMaskingBehaviour().getAjaxCallDecorator();
                    } catch (Exception e) {
                        log.error("Failed to get IAjaxCallDecorator: ", e);
                    }
                    return null;
                }
            }.add(new Image("tcStudyImg", ImageManager.IMAGE_COMMON_SEARCH)
                    .add(new ImageSizeBehaviour("vertical-align: middle;")))
                    .add(new TooltipBehaviour("tc.result.table.", "showStudy"))
                    .add(new SecurityBehavior(TCPanel.getModuleName() + ":showTCStudy"))
                    .setOutputMarkupId(true);

            final Component forumLink = new IndicatingAjaxLink<String>("tc-forum") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    try {
                        TCForumPostsPanel content = new TCForumPostsPanel(forumWindow.getContentId(),
                                new Model<String>(TCForumIntegration
                                        .get(WebCfgDelegate.getInstance().getTCForumIntegrationType())
                                        .getPostsPageURL(tc)));
                        forumWindow.setInitialHeight(820);
                        forumWindow.setInitialWidth(1024);
                        forumWindow.setContent(content);
                        forumWindow.show(target);
                    } catch (Exception e) {
                        log.error("Unable to open case forum page!", e);
                    }
                }

                @Override
                public boolean isVisible() {
                    return TCForumIntegration
                            .get(WebCfgDelegate.getInstance().getTCForumIntegrationType()) != null;
                }

                @Override
                protected void onComponentTag(ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("ondblclick", jsStopEventPropagationInline);
                }

                @Override
                protected IAjaxCallDecorator getAjaxCallDecorator() {
                    try {
                        return TCPanel.getMaskingBehaviour().getAjaxCallDecorator();
                    } catch (Exception e) {
                        log.error("Failed to get IAjaxCallDecorator: ", e);
                    }
                    return null;
                }
            }.add(new Image("tcForumImg", ImageManager.IMAGE_TC_FORUM)
                    .add(new ImageSizeBehaviour("vertical-align: middle;")))
                    .add(new TooltipBehaviour("tc.result.table.", "showForum")).setOutputMarkupId(true);

            item.add(viewLink);
            item.add(editLink);
            item.add(studyLink);
            item.add(forumLink);

            item.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (selected != null && selected.equals(tc)) {
                        return "mouse-out-selected";
                    } else {
                        return item.getIndex() % 2 == 1 ? "even-mouse-out" : "odd-mouse-out";
                    }
                }
            }));

            item.add(new AttributeModifier("selected", true, new AbstractReadOnlyModel<String>() {
                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (selected != null && selected.equals(tc)) {
                        return "selected";
                    } else {
                        return null;
                    }
                }
            }));

            item.add(new AttributeModifier("onmouseover", true, new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    StringBuffer sbuf = new StringBuffer();
                    sbuf.append("if ($(this).attr('selected')==null) {");
                    sbuf.append("   $(this).removeClass();");
                    sbuf.append("   if (").append(item.getIndex())
                            .append("%2==1) $(this).addClass('even-mouse-over');");
                    sbuf.append("   else $(this).addClass('odd-mouse-over');");
                    sbuf.append("}");
                    return sbuf.toString();
                }
            }));

            item.add(new AttributeModifier("onmouseout", true, new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    StringBuffer sbuf = new StringBuffer();
                    sbuf.append("if ($(this).attr('selected')==null) {");
                    sbuf.append("   $(this).removeClass();");
                    sbuf.append("   if (").append(item.getIndex())
                            .append("%2==1) $(this).addClass('even-mouse-out');");
                    sbuf.append("   else $(this).addClass('odd-mouse-out');");
                    sbuf.append("}");
                    return sbuf.toString();
                }
            }));

            item.add(new AjaxEventBehavior("onclick") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    selectTC(item, tc, target);
                }
            });

            item.add(new AjaxEventBehavior("ondblclick") {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onEvent(AjaxRequestTarget target) {
                    boolean edit = WebCfgDelegate.getInstance().getTCEditOnDoubleClick();
                    if (edit) {
                        edit = SecureComponentHelper.isActionAuthorized(editLink, "render");
                    }

                    openTC(selected, edit, target);
                }

                @Override
                protected IAjaxCallDecorator getAjaxCallDecorator() {
                    try {
                        return new IAjaxCallDecorator() {
                            private static final long serialVersionUID = 1L;

                            public final CharSequence decorateScript(CharSequence script) {
                                return "if(typeof showMask == 'function') { showMask(); $('body').css('cursor','wait'); };"
                                        + script;
                            }

                            public final CharSequence decorateOnSuccessScript(CharSequence script) {
                                return "hideMask();$('body').css('cursor','');" + script;
                            }

                            public final CharSequence decorateOnFailureScript(CharSequence script) {
                                return "hideMask();$('body').css('cursor','');" + script;
                            }
                        };
                    } catch (Exception e) {
                        log.error("Failed to get IAjaxCallDecorator: ", e);
                    }
                    return null;
                }
            });
        }
    };
    dataView.setItemReuseStrategy(new ReuseIfModelsEqualStrategy());
    dataView.setItemsPerPage(WebCfgDelegate.getInstance().getDefaultFolderPagesize());
    dataView.setOutputMarkupId(true);

    SortLinkGroup sortGroup = new SortLinkGroup(dataView);
    add(new SortLink("sortTitle", sortGroup, TCModel.Sorter.Title));
    add(new SortLink("sortAbstract", sortGroup, TCModel.Sorter.Abstract));
    add(new SortLink("sortDate", sortGroup, TCModel.Sorter.Date));
    add(new SortLink("sortAuthor", sortGroup, TCModel.Sorter.Author));

    add(dataView);

    add(new Label("numberOfMatchingInstances", new StringResourceModel("tc.list.numberOfMatchingInstances",
            this, null, new Object[] { new Model<Integer>() {

                private static final long serialVersionUID = 1L;

                @Override
                public Integer getObject() {
                    return ((TCListModel) TCResultPanel.this.getDefaultModel()).getObject().size();
                }
            } })));

    add(new PagingNavigator("navigator", dataView));
}