Java Code Examples for org.apache.wicket.markup.html.link.Link.add()

The following are Jave code examples for showing how to use add() of the org.apache.wicket.markup.html.link.Link class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: openNaEF   File: LocationViewPage.java   Source Code and License Vote up 6 votes
private void createAddLocationLink() {
    Link<Void> link = new Link<Void>("addLocation") {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            LocationAddPage page = new LocationAddPage(LocationViewPage.this, current);
            setResponsePage(page);
        }
    };
    if (LocationUtil.isTrash(current)) {
        link.setEnabled(false);
        link.setVisible(false);
    }

    LocationType type = LocationType.getByCaption(LocationRenderer.getLocationType(current));
    if (LocationType.RACK.equals(type)) {
        link.add(new Label("label", ""));
    } else {
        link.add(new Label("label", "Add child location"));
    }
    add(link);
}
 
Example 2
Project: vlo-curation   File: FacetValuesPanel.java   Source Code and License Vote up 6 votes
/**
 * Adds an individual facet value selection link to a dataview item
 *
 * @param item item to add link to
 */
private void addFacetValue(String id, final ListItem<Count> item) {
    item.setDefaultModel(new CompoundPropertyModel<>(item.getModel()));

    // link to select an individual facet value
    final Link selectLink = new IndicatingAjaxFallbackLink(id) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            // reset filter
            ((NameAndCountFieldValuesFilter) filterModel.getObject()).setName(null);

            // call callback
            onValuesSelected(
                    // for now only single values can be selected
                    Collections.singleton(item.getModelObject().getName()),
                    target);
        }
    };
    item.add(selectLink);

    // 'name' field from Count (name of value)
    selectLink.add(new FieldValueLabel("name", fieldNameModel));
    // 'count' field from Count (document count for value)
    selectLink.add(new Label("count"));
}
 
Example 3
Project: vlo-curation   File: AjaxFallbackLinkLabel.java   Source Code and License Vote up 6 votes
public AjaxFallbackLinkLabel(String id, IModel<T> linkModel, IModel<?> contentModel, boolean indicator) {
    super(id);
    final Link link;
    if (indicator) {
        link = new IndicatingAjaxFallbackLink<T>("link", linkModel) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                AjaxFallbackLinkLabel.this.onClick(target);
            }
        };
    } else {
        link = new AjaxFallbackLink<T>("link", linkModel) {

            @Override
            public void onClick(AjaxRequestTarget target) {
                AjaxFallbackLinkLabel.this.onClick(target);
            }
        };
    }
    add(link);

    link.add(new Label("content", contentModel));
}
 
Example 4
Project: owsi-core-parent   File: LinkBreadCrumbElementPanel.java   Source Code and License Vote up 6 votes
public LinkBreadCrumbElementPanel(String id, BreadCrumbElement breadCrumbElement, BreadCrumbMarkupTagRenderingBehavior renderingBehavior) {
	super(id, breadCrumbElement.getLabelModel());
	
	Link<Void> breadCrumbLink = new BookmarkablePageLink<Void>("breadCrumbElementLink", breadCrumbElement.getPageClass(),
			breadCrumbElement.getPageParameters()) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onConfigure() {
			super.onConfigure();
			
			setVisible(Session.get().getAuthorizationStrategy().isInstantiationAuthorized(getPageClass()));
		}
	};
	breadCrumbLink.setBody(getModel());
	breadCrumbLink.add(renderingBehavior);
	add(breadCrumbLink);
	
	add(
			Condition.componentVisible(breadCrumbLink).thenShowInternal()
	);
}
 
Example 5
Project: artifactory   File: ArchiveSearchPanel.java   Source Code and License Vote up 6 votes
@SuppressWarnings({"unchecked"})
@Override
public void populateItem(final Item cellItem, String componentId, IModel model) {
    final ActionableArchiveSearchResult result =
            (ActionableArchiveSearchResult) cellItem.getParent().getParent().getDefaultModelObject();
    final String relDirPath = result.getSearchResult().getRelDirPath();
    Link linkToTreeView = new Link<String>(componentId, Model.of(relDirPath)) {
        @Override
        public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
            replaceComponentTagBody(markupStream, openTag, relDirPath);
        }

        @Override
        public void onClick() {
            RequestCycle.get().setResponsePage(new BrowseRepoPage(result.getArchiveRepoPath()));
        }
    };
    linkToTreeView.add(new CssClass("item-link"));
    cellItem.add(linkToTreeView);
}
 
Example 6
Project: AppStash   File: ProductItemPanel.java   Source Code and License Vote up 6 votes
private Component productDetailImageLink() {
    Link<Void> detailPageLink = new Link<Void>("productDetailLink") {
        @Override
        public void onClick() {
            PageParameters pageParameters = new PageParameters();
            pageParameters.set("urlname", productUrlModel.getObject());
            setResponsePage(new ProductDetailPage(pageParameters));
        }
    };
    WebMarkupContainer image = new WebMarkupContainer("image");
    image.add(new AttributeModifier("src", new ImageLinkModel(productInfoModel, this)));
    image.add(new AttributeModifier("title", new PropertyModel<String>(productInfoModel, "description")));
    image.add(new AttributeModifier("alt", new PropertyModel<String>(productInfoModel, "name")));
    image.setOutputMarkupId(true);

    detailPageLink.add(image);
    return detailPageLink;
}
 
Example 7
Project: nocket   File: DefaultLoginStatusBar.java   Source Code and License Vote up 6 votes
/**
 * Instantiates a new login status bar.
 *
 * @param id the id
 */
public DefaultLoginStatusBar(String id) {
	super(id);
	final Label userStatus = new Label("loggedin", new AbstractReadOnlyModel<String>() {
		@Override
		public String getObject() {
			final DefaultLoginStatusBar bar = DefaultLoginStatusBar.this;
			return isLoggedIn() ? getLoggedInUserName() : bar.getString("notloggedin");
		}
	});
	add(userStatus);
	final Link<WebPage> actionLink = new Link<WebPage>("actionlink") {
		@Override
		public void onClick() {
			Class<? extends WebPage> resp =	(isLoggedIn() ? doLogout() : getLoginPage());
			if(resp != null)
				setResponsePage(resp);
		}
	};
	final Label loginactionlabel = new MyLabel("loginactionlabel", new ResourceModel("login"), false);
	final Label logoutactionlabel = new MyLabel("logoutactionlabel", new ResourceModel("logout"), true);
	actionLink.add(loginactionlabel);
	actionLink.add(logoutactionlabel);
	add(actionLink);
}
 
Example 8
Project: nocket   File: ActionColumn.java   Source Code and License Vote up 6 votes
/**
 * Instantiates a new link panel.
 *
 * @param id the id
 * @param column the column
 * @param rowModel the row model
 */
public LinkPanel(String id, final ActionColumn<T> column, IModel<T> rowModel) {
    super(id);
    Link<T> link = new Link<T>("link", rowModel) {
        @Override
        public void onClick() {
            column.onClick(getModel());
        }

        @Override
        public boolean isEnabled() {
            return column.isEnabled(getModel());
        }

        @Override
        public boolean isVisible() {
            return column.isVisible(getModel());
        }

    };
    add(link);
    link.add(new Label("label", column.getCellLabel(rowModel)));
}
 
Example 9
Project: gitblit   File: LinkPanel.java   Source Code and License Vote up 6 votes
public LinkPanel(String wicketId, String bootstrapIcon, String linkCssClass, IModel<String> model,
		Class<? extends WebPage> clazz, PageParameters parameters, boolean newWindow) {
	super(wicketId);
	this.labelModel = model;
	Link<Void> link = null;
	if (parameters == null) {
		link = new BookmarkablePageLink<Void>("link", clazz);
	} else {
		link = new BookmarkablePageLink<Void>("link", clazz, parameters);
	}
	if (newWindow) {
		link.add(new SimpleAttributeModifier("target", "_blank"));
	}
	if (linkCssClass != null) {
		link.add(new SimpleAttributeModifier("class", linkCssClass));
	}
	Label icon = new Label("icon");
	if (StringUtils.isEmpty(bootstrapIcon)) {
		link.add(icon.setVisible(false));
	} else {
		WicketUtils.setCssClass(icon, bootstrapIcon);
		link.add(icon);
	}
	link.add(new Label("label", labelModel).setRenderBodyOnly(true));
	add(link);
}
 
Example 10
Project: IRCBlit   File: GravatarImage.java   Source Code and License Vote up 6 votes
public GravatarImage(String id, PersonIdent person, int width, boolean linked) {
	super(id);

	String email = person.getEmailAddress() == null ? person.getName().toLowerCase() : person.getEmailAddress().toLowerCase();
	String hash = StringUtils.getMD5(email);
	Link<Void> link = new BookmarkablePageLink<Void>("link", GravatarProfilePage.class,
			WicketUtils.newObjectParameter(hash));
	link.add(new SimpleAttributeModifier("target", "_blank"));
	String url = ActivityUtils.getGravatarThumbnailUrl(email, width);
	ExternalImage image = new ExternalImage("image", url);
	WicketUtils.setCssClass(image, "gravatar");
	link.add(image);
	if (linked) {
		WicketUtils.setHtmlTooltip(link,
			MessageFormat.format("View Gravatar profile for {0}", person.getName()));
	} else {
		WicketUtils.setHtmlTooltip(link, person.getName());
	}
	add(link.setEnabled(linked));
	setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true));
}
 
