Example usage for org.apache.wicket.markup.html.basic MultiLineLabel MultiLineLabel

List of usage examples for org.apache.wicket.markup.html.basic MultiLineLabel MultiLineLabel

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.basic MultiLineLabel MultiLineLabel.

Prototype

public MultiLineLabel(final String id) 

Source Link

Document

Constructor.

Usage

From source file:cz.zcu.kiv.eegdatabase.wui.ui.articles.components.ArticleCommentPanel.java

License:Apache License

public ArticleCommentPanel(String id, IModel<ArticleComment> model) {
    super(id, new CompoundPropertyModel<ArticleComment>(model));

    setRenderBodyOnly(true);//from   w w w.  j  ava2  s  .c  o  m
    add(new TimestampLabel("time", model.getObject().getTime(), StringUtils.DATE_TIME_FORMAT_PATTER));
    add(new Label("person.givenname").setRenderBodyOnly(true));
    add(new Label("person.surname").setRenderBodyOnly(true));

    add(new MultiLineLabel("text"));
    List<ArticleComment> commentList = new ArrayList<ArticleComment>(model.getObject().getChildren());
    PropertyListView<ArticleComment> comments = new PropertyListView<ArticleComment>("children", commentList) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ArticleComment> item) {
            item.add(new ArticleCommentPanel("comments", item.getModel()));
        }
    };
    comments.setRenderBodyOnly(true);

    PageParameters parameters = PageParametersUtils.getPageParameters(PageParametersUtils.ARTICLE,
            model.getObject().getArticle().getArticleId());
    parameters = PageParametersUtils.addParameters(parameters, PageParametersUtils.COMMENT,
            model.getObject().getCommentId());

    BookmarkablePageLink<Void> addCommentLink = new BookmarkablePageLink<Void>("addCommentLink",
            ArticleCommentFormPage.class, parameters);

    add(comments, addCommentLink);
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.articles.ViewArticlePage.java

License:Apache License

private void setupComponents(int articleId) {

    add(new ButtonPageMenu("leftMenu", ArticlesPageLeftMenu.values()));
    PageParameters pageParameters = PageParametersUtils.getDefaultPageParameters(articleId);

    final Article article = articleFacade.getArticleDetail(articleId, EEGDataBaseSession.get().getLoggedUser());
    CompoundPropertyModel<Article> model = new CompoundPropertyModel<Article>(article);
    setDefaultModel(model);/*w  w w. j a  v a 2  s. com*/

    Label pageTitle = new Label("title");
    add(pageTitle);

    ResearchGroup group = article.getResearchGroup();
    add(new Label("group", group == null ? ResourceUtils.getString("label.publicArticle") : group.getTitle()));
    add(new TimestampLabel("time", article.getTime(), StringUtils.DATE_FORMAT_PATTER));
    add(new Label("person.givenname").setRenderBodyOnly(true));
    add(new Label("person.surname").setRenderBodyOnly(true));

    BookmarkablePageLink<Void> editLink = new BookmarkablePageLink<Void>("editLink", ArticleFormPage.class,
            pageParameters);
    AjaxConfirmLink<Void> deleteLink = new AjaxConfirmLink<Void>("deleteLink",
            ResourceUtils.getString("text.delete.article")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            // delete article
            articleFacade.delete(article);
            setResponsePage(ArticlesPage.class);
        }
    };
    Person loggedUser = EEGDataBaseSession.get().getLoggedUser();
    boolean showControlLinks = EEGDataBaseSession.get().hasRole(UserRole.ROLE_ADMIN.name())
            || loggedUser.getPersonId() == article.getPerson().getPersonId();

    editLink.setVisibilityAllowed(showControlLinks);
    deleteLink.setVisibilityAllowed(showControlLinks);
    add(editLink, deleteLink);

    add(new SubscribeLink("subscribe", model, articleFacade));

    add(new MultiLineLabel("text"));

    ArticleComment comment = new ArticleComment(loggedUser);
    comment.setArticle(article);
    ArticleCommentFormPanel articleCommentFormPanel = new ArticleCommentFormPanel("commentFormPanel",
            new Model<ArticleComment>(comment), getFeedback());
    boolean canUserAddComment = securityFacade.userIsGroupAdmin() || securityFacade.userIsExperimenter();
    articleCommentFormPanel.setVisibilityAllowed(canUserAddComment);
    add(articleCommentFormPanel);

    List<ArticleComment> commentList = new ArrayList<ArticleComment>(model.getObject().getArticleComments());
    PropertyListView<ArticleComment> comments = new PropertyListView<ArticleComment>("articleComments",
            commentList) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<ArticleComment> item) {
            item.add(new ArticleCommentPanel("commentPanel", item.getModel()));
        }
    };
    comments.setRenderBodyOnly(true);

    add(comments);

}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.licenses.components.ViewLicensePanel.java

