org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator Java Examples

The following examples show how to use org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator. 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: DeleteRowCommandColumn.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<ODocument>> cellItem, String componentId, final IModel<ODocument> rowModel) {
	cellItem.add(new AjaxFormCommand<ODocument>(componentId, "command.remove") {

           @Override
           public void onClick(Optional<AjaxRequestTarget> targetOptional) {
               super.onClick(targetOptional);
               rowModel.getObject().delete();
               DataTable<?, ?> table = findParent(DataTable.class);
               if(table!=null && targetOptional.isPresent()) targetOptional.get().add(table);
           }

           @Override
           protected void onConfigure() {
               super.onConfigure();
               setVisibilityAllowed(modeModel.getObject().equals(DisplayMode.EDIT));
           }

       }.setBootstrapSize(BootstrapSize.EXTRA_SMALL)
               .setBootstrapType(BootstrapType.DANGER)
               .setIcon((String) null));
}
 
Example #2
Source File: CurrencyPropertyColumn.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel)
{
  final BigDecimal value = (BigDecimal) BeanHelper.getProperty(rowModel.getObject(), getPropertyExpression());
  final Label label;
  if (this.suppressZeroValues == true && value != null && value.compareTo(BigDecimal.ZERO) == 0) {
    label = new PlainLabel(componentId, "");
  } else {
    label = new PlainLabel(componentId, CurrencyFormatter.format(value));
  }
  item.add(label);
  if (cellItemListener != null) {
    cellItemListener.populateItem(item, componentId, rowModel);
  }
  if (value != null && value.compareTo(BigDecimal.ZERO) < 0 && displayRedNegativeValues == true) {
    // Negative value.
    item.add(AttributeModifier.append("style", new Model<String>("white-space: nowrap; text-align: right; color: red !important;")));
  } else {
    item.add(AttributeModifier.append("style", new Model<String>("white-space: nowrap; text-align: right;")));
  }
}
 
Example #3
Source File: TaskPropertyColumn.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel)
{
  final TaskDO task = getTask(rowModel);
  if (task == null) {
    item.add(new Label(componentId, ""));
  } else {
    final Label label = new Label(componentId, task.getTitle());
    final String taskPath = getTaskFormatter().getTaskPath(task.getId(), false, OutputType.PLAIN);
    WicketUtils.addTooltip(label, taskPath);
    label.setEscapeModelStrings(false);
    item.add(label);
  }
  if (cellItemListener != null)
    cellItemListener.populateItem(item, componentId, rowModel);
}
 
Example #4
Source File: ApplicationDirectoryPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
protected List<IColumn<ApplicationTO, String>> getColumns() {
    final List<IColumn<ApplicationTO, String>> columns = new ArrayList<>();

    columns.add(new PropertyColumn<>(
            new ResourceModel(Constants.KEY_FIELD_NAME), Constants.KEY_FIELD_NAME, Constants.KEY_FIELD_NAME));
    columns.add(new PropertyColumn<>(new ResourceModel("description"), "description", "description"));
    columns.add(new AbstractColumn<ApplicationTO, String>(new ResourceModel("privileges")) {

        private static final long serialVersionUID = 2054811145491901166L;

        @Override
        public void populateItem(
                final Item<ICellPopulator<ApplicationTO>> item,
                final String componentId,
                final IModel<ApplicationTO> rowModel) {

            item.add(new Label(componentId, '[' + rowModel.getObject().getPrivileges().stream().
                    map(EntityTO::getKey).collect(Collectors.joining(", ")) + ']'));
        }
    });

    return columns;
}
 
Example #5
Source File: SecurityPanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public void populateItem(Item<ICellPopulator<AclEntry>> cellItem, String componentId, final IModel<AclEntry> rowModel) {
    Component component = new AbstractImageLabelPanel(componentId) {

        @Override
        public String getDisplayString() {
            return rowModel.getObject().getName();
        }

        @Override
        public String getImageName() {
            if (rowModel.getObject().getType() == AclEntry.USER_TYPE) {
                return "images/user.png";
            } else if (rowModel.getObject().getType() == AclEntry.GROUP_TYPE) {
                return "images/group.png";
            }

            // TODO
            return null; // return "blank.png"
        }

    };
    cellItem.add(component);
    cellItem.add(AttributeModifier.append("class", "name-col"));
}
 