Example 11
Project: IRCBlit   File: LinkPanel.java   Source Code and License Vote up 6 votes
public LinkPanel(String wicketId, String bootstrapIcon, String linkCssClass, IModel<String> model,
		Class<? extends WebPage> clazz, PageParameters parameters, boolean newWindow) {
	super(wicketId);
	this.labelModel = model;
	Link<Void> link = null;
	if (parameters == null) {
		link = new BookmarkablePageLink<Void>("link", clazz);
	} else {
		link = new BookmarkablePageLink<Void>("link", clazz, parameters);
	}
	if (newWindow) {
		link.add(new SimpleAttributeModifier("target", "_blank"));
	}
	if (linkCssClass != null) {
		link.add(new SimpleAttributeModifier("class", linkCssClass));
	}
	Label icon = new Label("icon");
	if (StringUtils.isEmpty(bootstrapIcon)) {
		link.add(icon.setVisible(false));
	} else {
		WicketUtils.setCssClass(icon, bootstrapIcon);
		link.add(icon);
	}
	link.add(new Label("label", labelModel).setRenderBodyOnly(true));
	add(link);
}
 
Example 12
Project: projectforge-webapp   File: RechnungEditForm.java   Source Code and License Vote up 6 votes
@SuppressWarnings("serial")
@Override
protected void onRenderPosition(final WebMarkupContainer item, final RechnungsPositionDO position)
{
  // item.add(new AuftragsPositionFormComponent("orderPosition", new PropertyModel<AuftragsPositionDO>(position, "auftragsPosition"),
  // false));

  final Link<String> orderLink = new Link<String>("orderLink") {
    @Override
    public void onClick()
    {
      if (position.getAuftragsPosition() != null) {
        final PageParameters parameters = new PageParameters();
        parameters.add(AbstractEditPage.PARAMETER_KEY_ID, position.getAuftragsPosition().getAuftrag().getId());
        final AuftragEditPage auftragEditPage = new AuftragEditPage(parameters);
        auftragEditPage.setReturnToPage(getParentPage());
        setResponsePage(auftragEditPage);
      }
    }
  };
  item.add(orderLink);
  if (position.getAuftragsPosition() == null) {
    orderLink.setVisible(false);
  }
  orderLink.add(new PresizedImage("linkImage", WebConstants.IMAGE_FIND));
}
 
Example 13
Project: projectforge-webapp   File: AbstractSecuredPage.java   Source Code and License Vote up 6 votes
@SuppressWarnings("serial")
private void addBreadCrumbs(final RepeatingView breadcrumbItems, final AbstractSecuredPage page)
{
  final WebPage returnTo = page.getReturnToPage();
  if (returnTo != null && returnTo instanceof AbstractSecuredPage) {
    addBreadCrumbs(breadcrumbItems, (AbstractSecuredPage) returnTo);
  }
  final WebMarkupContainer li = new WebMarkupContainer(breadcrumbItems.newChildId());
  breadcrumbItems.add(li);
  final Link<Void> pageLink = new Link<Void>("link") {

    @Override
    public void onClick()
    {
      setResponsePage(page);
    }
  };
  li.add(pageLink);
  pageLink.add(new Label("label", page.getTitle()));
}
 
Example 14
Project: Jouve-Project   File: SwitchSearchMethod.java   Source Code and License Vote up 6 votes
public SwitchSearchMethod(String id, SimpleSearch search) {
	super(id);
	boolean isSimple = search.getAdvancedSearchRule() == null;
	SimpleSearch clonedSimpleSearch = search.clone();
	String linkLabelResource;
	
	RecordCollectionServices recordCollectionServices = ConstellioSpringUtils.getRecordCollectionServices();
	RecordCollection recordCollection = recordCollectionServices.get(search.getCollectionName());
	setVisible(recordCollection != null && recordCollection.isAdvancedSearchEnabled());
	
	if (isSimple) {
		linkLabelResource = "toAdvancedSearch";
		clonedSimpleSearch.setAdvancedSearchRule(SearchRulesFactory.getInitialSearchRuleFor(recordCollection));
	} else {
		linkLabelResource = "toSimpleSearch";
		clonedSimpleSearch.setAdvancedSearchRule(null);
	}

       PageFactoryPlugin pageFactoryPlugin = PluginFactory.getPlugin(PageFactoryPlugin.class);
	Link link = new BookmarkablePageLink("link", pageFactoryPlugin.getSearchFormPage(), SearchFormPage.getParameters(clonedSimpleSearch));
	link.add(new Label("label", new StringResourceModel(linkLabelResource, SwitchSearchMethod.this, null)));
	add(link);
}
 
Example 15
Project: nextreports-server   File: WidgetPopupMenuModel.java   Source Code and License Vote up 6 votes
private Link createDetachLink(final IModel<Widget> model) {
	Link<Void> link = new Link<Void>(MenuPanel.LINK_ID) {

		private static final long serialVersionUID = 1L;

		@Override
		public void onClick() {
			setResponsePage(new WidgetZoomPage(model.getObject().getId()));
		}

	};		
	
	// see busy-indicator.js
	// we do not want a busy indicator in this situation
	link.add(new AttributeAppender("class", new Model<String>("noBusyIndicator"), " "));
	
	PopupSettings popupSettings = new PopupSettings(PopupSettings.RESIZABLE | PopupSettings.SCROLLBARS);
	popupSettings.setWidth(POPUP_WIDTH).setHeight(POPUP_HEIGHT);
	link.setPopupSettings(popupSettings);
	return link;
}
 
Example 16
Project: gitplex-mit   File: PageTabLink.java   Source Code and License Vote up 5 votes
public PageTabLink(String id, PageTab tab) {
	super(id);
	
	Link<?> pageLink = newLink("link", tab.getMainPageClass());
	add(pageLink);
	pageLink.add(new Label("label", tab.getTitleModel()));
}
 
Example 17
Project: gitplex-mit   File: ProjectSettingTabLink.java   Source Code and License Vote up 5 votes
@Override
protected void onInitialize() {
	super.onInitialize();
	
	ProjectSettingPage page = (ProjectSettingPage) getPage();
	Link<Void> link = new ViewStateAwarePageLink<Void>("link", 
			tab.getMainPageClass(), ProjectSettingPage.paramsOf(page.getProject()));
	link.add(new WebMarkupContainer("icon").add(AttributeAppender.append("class", tab.getIconClass())));
	link.add(new Label("label", tab.getTitleModel()));
	add(link);
}
 
Example 18
Project: gitplex-mit   File: ProjectTabLink.java   Source Code and License Vote up 5 votes
@Override
protected void onInitialize() {
	super.onInitialize();
	
	ProjectPage page = (ProjectPage) getPage();
	Link<Void> link = new ViewStateAwarePageLink<Void>("link", 
			tab.getMainPageClass(), ProjectPage.paramsOf(page.getProject()));
	link.add(new WebMarkupContainer("icon").add(AttributeAppender.append("class", tab.getIconClass())));
	
	link.add(new Label("text", tab.getTitleModel()));
	
	link.add(new Label("count", tab.getCount()).setVisible(tab.getCount()!=0));
	add(link);
}
 
Example 19
Project: gitplex-mit   File: AdministrationTabLink.java   Source Code and License Vote up 5 votes
@Override
protected void onInitialize() {
	super.onInitialize();
	
	Link<Void> link = new ViewStateAwarePageLink<Void>("link", tab.getMainPageClass());
	link.add(new WebMarkupContainer("icon").add(AttributeAppender.append("class", tab.getIconClass())));
	link.add(new Label("label", tab.getTitleModel()));
	add(link);
}
 
Example 20
Project: gitplex-mit   File: GroupTabLink.java   Source Code and License Vote up 5 votes
@Override
protected void onInitialize() {
	super.onInitialize();
	
	GroupPage page = (GroupPage) getPage();
	Link<Void> link = new ViewStateAwarePageLink<Void>("link", 
			tab.getMainPageClass(), GroupPage.paramsOf(page.getGroup()));
	link.add(new WebMarkupContainer("icon").add(AttributeAppender.append("class", tab.getIconClass())));
	link.add(new Label("label", tab.getTitleModel()));
	add(link);
}
 
Example 21
Project: gitplex-mit   File: UserTabLink.java   Source Code and License Vote up 5 votes
@Override
protected void onInitialize() {
	super.onInitialize();
	
	UserPage page = (UserPage) getPage();
	Link<Void> link = new ViewStateAwarePageLink<Void>("link", 
			tab.getMainPageClass(), UserPage.paramsOf(page.getUser()));
	link.add(new WebMarkupContainer("icon").add(AttributeAppender.append("class", tab.getIconClass())));
	link.add(new Label("label", tab.getTitleModel()));
	add(link);
}
 
Example 22
Project: openNaEF   File: LinkEditPage.java   Source Code and License Vote up 5 votes
private Link<Void> createLink(String id, PortDto port) {
    PageParameters param = NodeUtil.getNodeParameters(port);
    Link<Void> link = new BookmarkablePageLink<Void>(id, SimpleNodeDetailPage.class, param);
    link.setEnabled(port != null);
    link.add(new Label("nodeName", new Model<String>(NodeUtil.getNodeName(port))));
    return link;
}
 
Example 23
Project: openNaEF   File: SubnetNamespaceDetailPage.java   Source Code and License Vote up 5 votes
public static Link<Void> getIpSubnetLink(IpSubnetNamespaceDto address) {
    if (address == null) {
        throw new IllegalStateException("address is null.");
    }
    Link<Void> link = new Link<Void>("ipSubnetDetail") {
        private static final long serialVersionUID = 1L;

        public void onClick() {
        }
    };
    Label subnetName = new Label("ipSubnetName");
    link.add(subnetName);
    return link;
}
 
Example 24
Project: openNaEF   File: SubnetDetailPage.java   Source Code and License Vote up 5 votes
public static Link<Void> getIpSubnetLink(IpSubnetAddressDto address) {
    if (address == null) {
        throw new IllegalStateException("address is null.");
    }
    Link<Void> link = new Link<Void>("ipSubnetDetail") {
        private static final long serialVersionUID = 1L;

        public void onClick() {
        }
    };
    Label subnetName = new Label("ipSubnetName");
    link.add(subnetName);
    return link;
}
 
