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

The following examples show how to use org.apache.wicket.markup.html.link.Link. These examples are extracted from open source projects. 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 Project: oodt   Source File: WorkflowTaskViewerPage.java    License: Apache License 2.0 6 votes vote down vote up
public WorkflowTaskViewerPage(PageParameters params) {
  add(new Link("home_link"){
    /* (non-Javadoc)
    * @see org.apache.wicket.markup.html.link.Link#onClick()
    */
   @Override
   public void onClick() {
     setResponsePage(getApplication().getHomePage());
   }
});    
  add(new Label("task_id", params.getString("id")));
  WorkflowTaskViewer viewerComponent = new WorkflowTaskViewer("task_viewer",
      ((WMMonitorAppBase) getApplication()).getWorkflowUrl(), params
          .getString("id"), WorkflowConditionViewerPage.class);
  add(viewerComponent);
}
 
Example 2
@SuppressWarnings("serial")
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "nummer", SortOrder.DESCENDING);
  form.add(dataTable);
  final ContentMenuEntryPanel exportExcelButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Object>("link") {
    @Override
    public void onClick()
    {
      final List<AuftragDO> list = getList();
      final byte[] xls = orderExport.export(list);
      if (xls == null || xls.length == 0) {
        form.addError("datatable.no-records-found");
        return;
      }
      final String filename = "ProjectForge-OrderExport_" + DateHelper.getDateAsFilenameSuffix(new Date()) + ".xls";
      DownloadUtils.setDownloadTarget(xls, filename);
    };
  }, getString("exportAsXls")).setTooltip(getString("tooltip.export.excel"));
  addContentMenuEntry(exportExcelButton);

}
 
Example 3
Source Project: onedev   Source File: NewPullRequestPage.java    License: MIT License 6 votes vote down vote up
private Fragment newAcceptedFrag() {
	Fragment fragment = new Fragment("status", "mergedFrag", this);
	fragment.add(new BranchLink("sourceBranch", getPullRequest().getSource()));
	fragment.add(new BranchLink("targetBranch", getPullRequest().getTarget()));
	fragment.add(new Link<Void>("swapBranches") {

		@Override
		public void onClick() {
			setResponsePage(
					NewPullRequestPage.class, 
					paramsOf(getProject(), getPullRequest().getSource(), getPullRequest().getTarget()));
		}
		
	});
	return fragment;
}
 
Example 4
Source Project: oodt   Source File: WorkflowInstanceViewerPage.java    License: Apache License 2.0 6 votes vote down vote up
public WorkflowInstanceViewerPage(PageParameters params){
  add(new Link("home_link"){
    /* (non-Javadoc)
    * @see org.apache.wicket.markup.html.link.Link#onClick()
    */
   @Override
   public void onClick() {
     setResponsePage(getApplication().getHomePage());
   }
});
  
  add(new WorkflowInstancesViewer("instance_viewer", ((WMMonitorApp)getApplication()).getWorkflowUrl(), 
      params.getString("status", "ALL"), params.getInt("pageNum", 1), ((WMMonitorApp)getApplication()).getStatuses(), 
      ((WMMonitorApp)getApplication()).getLifecycleFilePath(), ((WMMonitorApp)getApplication()).getInstMetFieldsFilePath(),
      WorkflowViewerPage.class, WorkflowTaskViewerPage.class, WorkflowInstanceViewerPage.class));
}
 
Example 5
@SuppressWarnings("serial")
protected void addCachesMenu()
{
  // Caches
  final ContentMenuEntryPanel cachesMenu = new ContentMenuEntryPanel(getNewContentMenuChildId(),
      getString("system.admin.group.title.systemChecksAndFunctionality.caches"));
  addContentMenuEntry(cachesMenu);
  // Refresh caches.
  final Link<Void> refreshCachesLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      refreshCaches();
    }
  };
  final ContentMenuEntryPanel refreshCachesLinkMenuItem = new ContentMenuEntryPanel(cachesMenu.newSubMenuChildId(), refreshCachesLink,
      getString("system.admin.button.refreshCaches")).setTooltip(getString("system.admin.button.refreshCaches.tooltip"));
  cachesMenu.addSubMenuEntry(refreshCachesLinkMenuItem);
}
 