Example #6
Source File: ParametersDirectoryPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
protected List<IColumn<ConfParam, String>> getColumns() {
    final List<IColumn<ConfParam, String>> columns = new ArrayList<>();
    columns.add(new PropertyColumn<>(new ResourceModel("schema"), "schema"));
    columns.add(new PropertyColumn<ConfParam, String>(new ResourceModel("values"), "values") {

        private static final long serialVersionUID = -1822504503325964706L;

        @Override
        public void populateItem(
                final Item<ICellPopulator<ConfParam>> item,
                final String componentId,
                final IModel<ConfParam> rowModel) {

            if (rowModel.getObject().getValues().toString().length() > 96) {
                item.add(new Label(componentId, getString("tooLong")).
                        add(new AttributeModifier("style", "font-style:italic")));
            } else {
                super.populateItem(item, componentId, rowModel);
            }
        }
    });
    return columns;
}
 
Example #7
Source File: ConnObjectAttrColumn.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
public void populateItem(
        final Item<ICellPopulator<ConnObjectTO>> cellItem,
        final String componentId,
        final IModel<ConnObjectTO> rowModel) {

    Optional<Attr> attr = rowModel.getObject().getAttr(name);
    List<String> values = attr.map(Attr::getValues).orElse(null);

    if (values == null || values.isEmpty()) {
        cellItem.add(new Label(componentId, ""));
    } else if (values.size() == 1) {
        cellItem.add(new Label(componentId, values.get(0)));
    } else {
        cellItem.add(new Label(componentId, values.toString()));
    }
}
 
Example #8
Source File: BooleanImagePropertyColumn.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<T>> item, String componentId, final IModel<T> rowModel) {
       item.add(new AbstractImagePanel(componentId) {

		private static final long serialVersionUID = 1L;

		@Override
           public String getImageName() {
               if ((Boolean) PropertyResolver.getValue(getPropertyExpression(), rowModel.getObject())) {
               	String theme = settings.getSettings().getColorTheme();                	
                   return "images/" + ThemesManager.getTickImage(theme, (NextServerApplication)getApplication());
               } else {
                   return "images/delete.gif";
               }
           }

       });
   }
 
Example #9
Source File: SchemaOClassesModalPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private IColumn<OClass, String> createCheckBoxColumn() {
    return new CheckBoxColumn<OClass, String, String>(OClassClassNameConverter.INSTANCE) {
        @Override
        public void populateItem(Item<ICellPopulator<OClass>> cellItem, String componentId, final IModel<OClass> rowModel) {
            cellItem.add(new BooleanEditPanel(componentId, getCheckBoxModel(rowModel)) {
                @Override
                protected void onConfigure() {
                    super.onConfigure();
                    List<OArchitectOClass> classes = existClasses.getObject();
                    if (classes != null) {
                        setEnabled(!OArchitectClassesUtils.isClassContainsIn(rowModel.getObject().getName(), classes));
                    }
                }
            });
        }
    };
}
 
Example #10
Source File: OrienteerCloudOModulesConfigurationsPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private List<IColumn<OArtifact, String>> getColumns(IModel<DisplayMode> modeModel) {
    List<IColumn<OArtifact, String>> columns = Lists.newArrayList();
    columns.add(new CheckBoxColumn<OArtifact, OArtifact, String>(new IdentityConverter<OArtifact>()) {
        @Override
        public void populateItem(Item<ICellPopulator<OArtifact>> cellItem, String componentId, final IModel<OArtifact> rowModel) {
            cellItem.add(new BooleanEditPanel(componentId, getCheckBoxModel(rowModel)) {
                @Override
                public boolean isEnabled() {
                    return rowModel.getObject() != null && !rowModel.getObject().isDownloaded();
                }
            });
        }
    });
    columns.add(new OArtifactColumn(OArtifactField.GROUP.asModel(), modeModel));
    columns.add(new OArtifactColumn(OArtifactField.ARTIFACT.asModel(), modeModel));
    columns.add(new OArtifactColumn(OArtifactField.VERSION.asModel(), DisplayMode.EDIT.asModel()));
    columns.add(new OArtifactColumn(OArtifactField.DESCRIPTION.asModel(), modeModel));
    columns.add(new OArtifactColumn(OArtifactField.DOWNLOADED.asModel(), modeModel));
    return columns;
}
 
