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

The following examples show how to use org.apache.wicket.markup.html.link.Link#setEnabled() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
Source File: ConsumptionBarPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @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);
}
 
Example 10
Source File: SakaiPage.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Add a menu entry linking to a class page.
 * <p>
 * Automatically disable the link if it's to the current page.
 * </p>
 *
 * @param clazz classPage
 * @param text  Link's text
 * @param title Title attribute for the link
 */
protected void addMenuLink(Class<? extends Page> clazz, IModel<String> text, IModel<String> title) {
    Link<Page> link = new BookmarkablePageLink<Page>("menuItem", clazz);
    link.setEnabled(!getClass().equals(clazz));
    addMenuLink(link, text, title);
}
 
Example 11
Source File: SakaiPage.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Add a menu entry linking to a class page.
 * <p>
 * Automatically disable the link if it's to the current page.
 * </p>
 *
 * @param clazz classPage
 * @param text  Link's text
 * @param title Title attribute for the link
 */
protected void addMenuLink(Class<? extends Page> clazz, IModel<String> text, IModel<String> title) {
    Link<Page> link = new BookmarkablePageLink<Page>("menuItem", clazz);
    link.setEnabled(!getClass().equals(clazz));
    addMenuLink(link, text, title);
}