Java Code Examples for org.apache.wicket.markup.html.basic.Label#add()
The following examples show how to use
org.apache.wicket.markup.html.basic.Label#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RangeFilterPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private WebMarkupContainer getRangeContainer(final Component component, final String filterId, boolean first) { WebMarkupContainer container = new WebMarkupContainer("container") { @Override public IMarkupFragment getMarkup(Component child) { if (child != null && child.getId().equals(filterId)) return markupProvider.provideMarkup(component); return super.getMarkup(child); } }; container.add(component); Label label = new Label("label", new ResourceModel(first ? "widget.document.filter.range.startValue" : "widget.document.filter.range.endValue")); label.add(AttributeModifier.replace("for", component.getMarkupId())); container.add(label); return container; }
Example 2
Source File: MessagePage.java From projectforge-webapp with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("serial") private void init() { final Label msgLabel = new Label("message", new Model<String>() { @Override public String getObject() { return message; } }); msgLabel.add(new AttributeModifier("class", new Model<String>() { @Override public String getObject() { if (warning == true) { return "alert alert-warning"; } else { return "alert alert-success"; } }; })); body.add(msgLabel); }
Example 3
Source File: AnnotationInfoPanel.java From webanno with Apache License 2.0 | 6 votes |
private Label createSelectedAnnotationTypeLabel() { Label label = new Label("selectedAnnotationType", LoadableDetachableModel.of(() -> { try { AnnotationDetailEditorPanel editorPanel = findParent( AnnotationDetailEditorPanel.class); return String.valueOf(selectFsByAddr(editorPanel.getEditorCas(), getModelObject().getSelection().getAnnotation().getId())).trim(); } catch (IOException e) { return ""; } })); label.setOutputMarkupPlaceholderTag(true); // We show the extended info on the selected annotation only when run in development mode label.add(visibleWhen(() -> getModelObject().getSelection().getAnnotation().isSet() && DEVELOPMENT.equals(getApplication().getConfigurationType()))); return label; }
Example 4
Source File: ActiveLearningSidebar.java From inception with Apache License 2.0 | 5 votes |
private Label createNoRecommendationLabel() { Label noRecommendation = new Label(CID_NO_RECOMMENDATION_LABEL, "There are no further suggestions."); noRecommendation.add(visibleWhen(() -> { ActiveLearningUserState alState = alStateModel.getObject(); return alState.isSessionActive() && !alState.getSuggestion().isPresent() && !activeLearningService.hasSkippedSuggestions( getModelObject().getUser(), alState.getLayer()); })); noRecommendation.setOutputMarkupPlaceholderTag(true); return noRecommendation; }
Example 5
Source File: GalleryImageEdit.java From sakai with Educational Community License v2.0 | 5 votes |
private AjaxFallbackButton createRemoveConfirmButton( final String userId, final GalleryImage image, final int galleryPageIndex, final Label formFeedback, Form imageEditForm) { AjaxFallbackButton removeConfirmButton = new AjaxFallbackButton( "galleryRemoveImageConfirmButton", new ResourceModel( "button.gallery.remove.confirm"), imageEditForm) { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (imageLogic.removeGalleryImage( userId, image.getId())) { setResponsePage(new MyPictures(galleryPageIndex)); } else { // user alert formFeedback.setDefaultModel(new ResourceModel( "error.gallery.remove.failed")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.add(formFeedback); } } }; return removeConfirmButton; }
Example 6
Source File: MenuItem.java From sakai with Educational Community License v2.0 | 5 votes |
public MenuItem(String id, IModel itemText, Class itemPageClass, PageParameters pageParameters, boolean first, Class menusCurrentPageClass) { super(id); boolean currentPage = itemPageClass.equals(menusCurrentPageClass); // link version menuItemLinkHolder = new WebMarkupContainer("menuItemLinkHolder"); menuItemLink = new BookmarkablePageLink("menuItemLink", itemPageClass, pageParameters); menuLinkText = new Label("menuLinkText", itemText); menuLinkText.setRenderBodyOnly(true); menuItemLink.add(menuLinkText); menuItemLinkHolder.add(menuItemLink); menuItemLinkHolder.setVisible(!currentPage); add(menuItemLinkHolder); // span version menuItemLabel = new Label("menuItemLabel", itemText); menuItemLabel.setVisible(currentPage); add(menuItemLabel); //add current page styling AttributeModifier currentPageStyling = new AttributeModifier("class", new Model("current")); if(currentPage) { menuItemLabel.add(currentPageStyling); } if(first) { add(new AttributeModifier("class", new Model("firstToolBarItem"))); } }
Example 7
Source File: HomePage.java From nextreports-server with Apache License 2.0 | 5 votes |
public HomePage(PageParameters parameters) { super(parameters); // clear search context NextServerSession.get().setSearchContext(null); growlLabel = new Label("growl", ""); growlLabel.setOutputMarkupId(true); growlBehavior = new JGrowlAjaxBehavior(); growlLabel.add(growlBehavior); add(growlLabel); // add slidebar addSlidebar(); // add css /* add(new Behavior() { @Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.render(CssReferenceHeaderItem.forUrl("css/style.css")); response.render(CssReferenceHeaderItem.forUrl("css/table.css")); response.render(CssReferenceHeaderItem.forUrl("css/layout.css")); } }); */ }
Example 8
Source File: AjaxLazyLoadFragment.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @param markupId The components markupid. * @return The component to show while the real component is being created. */ public Component getLoadingComponent(String markupId) { Label indicator = new Label(markupId, "<img src=\"" + RequestCycle.get().urlFor(AbstractDefaultAjaxBehavior.INDICATOR, null) + "\"/>"); indicator.setEscapeModelStrings(false); indicator.add(new AttributeModifier("title", new Model("..."))); return indicator; }
Example 9
Source File: ColoringRulesConfigurationPanel.java From webanno with Apache License 2.0 | 5 votes |
private ListView<ColoringRule> createKeyBindingsList(String aId, IModel<List<ColoringRule>> aKeyBindings) { return new ListView<ColoringRule>(aId, aKeyBindings) { private static final long serialVersionUID = 432136316377546825L; @Override protected void populateItem(ListItem<ColoringRule> aItem) { ColoringRule coloringRule = aItem.getModelObject(); Label value = new Label("pattern", coloringRule.getPattern()); value.add(new StyleAttributeModifier() { private static final long serialVersionUID = 3627596292626670610L; @Override protected Map<String, String> update(Map<String, String> aStyles) { aStyles.put("background-color", coloringRule.getColor()); return aStyles; } }); aItem.add(value); aItem.add(new LambdaAjaxLink("removeColoringRule", _target -> removeColoringRule(_target, aItem.getModelObject()))); } }; }
Example 10
Source File: AjaxLazyLoadImage.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @param markupId * The components markupid. * @return The component to show while the real component is being created. */ public Component getLoadingComponent(String markupId) { Label indicator = new Label(markupId, "<img src=\"" + RequestCycle.get().urlFor(AbstractDefaultAjaxBehavior.INDICATOR, null) + "\"/>"); indicator.setEscapeModelStrings(false); indicator.add(new AttributeModifier("title", new Model("..."))); return indicator; }
Example 11
Source File: TextBreakPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); Label label = new Label("label", getModel()); label.add(AttributeModifier.append("style", String.format("max-width: %spx;", Integer.toString(maxWidth)))); add(label); }
Example 12
Source File: AjaxLazyLoadFragment.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @param markupId The components markupid. * @return The component to show while the real component is being created. */ public Component getLoadingComponent(String markupId) { Label indicator = new Label(markupId, "<img src=\"" + RequestCycle.get().urlFor(AbstractDefaultAjaxBehavior.INDICATOR, null) + "\"/>"); indicator.setEscapeModelStrings(false); indicator.add(new AttributeModifier("title", new Model("..."))); return indicator; }
Example 13
Source File: LabelForPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public LabelForPanel(final String id, final Component field, final String text) { super(id); field.setOutputMarkupId(true); final Label label = new Label("label", text); label.add(AttributeModifier.replace("for", field.getMarkupId())); add(label); }
Example 14
Source File: AdministratePage.java From sakai with Educational Community License v2.0 | 4 votes |
public AdministratePage(){ disableLink(administrateLink); //Form Feedback (Saved/Error) final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //Add Delegated Access to My Workspaces: final Label addDaMyworkspaceStatusLabel = new Label("lastRanInfo", new AbstractReadOnlyModel<String>() { @Override public String getObject() { String lastRanInfoStr = projectLogic.getAddDAMyworkspaceJobStatus(); if(lastRanInfoStr == null){ lastRanInfoStr = new ResourceModel("addDaMyworkspace.job.status.none").getObject(); }else{ try{ long lastRanInfoInt = Long.parseLong(lastRanInfoStr); if(lastRanInfoInt == -1){ return new ResourceModel("addDaMyworkspace.job.status.failed").getObject(); }else if(lastRanInfoInt == 0){ return new ResourceModel("addDaMyworkspace.job.status.scheduled").getObject(); }else{ Date successDate = new Date(lastRanInfoInt); return new ResourceModel("addDaMyworkspace.job.status.success").getObject() + " " + format.format(successDate); } }catch (Exception e) { return new ResourceModel("na").getObject(); } } return lastRanInfoStr; } }); addDaMyworkspaceStatusLabel.setOutputMarkupPlaceholderTag(true); final String addDaMyworkspaceStatusLabelId = addDaMyworkspaceStatusLabel.getMarkupId(); add(addDaMyworkspaceStatusLabel); Form<?> addDaMyworkspaceForm = new Form("addDaMyworkspaceForm"); AjaxButton addDaMyworkspaceButton = new AjaxButton("addDaMyworkspace", new StringResourceModel("addDaMyworkspaceTitle", null)){ @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { projectLogic.scheduleAddDAMyworkspaceJobStatus(); //display a "saved" message formFeedback.setDefaultModel(new ResourceModel("success.addDaMyworkspace")); formFeedback.add(new AttributeModifier("class", true, new Model("success"))); target.add(formFeedback); target.appendJavaScript("hideFeedbackTimer('" + formFeedbackId + "');"); target.add(addDaMyworkspaceStatusLabel,addDaMyworkspaceStatusLabelId); } }; addDaMyworkspaceForm.add(addDaMyworkspaceButton); add(addDaMyworkspaceForm); }
Example 15
Source File: PairwiseUnitizingAgreementTable.java From webanno with Apache License 2.0 | 4 votes |
private Label makeUpperDiagonalCellLabel(String aRater1, String aRater2) { UnitizingAgreementResult result = getModelObject().getStudy(aRater1, aRater2); boolean noDataRater0 = isAllNull(result, 0); boolean noDataRater1 = isAllNull(result, 1); String label; if (result.getStudy().getUnitCount() == 0) { label = "no positions"; } else if (noDataRater0 && noDataRater1) { label = "no labels"; } else if (noDataRater0) { label = "no labels from " + result.getCasGroupIds().get(0); } else if (noDataRater1) { label = "no labels from " + result.getCasGroupIds().get(1); } // else if (incPos == result.getRelevantSetCount()) { // label = "positions disjunct"; // } // else if (incLabel == result.getRelevantSetCount()) { // label = "labels disjunct"; // } // else if ((incLabel + incPos) == result.getRelevantSetCount()) { // label = "labels/positions disjunct"; // } else { label = String.format("%.2f", result.getAgreement()); } String tooltipTitle = result.getCasGroupIds().get(0) + '/' + result.getCasGroupIds().get(1); String tooltipContent = "Positions annotated:\n" + String.format("- %s: %d/%d%n", result.getCasGroupIds().get(0), getNonNullCount(result, 0), result.getStudy().getUnitCount(0)) + String.format("- %s: %d/%d%n", result.getCasGroupIds().get(1), getNonNullCount(result, 1), result.getStudy().getUnitCount(1)) + String.format("Distinct labels used: %d%n", result.getStudy().getCategoryCount()); Label l = new Label("label", Model.of(label)); DescriptionTooltipBehavior tooltip = new DescriptionTooltipBehavior( tooltipTitle, tooltipContent); tooltip.setOption("position", (Object) null); l.add(tooltip); l.add(new AttributeAppender("style", "cursor: help", ";")); return l; }
Example 16
Source File: FormGroupBorder.java From etcd-viewer with Apache License 2.0 | 4 votes |
public FormGroupBorder(String id, IModel<String> labelModel) { super(id); formComponent = new LoadableDetachableModel<FormComponent<?>>() { private static final long serialVersionUID = 1L; @Override protected FormComponent<?> load() { return getBodyContainer().visitChildren(FormComponent.class, new IVisitor<FormComponent<?>, FormComponent<?>>() { @Override public void component(FormComponent<?> object, IVisit<FormComponent<?>> visit) { visit.stop(object); } }); } }; Label label; addToBorder(label = new Label("label", labelModel)); label.add(new AttributeAppender("for", new PropertyModel<>(formComponent, "markupId"))); addToBorder(feedbackPanel = new FeedbackPanel("feedback", new ContainerFeedbackMessageFilter(getBodyContainer()))); WebMarkupContainer feedbackIcon; addToBorder(feedbackIcon = new WebMarkupContainer("feedbackIcon")); feedbackIcon.add(new AttributeAppender("class", new LoadableDetachableModel<String>() { private static final long serialVersionUID = 1L; @Override protected String load() { if (!feedbackPanel.anyMessage()) { return ""; } return feedbackPanel.anyErrorMessage() ? "glyphicon-remove" : "glyphicon-ok"; } }, " ")); add(new AttributeAppender("class", new LoadableDetachableModel<String>() { private static final long serialVersionUID = 1L; @Override protected String load() { if (!feedbackPanel.anyMessage()) { return ""; } return feedbackPanel.anyErrorMessage() ? "has-feedback has-error" : "has-feedback has-success"; } }, " ")); }
Example 17
Source File: AbstractInfoPanel.java From inception with Apache License 2.0 | 4 votes |
public ViewMode(String id, CompoundPropertyModel<? extends KBObject> compoundModel, StatementDetailPreference aDetailPreference) { super(id, "viewMode", AbstractInfoPanel.this); Label uiLabel = new Label("uiLabel", compoundModel.bind("uiLabel")); add(uiLabel); add(new Label("typeLabel", new ResourceModel(getTypeLabelResourceKey()))); Label identifier = new Label("idtext"); TooltipBehavior tip = new TooltipBehavior(); tip.setOption("autoHide", false); tip.setOption("content", Options.asString((compoundModel.bind("identifier").getObject()))); tip.setOption("showOn", Options.asString("click")); identifier.add(tip); add(identifier); // button for deleting the KBObject LambdaAjaxLink deleteButton = new LambdaAjaxLink("delete", AbstractInfoPanel.this::confirmActionDelete).onConfigure((_this) -> _this.setVisible(kbObjectModel.getObject() != null && isNotEmpty(kbObjectModel.getObject().getIdentifier())) ); deleteButton.add(new Label("label", new ResourceModel(getDeleteButtonResourceKey()))); deleteButton.add(new WriteProtectionBehavior(kbModel)); add(deleteButton); // button for creating a new subclass that is only visible for concepts LambdaAjaxLink createSubclassButton = new LambdaAjaxLink("createSubclass", AbstractInfoPanel.this::actionCreateSubclass).onConfigure((_this) -> _this.setVisible(kbObjectModel.getObject() != null && isNotEmpty(kbObjectModel.getObject().getIdentifier()) && kbObjectModel.getObject() instanceof KBConcept) ); createSubclassButton.add(new Label("subclassLabel", new ResourceModel(getCreateSubclassButtonResourceKey()))); createSubclassButton.add(new WriteProtectionBehavior(kbModel)); add(createSubclassButton); // show statements about this KBObject StatementsPanel statementsPanel = new StatementsPanel("statements", kbModel, handleModel, getDetailPreference()); Comparator<StatementGroupBean> comparator = getStatementGroupComparator(); if (comparator != null) { statementsPanel.setStatementGroupComparator(comparator); } add(statementsPanel); }
Example 18
Source File: GalleryImageEdit.java From sakai with Educational Community License v2.0 | 4 votes |
private AjaxFallbackButton createSetProfileImageConfirmButton( final String userId, final GalleryImage image, final int galleryPageIndex, final Label formFeedback, Form imageEditForm) { AjaxFallbackButton setProfileImageButton = new AjaxFallbackButton( "gallerySetProfileImageConfirmButton", new ResourceModel( "button.gallery.setprofile.confirm"), imageEditForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { if (imageLogic.setUploadedProfileImage( userId, sakaiProxy.getResource( image.getMainResource()).getBytes(), "", "")) { sakaiProxy.postEvent( ProfileConstants.EVENT_PROFILE_IMAGE_CHANGE_UPLOAD, "/profile/" + userId, true); if (true == sakaiProxy.isWallEnabledGlobally()) { wallLogic .addNewEventToWall( ProfileConstants.EVENT_PROFILE_IMAGE_CHANGE_UPLOAD, sakaiProxy.getCurrentUserId()); } if (sakaiProxy.isSuperUserAndProxiedToUser( userId)) { setResponsePage(new MyProfile(userId)); } else { setResponsePage(new MyProfile()); } } else { // user alert formFeedback.setDefaultModel(new ResourceModel( "error.gallery.setprofile.failed")); formFeedback.add(new AttributeModifier("class", true, new Model("alertMessage"))); target.add(formFeedback); } } }; return setProfileImageButton; }
Example 19
Source File: CompanyProfileEdit.java From sakai with Educational Community License v2.0 | 4 votes |
public CompanyProfileEdit(String id, CompanyProfile companyProfile) { super(id, new Model(companyProfile)); WebMarkupContainer companyNameContainer = new WebMarkupContainer( "companyNameContainer"); companyNameContainer.add(new Label("companyNameLabel", new ResourceModel("profile.business.company.name"))); TextField companyName = new TextField("companyName", new PropertyModel(companyProfile, "companyName")); companyName.setOutputMarkupId(true); companyNameContainer.add(companyName); String companyNameId = companyName.getMarkupId(); Label companyNameAccessibilityLabel = new Label("companyNameAccessibilityLabel", new ResourceModel("accessibility.profile.companyname.input")); companyNameAccessibilityLabel.add(new AttributeAppender("for",new Model(companyNameId)," ")); companyNameContainer.add(companyNameAccessibilityLabel); add(companyNameContainer); WebMarkupContainer companyWebAddressContainer = new WebMarkupContainer( "companyWebAddressContainer"); companyWebAddressContainer.add(new Label("companyWebAddressLabel", new ResourceModel("profile.business.company.web"))); TextField companyWebAddress = new TextField("companyWebAddress", new PropertyModel(companyProfile, "companyWebAddress")) { private static final long serialVersionUID = 1L; // add http:// if missing @Override protected void convertInput() { String input = getInput(); if (StringUtils.isNotBlank(input) && !(input.startsWith("http://") || input .startsWith("https://"))) { setConvertedInput("http://" + input); } else { setConvertedInput(StringUtils.isBlank(input) ? null : input); } } }; companyWebAddress.setOutputMarkupId(true); companyWebAddress.add(new UrlValidator()); companyWebAddressContainer.add(companyWebAddress); String companyUrlId = companyWebAddress.getMarkupId(); Label companyUrlAccessibilityLabel = new Label("companyUrlAccessibilityLabel", new ResourceModel("accessibility.profile.companyurl.input")); companyUrlAccessibilityLabel.add(new AttributeAppender("for",new Model(companyUrlId)," ")); companyWebAddressContainer.add(companyUrlAccessibilityLabel); final FeedbackLabel companyWebAddressFeedback = new FeedbackLabel( "companyWebAddressFeedback", companyWebAddress); companyWebAddressFeedback.setOutputMarkupId(true); companyWebAddressContainer.add(companyWebAddressFeedback); companyWebAddress.add(new ComponentVisualErrorBehaviour("onblur", companyWebAddressFeedback)); companyWebAddress.add(new AttributeAppender("aria-describedby",new Model(companyWebAddressFeedback.getMarkupId())," ")); add(companyWebAddressContainer); WebMarkupContainer companyDescriptionContainer = new WebMarkupContainer( "companyDescriptionContainer"); companyDescriptionContainer.add(new Label("companyDescriptionLabel", new ResourceModel("profile.business.company.description"))); TextArea companyDescription = new TextArea("companyDescription", new PropertyModel(companyProfile, "companyDescription")); companyDescription.setOutputMarkupId(true); companyDescriptionContainer.add(companyDescription); String companyDescriptionId = companyDescription.getMarkupId(); Label companyDescriptionAccessibilityLabel = new Label("companyDescriptionAccessibilityLabel", new ResourceModel("accessibility.profile.companydescription.input")); companyDescriptionAccessibilityLabel.add(new AttributeAppender("for",new Model(companyDescriptionId)," ")); companyDescriptionContainer.add(companyDescriptionAccessibilityLabel); add(companyDescriptionContainer); }
Example 20
Source File: AdministratePage.java From sakai with Educational Community License v2.0 | 4 votes |
public AdministratePage(){ disableLink(administrateLink); //Form Feedback (Saved/Error) final Label formFeedback = new Label("formFeedback"); formFeedback.setOutputMarkupPlaceholderTag(true); final String formFeedbackId = formFeedback.getMarkupId(); add(formFeedback); //Add Delegated Access to My Workspaces: final Label addDaMyworkspaceStatusLabel = new Label("lastRanInfo", new AbstractReadOnlyModel<String>() { @Override public String getObject() { String lastRanInfoStr = projectLogic.getAddDAMyworkspaceJobStatus(); if(lastRanInfoStr == null){ lastRanInfoStr = new ResourceModel("addDaMyworkspace.job.status.none").getObject(); }else{ try{ long lastRanInfoInt = Long.parseLong(lastRanInfoStr); if(lastRanInfoInt == -1){ return new ResourceModel("addDaMyworkspace.job.status.failed").getObject(); }else if(lastRanInfoInt == 0){ return new ResourceModel("addDaMyworkspace.job.status.scheduled").getObject(); }else{ Date successDate = new Date(lastRanInfoInt); return new ResourceModel("addDaMyworkspace.job.status.success").getObject() + " " + format.format(successDate); } }catch (Exception e) { return new ResourceModel("na").getObject(); } } return lastRanInfoStr; } }); addDaMyworkspaceStatusLabel.setOutputMarkupPlaceholderTag(true); final String addDaMyworkspaceStatusLabelId = addDaMyworkspaceStatusLabel.getMarkupId(); add(addDaMyworkspaceStatusLabel); Form<?> addDaMyworkspaceForm = new Form("addDaMyworkspaceForm"); AjaxButton addDaMyworkspaceButton = new AjaxButton("addDaMyworkspace", new StringResourceModel("addDaMyworkspaceTitle", null)){ @Override protected void onSubmit(AjaxRequestTarget target, Form<?> arg1) { projectLogic.scheduleAddDAMyworkspaceJobStatus(); //display a "saved" message formFeedback.setDefaultModel(new ResourceModel("success.addDaMyworkspace")); formFeedback.add(new AttributeModifier("class", true, new Model("success"))); target.add(formFeedback); target.appendJavaScript("hideFeedbackTimer('" + formFeedbackId + "');"); target.add(addDaMyworkspaceStatusLabel,addDaMyworkspaceStatusLabelId); } }; addDaMyworkspaceForm.add(addDaMyworkspaceButton); add(addDaMyworkspaceForm); }