public ViewLicensePanel(String id, final IModel<License> model, boolean showRemoveButton) {
    super(id, new CompoundPropertyModel<License>(model));
    this.model = model;

    add(new Label("title"));
    add(new Label("licenseType"));
    add(new MultiLineLabel("description"));

    IModel<String> link = new PropertyModel<String>(model, "link");
    licenseLink = new ExternalLink("link", link, link);
    add(licenseLink);/*from   ww  w . jav a2  s.  c o m*/

    add(new Label("attachmentFileName"));
    boolean isContent = model.getObject() != null && model.getObject().getAttachmentFileName() != null;
    ByteArrayResource res;
    if (isContent) {
        res = new ByteArrayResource("", facade.getLicenseAttachmentContent(model.getObject().getLicenseId()),
                model.getObject().getAttachmentFileName());
    } else {
        res = new ByteArrayResource("");
    }
    downloadLink = new ResourceLink<Void>("download", res);
    downloadLink.setVisible(isContent);
    add(downloadLink);

    this.form = new Form<Void>("form");
    add(form);
    button = new AjaxButton("removeButton", ResourceUtils.getModel("button.remove")) {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            onRemoveAction(model, target, form);
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            this.setVisible(true);
        }
    };
    button.setVisibilityAllowed(showRemoveButton);
    form.add(button);

}

From source file:net.lunikon.rethul.web.components.StringEditPanel.java

License:Open Source License

private void build() {
    stringModel = createStringModel();//from  w  ww. j  a v  a 2s .co  m

    // form
    form = new Form<LocalizedString>("form", new CompoundPropertyModel<LocalizedString>(stringModel)) {
        @Override
        protected void beforeUpdateFormComponentModels() {
            if (getModelObject() == null)
                setModelObject(new LocalizedString());
        }

        @Override
        protected void onSubmit() {
            LocalizedString string = getModelObject();
            updateLocalizedString(string);
        }
    };
    add(form);

    // master information
    WebMarkupContainer master = new WebMarkupContainer("master");
    master.setDefaultModel(new CompoundPropertyModel<LocalizedString>(getModel()));
    form.add(master);

    IModel<String> statusModel = new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            LocalizedString ls = stringModel.getObject();
            if (ls == null)
                return "missing";
            return ls.isPending() ? "pending" : "done";
        }
    };
    master.add(new Label("key") //
            .add(new AttributeAppender("class", true, statusModel, " ")));
    master.add(new MultiLineLabel("translation"));

    // text area
    TextArea<String> translation = new TextArea<String>("translation");
    translation.setType(String.class);
    translation.setRequired(true);
    form.add(translation);

    // actions
    form.add(new Button("save") {
        @Override
        public void onSubmit() {
            // in all cases, remove pending-mark
            form.getModelObject().setPending(false);

            onSave();
        }
    });
    form.add(new Button("savePending") {
        @Override
        public void onSubmit() {
            // mark string as pending
            form.getModelObject().setPending(true);

            onSaveAsPending();
        }
    });

    // when using the master text, regular form processing has to be
    // by-passed
    form.add(new Button("useMaster") {
        @Override
        public void onSubmit() {
            LocalizedString master = StringEditPanel.this.getModelObject();
            if (master == null)
                return;

            // create new object if doesn't exist
            LocalizedString string = form.getModelObject();
            if (string == null) {
                string = new LocalizedString();
                form.setModelObject(string);
            }

            // use text from master to update localized string
            String translation = master.getTranslation();
            string.setTranslation(translation);
            string.setPending(false);

            // clear form
            clear();

            onUseMaster();

            // update string
            updateLocalizedString(string);
        }
    }.setDefaultFormProcessing(false));
}

