Java Code Examples for org.apache.wicket.markup.repeater.Item#add()

The following examples show how to use org.apache.wicket.markup.repeater.Item#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: HealthPage.java    From JPPF with Apache License 2.0 6 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<DefaultMutableTreeNode>> cellItem, final String componentId, final IModel<DefaultMutableTreeNode> rowModel) {
  super.populateItem(cellItem, componentId, rowModel);
  final DefaultMutableTreeNode node = rowModel.getObject();
  final AbstractTopologyComponent comp = (AbstractTopologyComponent) node.getUserObject();
  String cssClass = "default_cursor ";
  final boolean selected = selectionHandler.isSelected(comp.getUuid());
  boolean inactive = false;
  if (comp.isPeer()) cssClass += "peer ";
  else if (comp.isNode()) {
    final TopologyNode data = (TopologyNode) node.getUserObject();
    inactive = !data.getManagementInfo().isActive();
    if (data.getStatus() == TopologyNodeStatus.UP) {
      if (inactive) cssClass += selected ? "tree_inactive_selected " : "tree_inactive ";
      else cssClass += selected ? "tree_selected " : "node_up ";
    }
    else cssClass += selected ? "tree_inactive_selected " : "node_tree_down ";
  } else if (comp.isDriver()) {
    final TopologyDriver driver = (TopologyDriver) node.getUserObject();
    if (driver.getConnection().getStatus().isWorkingStatus()) cssClass += (selected) ? "tree_selected " : "driver_up ";
    else cssClass = (selected) ? "tree_inactive_selected" : "driver_down";
  }
  cellItem.add(new AttributeModifier("class", cssClass));
}
 
Example 2
Source File: AjaxCheckTablePanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void populateItem(final Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) {
      	final HighlitableDataItem highlitableDataItem = item.findParent(HighlitableDataItem.class);
      	IModel<Boolean> checkBoxModel = new LoadableDetachableModel<Boolean>() {

		private static final long serialVersionUID = 1L;

		@Override
		protected Boolean load() {
			return highlitableDataItem.isHighlite();
		}
      		
      	};
      	if (isCheckable(rowModel)) {
      		item.add(new CheckBoxColumnPanel(componentId, checkBoxModel));
      		item.add(AttributeModifier.replace("class", "checkboxColumn"));
      	} else {
      		item.add(new EmptyPanel(componentId));
      	}
}
 
Example 3
Source File: TopologyPage.java    From JPPF with Apache License 2.0 6 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<DefaultMutableTreeNode>> cellItem, final String componentId, final IModel<DefaultMutableTreeNode> rowModel) {
  final NodeModel<DefaultMutableTreeNode> nodeModel = (NodeModel<DefaultMutableTreeNode>) rowModel;
  final DefaultMutableTreeNode treeNode = nodeModel.getObject();
  final AbstractTopologyComponent comp = (AbstractTopologyComponent) treeNode.getUserObject();
  final String value = (String) treeModel.getValueAt(treeNode, index);
  cellItem.add(new Label(componentId, value));
  if (traceEnabled) log.trace(String.format("index %d populating value=%s, treeNode=%s", index, value, treeNode));
  String cssClass = "default_cursor ";
  final boolean selected = selectionHandler.isSelected(comp.getUuid());
  if (comp.isNode()) {
    final TopologyNode data = (TopologyNode) treeNode.getUserObject();
    if (data.isNode()) cssClass += ((data.getStatus() == TopologyNodeStatus.UP) ? "node_up " : "node_down ") + getCssClass();
  } else if (!selected) cssClass += "empty ";
  if (selected && !comp.isPeer()) cssClass += "tree_selected ";
  cellItem.add(new AttributeModifier("class", cssClass));
}
 
Example 4
Source File: InfinitePagingDataTable.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
protected Item newCellItem(final String id, final int index, final IModel model)
{
	Item item = InfinitePagingDataTable.this.newCellItem(id, index, model);
	final IColumn<T, S> column = InfinitePagingDataTable.this.columns.get(index);
	if (column instanceof IStyledColumn)
	{
		item.add(new CssAttributeBehavior()
		{
			private static final long serialVersionUID = 1L;

			@Override
			protected String getCssClass()
			{
				return ((IStyledColumn<T, S>)column).getCssClass();
			}
		});
	}

	return item;
}
 
