Example usage for org.apache.wicket.request.resource ContextRelativeResource ContextRelativeResource

List of usage examples for org.apache.wicket.request.resource ContextRelativeResource ContextRelativeResource

Introduction

In this page you can find the example usage for org.apache.wicket.request.resource ContextRelativeResource ContextRelativeResource.

Prototype

public ContextRelativeResource(String pathRelativeToContextRoot) 

Source Link

Document

Construct.

Usage

From source file:biz.turnonline.ecosystem.origin.frontend.page.DecoratedPage.java

License:Apache License

protected Navbar newNavbar(String componentId) {
    Navbar navbar = new Navbar(componentId) {
        @Override/* w  w  w . java 2 s. c  o  m*/
        protected Image newBrandImage(String markupId) {
            Image image = super.newBrandImage(markupId);

            image.setImageResource(new ContextRelativeResource("logo.png"));

            return image;
        }
    };

    navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.RIGHT, newNavbarComponents()));
    navbar.get("brandName").get("brandImage").add(AttributeModifier.append("style", "max-height:32px;"));
    navbar.setInverted(true);

    return navbar;
}

From source file:ca.travelagency.components.CheckMarkPanel.java

License:Apache License

public CheckMarkPanel(String id, boolean checked) {
    super(id);/*from  w  w w. java  2 s .  c  om*/
    ContextRelativeResource contextRelativeResource = new ContextRelativeResource(
            "images/" + (checked ? "checked.png" : "blank.png"));
    add(new Image(IMAGE, contextRelativeResource));
}

From source file:ca.travelagency.invoice.items.ItemRowPanel.java

License:Apache License

private IndicatingAjaxLink<Void> makeMoveLink(final String id, final ItemsPanel itemsPanel) {
    IndicatingAjaxLink<Void> link = new IndicatingAjaxLink<Void>(id) {
        private static final long serialVersionUID = 1L;

        @Override/*from  w  ww . j  a va2  s  .com*/
        public void onClick(AjaxRequestTarget target) {
            if (MOVE_UP.equals(id)) {
                itemsPanel.moveUp(target, getInvoiceItem());
            } else {
                itemsPanel.moveDown(target, getInvoiceItem());
            }
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new BlockUIDecorator());
        }
    };

    ContextRelativeResource contextRelativeResource = new ContextRelativeResource(
            "images/" + (MOVE_UP.equals(id) ? "move_up.png" : "move_down.png"));
    link.add(new Image(MOVE_LABEL, contextRelativeResource));
    return link;
}

From source file:com.ccc.crest.need.template.FooterPanel.java

License:Open Source License

public FooterPanel(String id) {
    super(id);/*from ww  w. ja v  a  2s. c  o m*/
    Properties properties = CrestController.getCrestController().getProperties();
    String copyrightYear = properties.getProperty(CrestServlet.CopyrightYearKey);
    String copyrightowner = properties.getProperty(CrestServlet.CopyrightOwnerKey);
    String crestImg = "/images/server_error.png";
    if (((CrestController) CoreController.getController()).isCrestUp())
        crestImg = "/images/server.png";
    String xmlApiImg = "/images/server_error.png";
    if (((CrestController) CoreController.getController()).isXmlApiUp())
        xmlApiImg = "/images/server.png";
    add(new Label("crestServerLabel", "crest server"));
    add(new Image("crestServerImage", new ContextRelativeResource(crestImg)));
    add(new Label("xmlApiServerLabel", "xmlapi server"));
    add(new Image("xmlApiServerImage", new ContextRelativeResource(xmlApiImg)));
    add(new Label("copyright", copyrightYear + " " + copyrightowner));

    //        add(new NonCachingImage("crestServerImage", new AbstractReadOnlyModel<DynamicImageResource>()
    //        {
    //            @Override
    //            public DynamicImageResource getObject()
    //            {
    //                DynamicImageResource dir = new DynamicImageResource()
    //                {
    //                    private static final long serialVersionUID = 7691769266370001440L;
    //
    //                    @Override
    //                    protected byte[] getImageData(Attributes attributes)
    //                    {
    //                        String crestImg = "/images/server_error.png";
    //                        if (((CrestController) CoreController.getController()).isCrestUp())
    //                            crestImg = "/images/server.png";
    //                        ResourceReference ir;
    ////                        new ContextRelativeResource(crestImg).
    //                        return getCurrImage();
    //                    }
    //                };
    //                dir.setFormat("image/png");
    //                return dir;
    //            }
    //        }));
}

