use of cz.metacentrum.perun.webgui.model.GeneralObject in project perun by CESNET.
the class JsonUtils method addColumn.
/**
* Returns a column with a header.
*
* @param <R> the row type
* @param <R> the cell type
* @param cell the cell used to render the column
* @param headerText the header string
* @param getValue the value getter for the cell
* @deprecated Shouldn't be used when returning the same object - use the method without Getter in parameter instead *
*/
public static <R> Column<R, R> addColumn(Cell<R> cell, String headerText, final GetValue<R, R> getValue, final FieldUpdater<R, String> tableFieldUpdater, boolean custom) {
Column<R, R> column = new Column<R, R>(cell) {
@Override
public R getValue(R object) {
return object;
}
@Override
public String getCellStyleNames(Cell.Context context, R object) {
if (tableFieldUpdater != null) {
return super.getCellStyleNames(context, object) + " pointer";
} else {
return super.getCellStyleNames(context, object);
}
}
};
if (tableFieldUpdater != null) {
FieldUpdater<R, R> tableFieldUpdater2 = new FieldUpdater<R, R>() {
public void update(int index, R object, R value) {
GeneralObject go = (GeneralObject) value;
tableFieldUpdater.update(index, object, go.getName());
}
};
column.setFieldUpdater(tableFieldUpdater2);
}
return column;
}
use of cz.metacentrum.perun.webgui.model.GeneralObject in project perun by CESNET.
the class GetAttributesV2 method getEmptyTable.
/**
* Returns empty table widget with attributes
*
* @return table widget
*/
public CellTable<Attribute> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<Attribute>(list);
// Cell table
table = new PerunTable<Attribute>(list);
// remove row count change handler
table.removeRowCountChangeHandler();
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Attribute> columnSortHandler = new ListHandler<Attribute>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("No settings found. Use 'Add' button to add new setting.");
// because of tab index
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
// checkbox column
if (checkable) {
// checkbox column column
Column<Attribute, Attribute> checkBoxColumn = new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {
@Override
public Attribute getValue(Attribute object) {
// Get the value from the selection model.
GeneralObject go = object.cast();
go.setChecked(selectionModel.isSelected(object));
return go.cast();
}
};
// updates the columns size
table.setColumnWidth(checkBoxColumn, 40.0, Unit.PX);
// Add the columns
// Checkbox column header
CheckboxCell cb = new CheckboxCell();
Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {
public Boolean getValue() {
//return true to see a checked checkbox.
return false;
}
};
checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {
public void update(Boolean value) {
// sets selected to all, if value = true, unselect otherwise
for (Attribute obj : list) {
if (obj.isWritable()) {
selectionModel.setSelected(obj, value);
}
}
}
});
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager(0));
table.addColumn(checkBoxColumn, checkBoxHeader);
}
// Create ID column.
table.addIdColumn("Attr ID", null, 90);
// Name column
Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());
// Description column
Column<Attribute, Attribute> descriptionColumn = JsonUtils.addColumn(new PerunAttributeDescriptionCell());
// Value column
Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell());
valueColumn.setFieldUpdater(new FieldUpdater<Attribute, Attribute>() {
public void update(int index, Attribute object, Attribute value) {
object = value;
selectionModel.setSelected(object, object.isAttributeValid());
}
});
// Sorting name column
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));
// Sorting description column
descriptionColumn.setSortable(true);
columnSortHandler.setComparator(descriptionColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));
// Add sorting
this.table.addColumnSortHandler(columnSortHandler);
// updates the columns size
this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
// Add the columns.
this.table.addColumn(nameColumn, "Name");
this.table.addColumn(valueColumn, "Value");
this.table.addColumn(descriptionColumn, "Description");
return this.table;
}
use of cz.metacentrum.perun.webgui.model.GeneralObject in project perun by CESNET.
the class GetUserExtSources method getTable.
/**
* Return table with checkboxes containing user external sources
*
* @return table containing user ext sources
*/
public CellTable<UserExtSource> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<UserExtSource>(list);
// Cell table
table = new PerunTable<UserExtSource>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<UserExtSource> columnSortHandler = new ListHandler<UserExtSource>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<UserExtSource>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// checkbox column column
com.google.gwt.user.cellview.client.Column<UserExtSource, UserExtSource> checkBoxColumn = new com.google.gwt.user.cellview.client.Column<UserExtSource, UserExtSource>(new PerunCheckboxCell<UserExtSource>(true, false, false)) {
@Override
public UserExtSource getValue(UserExtSource object) {
// Get the value from the selection model.
GeneralObject go = object.cast();
go.setChecked(selectionModel.isSelected(object));
return go.cast();
}
};
// updates the columns size
table.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
// Add the columns
// Checkbox column header
CheckboxCell cb = new CheckboxCell();
Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {
public Boolean getValue() {
//return true to see a checked checkbox.
return false;
}
};
checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {
public void update(Boolean value) {
// sets selected to all, if value = true, unselect otherwise
for (UserExtSource obj : list) {
if (!obj.isPersistent()) {
selectionModel.setSelected(obj, value);
}
}
}
});
table.addColumn(checkBoxColumn, checkBoxHeader);
table.addIdColumn("UES ID", tableFieldUpdater, 100);
// Name column
Column<UserExtSource, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<UserExtSource, String>() {
public String getValue(UserExtSource extSource) {
return String.valueOf(extSource.getExtSource().getName());
}
}, tableFieldUpdater);
// Login column
Column<UserExtSource, String> loginColumn = JsonUtils.addColumn(new JsonUtils.GetValue<UserExtSource, String>() {
public String getValue(UserExtSource extSource) {
return String.valueOf(extSource.getLogin());
}
}, tableFieldUpdater);
// LOA column
Column<UserExtSource, String> loaColumn = JsonUtils.addColumn(new JsonUtils.GetValue<UserExtSource, String>() {
public String getValue(UserExtSource extSource) {
return String.valueOf(extSource.getLoa());
}
}, tableFieldUpdater);
// sort name column
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new GeneralComparator<UserExtSource>(GeneralComparator.Column.NAME));
// sort login column
loginColumn.setSortable(true);
columnSortHandler.setComparator(loginColumn, new Comparator<UserExtSource>() {
public int compare(UserExtSource o1, UserExtSource o2) {
return o1.getLogin().compareTo(o2.getLogin());
}
});
// sort login column
loaColumn.setSortable(true);
columnSortHandler.setComparator(loaColumn, new Comparator<UserExtSource>() {
public int compare(UserExtSource o1, UserExtSource o2) {
return o1.getLoa() - o2.getLoa();
}
});
table.addColumn(nameColumn, "External source name");
table.addColumn(loginColumn, "ID in external source");
table.addColumn(loaColumn, "Level of assurance");
return table;
}
use of cz.metacentrum.perun.webgui.model.GeneralObject in project perun by CESNET.
the class GetVosWhereUserIsAdmin method getTable.
/**
* Returns the table widget with VOs.
* @return The table Widget
*/
public CellTable<VirtualOrganization> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<VirtualOrganization>(list);
// Cell table
table = new PerunTable<VirtualOrganization>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<VirtualOrganization> columnSortHandler = new ListHandler<VirtualOrganization>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<VirtualOrganization>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// checkbox column column
if (checkable) {
table.addCheckBoxColumn();
}
VoColumnProvider columnProvider = new VoColumnProvider(table, tableFieldUpdater);
IsClickableCell<GeneralObject> authz = VoColumnProvider.getDefaultClickableAuthz();
columnProvider.addIdColumn(authz, 100);
columnProvider.addShortNameColumn(authz, 200);
columnProvider.addNameColumn(authz, 0);
return table;
}
use of cz.metacentrum.perun.webgui.model.GeneralObject in project perun by CESNET.
the class GetVosWhereUserIsMember method getTable.
/**
* Returns the table widget with VOs.
* @return The table Widget
*/
public CellTable<VirtualOrganization> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<VirtualOrganization>(list);
// Cell table
table = new PerunTable<VirtualOrganization>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<VirtualOrganization> columnSortHandler = new ListHandler<VirtualOrganization>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<VirtualOrganization>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// columns
if (this.checkable) {
table.addCheckBoxColumn();
}
VoColumnProvider columnProvider = new VoColumnProvider(table, tableFieldUpdater);
IsClickableCell<GeneralObject> authz = VoColumnProvider.getDefaultClickableAuthz();
columnProvider.addIdColumn(authz, 100);
columnProvider.addShortNameColumn(authz, 200);
columnProvider.addNameColumn(authz, 0);
return table;
}
Aggregations