Example 5
Source File: AbstractInfinitePagingDataGridView.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * @param item
 * @see org.apache.wicket.markup.repeater.RefreshingView#populateItem(org.apache.wicket.markup.repeater.Item)
 */
@Override
protected final void populateItem(final Item<T> item)
{
	RepeatingView cells = new RepeatingView(CELL_REPEATER_ID);
	item.add(cells);

	int populatorsNumber = populators.size();
	for (int i = 0; i < populatorsNumber; i++)
	{
		ICellPopulator<T> populator = populators.get(i);
		IModel<ICellPopulator<T>> populatorModel = new Model<>(populator);
		Item<ICellPopulator<T>> cellItem = newCellItem(cells.newChildId(), i, populatorModel);
		cells.add(cellItem);

		populator.populateItem(cellItem, CELL_ITEM_ID, item.getModel());

		if (cellItem.get("cell") == null)
		{
			throw new WicketRuntimeException(
				populator.getClass().getName() +
					".populateItem() failed to add a component with id [" +
					CELL_ITEM_ID +
					"] to the provided [cellItem] object. Make sure you call add() on cellItem and make sure you gave the added component passed in 'componentId' id. ( *cellItem*.add(new MyComponent(*componentId*, rowModel) )");
		}
	}
}
 
Example 6
Source File: OIndexDefinitionColumn.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<OIndex<?>>> cellItem,
		String componentId, IModel<OIndex<?>> rowModel) {
	if(DisplayMode.EDIT.equals(getModeObject()))
	{
		super.populateItem(cellItem, componentId, rowModel);
	}
	else
	{
		cellItem.add(new OIndexViewPanel(componentId, rowModel));
	}
}
 
Example 7
Source File: TableRendererPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private void setCellStyle(Item cellItem, IModel rowModel, int rowIndex) {
  	List<Map<String, Object>> styles = ((RowData)rowModel.getObject()).getStyles();    	
if (styles.size() > rowIndex) {				
	Map<String, Object> style = styles.get(rowIndex);
	boolean needed = setIframeStyleParameters(style);
	Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR);
	if ((val != null) || (iframeFontSize != null)) {				
		String text = HtmlUtil.getCssCode(null, style, needed);
		cellItem.add(new AttributeAppender("style", Model.of(text)));
	}
}
  }
 
Example 8
Source File: ProductItemListPanel.java    From AppStash with Apache License 2.0 5 votes vote down vote up
private DataView<ProductInfo> productList(final String parentTag) {
    DataView<ProductInfo> productsView = new DataView<ProductInfo>("products", productsProvider()) {
        @Override
        protected void populateItem(Item<ProductInfo> item) {
            item.add(newProductItemPanel("product", parentTag, item.getModel()));
        }
    };
    productsView.add(new HighLightBehavior());
    return productsView;
}
 
Example 9
Source File: OPropertyDefinitionColumn.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<OProperty>> cellItem,
		String componentId, IModel<OProperty> rowModel) {
	if(DisplayMode.EDIT.equals(getModeObject()))
	{
		super.populateItem(cellItem, componentId, rowModel);
	}
	else
	{
		cellItem.add(new OPropertyViewPanel(componentId, rowModel));
	}
}
 
Example 10
Source File: KeyPropertyColumn.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel) {
    BeanWrapper bwi = new BeanWrapperImpl(rowModel.getObject());
    Object obj = bwi.getPropertyValue(getPropertyExpression());

    item.add(new Label(componentId, StringUtils.EMPTY));
    item.add(new AttributeModifier("title", Objects.requireNonNull(obj).toString()));
    item.add(new AttributeModifier("class", "fa fa-key"));
    item.add(new AttributeModifier("style", "display: table-cell; text-align: center;"));
}
 