Example 25
Project: GeoCrawler   File: SeedListsPage.java   Source Code and License Vote up 5 votes
public SeedListsPage() {

    RefreshingView<SeedList> seedLists = new RefreshingView<SeedList>(
        "seedLists") {

      @Override
      protected Iterator<IModel<SeedList>> getItemModels() {
        return new CpmIteratorAdapter<SeedList>(seedListService.findAll());
      }

      @Override
      protected void populateItem(final Item<SeedList> item) {
        PageParameters params = new PageParameters();
        params.add("id", item.getModelObject().getId());

        Link<Void> edit = new BookmarkablePageLink<Void>("edit",
            SeedPage.class, params);
        edit.add(new Label("name"));
        item.add(edit);

        item.add(new Label("seedUrlsCount"));

        item.add(new Link<SeedList>("delete", item.getModel()) {
          @Override
          public void onClick() {
            seedListService.delete(item.getModelObject().getId());
          }
        });
      }
    };

    add(seedLists);
    add(new BookmarkablePageLink<Void>("newSeedList", SeedPage.class));
  }
 
Example 26
Project: vlo-curation   File: LinkDisabledClassBehaviour.java   Source Code and License Vote up 5 votes
@Override
public void bind(Component component) {
    super.bind(component);
    if (component instanceof Link) {
        final Link link = (Link) component;
        final AbstractReadOnlyModel<String> disabledModel = new AbstractReadOnlyModel<String>() {
            @Override
            public String getObject() {
                return link.isEnabled() ? null : "disabled";
            }
        };
        link.add(new AttributeAppender("class", disabledModel, " "));
        link.add(new AttributeModifier("disabled", disabledModel));
    } else {
        throw new RuntimeException(getClass().getName() + " can only be used with Link components");
    }
}
 
Example 27
Project: vlo-curation   File: SimpleSearchBrowsePanel.java   Source Code and License Vote up 5 votes
/**
 *
 * @param id component id
 * @param model model of current selection
 */
public SimpleSearchBrowsePanel(String id, IModel<QueryFacetsSelection> model) {
    super(id, model);

    final IModel<Long> documentCountModel = new AbstractReadOnlyModel<Long>() {

        @Override
        public Long getObject() {
            return documentService.getDocumentCount(getModel().getObject());
        }
    };

    // add a link to browse all records
    final Link browseAllLink = new Link("browseAll") {

        @Override
        public void onClick() {
            setResponsePage(new FacetedSearchPage(SimpleSearchBrowsePanel.this.getModel()));
        }
    };
    // set label on basis of string defined in resource bundle that takes the count model as a parameter
    browseAllLink.add(new Label("recordCount", StringResourceModelMigration.of("simplesearch.allrecords", documentCountModel, new Object[]{})));
    add(browseAllLink);

    // add selectors for some facets
    add(new FacetSelectorsView("facet", getModel()));

    // make this panel AJAX-updatable
    setOutputMarkupId(true);
}
 
Example 28
Project: vlo-curation   File: AllFacetValuesPanel.java   Source Code and License Vote up 5 votes
private DataView<FacetField.Count> createValuesView(String id) {
    final IModel<String> fieldNameModel = new PropertyModel<>(getModel(), "name");
    return new DataView<FacetField.Count>(id, valuesProvider, ITEMS_PER_PAGE) {

        @Override
        protected void populateItem(final Item<FacetField.Count> item) {
            item.setDefaultModel(new CompoundPropertyModel<>(item.getModel()));

            // link to select an individual facet value
            final Link selectLink = new AjaxFallbackLink("facetSelect") {

                @Override
                public void onClick(AjaxRequestTarget target) {
                    // call callback
                    onValuesSelected(
                            // for now only single values can be selected
                    		Collections.singleton(item.getModelObject().getName()),
                            target);
                }
            };
            item.add(selectLink);

            // 'name' field from Count (name of value)
            selectLink.add(new FieldValueLabel("name", fieldNameModel));

            // 'count' field from Count (document count for value)
            item.add(new Label("count"));
        }
    };
}
 
Example 29
Project: vlo-curation   File: BootstrapDropdown.java   Source Code and License Vote up 5 votes
protected Component createDropDownLink(String id) {
    //link that activates dropdown
    final Link<Boolean> link = new Link<Boolean>(id, openStateModel) {
        @Override
        public void onClick() {
            getModel().setObject(!getModelObject());
        }
    };
    final Serializable buttonClass = getButtonClass();
    if (buttonClass != null) {
        link.add(new AttributeAppender("class", buttonClass, " "));
    }

    //optional icon
    final WebMarkupContainer icon = new WebMarkupContainer("buttonIcon");
    final Serializable iconClass = getButtonIconClass();
    if (iconClass != null) {
        icon.add(new AttributeModifier("class", iconClass));
    }
    link.add(icon);

    //caret
    final WebMarkupContainer caret = new WebMarkupContainer("caret");
    caret.setVisible(showCaret());
    link.add(caret);
    return link;
}
 
Example 30
Project: vlo-curation   File: ToggleLink.java   Source Code and License Vote up 5 votes
public ToggleLink(String id, IModel<Boolean> model, final IModel<String> showTextModel, final IModel<String> hideTextModel) {
    super(id, model);
    final Link<Boolean> link = new IndicatingAjaxFallbackLink<Boolean>("link", model) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            getModel().setObject(!getModelObject());
            if (target != null) {
                target.add(ToggleLink.this);
            }
            ToggleLink.this.onClick(target);
        }
    };
    link.add(new Label("label", new AbstractReadOnlyModel<String>() {
        @Override
        public String getObject() {
            if (ToggleLink.this.getModelObject()) {
                return hideTextModel.getObject();
            } else {
                return showTextModel.getObject();
            }
        }

        @Override
        public void detach() {
            showTextModel.detach();
            hideTextModel.detach();
        }

    }));
    add(link);

    setOutputMarkupId(true);
}
 
Example 31
Project: singular-server   File: NewRequirementLink.java   Source Code and License Vote up 5 votes
protected void addSingleButton(ISupplier<Boolean> visibleSupplier) {
    Optional<RequirementData> findFirst = requirements.getObject().stream().findFirst();
    if(findFirst.isPresent()){
        Link<String> newButton = buildLink("_botao", labelModel, findFirst.get());
        newButton.add($b.visibleIf(visibleSupplier));
        this.add(newButton);
    }
}
 
Example 32
Project: owsi-core-parent   File: LinkGeneratorBreadCrumbElementPanel.java   Source Code and License Vote up 5 votes
public LinkGeneratorBreadCrumbElementPanel(String id, BreadCrumbElement breadCrumbElement, BreadCrumbMarkupTagRenderingBehavior renderingBehavior) {
	super(id, breadCrumbElement.getLabelModel());
	
	Link<Void> breadCrumbLink = breadCrumbElement.getLinkGenerator().link("breadCrumbElementLink").hideIfInvalid();
	breadCrumbLink.setBody(getModel());
	breadCrumbLink.add(renderingBehavior);
	add(breadCrumbLink);
	
	add(
			Condition.componentVisible(breadCrumbLink).thenShowInternal()
	);
}
 
Example 33
Project: artifactory   File: GroupPermissionsPanel.java   Source Code and License Vote up 5 votes
private LinkPanel(String id, IModel model) {
    super(id, model);
    PermissionsRow permRow = (PermissionsRow) model.getObject();
    final PermissionTargetInfo permissionTarget = permRow.getPermissionTarget();
    Link link = new Link("link") {
        @Override
        public void onClick() {
            setResponsePage(new AclsPage(InfoFactoryHolder.get().copyPermissionTarget(permissionTarget)));
        }
    };
    add(link);
    link.add(new Label("label", permissionTarget.getName()));
}
 
Example 34
Project: artifactory   File: UserPermissionsPanel.java   Source Code and License Vote up 5 votes
private LinkPanel(String id, IModel<PermissionsRow> model) {
    super(id, model);
    PermissionsRow permRow = model.getObject();
    final MutablePermissionTargetInfo permissionTarget = InfoFactoryHolder.get()
            .copyPermissionTarget(permRow.getPermissionTarget());
    Link link = new Link("link") {
        @Override
        public void onClick() {
            setResponsePage(new AclsPage(permissionTarget));
        }
    };
    add(link);
    link.add(new Label("label", permissionTarget.getName()));
}
 
Example 35
Project: sakai   File: SakaiPage.java   Source Code and License Vote up 5 votes
/**
 * Add a menu entry with a custom link.
 *
 * @param link  Link to add to the menu bar
 * @param text  Link's text
 * @param title Title attribute for the link
 */
protected void addMenuLink(Link<Page> link, IModel<String> text, IModel<String> title) {
    WebMarkupContainer parent = new WebMarkupContainer(menu.newChildId());
    menu.add(parent);
    link.add(new Label("menuItemText", text).setRenderBodyOnly(true));
    if (title != null)
        link.add(new AttributeModifier("title", title));

    parent.add(link);
}
 
Example 36
Project: ontopia   File: LinkPanel.java   Source Code and License Vote up 5 votes
public LinkPanel(String id) {
  super(id);

  // add link with label
  Link<Page> link = newLink("link");
  link.add(newLabel("label"));
  add(link);
}
 
Example 37
Project: edemocracia   File: MoveTopicosWizard.java   Source Code and License Vote up 5 votes
public TopicoStep(IDynamicWizardStep previous) {
	super(previous,"Escolha o Tópico","CLique no tópico a mover");
	setComplete(false);
	

	ListView<Topico> topicos = new ListView<Topico>("topicos",
			new ModeloListaTopicosDeForum(info.getIdComunidadeOrigem(), info.getIdForumOrigem())) {

		private static final long serialVersionUID = -5113198906301138306L;

		@Override
		protected void populateItem(final ListItem<Topico> item) {
			Link<Void> linkTopico = new AjaxFallbackLink<Void>(
					"link_topico") {

				private static final long serialVersionUID = 2729459814700718807L;

				@Override
				public void onClick(AjaxRequestTarget target) {
					info.setIdTopico(item.getModelObject().getId());
					info.setNomeTopico(item.getModelObject().getAssunto());
					setComplete(true);

				}
			};
			
			Label nomeTopico = new Label("nome_topico", item.getModelObject().toString());
			linkTopico.setOutputMarkupId(true);
			linkTopico.add(nomeTopico);
			item.add(linkTopico);

		}
	};
	topicos.setOutputMarkupId(true);
	add(topicos);

}
 
