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

The following examples show how to use org.apache.wicket.markup.html.link.Link#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: ProductItemPanel.java    From AppStash with Apache License 2.0 6 votes vote down vote up
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 2
Source File: AbstractSecuredPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@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 3
Source File: ArtifactPortfolioPanel.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
@Override
protected void addItemColumns(Item<Artifact> item, IModel<? extends Artifact> artifactModel) {
	item.add(new Label("groupId", BindingModel.of(artifactModel, Binding.artifact().group().groupId())));
	Link<Void> artifactLink = AdministrationArtifactDescriptionPage.linkDescriptor(ReadOnlyModel.of(artifactModel))
			.link("artifactLink");
	artifactLink.add(new Label("artifactId", BindingModel.of(artifactModel, Binding.artifact().artifactId())));
	item.add(artifactLink);
	item.add(new Label("nbVersions", BindingModel.of(artifactModel, Binding.artifact().versions().size())));
	
	final IModel<ArtifactDeprecationStatus> deprecatedModel = BindingModel.of(artifactModel, Binding.artifact().deprecationStatus());
	item.add(new BooleanIcon("deprecated", new LoadableDetachableModel<Boolean>() {
		private static final long serialVersionUID = 1L;

		@Override
		protected Boolean load() {
			return ArtifactDeprecationStatus.DEPRECATED.equals(deprecatedModel.getObject());
		}
	}));
}
 
Example 4
Source File: StateStatsBar.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	int totalCount = getModelObject().values().stream().collect(Collectors.summingInt(it->it));
	if (totalCount != 0) {
		RepeatingView statesView = new RepeatingView("states");
		for (StateSpec state: OneDev.getInstance(SettingManager.class).getIssueSetting().getStateSpecs()) {
			Integer count = getModelObject().get(state.getName());
			if (count != null) { 
				Link<Void> link = newStateLink(statesView.newChildId(), state.getName());
				link.add(AttributeAppender.append("title", count + " " + state.getName().toLowerCase() + " issues"));
				link.add(AttributeAppender.append("data-percent", count*1.0/totalCount));
				link.add(AttributeAppender.append("style", "background-color: " + state.getColor()));
				statesView.add(link);
			}
		}
		add(statesView);
	} else {
		add(new Label("states", "&nbsp;") {

			@Override
			protected void onComponentTag(ComponentTag tag) {
				super.onComponentTag(tag);
				tag.setName("span");
			}
			
		}.setEscapeModelStrings(false));
		add(AttributeAppender.append("title", "No issues in milestone"));
	}
	
	setOutputMarkupId(true);
}
 
Example 5
Source File: LinkPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
public LinkPanel(String id) {
  super(id);

  // add link with label
  Link<Page> link = newLink("link");
  link.add(newLabel("label"));
  add(link);
}
 
Example 6
Source File: ProjectSettingTabLink.java    From onedev with MIT License 5 votes vote down vote up
@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("label", tab.getTitleModel()));
	add(link);
}
 
Example 7
Source File: UserGroupPortfolioPanel.java    From artifact-listener with Apache License 2.0 5 votes vote down vote up
@Override
protected void addItemColumns(Item<UserGroup> item, IModel<? extends UserGroup> userGroupModel) {
	Link<Void> nameLink = AdministrationUserGroupDescriptionPage.linkDescriptor(ReadOnlyModel.of(userGroupModel))
			.link("nameLink");
	nameLink.add(new Label("name", BindingModel.of(userGroupModel, Binding.userGroup().name())));
	item.add(nameLink);
	item.add(new Label("description", BindingModel.of(userGroupModel, Binding.userGroup().description())));
}
 
Example 8
Source File: PageTabLink.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	Link<?> pageLink = newLink("link", tab.getMainPageClass());
	add(pageLink);
	pageLink.add(new Label("label", tab.getTitleModel()));
}
 
Example 9
Source File: UserTabLink.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	UserPage page = (UserPage) getPage();
	Link<Void> link = new ViewStateAwarePageLink<Void>("link", 
			tab.getMainPageClass(), UserPage.paramsOf(page.getUser()));
	if (tab.getIconClass() != null)
		link.add(new WebMarkupContainer("icon").add(AttributeAppender.append("class", tab.getIconClass())));
	else
		link.add(new WebMarkupContainer("icon").setVisible(false));
	link.add(new Label("label", tab.getTitleModel()));
	add(link);
}
 
Example 10
Source File: PaginationSupportImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean markSelectedSortLink(final Link link,
                                    final PageParameters pageParameters, final String sortOrder, final String sortField) {
    if (isSortSelected(pageParameters, sortOrder, sortField)) {
        link.add(new AttributeModifier("class", "sort-order-active sort-order active"));
        return true;
    } else {
        link.add(new AttributeModifier("class", "sort-order"));
        return false;
    }
}
 
Example 11
Source File: PaginationSupportImpl.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean markSelectedPageSizeLink(final Link link,
                                        final PageParameters pageParameters, final List<String> itemsPerPageOptions, final int pageSize) {
    if (isPageSizeSelected(pageParameters, itemsPerPageOptions, pageSize)) {
        link.add(new AttributeModifier("class", "items-per-page-active items-per-page active"));
        return true;
    } else {
        link.add(new AttributeModifier("class", "items-per-page"));
        return false;
    }
}
 