Example 6
@SuppressWarnings("serial")
@Override
protected void init()
{
  dataTable = createDataTable(createColumns(this, true), "datum", SortOrder.DESCENDING);
  form.add(dataTable);
  addExcelExport(getString("fibu.common.creditor"), getString("fibu.eingangsrechnungen"));
  if (Configuration.getInstance().isCostConfigured() == true) {
    final ContentMenuEntryPanel exportExcelButton = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Object>("link") {
      @Override
      public void onClick()
      {
        exportExcelWithCostAssignments();
      };
    }, getString("fibu.rechnung.kostExcelExport")).setTooltip(getString("fibu.rechnung.kostExcelExport.tootlip"));
    addContentMenuEntry(exportExcelButton);
  }
}
 
Example 7
Source Project: artifact-listener   Source File: ArtifactPortfolioPanel.java    License: 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 8
Source Project: the-app   Source File: ProductItemPanel.java    License: 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 9
Source Project: oodt   Source File: WorkflowsViewerPage.java    License: Apache License 2.0 6 votes vote down vote up
public WorkflowsViewerPage() {
  add(new Link("home_link") {
    /*
     * (non-Javadoc)
     * 
     * @see org.apache.wicket.markup.html.link.Link#onClick()
     */
    @Override
    public void onClick() {
      setResponsePage(getApplication().getHomePage());
    }
  });

  add(new WorkflowsViewer("workflows_viewer",
      ((WMMonitorApp) getApplication()).getWorkflowUrl(),
      WorkflowViewerPage.class));
}
 
Example 10
@SuppressWarnings("serial")
public AddressEditLinkPanel(final String id, final WebPage returnToPage, final AddressDO address, final String addressText)
{
  super(id);
  add(new Link<Object>("link") {
    @Override
    public void onClick()
    {
      final PageParameters parameters = new PageParameters();
      parameters.add(AbstractEditPage.PARAMETER_KEY_ID, address.getId());
      final AddressEditPage editPage = new AddressEditPage(parameters);
      editPage.setReturnToPage(returnToPage);
      setResponsePage(editPage);
    }
  }.add(new Label("label", addressText).setRenderBodyOnly(true)));
}
 
Example 11
private void addTopMenuPanel()
{
  if (isNew() == false) {
    final Integer id = form.getData().getId();

    @SuppressWarnings("serial")
    final ContentMenuEntryPanel menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
      @Override
      public void onClick()
      {
        final PageParameters params = new PageParameters();
        params.set(TrainingEditForm.PARAM_TRAINING_ID, id);
        final TrainingAttendeeListPage page = new TrainingAttendeeListPage(params);
        page.setReturnToPage(TrainingEditPage.this);
        setResponsePage(page);
      };
    }, getString("plugins.skillmatrix.skilltraining.attendee.menu"));
    addContentMenuEntry(menu);
  }
}
 
Example 12
@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
Source Project: nextreports-server   Source File: WidgetPopupMenuModel.java    License: Apache License 2.0 6 votes vote down vote up
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 14
Source Project: yes-cart   Source File: LinksSupportImpl.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public Link newAddToCartLink(final String linkId,
                             final String supplier,
                             final String skuCode,
                             final String quantity,
                             final PageParameters pageParameters) {

    final PageParameters params = getFilteredCurrentParameters(pageParameters);
    params.set(ShoppingCartCommand.CMD_ADDTOCART, skuCode);
    params.set(ShoppingCartCommand.CMD_P_SUPPLIER, supplier);
    if (quantity != null) { // null quantity will pick min from product
        params.set(ShoppingCartCommand.CMD_P_QTY, quantity);
    }
    return new BookmarkablePageLink(linkId, getHomePage(), params);
}
 
Example 15
Source Project: Orienteer   Source File: DefaultRestorePasswordPage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates container which contains success message about restoring user password
 * @param id component id
 * @return restore success message
 */