Example #11
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) {
  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();
    if (traceEnabled) log.trace("node status: {}", data.getStatus());
    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 #12
Source File: CheckTablePanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
private IColumn<T, String> createCheckColumn() {
     return new AbstractColumn<T, String>(new Model<String>("Select")) {

         private static final long serialVersionUID = 1L;

public void populateItem(Item<ICellPopulator<T>> item, String componentId, IModel<T> rowModel) {
             item.add(new CheckBoxPanel(componentId, rowModel, item));
             item.add(AttributeAppender.append("class", "checkboxColumn"));
         }

         @Override
         public Component getHeader(String s) {
             return new CheckBoxHeaderPanel(s);
         }

     };
 }
 
Example #13
Source File: JobsPage.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 AbstractJobComponent comp = (AbstractJobComponent) node.getUserObject();
  String cssClass = "default_cursor ";
  final boolean selected = selectionHandler.isSelected(comp.getUuid());
  boolean inactive = false;
  if (comp instanceof Job) {
    final Job data = (Job) comp;
    inactive = data.getJobInformation().isSuspended();
    if (inactive) cssClass += (selected) ? "tree_inactive_selected " : "tree_inactive ";
    else cssClass = (selected) ? "tree_selected " : "node_up ";
  } else if (comp instanceof JobDriver) {
    final TopologyDriver driver = ((JobDriver) comp).getTopologyDriver();
    if (driver.getConnection().getStatus().isWorkingStatus()) cssClass += (selected) ? "tree_selected " : "driver_up ";
    else cssClass = (selected) ? "tree_inactive_selected " : "driver_down ";
  } else if (comp instanceof JobDispatch) {
    cssClass += "node_up ";
  }
  cellItem.add(new AttributeModifier("class", cssClass));
}
 
Example #14
Source File: AbstractInfinitePagingDataGridView.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * @see org.apache.wicket.markup.repeater.data.DataViewBase#onDetach()
 */
@Override
protected void onDetach()
{
	super.onDetach();
	if (populators != null)
	{
		for (ICellPopulator<T> populator : populators)
		{
			populator.detach();
		}
	}
}
 
Example #15
Source File: AttrColumn.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(
        final Item<ICellPopulator<T>> cellItem, final String componentId, final IModel<T> rowModel) {

    List<String> values = new ArrayList<>();

    switch (schemaType) {
        case PLAIN:
            rowModel.getObject().getPlainAttr(name).ifPresent(attr -> values.addAll(attr.getValues()));
            break;

        case DERIVED:
            rowModel.getObject().getDerAttr(name).ifPresent(attr -> values.addAll(attr.getValues()));
            break;

        case VIRTUAL:
            rowModel.getObject().getVirAttr(name).ifPresent(attr -> values.addAll(attr.getValues()));
            break;

        default:
    }

    if (values.isEmpty()) {
        cellItem.add(new Label(componentId, ""));
    } else if (values.size() == 1) {
        cellItem.add(new Label(componentId, values.get(0)));
    } else {
        cellItem.add(new Label(componentId, values.toString()));
    }
}
 
Example #16
Source File: UserPropertyColumn.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void populateItem(final Item<ICellPopulator<T>> item, final String componentId, final IModel<T> rowModel)
{
  final Label label = new Label(componentId, new Model<String>(getLabelString(rowModel)));
  item.add(label);
  if (cellItemListener != null)
    cellItemListener.populateItem(item, componentId, rowModel);
}
 
Example #17
Source File: TypeColumn.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public void populateItem(Item<ICellPopulator<Entity>> item, String componentId, IModel<Entity> rowModel) {
    String type = rowModel.getObject().getClass().getSimpleName();
    Entity entity = rowModel.getObject(); 
    if (entity instanceof Report) {
        type = ((Report) entity).getType() + " " + new StringResourceModel(type, null).getString();
    } else if (entity instanceof DataSource) {
    	type = ((DataSource) entity).getVendor();
    } else if ((entity instanceof Folder) || (entity instanceof Chart)) {
    	type = new StringResourceModel(type, null).getString();
    }
    item.add(new Label(componentId, new Model<String>(type)));
}
 
Example #18
Source File: AnalysisBooleanImagePropertyColumn.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
public void populateItem(Item<ICellPopulator<T>> item, String componentId, final IModel<T> rowModel) {
    item.add(new AbstractImagePanel(componentId) {

        @Override
        public String getImageName() {
            if ((Boolean) PropertyResolver.getValue(getPropertyExpression(), rowModel.getObject())) {                	             	
                return "images/sortascend.png";
            } else {
                return "images/sortdescend.png";
            }
        }
    });
}
 