From source file:com.evolveum.midpoint.web.page.admin.users.PageUser.java

License:Apache License

private void initSummaryInfo(Form mainForm) {

    WebMarkupContainer summaryContainer = new WebMarkupContainer(ID_SUMMARY_PANEL);
    summaryContainer.setOutputMarkupId(true);

    summaryContainer.add(new VisibleEnableBehaviour() {

        @Override// w ww  .j a  va 2s  .  co  m
        public boolean isVisible() {
            if (getPageParameters().get(OnePageParameterEncoder.PARAMETER).isEmpty()) {
                return false;
            } else {
                return true;
            }
        }
    });

    mainForm.add(summaryContainer);

    summaryUser = new AbstractReadOnlyModel<PrismObject<UserType>>() {

        @Override
        public PrismObject<UserType> getObject() {
            ObjectWrapper user = userModel.getObject();
            return user.getObject();
        }
    };

    summaryContainer
            .add(new Label(ID_SUMMARY_NAME, new PrismPropertyModel<UserType>(summaryUser, UserType.F_NAME)));
    summaryContainer.add(new Label(ID_SUMMARY_FULL_NAME,
            new PrismPropertyModel<UserType>(summaryUser, UserType.F_FULL_NAME)));
    summaryContainer.add(new Label(ID_SUMMARY_GIVEN_NAME,
            new PrismPropertyModel<UserType>(summaryUser, UserType.F_GIVEN_NAME)));
    summaryContainer.add(new Label(ID_SUMMARY_FAMILY_NAME,
            new PrismPropertyModel<UserType>(summaryUser, UserType.F_FAMILY_NAME)));

    Image img = new Image(ID_SUMMARY_PHOTO, new AbstractReadOnlyModel<AbstractResource>() {

        @Override
        public AbstractResource getObject() {
            if (summaryUser.getObject().asObjectable().getJpegPhoto() != null) {
                return new ByteArrayResource("image/jpeg",
                        summaryUser.getObject().asObjectable().getJpegPhoto());
            } else {
                return new ContextRelativeResource("img/placeholder.png");
            }

        }
    });
    summaryContainer.add(img);
}

From source file:com.gitblit.wicket.WicketUtils.java

License:Apache License

public static ContextRelativeResource getResource(String file) {
    return new ContextRelativeResource(file);
}

From source file:cz.zcu.kiv.eegdatabase.wui.components.utils.ResourceUtils.java

License:Apache License

/**
 * Get image from directory images. Not tested.
 * //  ww  w. j  av a2  s .  com
 * @param id
 * @param imageFileName
 * @return
 */
public static Image getImage(String id, String imageFileName) {

    return new Image(id, new ContextRelativeResource("/images/" + imageFileName));
}