protected WebMarkupContainer createRestoreSuccessMessage(String id) {
    return new WebMarkupContainer(id) {
        @Override
        protected void onConfigure() {
            super.onConfigure();
            setVisible(DBClosure.sudo(db -> getModelObject()) == null);
        }

        @Override
        protected void onInitialize() {
            super.onInitialize();
            add(new Link<Void>("loginPage") {
                @Override
                public void onClick() {
                    throw new RedirectToUrlException("/login");
                }
            });
            setOutputMarkupPlaceholderTag(true);
        }
    };
}
 
Example 16
Source Project: sakai   Source File: SakaiPage.java    License: Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 17
Source Project: onedev   Source File: HtmlReportTab.java    License: MIT License 5 votes vote down vote up
@Override
public Component render(String componentId) {
	return new PageTabLink(componentId, this) {

		@Override
		protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) {
			BuildDetailPage page = (BuildDetailPage) getPage();
			PageParameters params = HtmlReportPage.paramsOf(
					page.getBuild(), getTitle());
			return new ViewStateAwarePageLink<Void>(linkId, pageClass, params);
		}
		
	};
}
 
Example 18
Source Project: oodt   Source File: Home.java    License: Apache License 2.0 5 votes vote down vote up
/**
* Constructor that is invoked when page is invoked without a session.
* 
* @param parameters
*            Page parameters
*/
  public Home(final PageParameters parameters) {

      add(new Link<Object>("find_product"){
        /* (non-Javadoc)
         * @see org.apache.wicket.markup.html.link.Link#onClick()
         */
        @Override
        public void onClick() {
          setResponsePage(TypesPage.class);            
        }
      });
  }
 
Example 19
@SuppressWarnings("serial")
protected void addConfigurationMenu()
{
  // Configuration
  final ContentMenuEntryPanel configurationMenu = new ContentMenuEntryPanel(getNewContentMenuChildId(),
      getString("system.admin.group.title.systemChecksAndFunctionality.configuration"));
  addContentMenuEntry(configurationMenu);
  // Check re-read configuration
  final Link<Void> rereadConfigurationLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      rereadConfiguration();
    }
  };
  final ContentMenuEntryPanel rereadConfigurationLinkMenuItem = new ContentMenuEntryPanel(configurationMenu.newSubMenuChildId(),
      rereadConfigurationLink, getString("system.admin.button.rereadConfiguration"))
  .setTooltip(getString("system.admin.button.rereadConfiguration.tooltip"));
  configurationMenu.addSubMenuEntry(rereadConfigurationLinkMenuItem);

  // Export configuration.
  final Link<Void> exportConfigurationLink = new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      exportConfiguration();
    }
  };
  final ContentMenuEntryPanel exportConfigurationLinkMenuItem = new ContentMenuEntryPanel(configurationMenu.newSubMenuChildId(),
      exportConfigurationLink, getString("system.admin.button.exportConfiguration"))
  .setTooltip(getString("system.admin.button.exportConfiguration.tooltip"));
  configurationMenu.addSubMenuEntry(exportConfigurationLinkMenuItem);
}
 
Example 20
Source Project: onedev   Source File: StateStatsBar.java    License: 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 21
Source Project: onedev   Source File: NewPullRequestPage.java    License: MIT License 5 votes vote down vote up
private Fragment newEffectiveFrag() {
	Fragment fragment = new Fragment("status", "effectiveFrag", this);

	fragment.add(new Label("description", new AbstractReadOnlyModel<String>() {

		@Override
		public String getObject() {
			if (requestModel.getObject().isOpen())
				return "This change is already opened for merge by pull request";
			else 
				return "This change is squashed/rebased onto base branch via pull request";
		}
		
	}).setEscapeModelStrings(false));
	
	fragment.add(new Link<Void>("link") {

		@Override
		protected void onInitialize() {
			super.onInitialize();
			add(new Label("label", new AbstractReadOnlyModel<String>() {

				@Override
				public String getObject() {
					return "#" + getPullRequest().getNumber();
				}
				
			}));
		}

		@Override
		public void onClick() {
			PageParameters params = PullRequestDetailPage.paramsOf(getPullRequest());
			setResponsePage(PullRequestActivitiesPage.class, params);
		}
		
	});
	
	return fragment;
}
 