Example 12
Source File: EventToWorkflowViewer.java    From oodt with Apache License 2.0 5 votes vote down vote up
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 13
Source File: AdminPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("serial")
protected void addDevelopmentMenu()
{
  if (WebConfiguration.isDevelopmentMode() == false) {
    // Do nothing.
    return;
  }
  // Development actions
  final ContentMenuEntryPanel developmentMenu = new ContentMenuEntryPanel(getNewContentMenuChildId(), "Development");
  addContentMenuEntry(developmentMenu);
  // Check I18n properties.
  final Link<Void> checkI18nPropertiesLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      checkI18nProperties();
    }
  };
  final ContentMenuEntryPanel checkI18nPropertiesLinkMenuItem = new ContentMenuEntryPanel(developmentMenu.newSubMenuChildId(),
      checkI18nPropertiesLink, getString("system.admin.button.checkI18nProperties"))
  .setTooltip(getString("system.admin.button.checkI18nProperties.tooltip"));
  developmentMenu.addSubMenuEntry(checkI18nPropertiesLinkMenuItem);
  // Create test objects
  final Link<Void> createTestObjectsLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      createTestBooks();
    }
  };
  createTestObjectsLink.add(WicketUtils.javaScriptConfirmDialogOnClick(getLocalizedMessage(
      "system.admin.development.testObjectsCreationQuestion", AdminPage.NUMBER_OF_TEST_OBJECTS_TO_CREATE, "BookDO")));
  final ContentMenuEntryPanel createTestObjectsLinkMenuItem = new ContentMenuEntryPanel(developmentMenu.newSubMenuChildId(),
      createTestObjectsLink, "BookDO").setTooltip("Creates 100 books of type BookDO for testing.");
  developmentMenu.addSubMenuEntry(createTestObjectsLinkMenuItem);
}
 
Example 14
Source File: MonthlyEmployeeReportPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("serial")
private WebMarkupContainer addLabelCols(final WebMarkupContainer row, final Kost2DO cost2, final TaskDO task, final String searchString,
    final PFUserDO user, final long startTime, final long stopTime)
{
  final WebMarkupContainer result = new WebMarkupContainer("cost2");
  row.add(result);
  final Link<String> link = new Link<String>("link") {
    @Override
    public void onClick()
    {
      final PageParameters params = new PageParameters();
      params.add("userId", user.getId());
      if (task != null) {
        params.add("taskId", task.getId());
      }
      params.add("startTime", startTime);
      params.add("stopTime", stopTime);
      params.add("storeFilter", false);
      if (searchString != null) {
        params.add("searchString", searchString);
      }
      setResponsePage(new TimesheetListPage(params));
    }
  };
  result.add(link);
  WicketUtils.addRowClick(row);
  if (cost2 != null) {
    final ProjektDO project = cost2.getProjekt();
    final KundeDO customer = project != null ? project.getKunde() : null;
    final Kost2ArtDO costType = cost2.getKost2Art();
    link.add(new Label("label", KostFormatter.format(cost2)));
    if (project != null) {
      row.add(new Label("customer", customer != null ? customer.getName() : ""));
      row.add(new Label("project", project.getName()));
    } else {
      row.add(new Label("customer", cost2.getDescription()).add(AttributeModifier.replace("colspan", "2")));
      row.add(new Label("project", "").setVisible(false));
    }
    addCostType(row, costType.getName());
  } else {
    if (task != null) {
      // Entries for one task (not cost2).
      link.add(new Label("label", taskFormatter.getTaskPath(task.getId(), true, OutputType.PLAIN)));
    } else {
      link.add(new Label("label", getString("sum")));
    }
    result.add(AttributeModifier.replace("colspan", "4"));
    row.add(new Label("customer", "").setVisible(false));
    row.add(new Label("project", "").setVisible(false));
    addCostType(row, null);
  }
  return result;
}
 
Example 15
Source File: BasePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/** 
 * 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 16
Source File: BasePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/** 
 * 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 17
Source File: BasePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * 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 18
Source File: AdminPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@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 19
Source File: BasePage.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * Helper to disable a link. Add the Sakai class 'current'.
 */
protected final 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 20
Source File: ShoppingCartItemsList.java    From yes-cart with Apache License 2.0 3 votes vote down vote up
/**
 * Get link to show product with selected in cart product sku.
 *
 * @param productSku product sku
 * @param cartItem   cart item
 *
 * @return link to show product and selected SKU
 */
private Link getProductLink(final ProductSkuDecorator productSku, final CartItem cartItem) {
    final Link productLink = ((AbstractWebPage) getPage()).getWicketSupportFacade().links()
            .newProductSkuLink(PRODUCT_LINK, cartItem.getSupplierCode(), productSku.getId());
    productLink.add(new Label(PRODUCT_NAME_LABEL, productSku.getName(getLocale().getLanguage())).setEscapeModelStrings(false));
    return productLink;
}