Java Code Examples for org.apache.wicket.Component#add()

The following examples show how to use org.apache.wicket.Component#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: IssueActivitiesPanel.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onBeforeRender() {
	activitiesView = new RepeatingView("activities");
	addOrReplace(activitiesView);
	Issue issue = getIssue();

	for (IssueActivity activity: getActivities()) {
		if (issue.isVisitedAfter(activity.getDate())) {
			activitiesView.add(newActivityRow(activitiesView.newChildId(), activity));
		} else {
			Component row = newActivityRow(activitiesView.newChildId(), activity);
			row.add(AttributeAppender.append("class", "new"));
			activitiesView.add(row);
		}
	}		
	
	super.onBeforeRender();
}
 
Example 2
Source File: MetricSelectDropDownPanel.java    From inception with Apache License 2.0 5 votes vote down vote up
private static void show(AjaxRequestTarget target, Component component)
{
    component.add(new DisplayNoneBehavior());

    String js = "$('#" + component.getMarkupId()
            + "').animate({'width': '+=100'},  100); $('#"
            + ((DropDownChoice) component).getMarkupId() + "').show();";
    target.appendJavaScript(js);
}
 
Example 3
Source File: SkillTreeBuilder.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
protected void addColumn(final WebMarkupContainer parent, final Component component, final String cssStyle)
{
  if (cssStyle != null) {
    component.add(AttributeModifier.append("style", new Model<String>(cssStyle)));
  }
  parent.add(component);
}
 
Example 4
Source File: SearchEntityPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private void makeSearchComponentVisible(Component component, boolean isRowLabel) {
	component.setVisible(true);
	if (isRowLabel) {
		component.add(AttributeModifier.replace("class", "row-label row-bottom"));
	} else {
		component.add(AttributeModifier.replace("class", "row-bottom"));
	}
}
 
Example 5
Source File: DefaultTreeTablePanel.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
protected void addColumn(final WebMarkupContainer parent, final Component component, final String cssStyle)
{
  if (cssStyle != null) {
    component.add(AttributeModifier.append("style", new Model<String>(cssStyle)));
  }
  parent.add(component);
}
 
Example 6
Source File: OToursModule.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onInstantiation(Component component) {
	if(component instanceof Page) {
		component.add(new CustomizationBehavior());
	}
	
}
 
Example 7
Source File: DroppableBehavior.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBind() {
  super.onBind();
  Component c = getComponent();
  c.setOutputMarkupId(true);
  c.add(new AttributeAppender("class", new Model<String>("do_" + id), " "));    
}
 
Example 8
Source File: DraggableBehavior.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBind() {
  super.onBind();
  Component c = getComponent();
  c.setOutputMarkupId(true);
  c.add(new AttributeAppender("class", new Model<String>("dg_" + id), " "));    
}
 
Example 9
Source File: SettingsCategoryPanel.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Helper to handle the value and style updates of the running total label
 *
 * @param runningTotal label component to update
 * @param runningTotalMessage error message component
 * @return
 */
private void updateRunningTotal(final Component runningTotal, final Component runningTotalMessage) {

	final List<CategoryDefinition> categories = this.model.getObject().getGradebookInformation().getCategories();

	BigDecimal total = BigDecimal.ZERO;
	for (final CategoryDefinition categoryDefinition : categories) {

		Double catWeight = categoryDefinition.getWeight();
		if (catWeight == null) {
			catWeight = 0D;
		}

		BigDecimal weight = BigDecimal.valueOf(catWeight);
		if (weight == null) {
			weight = BigDecimal.ZERO;
		}

		if (!categoryDefinition.getExtraCredit()) {
			total = total.add(weight);
		}
	}

	// if comparison passes, we have '1' as the value
	if (total.compareTo(BigDecimal.ONE) == 0) {
		runningTotal.add(new AttributeModifier("class", "text-success"));
		runningTotalMessage.setVisible(false);
	} else {
		runningTotal.add(new AttributeModifier("class", "text-danger"));
		runningTotalMessage.setVisible(true);
	}

	runningTotal.setDefaultModel(Model.of(FormatHelper.formatDoubleAsPercentage(total.doubleValue() * 100)));
}
 