Example 38
Project: edemocracia   File: MoveTopicosWizard.java   Source Code and License Vote up 5 votes
public ComunidadeDestinoStep(IDynamicWizardStep previousStep) {
	super(previousStep,"Escolha a Comunidade de Destino","Clique na comunidade para onde o tópico será movido");
	
	ListView<Group> comunidades = new ListView<Group>("comunidades",
			new ModeloListaComunidadesDestino(info.getIdUsuario(),info.getIdComunidadeOrigem())) {

		private static final long serialVersionUID = -5113198906301138306L;

		@Override
		protected void populateItem(final ListItem<Group> item) {
			Link<Void> linkComunidade = new AjaxFallbackLink<Void>(
					"link_comunidade") {

				private static final long serialVersionUID = 2729459814700718807L;

				@Override
				public void onClick(AjaxRequestTarget target) {
					Group comunidade = item.getModelObject();
					info.setIdComunidadeDestino(comunidade.getGroupId());
					info.setUrlComunidadeDestino(comunidade.getFriendlyURL());
					info.setNomeComunidadeDestino(comunidade.getName());
					setComplete(true);
				}
			};
			
			Label nomeComunidade = new Label("nome_comunidade", item.getModelObject().getName());
			linkComunidade.setOutputMarkupId(true);
			linkComunidade.add(nomeComunidade);
			item.add(linkComunidade);

		}
	};
	comunidades.setOutputMarkupId(true);
	add(comunidades);

	
}
 
Example 39
Project: nocket   File: ActionIconColumn.java   Source Code and License Vote up 5 votes
/**
 * Instantiates a new link image panel.
 *
 * @param id the id
 * @param column the column
 * @param rowModel the row model
 */
public LinkImagePanel(String id, final ActionIconColumn<T> column, IModel<T> rowModel) {
    super(id);

    Link<T> link = new Link<T>("link", rowModel) {
        @Override
        public void onClick() {
            column.onClick(getModel());
        }

        @Override
        public boolean isEnabled() {
            return column.isEnabled(getModel());
        }

        @Override
        public boolean isVisible() {
            return column.isVisible(getModel());
        }
    };
    add(link);

    Image icon = new Image("icon", column.getIcon(rowModel)) {

        @Override
        protected boolean shouldAddAntiCacheParameter() {
            return WebApplication.get().usesDevelopmentConfig();
        }

    };

    String tooltip = column.getTooltip(rowModel);
    if (tooltip != null) {
        icon.add(new AttributeAppender("title", tooltip));
    }

    link.add(icon);

}
 
Example 40
Project: nocket   File: ClickablePropertyColumn.java   Source Code and License Vote up 5 votes
/**
 * Instantiates a new link panel.
 *
 * @param id the id
 * @param rowModel the row model
 * @param labelModel the label model
 */
public LinkPanel(String id, IModel<T> rowModel, IModel<?> labelModel) {
    super(id);
    Link<T> link = new Link<T>("link", rowModel) {
        private static final long serialVersionUID = 1L;

        @Override
        public void onClick() {
            ClickablePropertyColumn.this.onClick(getModel());
        }
    };
    add(link);
    link.add(new Label("label", labelModel));
}
 
Example 41
Project: sakai   File: SakaiPage.java   Source Code and License Vote up 5 votes
/**
 * Add a menu entry with a custom link.
 *
 * @param link  Link to add to the menu bar
 * @param text  Link's text
 * @param title Title attribute for the link
 */
protected void addMenuLink(Link<Page> link, IModel<String> text, IModel<String> title) {
    WebMarkupContainer parent = new WebMarkupContainer(menu.newChildId());
    menu.add(parent);
    link.add(new Label("menuItemText", text).setRenderBodyOnly(true));
    if (title != null)
        link.add(new AttributeModifier("title", title));

    parent.add(link);
}
 
Example 42
Project: oodt   File: EventToWorkflowViewer.java   Source Code and License Vote up 5 votes
public EventToWorkflowViewer(String id, String workflowUrlStr, final Class<? extends WebPage> viewerPage) {
  super(id);
  this.wm = new WorkflowMgrConn(workflowUrlStr);
  WebMarkupContainer wTable = new WebMarkupContainer("wtable");
  wTable.setVisible(false);
  PropertyModel<List<Workflow>> workflowsModel = new PropertyModel<List<Workflow>>(this, "workflows");
  ListView<Workflow> workflowView = new ListView<Workflow>("workflow_list", workflowsModel) {
    private static final long serialVersionUID = 5894604290395257941L;

    @Override
    protected void populateItem(ListItem<Workflow> item) {
      Link<String> wLink = new Link<String>("workflow_link", new Model(item.getModelObject().getId())){
        
         /* (non-Javadoc)
         * @see org.apache.wicket.markup.html.link.Link#onClick()
         */
        @Override
        public void onClick() {
          PageParameters params = new PageParameters();
          params.add("id", getModelObject());
          setResponsePage(viewerPage, params);
        }
      };
      
      wLink.add(new Label("workflow_name", item.getModelObject().getName()));
      item.add(wLink);
    }
  };

  EventWorkflowForm form = 
    new EventWorkflowForm("event_workflow_frm", workflowsModel, wTable);

  wTable.add(workflowView);
  add(wTable);
  add(form);
}
 
Example 43
Project: gitblit   File: BranchesPanel.java   Source Code and License Vote up 5 votes
private Link<Void> createDeleteBranchLink(final RepositoryModel repositoryModel, final RefModel entry)
{
	Link<Void> deleteLink = new Link<Void>("deleteBranch") {
		private static final long serialVersionUID = 1L;

		@Override
		public void onClick() {
			Repository r = GitBlit.self().getRepository(repositoryModel.name);
			if (r == null) {
				if (GitBlit.self().isCollectingGarbage(repositoryModel.name)) {
					error(MessageFormat.format(getString("gb.busyCollectingGarbage"), repositoryModel.name));
				} else {
					error(MessageFormat.format("Failed to find repository {0}", repositoryModel.name));
				}
				return;
			}
			boolean success = JGitUtils.deleteBranchRef(r, entry.getName());
			r.close();
			if (success) {
				info(MessageFormat.format("Branch \"{0}\" deleted", entry.displayName));
				// redirect to the owning page
				setResponsePage(getPage().getClass(), WicketUtils.newRepositoryParameter(repositoryModel.name));
			}
			else {
				error(MessageFormat.format("Failed to delete branch \"{0}\"", entry.displayName));
			}
		}
	};
	
	deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
			"Delete branch \"{0}\"?", entry.displayName )));
	return deleteLink;
}
 
Example 44
Project: IRCBlit   File: BranchesPanel.java   Source Code and License Vote up 5 votes
private Link<Void> createDeleteBranchLink(final RepositoryModel repositoryModel, final RefModel entry)
{
	Link<Void> deleteLink = new Link<Void>("deleteBranch") {
		private static final long serialVersionUID = 1L;

		@Override
		public void onClick() {
			Repository r = GitBlit.self().getRepository(repositoryModel.name);
			if (r == null) {
				if (GitBlit.self().isCollectingGarbage(repositoryModel.name)) {
					error(MessageFormat.format(getString("gb.busyCollectingGarbage"), repositoryModel.name));
				} else {
					error(MessageFormat.format("Failed to find repository {0}", repositoryModel.name));
				}
				return;
			}
			boolean success = JGitUtils.deleteBranchRef(r, entry.getName());
			r.close();
			if (success) {
				info(MessageFormat.format("Branch \"{0}\" deleted", entry.displayName));
				// redirect to the owning page
				setResponsePage(getPage().getClass(), WicketUtils.newRepositoryParameter(repositoryModel.name));
			}
			else {
				error(MessageFormat.format("Failed to delete branch \"{0}\"", entry.displayName));
			}
		}
	};
	
	deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
			"Delete branch \"{0}\"?", entry.displayName )));
	return deleteLink;
}
 
Example 45
Project: nextreports-server   File: AbstractImageAjaxLinkPanel.java   Source Code and License Vote up 5 votes
@Override
protected Link getLink() {
	Link link = super.getLink();
	link.add(getImage());
	
	return link;
}
 
Example 46
Project: projectforge-webapp   File: HRListResourceLinkPanel.java   Source Code and License Vote up 5 votes
public void refresh(final HRViewData hrViewData, final Date startTime)
{
  userRepeater.removeAll();
  final List<PFUserDO> unplannedUsers = hrDao.getUnplannedResources(hrViewData);
  for (final PFUserDO user : unplannedUsers) {
    if (user.isHrPlanning() == false || user.hasSystemAccess() == false) {
      continue;
    }
    final WebMarkupContainer container = new WebMarkupContainer(userRepeater.newChildId());
    userRepeater.add(container);
    @SuppressWarnings("serial")
    final Link<Object> link = new Link<Object>("resourceLink") {
      @Override
      public void onClick()
      {
        final DateHolder date = new DateHolder(startTime);
        final Long millis = date.getSQLDate().getTime();
        final PageParameters pageParams = new PageParameters();
        pageParams.add(WebConstants.PARAMETER_USER_ID, String.valueOf(user.getId()));
        pageParams.add(WebConstants.PARAMETER_DATE, millis.toString());
        final HRPlanningEditPage page = new HRPlanningEditPage(pageParams);
        page.setReturnToPage(hrListPage);
        setResponsePage(page);
      }
    };
    container.add(link);
    link.add(new Label("user", HtmlHelper.escapeXml(userFormatter.formatUser(user)) + "<br/>").setEscapeModelStrings(false));
  }
}
 