From source file:de.tudarmstadt.ukp.csniper.webapp.evaluation.page.EvaluationPage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 *///from  ww w.  j  a v  a  2  s.c  om
@SuppressWarnings({ "serial" })
public EvaluationPage() {
    contextViewsContainer = new WebMarkupContainer("contextViewsContainer") {
        {
            contextViews = new ListView<ContextView>("contextViews") {
                @Override
                protected void populateItem(ListItem aItem) {
                    aItem.add((Component) aItem.getModelObject());
                }
            };
            add(contextViews);
        }
    };
    contextViewsContainer.setOutputMarkupId(true);
    add(contextViewsContainer);

    columns = new ArrayList<IColumn<EvaluationResult, String>>();
    columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) {
        @Override
        public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId,
                final IModel<EvaluationResult> model) {
            EmbeddableImage iconContext = new EmbeddableImage(aComponentId,
                    new ContextRelativeResource("images/context.png"));
            iconContext.add(new AjaxEventBehavior("onclick") {
                @Override
                protected void onEvent(AjaxRequestTarget aTarget) {
                    try {
                        contextViews
                                .setList(asList(new ContextView(contextProvider, model.getObject().getItem())));
                        aTarget.add(contextViewsContainer);
                    } catch (IOException e) {
                        aTarget.add(getFeedbackPanel());
                        error("Unable to load context: " + e.getMessage());
                    }
                }
            });
            iconContext.add(new AttributeModifier("class", new Model<String>("clickableElement")));
            aCellItem.add(iconContext);
        }
    });
    columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) {
        @Override
        public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem,
                final String aComponentId, final IModel<EvaluationResult> model) {
            // PopupLink pl = new PopupLink(aComponentId, new AnalysisPage(model.getObject()
            // .getItem()), "analysis", "Analyse", 800, 600);
            // pl.add(new AttributeModifier("class", new Model<String>("clickableElement")));
            // aCellItem.add(pl);

            EmbeddableImage iconAnalysis = new EmbeddableImage(aComponentId,
                    new ContextRelativeResource("images/analysis.png"));
            iconAnalysis.add(new AjaxEventBehavior("onclick") {
                @Override
                protected void onEvent(AjaxRequestTarget aTarget) {
                    EvaluationItem item = model.getObject().getItem();
                    CachedParse cachedTree = repository.getCachedParse(item);
                    ParseTreeResource ptr;

                    if (cachedTree != null) {
                        ptr = new ParseTreeResource(cachedTree.getPennTree());
                    } else {
                        if (pp == null) {
                            pp = new ParsingPipeline();
                        }
                        CasHolder ch = new CasHolder(pp.parseInput("stanfordParser",
                                corpusService.getCorpus(item.getCollectionId()).getLanguage(),
                                item.getCoveredText()));
                        ptr = new ParseTreeResource(ch);
                    }
                    analysisModal.setContent(new AnalysisPanel(analysisModal.getContentId(), ptr));
                    analysisModal.show(aTarget);
                }
            });
            iconAnalysis.add(new AttributeModifier("class", new Model<String>("clickableElement")));
            aCellItem.add(iconAnalysis);
        }
    });
    // columns.add(new PropertyColumn(new Model<String>("ID"), "id", "id"));
    // columns.add(new PropertyColumn(new Model<String>("Collection"), "item.collectionId",
    // "item.collectionId"));
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Doc"), "item.documentId",
            "item.documentId"));
    // columns.add(new PropertyColumn(new Model<String>("Begin"), "item.beginOffset",
    // "item.beginOffset"));
    // columns.add(new PropertyColumn(new Model<String>("End"), "item.endOffset",
    // "item.endOffset"));
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Left"), "item.leftContext",
            "item.leftContext") {
        @Override
        public String getCssClass() {
            return contextAvailable ? "leftContext" : " hideCol";
        }
    });
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Match"), "item.match",
            "item.match") {
        @Override
        public String getCssClass() {
            return contextAvailable ? "match nowrap" : null;
        }
    });
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Right"), "item.rightContext",
            "item.rightContext") {
        @Override
        public String getCssClass() {
            return contextAvailable ? "rightContext" : " hideCol";
        }
    });
    columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("Label"), "result") {
        @Override
        public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId,
                final IModel<EvaluationResult> model) {
            final Label resultLabel = new Label(aComponentId, new PropertyModel(model, "result"));
            resultLabel.setOutputMarkupId(true);
            aCellItem.add(resultLabel);
            if (showResultColumns) {
                aCellItem.add(AttributeModifier.replace("class",
                        new Model<String>("editable " + model.getObject().getResult().toLowerCase())));
            }

            aCellItem.add(new AjaxEventBehavior("onclick") {
                @Override
                protected void onEvent(AjaxRequestTarget aTarget) {
                    EvaluationResult result = model.getObject();

                    // cycle to next result
                    Mark newResult = Mark.fromString(result.getResult()).next();

                    // update database
                    result.setResult(newResult.getTitle());
                    repository.updateEvaluationResult(result);

                    // update DataTable
                    aCellItem.add(AttributeModifier.replace("class",
                            new Model<String>("editable " + newResult.getTitle().toLowerCase())));
                    aTarget.add(resultLabel, aCellItem);
                }
            });
        }

        @Override
        public String getCssClass() {
            return (showResultColumns ? "" : " hideCol");
        }
    });
    columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("Comment"), "comment") {
        @Override
        public void populateItem(Item<ICellPopulator<EvaluationResult>> cellItem, String componentId,
                final IModel<EvaluationResult> model) {
            cellItem.add(
                    new AjaxEditableLabel<String>(componentId, new PropertyModel<String>(model, "comment")) {
                        @Override
                        public void onSubmit(final AjaxRequestTarget aTarget) {
                            super.onSubmit(aTarget);

                            EvaluationResult result = model.getObject();

                            // get new comment
                            String newComment = getEditor().getInput();

                            // update database
                            result.setComment(newComment);
                            repository.updateEvaluationResult(result);
                        }

                        @Override
                        public void onError(AjaxRequestTarget aTarget) {
                            super.onError(aTarget);
                            aTarget.add(getFeedbackPanel());
                        }
                    }.add(new DbFieldMaxLengthValidator(projectRepository, "EvaluationResult", "comment")));
        }

        @Override
        public String getCssClass() {
            return "editable" + (showResultColumns ? "" : " hideCol");
        }
    });

    // collection and type
    add(parentOptionsForm = new ParentOptionsForm("parentOptions"));

    tabs = new Tabs("tabs");
    tabs.setVisible(false);
    // query tab
    tabs.add(queryForm = new QueryForm("queryForm"));
    // revision tab
    tabs.add(reviewForm = new ReviewForm("reviewForm"));
    // completion tab
    tabs.add(new Form("completeForm") {
        {
            add(new ExtendedIndicatingAjaxButton("completeButton", new Model<String>("Complete"),
                    new Model<String>("Running query ...")) {
                {
                    setDefaultFormProcessing(false);
                }

                @Override
                public void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) {
                    AnnotationType type = parentOptionsForm.typeInput.getModelObject();
                    if (type == null) {
                        error(LocalizerUtil.getString(parentOptionsForm.typeInput, "Required"));
                        aTarget.add(getFeedbackPanel());
                        return;
                    }

                    ParentOptionsFormModel pModel = parentOptionsForm.getModelObject();
                    String user = SecurityContextHolder.getContext().getAuthentication().getName();
                    List<String> otherUsers = new ArrayList<String>(repository.listUsers());
                    otherUsers.remove(user);

                    // get items, create/persist results
                    List<EvaluationItem> items = repository.listEvaluationResultsMissing(pModel.collectionId,
                            pModel.type.getName(), user, otherUsers);
                    List<EvaluationResult> results = createEvaluationResults(items);
                    repository.writeEvaluationResults(results);

                    // persis. results: hide saveButton, show result columns and filter options
                    limitForm.setVisible(false);
                    filterForm.setChoices(ResultFilter.values());
                    showColumnsForm.setVisible(true && !pModel.type.getAdditionalColumns().isEmpty());
                    showResultColumns(true);
                    saveButton.setVisible(false);
                    predictButton.setVisible(true);
                    samplesetButton.setVisible(true);

                    // update dataprovider
                    dataProvider = new SortableEvaluationResultDataProvider(results);
                    dataProvider.setSort("item.documentId", SortOrder.ASCENDING);
                    dataProvider.setFilter(ResultFilter.ALL);
                    // then update the table
                    resultTable = resultTable.replaceWith(new CustomDataTable<EvaluationResult>("resultTable",
                            getAllColumns(pModel.type), dataProvider, ROWS_PER_PAGE));
                    contextAvailable = false;

                    updateComponents(aTarget);
                }

                @Override
                public void onError(AjaxRequestTarget aTarget, Form<?> aForm) {
                    super.onError(aTarget, aForm);
                    // Make sure the feedback messages are rendered
                    aTarget.add(getFeedbackPanel());
                }
            });
        }
    });
    // sampleset tab
    tabs.add(samplesetForm = new SamplesetForm("samplesetForm"));
    // sampleset tab
    tabs.add(findForm = new FindForm("findForm"));
    add(tabs);

    add(new Label("description", new LoadableDetachableModel<String>() {
        @Override
        protected String load() {
            Object value = PropertyResolver.getValue("type.description", parentOptionsForm.getModelObject());
            if (value != null) {
                RenderContext context = new BaseRenderContext();
                RenderEngine engine = new BaseRenderEngine();
                return engine.render(String.valueOf(value), context);
            } else {
                return getString("page.selectTypeHint");
            }
        }
    }).setEscapeModelStrings(false));
    add(filterForm = (FilterForm) new FilterForm("filterForm").setOutputMarkupPlaceholderTag(true));
    add(showColumnsForm = (ShowColumnsForm) new ShowColumnsForm("showColumnsForm")
            .setOutputMarkupPlaceholderTag(true));
    add(resultTable = new Label("resultTable").setOutputMarkupId(true));

    add(predictionModal = new ModalWindow("predictionModal"));
    final PredictionPanel predictionPanel = new PredictionPanel(predictionModal.getContentId());
    predictionModal.setContent(predictionPanel);
    predictionModal.setTitle("Predict results");
    predictionModal.setAutoSize(false);
    predictionModal.setInitialWidth(550);
    predictionModal.setInitialHeight(350);
    predictionModal.setCloseButtonCallback(new CloseButtonCallback() {
        @Override
        public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) {
            predictionPanel.cancel(aTarget);
            return true;
        }
    });

    add(samplesetModal = new ModalWindow("samplesetModal"));
    samplesetModal.setContent(new SamplesetPanel(samplesetModal.getContentId()));
    samplesetModal.setTitle("Create / Extend sampleset");
    samplesetModal.setAutoSize(true);

    add(analysisModal = new ModalWindow("analysisModal"));
    analysisModal.setTitle("Parse tree");
    analysisModal.setInitialWidth(65 * 16);
    analysisModal.setInitialHeight(65 * 9);
    // autosize does not work...
    // analysisModal.setAutoSize(true);

    add(new Form("saveForm") {
        {
            add(saveButton = (ExtendedIndicatingAjaxButton) new ExtendedIndicatingAjaxButton("saveButton",
                    new Model<String>("Start annotating"), new Model<String>("Preparing ...")) {
                @Override
                protected void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) {
                    // persist items and results
                    List<EvaluationItem> items = dataProvider.getItems();
                    items = repository.writeEvaluationItems(items);
                    List<EvaluationResult> results = createEvaluationResults(items);
                    dataProvider.setResults(results);
                    repository.writeEvaluationResults(results);

                    // save results, query
                    ParentOptionsFormModel pModel = parentOptionsForm.getModelObject();
                    String user = SecurityContextHolder.getContext().getAuthentication().getName();
                    QueryFormModel model = queryForm.getModelObject();
                    if (model.engine != null && !StringUtils.isBlank(model.query)) {
                        repository.recordQuery(model.engine.getName(), model.query, pModel.collectionId,
                                pModel.type.getName(), model.comment, user);
                    }

                    // hide saveButton, show result columns and filter options
                    limitForm.setVisible(false);
                    filterForm.setChoices(ResultFilter.values());
                    showColumnsForm.setVisible(true && !pModel.type.getAdditionalColumns().isEmpty());
                    showResultColumns(true);
                    saveButton.setVisible(false);
                    predictButton.setVisible(true);
                    samplesetButton.setVisible(true);

                    updateComponents(aTarget);
                }
            }.setOutputMarkupPlaceholderTag(true));

            add(predictButton = (ExtendedIndicatingAjaxButton) new ExtendedIndicatingAjaxButton("predictButton",
                    new Model<String>("Predict results"), new Model<String>("Predicting ...")) {
                @Override
                protected void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) {
                    aTarget.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
                    predictionModal.show(aTarget);
                }
            }.setOutputMarkupPlaceholderTag(true));

            add(samplesetButton = (ExtendedIndicatingAjaxButton) new ExtendedIndicatingAjaxButton(
                    "samplesetButton", new Model<String>("Save results as sampleset"),
                    new Model<String>("Saving...")) {
                @Override
                public void onSubmit(AjaxRequestTarget aTarget, Form<?> aForm) {
                    samplesetModal.show(aTarget);
                }
            }.setOutputMarkupPlaceholderTag(true));
        }
    });
    add(limitForm = (LimitForm) new LimitForm("limit").setOutputMarkupPlaceholderTag(true));

    // at start, don't show: save button, results columns, filter
    limitForm.setVisible(false);
    filterForm.setChoices();
    showColumnsForm.setVisible(false);
    showResultColumns(false);
    saveButton.setVisible(false);
    predictButton.setVisible(false);
    samplesetButton.setVisible(false);
}