From source file:net.lunikon.rethul.web.pages.SearchPage.java

License:Open Source License

private void buildTextSearch() {
    searchResultsModel = new LoadableDetachableModel<List<LocalizedString>>() {
        @Override/* ww w .  ja v  a 2  s .c  o  m*/
        protected List<LocalizedString> load() {
            if (searchPhrase == null)
                return Collections.emptyList();

            if (searchKey)
                return stringsDAO.searchKeys(getModelObject(), getFileLocale(), searchPhrase);

            return stringsDAO.search(getModelObject(), getFileLocale(), searchPhrase);
        }
    };

    // SEARCH form
    final IModel<String> phraseModel = new Model<String>();
    Form<Void> form = new Form<Void>("text-form") {
        @Override
        protected void onSubmit() {
            searchPhrase = phraseModel.getObject();
            searchKey = false;

            if (searchResultsModel.getObject().isEmpty())
                error(getString("SearchPage.e.text.failed"));
            else
                currentKey = null; // hide editor
        }
    };
    add(form);

    TextField<String> phrase = new RequiredTextField<String>("phrase", phraseModel);
    phrase.add(StringValidator.lengthBetween(1, 255));
    form.add(phrase);
    phrase.setLabel(new ResourceModel("SearchPage.search.text.label"));
    form.add(new SimpleFormComponentLabel("phrase-label", phrase));

    // SEARCH results
    add(new PropertyListView<LocalizedString>("text-results", searchResultsModel) {
        @Override
        protected void populateItem(ListItem<LocalizedString> item) {
            final String key = item.getModelObject().getKey();
            item.add(new Label("key"));
            item.add(new MultiLineLabel("translation"));
            item.add(new Link<LocalizedString>("select", item.getModel()) {
                @Override
                public void onClick() {
                    currentKey = key;
                }
            });
        }

        @Override
        public boolean isVisible() {
            return !getModelObject().isEmpty();
        }
    });
}

From source file:org.wicketstuff.jmx.markup.html.tree.detail.OperationPanel.java

License:Apache License

public OperationPanel(String id, JmxMBeanWrapper bean, final MBeanOperationInfo operation) {
    super(id, bean, operation);
    setOutputMarkupId(true);/*from www  .  ja  va 2s . com*/

    resultLabel = new MultiLineLabel("result");
    resultLabel.setOutputMarkupPlaceholderTag(true).setEscapeModelStrings(false);
    add(resultLabel.setVisible(false));
}

From source file:org.wicket_sapporo.workshop01.page.form.FormConfirmationPage.java

License:Apache License

public FormConfirmationPage(IModel<FormPageBean> formPageModel) {
    // setDefaultModel(IModel) ????Model?.
    // ?? CompoundPropertyModel ??????? CompoundPropertyModel ???????.
    setDefaultModel(CompoundPropertyModel.of(formPageModel));

    // CompoundPropertyModel????add??????
    // formPageModel???=????formPageBean?????.
    add(new Label("name"));
    add(new Label("age"));
    add(new MultiLineLabel("introduction"));

    // homePageLink ??WebApplication??HomePage?????????
    add(homePageLink("toHomePage"));
}

From source file:pl.edu.agh.student.view.HomePage.java

License:Open Source License

/**
 * Constructor that is invoked when page is invoked without a session.
 *
 * @param parameters Page parameters/*from w  ww.  j  a  va2  s  .  c o m*/
 */
public HomePage(final PageParameters parameters) {

    // Add the simplest type of label
    add(new Label("message", "If you see this message wicket is properly configured and running"));

    // Add commentListView of existing comments
    ArrayList<Data> data = new ArrayList<Data>();
    data.add(new Data(new Date(), "aaaa"));
    data.add(new Data(new Date(), "aaaa"));
    data.add(new Data(new Date(), "aaaa"));

    add(new PropertyListView<Data>("comments", data) {
        @Override
        public void populateItem(final ListItem<Data> listItem) {
            listItem.add(new Label("date"));
            listItem.add(new MultiLineLabel("text"));
        }
    }).setVersioned(false);
}