use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.
the class FindCompleteRichMembers method getEmptyTable.
/**
* Returns table with RichMembers
*
* @return CellTable widget
*/
public CellTable<RichMember> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<RichMember>(list);
// Cell table
table = new PerunTable<RichMember>(list);
table.setHyperlinksAllowed(false);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("No member found.");
Column<RichMember, RichMember> checkBoxColumn = new Column<RichMember, RichMember>(new PerunCheckboxCell<RichMember>(true, false, indirectCheckable)) {
@Override
public RichMember getValue(RichMember object) {
// Get the value from the selection model.
object.setChecked(selectionModel.isSelected(object));
return object;
}
};
// 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 (RichMember obj : list) {
if (!"INDIRECT".equalsIgnoreCase(obj.getMembershipType())) {
selectionModel.setSelected(obj, value);
}
}
}
});
if (checkable) {
table.addColumn(checkBoxColumn, checkBoxHeader);
}
MemberColumnProvider columnProvider = new MemberColumnProvider(dataProvider, null, table, tableFieldUpdater);
IsClickableCell<RichMember> authz = new IsClickableCell<RichMember>() {
@Override
public boolean isClickable(RichMember object) {
return true;
}
@Override
public String linkUrl(RichMember object) {
return null;
}
};
columnProvider.addIdColumn(authz, 110);
columnProvider.addUserIdColumn(authz, 110);
columnProvider.addStatusColumn(authz, 20);
columnProvider.addNameColumn(authz);
columnProvider.addOrganizationColumn(authz);
columnProvider.addEmailColumn(authz);
columnProvider.addLoginsColumn(authz);
return table;
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.
the class GetCompleteRichMembers method getEmptyTable.
/**
* Returns empty table
*
* @return CellTable widget
*/
public CellTable<RichMember> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<RichMember>(list);
// Cell table
table = new PerunTable<RichMember>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity)) {
loaderImage.setEmptyResultMessage("VO has no members.");
} else {
loaderImage.setEmptyResultMessage("Group has no members.");
}
Column<RichMember, RichMember> checkBoxColumn = new Column<RichMember, RichMember>(new PerunCheckboxCell<RichMember>(true, false, indirectCheckable)) {
@Override
public RichMember getValue(RichMember object) {
// Get the value from the selection model.
object.setChecked(selectionModel.isSelected(object));
return object;
}
};
// 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 (RichMember obj : list) {
if (!"INDIRECT".equalsIgnoreCase(obj.getMembershipType())) {
selectionModel.setSelected(obj, value);
}
}
}
});
if (checkable) {
table.addColumn(checkBoxColumn, checkBoxHeader);
}
MemberColumnProvider columnProvider = new MemberColumnProvider(dataProvider, backupList, table, tableFieldUpdater);
IsClickableCell<RichMember> authz = new IsClickableCell<RichMember>() {
@Override
public boolean isClickable(RichMember object) {
return true;
}
@Override
public String linkUrl(RichMember object) {
return null;
}
};
columnProvider.addIdColumn(authz, 110);
columnProvider.addUserIdColumn(authz, 110);
columnProvider.addStatusColumn(authz, 20);
columnProvider.addNameColumn(authz);
columnProvider.addOrganizationColumn(authz);
columnProvider.addEmailColumn(authz);
columnProvider.addLoginsColumn(authz);
return table;
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.
the class GetAttributes 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);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// because of tabindex
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
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.addColumn(checkBoxColumn, checkBoxHeader);
}
// Create ID column.
table.addIdColumn("Attribute ID", this.tableFieldUpdater);
// Name column
Column<Attribute, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getFriendlyName();
}
}, this.tableFieldUpdater);
// Create ENTITY column
Column<Attribute, String> entityColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute a) {
return a.getEntity();
}
}, this.tableFieldUpdater);
// Create def type column
Column<Attribute, String> defTypeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute a) {
return a.getDefinition();
}
}, this.tableFieldUpdater);
// Create type column.
Column<Attribute, String> typeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return renameContent(attribute.getType());
}
}, this.tableFieldUpdater);
Column<Attribute, String> valueColumn;
if (editable) {
valueColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getValue();
}
}, new FieldUpdater<Attribute, String>() {
public void update(int index, Attribute object, String newText) {
if (object.setValue(newText)) {
selectionModel.setSelected(object, true);
} else {
selectionModel.setSelected(object, false);
UiElements.cantSaveAttributeValueDialogBox(object);
}
}
});
} else {
valueColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getValue();
}
}, this.tableFieldUpdater);
}
// Create description column.
Column<Attribute, String> descriptionColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Attribute, String>() {
public String getValue(Attribute attribute) {
return attribute.getDescription();
}
}, this.tableFieldUpdater);
// Sorting name column
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getFriendlyName().compareToIgnoreCase(o2.getFriendlyName());
}
});
// Sorting type column
typeColumn.setSortable(true);
columnSortHandler.setComparator(typeColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getType().compareToIgnoreCase(o2.getType());
}
});
// Sorting description column
descriptionColumn.setSortable(true);
columnSortHandler.setComparator(descriptionColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getDescription().compareToIgnoreCase(o2.getDescription());
}
});
// Sorting value column
valueColumn.setSortable(true);
columnSortHandler.setComparator(valueColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getValue().compareToIgnoreCase(o2.getValue());
}
});
// Sorting value column
entityColumn.setSortable(true);
columnSortHandler.setComparator(entityColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getEntity().compareToIgnoreCase(o2.getEntity());
}
});
// Sorting value column
defTypeColumn.setSortable(true);
columnSortHandler.setComparator(defTypeColumn, new Comparator<Attribute>() {
public int compare(Attribute o1, Attribute o2) {
return o1.getDefinition().compareToIgnoreCase(o2.getDefinition());
}
});
// column size
this.table.setColumnWidth(typeColumn, 120.0, Unit.PX);
this.table.setColumnWidth(entityColumn, 100.0, Unit.PX);
this.table.setColumnWidth(defTypeColumn, 110.0, Unit.PX);
this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
this.table.setColumnWidth(valueColumn, 200.0, Unit.PX);
// Add the columns.
this.table.addColumn(nameColumn, "Name");
this.table.addColumn(entityColumn, "Entity");
this.table.addColumn(defTypeColumn, "Definition");
this.table.addColumn(typeColumn, "Value type");
this.table.addColumn(valueColumn, "Value");
this.table.addColumn(descriptionColumn, "Description");
return table;
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.
the class GetAttributesDefinitionV2 method getTable.
/**
* Returns table widget with attributes definitions
*
* @return table widget
*/
public CellTable<Attribute> getTable() {
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<Attribute>(list);
// Cell table
table = new PerunTable<Attribute>(list);
// 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);
// checkbox column column
if (checkable) {
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager(0));
table.addCheckBoxColumn();
}
// 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());
}
});
// updates the columns size
this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
// 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);
// Add the columns.
this.table.addColumn(nameColumn, "Name");
this.table.addColumn(valueColumn, "Value");
this.table.addColumn(descriptionColumn, "Description");
return table;
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler 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;
}
Aggregations