Example 47
Project: Jouve-Project   File: OpenSearchResultPanel.java   Source Code and License Vote up 5 votes
public OpenSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
		super(id);

		String title = (String) doc.getFieldValue("title");
		String excerpt = (String) doc.getFieldValue("description");
		final String url = (String) doc.getFieldValue("link");
        final String collectionName = dataProvider.getSimpleSearch().getCollectionName();
        final String searchLogDocId = dataProvider.getSimpleSearch().getSearchLogDocId();
        
        Link titleLink = new Link("titleLink") {
            @Override
            public void onClick() {
                RecordCollectionServices collectionServices = ConstellioSpringUtils.getRecordCollectionServices();
                RecordServices recordServices = ConstellioSpringUtils.getRecordServices();
                StatsServices statsServices = ConstellioSpringUtils.getStatsServices();
                
//                RecordCollection collection = collectionServices.get(collectionName);
//                Record record = recordServices.get(recordUrl, collection);
//                
//                statsServices.logClick(collection, record, searchLogDocId);
                getRequestCycle().setRequestTarget(new RedirectRequestTarget(url));
            }
        };

        // Add title
        if (StringUtils.isEmpty(title)) {
            title = url;
            if (title.length() > 120) {
                title = title.substring(0, 120) + " ...";
            }
        }

        Label titre = new Label("title", title);
        titleLink.add(titre.setEscapeModelStrings(false));
        add(titleLink);

        Label excerptLbl = new Label("excerpt", excerpt);
        add(excerptLbl.setEscapeModelStrings(false));
        add(new Label("url", url));
    }
 
Example 48
Project: nextreports-server   File: AbstractAjaxLinkPanel.java   Source Code and License Vote up 5 votes
@SuppressWarnings("serial")
	protected Link getLink() {
		Link link = new AjaxFallbackLink("link") {

			@Override
			public void onClick(AjaxRequestTarget target) {
				AbstractAjaxLinkPanel.this.onClick(target);
			}

		};
//		link.add(new SimpleAttributeModifier("class", "links"));
		link.add(new Label("label", getDisplayString()));

		return link;
	}
 
Example 49
Project: gitplex-mit   File: RequestDetailPage.java   Source Code and License Vote up 4 votes
@Override
public Component render(String componentId) {
	if (getMainPageClass() == CodeCommentsPage.class) {
		Fragment fragment = new Fragment(componentId, "codeCommentsTabLinkFrag", RequestDetailPage.this);
		Link<Void> link = new ViewStateAwarePageLink<Void>("link", CodeCommentsPage.class, paramsOf(getPullRequest())) {

			@Override
			public void onEvent(IEvent<?> event) {
				super.onEvent(event);
				if (event.getPayload() instanceof PageDataChanged) {
					((PageDataChanged)event.getPayload()).getHandler().add(this);
				}
			}
			
		};
		link.add(AttributeAppender.append("class", new LoadableDetachableModel<String>() {

			@Override
			protected String load() {
				PullRequest request = getPullRequest();
				if (request.getLastCodeCommentEventDate() != null && !request.isVisitedAfter(request.getLastCodeCommentEventDate()))
					return "new";
				else
					return "";
			}
			
		}));
		link.setOutputMarkupId(true);
		fragment.add(link);
		return fragment;
	} else {
		return new PageTabLink(componentId, this) {

			@Override
			protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) {
				return new ViewStateAwarePageLink<Void>(linkId, pageClass, paramsOf(getPullRequest()));
			}
			
		};
	}
}
 
Example 50
Project: gitplex-mit   File: DashboardPage.java   Source Code and License Vote up 4 votes
@Override
protected void onInitialize() {
	super.onInitialize();
	
	Link<Void> link = new BookmarkablePageLink<Void>("projects", ProjectListPage.class);
	link.add(new Label("count", GitPlex.getInstance(ProjectManager.class)
			.getAccessibleProjects(getLoginUser()).size()));
	add(link);
	
	add(new BookmarkablePageLink<Void>("addProject", NewProjectPage.class) {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(SecurityUtils.canCreateProjects());
		}
		
	});
	
	link = new BookmarkablePageLink<Void>("users", UserListPage.class);
	link.add(new Label("count", GitPlex.getInstance(UserManager.class).findAll().size()));
	add(link);
	
	add(new BookmarkablePageLink<Void>("addUser", NewUserPage.class) {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(SecurityUtils.isAdministrator());
		}
		
	});
	
	link = new BookmarkablePageLink<Void>("groups", GroupListPage.class);
	link.add(new Label("count", GitPlex.getInstance(GroupManager.class).findAll().size()));
	add(link);
	
	add(new BookmarkablePageLink<Void>("addGroup", NewGroupPage.class) {

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(SecurityUtils.isAdministrator());
		}
		
	});
	
	add(new BookmarkablePageLink<Void>("administration", SystemSettingPage.class) {
		
		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(SecurityUtils.isAdministrator());
		}
		
	});
}
 
Example 51
Project: openNaEF   File: SimpleNodeDetailPage.java   Source Code and License Vote up 4 votes
private void populateSlotInfo(NodeDto node) {
    ListView<SlotDto> slotTable = new ListView<SlotDto>("slotTable", slotsModel) {
        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(ListItem<SlotDto> item) {
            final SlotDto slot = item.getModelObject();
            slot.renew();
            final ModuleDto module = slot.getModule();
            String endOfUseClass = null;
            if (NodeUtil.isEndOfUse(slot)) {
                endOfUseClass = "end-of-use";
            }
            AttributeAppender appender = new AttributeAppender("class", new Model<String>(endOfUseClass), " ");
            item.add(appender);

            Link<Void> editSlot = new Link<Void>("editSlot") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onClick() {
                    setResponsePage(new SlotEditPage(SimpleNodeDetailPage.this, slot));
                }
            };
            item.add(editSlot);

            String slotId = NameUtil.getIfName(slot);
            editSlot.add(new Label("slotId", new Model<String>(slotId)));

            String slotType = HardwareRenderer.getSlotType(slot);
            item.add(new Label("slotType", new Model<String>(slotType)));

            String moduleName = HardwareRenderer.getModuleType(module);
            item.add(new Label("moduleName", new Model<String>(moduleName)));

            String operStatus = HardwareRenderer.getOperStatus(slot);
            item.add(new Label("operStatus", new Model<String>(operStatus)));

            String note = HardwareRenderer.getNote(slot);
            item.add(new Label("note", new Model<String>(note)));

            Label lastEditor = new Label("lastEditor", new Model<String>(HardwareRenderer.getLastEditor(slot)));
            item.add(lastEditor);
            Label lastEditTime = new Label("lastEditTime", new Model<String>(HardwareRenderer.getLastEditTime(slot)));
            item.add(lastEditTime);
            Label version = new Label("version", Model.of(HardwareRenderer.getVersion(slot)));
            item.add(version);

            Form<Void> deleteForm = new Form<Void>("removeModule");
            item.add(deleteForm);
            SubmitLink removeModuleLink = new SubmitLink("apply") {
                private static final long serialVersionUID = 1L;

                @Override
                public void onSubmit() {
                    ModuleRemovePage page = new ModuleRemovePage(SimpleNodeDetailPage.this, slot);
                    setResponsePage(page);
                }
            };
            removeModuleLink.setEnabled(slot.getModule() != null);
            removeModuleLink.setVisible(slot.getModule() != null);
            deleteForm.add(removeModuleLink);

            try {
                ExternalLink history = HistoryUtil.createHistoryLink(slot, "History");
                history.setEnabled(CoreConfiguration.getInstance().isDebug());
                history.setVisible(CoreConfiguration.getInstance().isDebug());
                item.add(history);
            } catch (Exception e) {
                throw ExceptionUtils.throwAsRuntime(e);
            }
        }
    };
    add(slotTable);
}
 
Example 52
Project: vlo-curation   File: SearchResultItemPanel.java   Source Code and License Vote up 4 votes
/**
 *
 * @param id markup id of the panel
 * @param documentModel model of document that this search item represents
 * @param selectionModel model of current selection (will be passed on to
 * record page when link is clicked)
 * @param expansionStateModel model for the expansion state of this search
 * item
 * @param availabilityOrdering ordering for availability 'tags'
 */
public SearchResultItemPanel(String id, IModel<SolrDocument> documentModel, IModel<SearchContext> selectionModel, IModel<ExpansionState> expansionStateModel, Ordering<String> availabilityOrdering) {
    super(id, documentModel);
    this.expansionStateModel = expansionStateModel;
    this.selectionModel = selectionModel;
    this.documentModel = documentModel;

    final Link recordLink = new RecordPageLink("recordLink", documentModel, selectionModel);
    recordLink.add(new SolrFieldLabel("title", documentModel, FacetConstants.FIELD_NAME, "Unnamed record"));
    add(recordLink);

    // add a link to toggle the expansion state
    add(createExpansionStateToggle("expansionStateToggle"));

    // add a collapsed details panel; only shown when expansion state is collapsed (through onConfigure)
    collapsedDetails = new SearchResultItemCollapsedPanel("collapsedDetails", documentModel, selectionModel, availabilityOrdering);
    add(collapsedDetails);

    // add a collapsed details panel; only shown when expansion state is expanded (through onConfigure)
    expandedDetails = new SearchResultItemExpandedPanel("expandedDetails", documentModel, selectionModel, availabilityOrdering);
    add(expandedDetails);

    // get model for resources
    final SolrFieldModel<String> resourcesModel = new SolrFieldModel<>(documentModel, FacetConstants.FIELD_RESOURCE);
    // wrap with a count provider
    final ResouceTypeCountDataProvider countProvider = new ResouceTypeCountDataProvider(resourcesModel, countingService);

    // add a container for the resource type counts (only visible if there are actual resources)
    add(new WebMarkupContainer("resources")
            // view that shows provided counts
            .add(new ResourceCountDataView("resourceCount", countProvider))
            .add(new WebMarkupContainer("noResources") {

                @Override
                protected void onConfigure() {
                    super.onConfigure();
                    setVisible(countProvider.size() == 0);
                }
            }.add(new RecordPageLink("recordLink", documentModel, selectionModel)) //initial tab *not* resources as there are none...
            )
    );

    add(new SearchResultItemLicensePanel("licenseInfo", documentModel, selectionModel, availabilityOrdering));

    final MarkupContainer scoreContainer = new WebMarkupContainer("scoreContainer");
    scoreContainer.add(new Label("score", new SolrFieldStringModel(documentModel, FacetConstants.FIELD_SOLR_SCORE)));
    scoreContainer.setVisible(config.isShowResultScores());
    add(scoreContainer);

    setOutputMarkupId(true);
}
 