Example 22
Source Project: artifact-listener   Source File: UserPortfolioPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void addItemColumns(Item<User> item, IModel<? extends User> userModel) {
	Link<Void> userNameLink = AdministrationUserDescriptionPage.linkDescriptor(ReadOnlyModel.of(userModel)).link("userNameLink");
	userNameLink.add(new Label("userName", BindingModel.of(userModel, Binding.user().userName())));
	item.add(userNameLink);
	item.add(new Label("fullName", BindingModel.of(userModel, Binding.user().fullName())));
	item.add(new BooleanIcon("active", BindingModel.of(userModel, Binding.user().active())));
	item.add(new EmailLink("email", BindingModel.of(userModel, Binding.user().email())));
}
 
Example 23
Source Project: onedev   Source File: IssueDetailPage.java    License: MIT License 5 votes vote down vote up
@Override
public Component render(String componentId) {
	return new PageTabLink(componentId, this) {

		@Override
		protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) {
			return new ViewStateAwarePageLink<Void>(linkId, pageClass, paramsOf(getIssue()));
		}
		
	};
}
 
Example 24
Source Project: AppStash   Source File: LoginInfoPanel.java    License: Apache License 2.0 5 votes vote down vote up
private Component logoutLink() {
    return new Link<Void>("logoutLnk") {
        private static final long serialVersionUID = 4400488573342897569L;

        @Override
        public void onClick() {
            getAuthenticationService().clearAuthentication();
            setResponsePage(ShopApplication.get().getHomePage());
            cart.clear();
            Session.get().clear();
        }
    };
}
 
Example 25
Source Project: ontopia   Source File: LinkPanel.java    License: 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 26
Source Project: onedev   Source File: ProjectTabLink.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	Link<?> link = newLink("link", tab.getMainPageClass());
	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 27
Source Project: onedev   Source File: InvalidCodeCommentPage.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	add(new Link<Void>("delete") {

		@Override
		public void onClick() {
			OneDev.getInstance(CodeCommentManager.class).delete(getCodeComment());
			
			Session.get().success("Code comment #" + getCodeComment().getId() + " deleted");
			
			String redirectUrlAfterDelete = WebSession.get().getRedirectUrlAfterDelete(CodeComment.class);
			if (redirectUrlAfterDelete != null)
				throw new RedirectToUrlException(redirectUrlAfterDelete);
			else
				setResponsePage(ProjectCodeCommentsPage.class, ProjectCodeCommentsPage.paramsOf(getProject()));
			
		}

		@Override
		protected void onConfigure() {
			super.onConfigure();
			setVisible(SecurityUtils.canManageCodeComments(getCodeComment().getProject()));
		}
		
	}.add(new ConfirmClickModifier("Really want to delete this code comment?")));
}
 
Example 28
@Override
protected Link getLink() {
	Link link = super.getLink();
	link.add(getImage());
	
	return link;
}
 
Example 29
Source Project: oodt   Source File: WorkflowsViewer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @param id
 */
public WorkflowsViewer(String id, String workflowUrlStr,
    final Class<? extends WebPage> wViewerPage) {
  super(id);
  this.wm = new WorkflowMgrConn(workflowUrlStr);

  List<Workflow> workflows = this.wm.safeGetWorkflows();
  add(new ListView<Workflow>("workflow_list", workflows) {

    @Override
    protected void populateItem(ListItem<Workflow> item) {
      Workflow w = item.getModelObject();
      item.add(new Label("workflow_id", w.getId()));
      item.add(new Label("workflow_name", w.getName()));
      item.add(new Link<String>("workflow_link", new Model(w.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(wViewerPage, params);
        }
      });
    }
  });

}
 
Example 30
Source Project: sakai   Source File: MyPictures.java    License: Educational Community License v2.0 5 votes vote down vote up
protected void populateItem(ListItem<File> listItem) {
	final File file = (File) listItem.getModelObject();
	listItem.add(new Label("file", file.getName()));
	listItem.add(new Link("delete") {
		public void onClick() {
			Files.remove(file);
		}
	});
}