Example #19
Source File: OClusterSecurityWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public OClusterSecurityWidget(String id, IModel<OCluster> model,
                                 IModel<ODocument> widgetDocumentModel) {
	super(id, model, widgetDocumentModel);

	List<IColumn<ORole, String>> sColumns = new ArrayList<IColumn<ORole,String>>();
	OClass oRoleClass = OrientDbWebSession.get().getDatabase().getMetadata().getSchema().getClass("ORole");
	sColumns.add(new AbstractColumn<ORole, String>(new OClassNamingModel(oRoleClass), "name") {

		@Override
		public void populateItem(Item<ICellPopulator<ORole>> cellItem,
				String componentId, IModel<ORole> rowModel) {
			cellItem.add(new LinkViewPanel(componentId, new PropertyModel<ODocument>(rowModel, "document")));
		}
	});
	sColumns.add(new SecurityRightsColumn(OrientPermission.CREATE));
	sColumns.add(new SecurityRightsColumn(OrientPermission.READ));
	sColumns.add(new SecurityRightsColumn(OrientPermission.UPDATE));
	sColumns.add(new SecurityRightsColumn(OrientPermission.DELETE));
	
	OQueryDataProvider<ORole> sProvider = new OQueryDataProvider<ORole>("select from ORole", ORole.class);
	sProvider.setSort("name", SortOrder.ASCENDING);
	GenericTablePanel<ORole> tablePanel = new GenericTablePanel<ORole>("tablePanel", sColumns, sProvider ,20);
	OSecurityHelper.secureComponent(tablePanel, OSecurityHelper.requireOClass("ORole", Component.ENABLE, OrientPermission.UPDATE));

	OrienteerDataTable<ORole, String> sTable = tablePanel.getDataTable();
	Command<ORole> saveCommand = new AbstractSaveCommand<ORole>(sTable, null);
	sTable.addCommand(saveCommand);
	sTable.setCaptionModel(new ResourceModel("cluster.security"));
	add(tablePanel);
	add(DisableIfPrototypeBehavior.INSTANCE, UpdateOnActionPerformedEventBehavior.INSTANCE_ALL_CONTINUE);
}
 
Example #20
Source File: OClassSecurityWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public OClassSecurityWidget(String id, IModel<OClass> model,
		IModel<ODocument> widgetDocumentModel) {
	super(id, model, widgetDocumentModel);

	
	List<IColumn<ORole, String>> sColumns = new ArrayList<IColumn<ORole,String>>();
	OClass oRoleClass = OrientDbWebSession.get().getDatabase().getMetadata().getSchema().getClass("ORole");
	sColumns.add(new AbstractColumn<ORole, String>(new OClassNamingModel(oRoleClass), "name") {

		@Override
		public void populateItem(Item<ICellPopulator<ORole>> cellItem,
				String componentId, IModel<ORole> rowModel) {
			cellItem.add(new LinkViewPanel(componentId, new PropertyModel<ODocument>(rowModel, "document")));
		}
	});
	sColumns.add(new SecurityRightsColumn(OrientPermission.EXECUTE));
	sColumns.add(new SecurityRightsColumn(OrientPermission.CREATE));
	sColumns.add(new SecurityRightsColumn(OrientPermission.READ));
	sColumns.add(new SecurityRightsColumn(OrientPermission.UPDATE));
	sColumns.add(new SecurityRightsColumn(OrientPermission.DELETE));
	
	OQueryDataProvider<ORole> sProvider = new OQueryDataProvider<ORole>("select from ORole", ORole.class);
	sProvider.setSort("name", SortOrder.ASCENDING);

	GenericTablePanel<ORole> tablePanel = new GenericTablePanel<ORole>("tablePanel", sColumns, sProvider ,20);
	OSecurityHelper.secureComponent(tablePanel, OSecurityHelper.requireOClass("ORole", Component.ENABLE, OrientPermission.UPDATE));

	OrienteerDataTable<ORole, String> sTable = tablePanel.getDataTable();
	Command<ORole> saveCommand = new AbstractSaveCommand<ORole>(sTable, null);
	sTable.addCommand(saveCommand);
	sTable.setCaptionModel(new ResourceModel("class.security"));
	add(tablePanel);
	add(DisableIfPrototypeBehavior.INSTANCE, UpdateOnActionPerformedEventBehavior.INSTANCE_ALL_CONTINUE);
}
 