Example 10
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets the html attribute placeholder.
 * @param component
 * @param value
 */
public static void setPlaceHolderAttribute(Component component, final String value)
{
  if (component instanceof ComponentWrapperPanel) {
    component = ((ComponentWrapperPanel) component).getFormComponent();
  }
  component.add(AttributeModifier.replace("placeholder", value));
}
 
Example 11
Source File: ImageView.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
private Component createSeoImage(final Component component, final SeoImage seoImage, final String lang) {
    if (seoImage != null) {

        final I18NWebSupport i18n = getI18NSupport();

        component.add(
                new AttributeModifier(HTML_ALT,
                        i18n.getFailoverModel(seoImage.getDisplayAlt(), seoImage.getAlt()).getValue(lang)),
                new AttributeModifier(HTML_TITLE,
                        i18n.getFailoverModel(seoImage.getDisplayTitle(), seoImage.getTitle()).getValue(lang))
        );

    }
    return component;
}
 
Example 12
Source File: InputAssistBehavior.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onBind() {
	super.onBind();
	
	Component input = getComponent();
	input.add(AttributeAppender.append("class", "input-assist"));
	input.setOutputMarkupId(true);
}
 
Example 13
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds onclick attribute with "javascript:rowClick(this);".
 * @param row Html tr element.
 */
public static void addRowClick(final Component row)
{
  row.add(AttributeModifier.replace("onclick", "javascript:rowClick(this);"));
  // add marker css class for contextMenu javaScript
  row.add(new AttributeAppender("class", Model.of("withContextMenu"), " "));
}
 
Example 14
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public static void append(final Component component, final RowCssClass... rowCssClasses)
{
  for (final RowCssClass rowCssClass : rowCssClasses) {
    component.add(AttributeModifier.append("class", rowCssClass.getCssClass()));
  }
}
 
Example 15
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public static Component setStrong(final Component component)
{
  component.add(AttributeModifier.append("style", "font-weight: bold;"));
  return component;
}
 
Example 16
Source File: CommitListPanel.java    From onedev with MIT License 4 votes vote down vote up
private void addCommitClass(Component item, int commitIndex) {
	item.add(AttributeAppender.append("class", " commit-item-" + commitIndex));
}
 
Example 17
Source File: SettingsCategoryPanel.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Helper to add the tooltip when drop/keep settings cause a field to be disabled.
 *
 * @param textfield
 * @param usage determines which message bundle to use for title and aria-label
 */
private void addDropKeepDisabledToolTip(final Component textfield, final DropKeepUsage usage) {
	textfield.add(AttributeModifier.replace("title", new ResourceModel(usage.getMessage())));
	textfield.add(AttributeModifier.replace("aria-label", new ResourceModel(usage.getMessage())));
}
 
Example 18
Source File: WicketUtils.java    From projectforge-webapp with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Sets attribute font-size: style="font-size: 1.1em;";
 * @param component
 * @param size
 * @return This for chaining.
 */
public static Component setFontSizeLarge(final Component component)
{
  component.add(AttributeModifier.append("style", "font-size: 1.5em;"));
  return component;
}
 
Example 19
Source File: SettingsCategoryPanel.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Helper to add the tooltip when drop/keep settings cause a field to be disabled.
 *
 * @param textfield
 * @param usage determines which message bundle to use for title and aria-label
 */
private void addDropKeepDisabledToolTip(final Component textfield, final DropKeepUsage usage) {
	textfield.add(AttributeModifier.replace("title", new ResourceModel(usage.getMessage())));
	textfield.add(AttributeModifier.replace("aria-label", new ResourceModel(usage.getMessage())));
}
 
Example 20
Source File: SettingsCategoryPanel.java    From sakai with Educational Community License v2.0 2 votes vote down vote up
/**
 * Helper to remove the tooltip from above
 *
 * @param textfield
 */
private void removeDropKeepDisabledToolTip(final Component textfield) {
	textfield.add(AttributeModifier.remove("title"));
	textfield.add(AttributeModifier.remove("aria-label"));
}