Example 11
Source File: AnalysisTablePanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
private void setCellStyle(Item cellItem, IModel rowModel, int rowIndex) {
  	List<Map<String, Object>> styles = ((AnalysisRow)rowModel.getObject()).getStyles();
if (styles.size() > rowIndex) {
	Map<String, Object> style = styles.get(rowIndex);
	Color val = (Color) style.get(StyleFormatConstants.FONT_COLOR);
	if (val != null) {
		String text = HtmlUtil.getCssCode(null, style, false);
		cellItem.add(new AttributeAppender("style", Model.of(text)));
	}
}
  }
 
Example 12
Source File: RecipientsPanel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public void populateItem(Item<ICellPopulator<Recipient>> item, String componentId, IModel<Recipient> rowModel) {
    final Recipient recipient = rowModel.getObject();
    final String name = recipient.getName();

    Component component = new AbstractImageLabelPanel(componentId) {

        @Override
        public String getDisplayString() {
            return name;
        }

        @Override
        public String getImageName() {
            if (recipient.getType() == Recipient.EMAIL_TYPE) {
                return "images/email.png";
            } else if (recipient.getType() == Recipient.USER_TYPE) {
                return "images/user.png";
            } else if (recipient.getType() == Recipient.GROUP_TYPE) {
                return "images/group.png";
            }
            // TODO
            return null; // return "blank.png"
        }

    };

    item.add(component);
}
 
Example 13
Source File: HealthPage.java    From JPPF with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<DefaultMutableTreeNode>> cellItem, final String componentId, final IModel<DefaultMutableTreeNode> rowModel) {
  final NodeModel<DefaultMutableTreeNode> nodeModel = (NodeModel<DefaultMutableTreeNode>) rowModel;
  final DefaultMutableTreeNode treeNode = nodeModel.getObject();
  final AbstractTopologyComponent comp = (AbstractTopologyComponent) treeNode.getUserObject();
  final String value = (String) treeModel.getValueAt(treeNode, index);
  cellItem.add(new Label(componentId, value));
  final boolean selected = selectionHandler.isSelected(comp.getUuid());
  String css = "";
  if (!comp.isPeer()) css += (selected ? "tree_selected" : getThresholdCssClass(comp));
  css += " " + getCssClass();
  cellItem.add(new AttributeModifier("class", css));
  if (traceEnabled && (index == 1)) log.trace(String.format("index=%d, value=%s, css=%s, comp=%s", index, value, css, comp));
}
 
Example 14
Source File: SearchEntityPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
public void populateItem(Item<ICellPopulator<Entity>> item, String componentId, IModel<Entity> rowModel) {
    Entity entity = rowModel.getObject();
    String path = entity.getPath();
    item.add(new Label(componentId, path));
}
 
Example 15
Source File: RecommendedArtifactPortfolioPanel.java    From artifact-listener with Apache License 2.0 4 votes vote down vote up
@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 16
Source File: ORoleSecurityWidget.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<String>> cellItem,
		String componentId, IModel<String> rowModel) {
	cellItem.add(new BooleanEditPanel(componentId, getSecurityRightsModel(rowModel)));
}
 
Example 17
Source File: OClassSecurityWidget.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<ORole>> cellItem,
		String componentId, IModel<ORole> rowModel) {
	cellItem.add(new BooleanEditPanel(componentId, getSecurityRightsModel(rowModel)));
}
 
Example 18
Source File: CheckGroupColumn.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel) {
    item.add(new CheckBoxPanel<>(componentId, rowModel, group));
}
 
Example 19
Source File: EditJasperParametersPanel.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
public void populateItem(Item<ICellPopulator<JasperParameterSource>> cellItem, String componentId, IModel<JasperParameterSource> model) {
    cellItem.add(new ActionPanel(componentId, model));
    cellItem.add(AttributeAppender.append("class", "actions-col"));
}
 
Example 20
Source File: SakaiResponsivePropertyColumn.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel)
{
	super.populateItem(item, componentId, rowModel);
	item.add(AttributeAppender.append(DATA_LABEL_ATTR, getDisplayModel()));
}