From source file:de.tudarmstadt.ukp.csniper.webapp.search.page.SearchPage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 */// ww  w .  ja v a2s .  c om
@SuppressWarnings({ "serial" })
public SearchPage() {
    contextViewsContainer = new WebMarkupContainer("contextViewsContainer") {
        {
            contextViews = new ListView<ContextView>("contextViews") {
                @Override
                protected void populateItem(ListItem aItem) {
                    aItem.add((Component) aItem.getModelObject());
                }
            };
            add(contextViews);
        }
    };
    contextViewsContainer.setOutputMarkupId(true);
    add(contextViewsContainer);

    columns = new ArrayList<IColumn<EvaluationResult, String>>();
    columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) {
        @Override
        public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId,
                final IModel<EvaluationResult> model) {
            EmbeddableImage iconContext = new EmbeddableImage(aComponentId,
                    new ContextRelativeResource("images/context.png"));
            iconContext.add(new AjaxEventBehavior("onclick") {
                @Override
                protected void onEvent(AjaxRequestTarget aTarget) {
                    try {
                        contextViews
                                .setList(asList(new ContextView(contextProvider, model.getObject().getItem())));
                        aTarget.add(contextViewsContainer);
                    } catch (IOException e) {
                        error("Unable to load context: " + e.getMessage());
                        aTarget.add(getFeedbackPanel());
                    }
                }
            });
            iconContext.add(new AttributeModifier("class", new Model<String>("clickableElement")));
            aCellItem.add(iconContext);
        }
    });
    columns.add(new AbstractColumn<EvaluationResult, String>(new Model<String>("")) {
        @Override
        public void populateItem(final Item<ICellPopulator<EvaluationResult>> aCellItem, String aComponentId,
                final IModel<EvaluationResult> model) {
            EmbeddableImage iconAnalysis = new EmbeddableImage(aComponentId,
                    new ContextRelativeResource("images/analysis.png"));
            iconAnalysis.add(new AjaxEventBehavior("onclick") {
                @Override
                protected void onEvent(AjaxRequestTarget aTarget) {
                    EvaluationItem item = model.getObject().getItem();
                    CachedParse cachedTree = repository.getCachedParse(item);
                    ParseTreeResource ptr;

                    if (cachedTree != null) {
                        ptr = new ParseTreeResource(cachedTree.getPennTree());
                    } else {
                        if (pp == null) {
                            pp = new ParsingPipeline();
                        }
                        CasHolder ch = new CasHolder(pp.parseInput("stanfordParser",
                                corpusService.getCorpus(item.getCollectionId()).getLanguage(),
                                item.getCoveredText()));
                        ptr = new ParseTreeResource(ch);
                    }
                    analysisModal.setContent(new AnalysisPanel(analysisModal.getContentId(), ptr));
                    analysisModal.show(aTarget);
                }
            });
            iconAnalysis.add(new AttributeModifier("class", new Model<String>("clickableElement")));
            aCellItem.add(iconAnalysis);
        }
    });
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Doc"), "item.documentId",
            "item.documentId"));
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Left"), "item.leftContext",
            "item.leftContext") {
        @Override
        public String getCssClass() {
            return contextAvailable ? "leftContext" : " hideCol";
        }
    });
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Match"), "item.match",
            "item.match") {
        @Override
        public String getCssClass() {
            return contextAvailable ? "match nowrap" : null;
        }
    });
    columns.add(new PropertyColumn<EvaluationResult, String>(new Model<String>("Right"), "item.rightContext",
            "item.rightContext") {
        @Override
        public String getCssClass() {
            return contextAvailable ? "rightContext" : " hideCol";
        }
    });

    add(queryForm = new QueryForm("queryForm"));

    add(limitForm = (LimitForm) new LimitForm("limit").setOutputMarkupPlaceholderTag(true));

    add(resultTable = new Label("resultTable").setOutputMarkupId(true));

    add(analysisModal = new ModalWindow("analysisModal"));
    analysisModal.setTitle("Parse tree");
    analysisModal.setInitialWidth(65 * 16);
    analysisModal.setInitialHeight(65 * 9);
    // autosize does not work...
    // analysisModal.setAutoSize(true);

    // at start, don't show: save button, results columns, filter
    limitForm.setVisible(false);
}