Example 53
Project: vlo-curation   File: SearchResultItemPanel.java   Source Code and License Vote up 4 votes
private Link createExpansionStateToggle(String id) {
    final Link expansionStateToggle = new IndicatingAjaxFallbackLink(id) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            // toggle the expansion state
            if (expansionStateModel.getObject() == ExpansionState.COLLAPSED) {
                expansionStateModel.setObject(ExpansionState.EXPANDED);
            } else {
                expansionStateModel.setObject(ExpansionState.COLLAPSED);
            }

            if (target != null) {
                // parial update (just this search result item)
                target.add(SearchResultItemPanel.this);

                // in case of a query, update highlight matching search terms after collapse/expand
                final String query = selectionModel.getObject().getSelection().getQuery();
                if (!Strings.isEmpty(query)) {
                    final HighlightSearchTermScriptFactory scriptFactory = new HighlightSearchTermScriptFactory();
                    final String selector = "#" + SearchResultItemPanel.this.getMarkupId();
                    target.appendJavaScript(scriptFactory.createScript(selector, query));
                }
            }
        }
    };
    expansionStateToggle.add(
            new WebMarkupContainer("state").add(
                    new AttributeModifier("class", new AbstractReadOnlyModel<String>() {

                        @Override
                        public String getObject() {
                            if (expansionStateModel.getObject() == ExpansionState.COLLAPSED) {
                                return "fa fa-plus-square-o";
                            } else {
                                return "fa fa-minus-square-o";
                            }
                        }
                    })));
    return expansionStateToggle;
}
 
Example 54
Project: elpaaso-core   File: ApplicationActionPanel.java   Source Code and License Vote up 4 votes
private void initComponent() {
    AjaxLink<Application> deleteBtn = new AjaxLink<Application>("app-delete", getModel()) {
        private static final long serialVersionUID = -3624723770141461652L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            parentPage.deleteApplication(target, getModelObject());
        }

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.getAjaxCallListeners().add(new DeleteConfirmationDecorator(WicketUtils.getStringResourceModel(this,"portal.application.action.delete.confirm", new Model<String[]>(new String[]{ getModelObject().getLabel() })).getObject()));
             
        }

        @Override
        public boolean isVisible() {
            return canBeDeleted;
        }
    };

    WebMarkupContainer deleteDisabledSpan = new WebMarkupContainer("app-delete-disable");
    if (canBeDeleted) {
        deleteDisabledSpan.setVisible(false);
    }
    add(deleteDisabledSpan);

    deleteSpan = new WebMarkupContainer("deleteImg");
    deleteBtn.add(deleteSpan);
    add(deleteBtn);

    Link<Application> editBtn = new Link<Application>("app-edit", getModel()) {

        private static final long serialVersionUID = -5024306917768033030L;

        @Override
        public void onClick() {
            PageParameters params = new PageParameters();
            params.set("appUid", getModelObject().getUID());
            params.set("edit", "1");

            SelectedAppPage appPage = new SelectedAppPage(params);
            setResponsePage(appPage);
        }
        
        @Override
        public boolean isVisible() {
            return getModelObject().isEditable();
        }
    };
    editBtn.add(new AttributeAppender("title", new ResourceModel("portal.application.action.modify")));

    WebMarkupContainer editDisabledSpan = new WebMarkupContainer("app-edit-disable");
    if (getModelObject().isEditable()) {
        editDisabledSpan.setVisible(false);
    }
    add(editDisabledSpan);

    editSpan = new WebMarkupContainer("editImg");
    editBtn.add(editSpan);
    add(editBtn);
}
 
Example 55
Project: sakai   File: WallItemCommentPanel.java   Source Code and License Vote up 4 votes
public WallItemCommentPanel(String id, WallItemComment comment) {
	super(id);
	
	setOutputMarkupId(true);
	
	// image wrapper, links to profile
	Link<String> wallItemPhoto = new Link<String>("wallItemPhotoWrap",
			new Model<String>(comment.getCreatorUuid())) {

		private static final long serialVersionUID = 1L;

		public void onClick() {
			setResponsePage(new ViewProfile(getModelObject()));
		}
	};

	// image		
	ProfileImage photo = new ProfileImage("wallItemPhoto", new Model<String>(comment.getCreatorUuid()));
	photo.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
	wallItemPhoto.add(photo);
	
	add(wallItemPhoto);

	// name and link to profile
	Link<String> wallItemProfileLink = new Link<String>(
			"wallItemProfileLink", new Model<String>(comment
					.getCreatorUuid())) {

		private static final long serialVersionUID = 1L;

		public void onClick() {
			setResponsePage(new ViewProfile(getModelObject()));
		}

	};
	wallItemProfileLink.add(new Label("wallItemCommentName", sakaiProxy
			.getUserDisplayName(comment.getCreatorUuid())));
	add(wallItemProfileLink);
	
	// content of the comment
	add(new Label("wallItemCommentText", new ResourceModel(comment.getText())));
			
	add(new Label("wallItemCommentDate", ProfileUtils.convertDateToString(comment
			.getDate(), ProfileConstants.WALL_DISPLAY_DATE_FORMAT)));
}
 
Example 56
Project: sakai   File: BasePage.java   Source Code and License Vote up 4 votes
/**
 * Disable a page nav link (PRFL-468)
 */
protected void disableLink(final Link<Void> l) {
	l.add(new AttributeAppender("class", new Model<String>("current"), " "));
	l.setEnabled(false);
}
 
Example 57
Project: sakai   File: BasePage.java   Source Code and License Vote up 4 votes
/** 
 * Helper to disable a link. Add the Sakai class 'current'.
 */
protected void disableLink(Link<Void> l) {
	l.add(new AttributeAppender("class", new Model<String>("current"), " "));
	l.setRenderBodyOnly(true);
	l.setEnabled(false);
}
 
Example 58
Project: sakai   File: BasePage.java   Source Code and License Vote up 4 votes
/**
 * Helper to disable a link. Add the Sakai class 'current'.
 */
protected void disableLink(final Link<Void> l) {
	l.add(new AttributeAppender("class", new Model<String>("current"), " "));
	l.replace(new Label("screenreaderlabel", getString("link.screenreader.tabselected")));
	l.setEnabled(false);
}
 
Example 59
Project: gradebookNG   File: BasePage.java   Source Code and License Vote up 4 votes
/** 
 * Helper to disable a link. Add the Sakai class 'current'.
 */
protected void disableLink(Link<Void> l) {
	l.add(new AttributeAppender("class", new Model<String>("current"), " "));
	l.setEnabled(false);
}
 
Example 60
Project: sakai   File: WallItemCommentPanel.java   Source Code and License Vote up 4 votes
public WallItemCommentPanel(String id, WallItemComment comment) {
	super(id);
	
	setOutputMarkupId(true);
	
	// image wrapper, links to profile
	Link<String> wallItemPhoto = new Link<String>("wallItemPhotoWrap",
			new Model<String>(comment.getCreatorUuid())) {

		private static final long serialVersionUID = 1L;

		public void onClick() {
			setResponsePage(new ViewProfile(getModelObject()));
		}
	};

	// image		
	ProfileImage photo = new ProfileImage("wallItemPhoto", new Model<String>(comment.getCreatorUuid()));
	photo.setSize(ProfileConstants.PROFILE_IMAGE_THUMBNAIL);
	wallItemPhoto.add(photo);
	
	add(wallItemPhoto);

	// name and link to profile
	Link<String> wallItemProfileLink = new Link<String>(
			"wallItemProfileLink", new Model<String>(comment
					.getCreatorUuid())) {

		private static final long serialVersionUID = 1L;

		public void onClick() {
			setResponsePage(new ViewProfile(getModelObject()));
		}

	};
	wallItemProfileLink.add(new Label("wallItemCommentName", sakaiProxy
			.getUserDisplayName(comment.getCreatorUuid())));
	add(wallItemProfileLink);
	
	// content of the comment
	add(new Label("wallItemCommentText", new ResourceModel(comment.getText())));
			
	add(new Label("wallItemCommentDate", ProfileUtils.convertDateToString(comment
			.getDate(), ProfileConstants.WALL_DISPLAY_DATE_FORMAT)));
}
 
Example 61
Project: sakai   File: BasePage.java   Source Code and License Vote up 4 votes
/**
 * Disable a page nav link (PRFL-468)
 */
protected void disableLink(final Link<Void> l) {
	l.add(new AttributeAppender("class", new Model<String>("current"), " "));
	l.setEnabled(false);
}
 
Example 62
Project: sakai   File: BasePage.java   Source Code and License Vote up 4 votes
/** 
 * Helper to disable a link. Add the Sakai class 'current'.
 */
protected void disableLink(Link<Void> l) {
	l.add(new AttributeAppender("class", new Model<String>("current"), " "));
	l.setRenderBodyOnly(true);
	l.setEnabled(false);
}
 