Example #21
Source File: AbstractOClassesListWidget.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
public AbstractOClassesListWidget(String id, IModel<T> model, IModel<ODocument> widgetDocumentModel) {
    super(id, model, widgetDocumentModel);

    IModel<DisplayMode> modeModel = DisplayMode.VIEW.asModel();
    List<IColumn<OClass, String>> columns = new ArrayList<IColumn<OClass,String>>();
    columns.add(new CheckBoxColumn<OClass, String, String>(OClassClassNameConverter.INSTANCE));
    columns.add(new OClassColumn(OClassPrototyper.NAME, modeModel));
    columns.add(new OClassMetaColumn(OClassPrototyper.SUPER_CLASSES, modeModel));
    columns.add(new OClassMetaColumn(OClassPrototyper.ABSTRACT, modeModel));
    columns.add(new OClassMetaColumn(OClassPrototyper.STRICT_MODE, modeModel));
    columns.add(new PropertyColumn<OClass, String>(new ResourceModel("class.count"), "count", "count"));
    columns.add(new AbstractColumn<OClass, String>(new ResourceModel("class.browse")) {

        /**
         *
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<OClass>> cellItem,
                                 String componentId, final IModel<OClass> rowModel) {
            cellItem.add(new BookmarkablePageLinkCommand<OClass>(componentId, "class.browse", BrowseOClassPage.class) {
                @Override
	public PageParameters getPageParameters() {
                    return BrowseOClassPage.preparePageParameters(rowModel.getObject(), DisplayMode.VIEW);
                }
            }.setIcon(FAIconType.angle_double_down).setBootstrapType(BootstrapType.INFO));
        }
    });
    AbstractJavaSortableDataProvider<OClass, String> provider = getOClassesDataProvider();
    provider.setSort("name", SortOrder.ASCENDING);
    GenericTablePanel<OClass> tablePanel = new GenericTablePanel<OClass>("tablePanel", columns, provider ,20);
    OrienteerDataTable<OClass, String> table = tablePanel.getDataTable();
    addTableCommands(table, modeModel);
    add(tablePanel);
}
 
Example #22
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 #23
Source File: OClassColumn.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<OClass>> cellItem,
		String componentId, IModel<OClass> rowModel) {
	if(DisplayMode.EDIT.equals(getModeObject()))
	{
		super.populateItem(cellItem, componentId, rowModel);
	}
	else
	{
		cellItem.add(new OClassViewPanel(componentId, rowModel));
	}
}
 
Example #24
Source File: OClusterColumn.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(Item<ICellPopulator<OCluster>> cellItem,
		String componentId, IModel<OCluster> rowModel) {
	if(DisplayMode.EDIT.equals(getModeObject()))
	{
		super.populateItem(cellItem, componentId, rowModel);
	}
	else
	{
		cellItem.add(new OClusterViewPanel(componentId, rowModel));
	}
}
 
Example #25
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 #26
Source File: TokenColumn.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
public void populateItem(
        final Item<ICellPopulator<T>> cellItem,
        final String componentId,
        final IModel<T> rowModel) {

    if (rowModel.getObject() instanceof UserTO) {
        if (StringUtils.isNotBlank(((UserTO) rowModel.getObject()).getToken())) {
            cellItem.add(new Label(componentId, new ResourceModel("tokenValued", "tokenValued")));
        } else {
            cellItem.add(new Label(componentId, new ResourceModel("tokenNotValued", "tokenNotValued")));
        }
    }
}
 
Example #27
Source File: BooleanPropertyColumn.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));
    if (obj != null && Boolean.valueOf(obj.toString())) {
        item.add(new AttributeModifier("class", "fa fa-check"));
        item.add(new AttributeModifier("style", "display: table-cell; text-align: center;"));
    }
}
 
Example #28
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 #29
Source File: DatePropertyColumn.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) {
    IModel<?> date = getDataModel(rowModel);

    String convertedDate = "";
    if (date.getObject() instanceof Date) {
        convertedDate = SyncopeConsoleSession.get().getDateFormat().format(date.getObject());
    }
    item.add(new Label(componentId, convertedDate));
}
 
Example #30
Source File: CollectionPropertyColumn.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void populateItem(
        final Item<ICellPopulator<T>> cellItem, final String componentId, final IModel<T> rowModel) {

    final Object value = getDataModel(rowModel).getObject();

    if (value instanceof Collection) {
        final List values = new ArrayList((Collection) value);
        Collections.sort(values);
        cellItem.add(new CollectionPanel(componentId, values));
    }
}