From source file:de.tudarmstadt.ukp.csniper.webapp.statistics.page.StatisticsPage.java

License:Apache License

/**
 * Constructor that is invoked when page is invoked without a session.
 *//*from w  w  w .  j a  v a  2 s  .  co m*/
public StatisticsPage() {
    super();
    contextViewsContainer = new WebMarkupContainer("contextViewsContainer") {
        {
            contextViews = new ListView<ContextView>("contextViews") {
                @Override
                protected void populateItem(ListItem aItem) {
                    aItem.add((Component) aItem.getModelObject());
                }
            };
            add(contextViews);
        }
    };
    contextViewsContainer.setOutputMarkupId(true);
    add(contextViewsContainer);

    columns.add(new AbstractColumn<AggregatedEvaluationResult, String>(new Model<String>("")) {
        @Override
        public void populateItem(final Item<ICellPopulator<AggregatedEvaluationResult>> aCellItem,
                String aComponentId, final IModel<AggregatedEvaluationResult> model) {
            EmbeddableImage iconContext = new EmbeddableImage(aComponentId,
                    new ContextRelativeResource("images/context.png"));
            iconContext.add(new AjaxEventBehavior("onclick") {
                @Override
                protected void onEvent(AjaxRequestTarget aTarget) {
                    try {
                        contextViews
                                .setList(asList(new ContextView(contextProvider, model.getObject().getItem())));
                        aTarget.add(contextViewsContainer);
                    } catch (IOException e) {
                        error("Unable to load context: " + e.getMessage());
                    }
                }
            });
            iconContext.add(new AttributeModifier("class", new Model<String>("clickableElement")));
            aCellItem.add(iconContext);
        }
    });
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Type"), "item.type",
            "item.type") {
        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return super.getCssClass() + " nowrap";
        }
    });
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Collection"),
            "item.collectionId", "item.collectionId") {
        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return super.getCssClass() + " nowrap";
        }

    });
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Document"),
            "item.documentId", "item.documentId") {
        private static final long serialVersionUID = 1L;

        @Override
        public String getCssClass() {
            return super.getCssClass() + " nowrap";
        }
    });
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Item"),
            "item.coveredText", "item.coveredText"));
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("#Correct"), "correct",
            "correct"));
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("#Wrong"), "wrong",
            "wrong"));
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("#Incomplete"),
            "incomplete", "incomplete"));
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Aggregated"),
            "classification", "classification"));
    // {
    // private static final long serialVersionUID = 1L;
    //
    // @Override
    // public void populateItem(Item<ICellPopulator<AggregatedEvaluationResult>> aCellItem,
    // String aComponentId, IModel<AggregatedEvaluationResult> aRowModel)
    // {
    // StatisticsFormModel sModel = statisticsForm.getModelObject();
    // ResultFilter aggregated = aRowModel.getObject().getClassification(sModel.users,
    // sModel.userThreshold, sModel.confidenceThreshold);
    // aCellItem.add(new Label(aComponentId, aggregated.getLabel()));
    // }
    // });
    columns.add(new PropertyColumn<AggregatedEvaluationResult, String>(new Model<String>("Confidence"),
            "confidence", "confidence"));
    // {
    // private static final long serialVersionUID = 1L;
    //
    // @Override
    // public void populateItem(Item<ICellPopulator<AggregatedEvaluationResult>> aCellItem,
    // String aComponentId, IModel<AggregatedEvaluationResult> aRowModel)
    // {
    // StatisticsFormModel sModel = statisticsForm.getModelObject();
    // double confidence = aRowModel.getObject().getConfidence(sModel.users,
    // sModel.userThreshold);
    // aCellItem.add(new Label(aComponentId, Double.toString(confidence)));
    // }
    // });

    add(exportModal = new ModalWindow("exportModal"));
    final ExportPanel exportPanel = new ExportPanel(exportModal.getContentId());
    exportModal.setContent(exportPanel);
    exportModal.setTitle("Export");
    exportModal.setInitialWidth(550);
    exportModal.setInitialHeight(350);
    exportModal.setCloseButtonCallback(new CloseButtonCallback() {
        @Override
        public boolean onCloseButtonClicked(AjaxRequestTarget aTarget) {
            exportPanel.cancel(aTarget);
            return true;
        }
    });

    add(exportDownload = new AjaxFileDownload());

    add(statisticsForm = new StatisticsForm("statisticsForm"));
    add(displayOptions = (WebMarkupContainer) new WebMarkupContainer("displayOptions") {
        private static final long serialVersionUID = 1L;
        {
            add(new Label("filterLabel",
                    new PropertyModel<List<ResultFilter>>(statisticsForm, "modelObject.filters")));
            add(new Label("collectionIdLabel",
                    new PropertyModel<Set<String>>(statisticsForm, "modelObject.collections")));
            add(new Label("typeLabel",
                    new PropertyModel<Set<AnnotationType>>(statisticsForm, "modelObject.types")) {
                private static final long serialVersionUID = 1L;

                @Override
                public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
                    Set<AnnotationType> types = (Set<AnnotationType>) getDefaultModelObject();
                    List<String> typeNames = new ArrayList<String>();
                    for (AnnotationType t : types) {
                        typeNames.add(t.getName());
                    }
                    Collections.sort(typeNames);
                    replaceComponentTagBody(markupStream, openTag, typeNames.toString());
                };
            });
        }
    }.setOutputMarkupPlaceholderTag(true).setVisible(false));
    add(resultTable = new Label("resultTable").setOutputMarkupId(true));
}