Example 63
Project: sakai   File: BasePage.java   Source Code and License Vote up 4 votes
/**
 * Helper to disable a link. Add the Sakai class 'current'.
 */
protected void disableLink(final Link<Void> l) {
	l.add(new AttributeAppender("class", new Model<String>("current"), " "));
	l.replace(new Label("screenreaderlabel", getString("link.screenreader.tabselected")));
	l.setEnabled(false);
}
 
Example 64
Project: IRCBlit   File: UsersPanel.java   Source Code and License Vote up 4 votes
public UsersPanel(String wicketId, final boolean showAdmin) {
	super(wicketId);

	Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);
	adminLinks.add(new BookmarkablePageLink<Void>("newUser", EditUserPage.class)
			.setVisible(GitBlit.self().supportsAddUser()));
	add(adminLinks.setVisible(showAdmin));

	final List<UserModel> users = GitBlit.self().getAllUsers();
	DataView<UserModel> usersView = new DataView<UserModel>("userRow",
			new ListDataProvider<UserModel>(users)) {
		private static final long serialVersionUID = 1L;
		private int counter;

		@Override
		protected void onBeforeRender() {
			super.onBeforeRender();
			counter = 0;
		}

		public void populateItem(final Item<UserModel> item) {
			final UserModel entry = item.getModelObject();
			LinkPanel editLink = new LinkPanel("username", "list", entry.username,
					EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
			WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.getDisplayName());
			item.add(editLink);
			
			if (StringUtils.isEmpty(entry.displayName)) {
				item.add(new Label("displayName").setVisible(false));
			} else {
				editLink = new LinkPanel("displayName", "list", entry.getDisplayName(),
					EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
				WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.getDisplayName());
				item.add(editLink);
			}

			if (StringUtils.isEmpty(entry.emailAddress)) {
				item.add(new Label("emailAddress").setVisible(false));
			} else {
				editLink = new LinkPanel("emailAddress", "list", entry.emailAddress,
					EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
				WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.getDisplayName());
				item.add(editLink);
			}

			item.add(new Label("accountType", entry.accountType.name() + (entry.canAdmin() ? ", admin":"")));
			item.add(new Label("teams", entry.teams.size() > 0 ? ("" + entry.teams.size()) : ""));
			item.add(new Label("repositories",
					entry.permissions.size() > 0 ? ("" + entry.permissions.size()) : ""));
			Fragment userLinks = new Fragment("userLinks", "userAdminLinks", this);
			userLinks.add(new BookmarkablePageLink<Void>("editUser", EditUserPage.class,
					WicketUtils.newUsernameParameter(entry.username)));
			Link<Void> deleteLink = new Link<Void>("deleteUser") {

				private static final long serialVersionUID = 1L;

				@Override
				public void onClick() {
					if (GitBlit.self().deleteUser(entry.username)) {
						users.remove(entry);
						info(MessageFormat.format(getString("gb.userDeleted"), entry.username));
					} else {
						error(MessageFormat.format(getString("gb.deleteUserFailed"),
								entry.username));
					}
				}
			};
			deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
					getString("gb.deleteUser"), entry.username)));
			userLinks.add(deleteLink);
			item.add(userLinks);

			WicketUtils.setAlternatingBackground(item, counter);
			counter++;
		}
	};
	add(usersView.setVisible(showAdmin));
}
 
Example 65
Project: gitblit   File: UsersPanel.java   Source Code and License Vote up 4 votes
public UsersPanel(String wicketId, final boolean showAdmin) {
	super(wicketId);

	Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);
	adminLinks.add(new BookmarkablePageLink<Void>("newUser", EditUserPage.class)
			.setVisible(GitBlit.self().supportsAddUser()));
	add(adminLinks.setVisible(showAdmin));

	final List<UserModel> users = GitBlit.self().getAllUsers();
	DataView<UserModel> usersView = new DataView<UserModel>("userRow",
			new ListDataProvider<UserModel>(users)) {
		private static final long serialVersionUID = 1L;
		private int counter;

		@Override
		protected void onBeforeRender() {
			super.onBeforeRender();
			counter = 0;
		}

		public void populateItem(final Item<UserModel> item) {
			final UserModel entry = item.getModelObject();
			LinkPanel editLink = new LinkPanel("username", "list", entry.username,
					EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
			WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.getDisplayName());
			item.add(editLink);
			
			if (StringUtils.isEmpty(entry.displayName)) {
				item.add(new Label("displayName").setVisible(false));
			} else {
				editLink = new LinkPanel("displayName", "list", entry.getDisplayName(),
					EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
				WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.getDisplayName());
				item.add(editLink);
			}

			if (StringUtils.isEmpty(entry.emailAddress)) {
				item.add(new Label("emailAddress").setVisible(false));
			} else {
				editLink = new LinkPanel("emailAddress", "list", entry.emailAddress,
					EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
				WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.getDisplayName());
				item.add(editLink);
			}

			item.add(new Label("accountType", entry.accountType.name() + (entry.canAdmin() ? ", admin":"")));
			item.add(new Label("teams", entry.teams.size() > 0 ? ("" + entry.teams.size()) : ""));
			item.add(new Label("repositories",
					entry.permissions.size() > 0 ? ("" + entry.permissions.size()) : ""));
			Fragment userLinks = new Fragment("userLinks", "userAdminLinks", this);
			userLinks.add(new BookmarkablePageLink<Void>("editUser", EditUserPage.class,
					WicketUtils.newUsernameParameter(entry.username)));
			Link<Void> deleteLink = new Link<Void>("deleteUser") {

				private static final long serialVersionUID = 1L;

				@Override
				public void onClick() {
					if (GitBlit.self().deleteUser(entry.username)) {
						users.remove(entry);
						info(MessageFormat.format(getString("gb.userDeleted"), entry.username));
					} else {
						error(MessageFormat.format(getString("gb.deleteUserFailed"),
								entry.username));
					}
				}
			};
			deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
					getString("gb.deleteUser"), entry.username)));
			userLinks.add(deleteLink);
			item.add(userLinks);

			WicketUtils.setAlternatingBackground(item, counter);
			counter++;
		}
	};
	add(usersView.setVisible(showAdmin));
}
 
Example 66
Project: projectforge-webapp   File: AdminPage.java   Source Code and License Vote up 4 votes
@SuppressWarnings("serial")
protected void addDatabaseActionsMenu()
{
  // Data-base actions
  final ContentMenuEntryPanel databaseActionsMenu = new ContentMenuEntryPanel(getNewContentMenuChildId(),
      getString("system.admin.group.title.databaseActions"));
  addContentMenuEntry(databaseActionsMenu);
  // Update all user preferences
  final Link<Void> updateUserPrefsLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      updateUserPrefs();
    }
  };
  final ContentMenuEntryPanel updateUserPrefsLinkMenuItem = new ContentMenuEntryPanel(databaseActionsMenu.newSubMenuChildId(),
      updateUserPrefsLink, getString("system.admin.button.updateUserPrefs"))
  .setTooltip(getString("system.admin.button.updateUserPrefs.tooltip"));
  databaseActionsMenu.addSubMenuEntry(updateUserPrefsLinkMenuItem);

  // Create missing data-base indices.
  final Link<Void> createMissingDatabaseIndicesLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      createMissingDatabaseIndices();
    }
  };
  final ContentMenuEntryPanel createMissingDatabaseIndicesLinkMenuItem = new ContentMenuEntryPanel(
      databaseActionsMenu.newSubMenuChildId(), createMissingDatabaseIndicesLink,
      getString("system.admin.button.createMissingDatabaseIndices"))
  .setTooltip(getString("system.admin.button.createMissingDatabaseIndices.tooltip"));
  databaseActionsMenu.addSubMenuEntry(createMissingDatabaseIndicesLinkMenuItem);
  // Fix data-base history entries.
  final Link<Void> fixDBHistoryEntriesLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      fixDBHistoryEntries();
    }
  };
  final ContentMenuEntryPanel fixDBHistoryEntriesLinkMenuItem = new ContentMenuEntryPanel(databaseActionsMenu.newSubMenuChildId(),
      fixDBHistoryEntriesLink, getString("system.admin.button.fixDBHistoryEntries"))
  .setTooltip(getString("system.admin.button.fixDBHistoryEntries.tooltip"));
  databaseActionsMenu.addSubMenuEntry(fixDBHistoryEntriesLinkMenuItem);
  {
    // Dump data-base.
    final Link<Void> dumpDatabaseLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
      @Override
      public void onClick()
      {
        dump();
      }
    };
    final ContentMenuEntryPanel dumpDatabaseLinkMenuItem = new ContentMenuEntryPanel(databaseActionsMenu.newSubMenuChildId(),
        dumpDatabaseLink, getString("system.admin.button.dump")).setTooltip(getString("system.admin.button.dump.tooltip"));
    databaseActionsMenu.addSubMenuEntry(dumpDatabaseLinkMenuItem);
    dumpDatabaseLink.add(WicketUtils.javaScriptConfirmDialogOnClick(getString("system.admin.button.dump.question")));
  }
  {
    // Schema export.
    final Link<Void> schemaExportLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
      @Override
      public void onClick()
      {
        schemaExport();
      }
    };
    final ContentMenuEntryPanel schemaExportLinkMenuItem = new ContentMenuEntryPanel(databaseActionsMenu.newSubMenuChildId(),
        schemaExportLink, getString("system.admin.button.schemaExport"))
    .setTooltip(getString("system.admin.button.schemaExport.tooltip"));
    databaseActionsMenu.addSubMenuEntry(schemaExportLinkMenuItem);
  }
}
 
Example 67
Project: projectforge-webapp   File: OrderPositionsPanel.java   Source Code and License Vote up 4 votes
@SuppressWarnings("serial")
public void init(final Set<AuftragsPositionVO> orderPositions)
{
  final RepeatingView positionsRepeater = new RepeatingView("pos");
  add(positionsRepeater);
  if (orderPositions != null) {
    final Iterator<AuftragsPositionVO> it = orderPositions.iterator();
    int orderNumber = -1;
    StringBuffer buf = new StringBuffer();
    Link<String> link = null;
    BigDecimal totalPersonDays = BigDecimal.ZERO;
    AuftragsPositionVO previousOrderPosition = null;
    while (it.hasNext() == true) {
      final AuftragsPositionVO orderPosition = it.next();
      if (orderPosition.getAuftragNummer() != null && orderNumber != orderPosition.getAuftragNummer().intValue()) {
        orderNumber = orderPosition.getAuftragNummer();
        final WebMarkupContainer item = new WebMarkupContainer(positionsRepeater.newChildId());
        positionsRepeater.add(item);
        final Label separatorLabel = new Label("separator", ", ");
        if (previousOrderPosition != null) {
          // Previous order position finished.
          addTitleAttribute(link, previousOrderPosition, totalPersonDays, buf);
          buf = new StringBuffer();
          totalPersonDays = BigDecimal.ZERO;
        } else {
          separatorLabel.setVisible(false); // Invisible for first entry.
        }
        previousOrderPosition = orderPosition;
        item.add(separatorLabel);
        link = new Link<String>("link") {
          @Override
          public void onClick()
          {
            final PageParameters params = new PageParameters();
            params.add(AbstractEditPage.PARAMETER_KEY_ID, String.valueOf(orderPosition.getAuftragId()));
            final AuftragEditPage page = new AuftragEditPage(params);
            page.setReturnToPage((AbstractSecuredPage) getPage());
            setResponsePage(page);
          };
        };
        item.add(link);
        link.add(new Label("label", String.valueOf(orderPosition.getAuftragNummer())));
      } else {
        buf.append("\n");
      }
      buf.append("#").append(orderPosition.getNumber()).append(" (");
      if (orderPosition.getPersonDays() != null) {
        buf.append(NumberFormatter.format(orderPosition.getPersonDays()));
        totalPersonDays = totalPersonDays.add(orderPosition.getPersonDays());
      } else {
        buf.append("??");
      }
      final String title = StringUtils.defaultString(orderPosition.getTitel());
      buf.append(" ").append(getString("projectmanagement.personDays.short")).append("): ").append(title);
      if (orderPosition.getStatus() != null) {
        if (StringUtils.isNotBlank(title) == true) {
          buf.append(", ");
        }
        buf.append(getString(orderPosition.getStatus().getI18nKey()));
      }
      if (it.hasNext() == false && link != null) {
        addTitleAttribute(link, orderPosition, totalPersonDays, buf);
      }
    }
  }
}
 
Example 68
Project: artifact-listener   File: RecommendedArtifactPortfolioPanel.java   Source Code and License Vote up 4 votes
@Override
protected void addItemColumns(final Item<Artifact> item, IModel<? extends Artifact> itemModel) {
	item.setOutputMarkupId(true);
	
	Artifact artifact = item.getModelObject();
	final IModel<Artifact> artifactModel = new ArtifactModel(Model.of(item.getModelObject().getArtifactKey()));
	final ArtifactLastVersionModel artifactLastVersionModel = new ArtifactLastVersionModel(artifactModel);
	
	item.add(new ClassAttributeAppender(new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;
		
		@Override
		protected String load() {
			User user = MavenArtifactNotifierSession.get().getUser();
			boolean isFollowed = user != null && userService.isFollowedArtifact(user, item.getModelObject());
			boolean isDeprecated = artifactModel.getObject() != null &&
					ArtifactDeprecationStatus.DEPRECATED.equals(artifactModel.getObject().getDeprecationStatus());
			return isFollowed ? "success" : (isDeprecated ? "warning" : null);
		}
	}));
	
	// GroupId column
	item.add(new Label("groupId", BindingModel.of(artifactModel, Binding.artifact().group().groupId())));
	item.add(new ExternalLink("groupLink", mavenCentralSearchUrlService.getGroupUrl(artifact.getGroup().getGroupId())));

	// ArtifactId column
	Link<Void> localArtifactLink = ArtifactDescriptionPage.linkDescriptor(artifactModel).link("localArtifactLink");
	localArtifactLink.add(new Label("artifactId", BindingModel.of(artifactModel, Binding.artifact().artifactId())));
	item.add(localArtifactLink);
	
	item.add(new ExternalLink("artifactLink", mavenCentralSearchUrlService.getArtifactUrl(artifact.getGroup().getGroupId(), artifact.getArtifactId())));
	
	// LastVersion, lastUpdateDate columns
	item.add(new Label("synchronizationPlannedPlaceholder", new ResourceModel("artifact.follow.synchronizationPlanned")) {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(artifactModel.getObject() != null && !artifactLastVersionModel.isLastVersionAvailable());
		}
	});
	
	WebMarkupContainer localContainer = new WebMarkupContainer("followedArtifact") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(artifactLastVersionModel.isLastVersionAvailable());
		}
	};
	localContainer.add(new ArtifactVersionTagPanel("latestVersion", Model.of(artifactLastVersionModel.getLastVersion())));
	String latestVersion = (artifact.getLatestVersion() != null ? artifact.getLatestVersion().getVersion() : "");
	localContainer.add(new ExternalLink("versionLink", mavenCentralSearchUrlService.getVersionUrl(artifact.getGroup().getGroupId(),
			artifact.getArtifactId(), latestVersion)));
	
	localContainer.add(new DateLabelWithPlaceholder("lastUpdateDate",
			Model.of(artifactLastVersionModel.getLastVersionUpdateDate()), DatePattern.SHORT_DATE));
	item.add(localContainer);

	// Followers count column
	Label followersCount = new CountLabel("followersCount", "artifact.follow.dataView.followers",
			BindingModel.of(artifactModel, Binding.artifact().followersCount()));
	followersCount.add(new AttributeModifier("class", new LoadableDetachableModel<String>() {
		private static final long serialVersionUID = 1L;

		@Override
		protected String load() {
			if (artifactModel.getObject() != null && artifactModel.getObject().getFollowersCount() > 0) {
				return "badge";
			}
			return null;
		}
	}));
	item.add(followersCount);
	
	// Follow actions
	item.add(new ArtifactFollowActionsPanel("followActions", artifactModel));
}
 
Example 69
Project: projectforge-webapp   File: ConsumptionBarPanel.java   Source Code and License Vote up 4 votes
/**
 * @param id
 * @param usage
 * @param maxValue
 * @param taskId
 * @param taskNodeFinished Depending on the task node is finished or not, the colors are different: E. g. a 95% used bar is green for
 *          finished tasks, for unfinished ones not.
 * @param unit
 * @param linkEnabled If true then the user can click on this bar for getting all time sheets behind this bar.
 */
public ConsumptionBarPanel(final String id, final BigDecimal usage, BigDecimal maxValue, final Integer taskId,
    final boolean taskNodeFinished, final String unit, final boolean linkEnabled)
{
  super(id);
  if (NumberHelper.isNotZero(maxValue) == false) {
    maxValue = null;
  }
  @SuppressWarnings("serial")
  final Link< Void> showTimesheetsLink = new Link<Void>("sheets") {
    @Override
    public void onClick()
    {
      final PageParameters parameters = new PageParameters();
      parameters.add(TimesheetListPage.PARAMETER_KEY_CLEAR_ALL, true);
      parameters.add(TimesheetListPage.PARAMETER_KEY_STORE_FILTER, false);
      parameters.add(TimesheetListPage.PARAMETER_KEY_TASK_ID, taskId);
      final TimesheetListPage timesheetListPage = new TimesheetListPage(parameters);
      setResponsePage(timesheetListPage);
    }
  };
  showTimesheetsLink.setEnabled(linkEnabled);
  add(showTimesheetsLink);
  final WebMarkupContainer bar = new WebMarkupContainer("bar");
  final Label progressLabel = new Label("progress", new Model<String>(" "));
  final int percentage = maxValue != null ? usage.divide(maxValue, 2, BigDecimal.ROUND_HALF_UP).multiply(NumberHelper.HUNDRED).intValue()
      : 0;
  final int width = percentage <= 100 ? percentage : 10000 / percentage;
  bar.add(AttributeModifier.replace("class", "progress"));
  if (percentage <= 80 || (taskNodeFinished == true && percentage <= 100)) {
    if (percentage > 0) {
      bar.add(AttributeModifier.append("class", "progress-done"));
    } else {
      bar.add(AttributeModifier.append("class", "progress-none"));
      progressLabel.setVisible(false);
    }
  } else if (percentage <= 90) {
    bar.add(AttributeModifier.append("class", "progress-80"));
  } else if (percentage <= 100) {
    bar.add(AttributeModifier.append("class", "progress-90"));
  } else if (taskNodeFinished == true && percentage <= 110) {
    bar.add(AttributeModifier.append("class", "progress-overbooked-min"));
  } else {
    bar.add(AttributeModifier.append("class", "progress-overbooked"));
  }
  if (maxValue == null && (usage == null || usage.compareTo(BigDecimal.ZERO) == 0)) {
    bar.setVisible(false);
  }
  progressLabel.add(AttributeModifier.replace("style", "width: " + width + "%;"));
  final StringBuffer buf = new StringBuffer();
  buf.append(NumberHelper.getNumberFractionFormat(getLocale(), usage.scale()).format(usage));
  if (unit != null) {
    buf.append(unit);
  }
  if (maxValue != null) {
    buf.append("/");
    buf.append(NumberHelper.getNumberFractionFormat(getLocale(), maxValue.scale()).format(maxValue));
    buf.append(unit);
    buf.append(" (").append(percentage).append("%)");
  }
  tooltip = buf.toString();
  WicketUtils.addTooltip(bar, tooltip);
  showTimesheetsLink.add(bar);
  bar.add(progressLabel);
}