use of com.google.gwt.cell.client.CheckboxCell 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.cell.client.CheckboxCell 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.cell.client.CheckboxCell in project perun by CESNET.
the class GetAllGroups method getEmptyTable.
/**
* Returns table with groups in hierarchical structure and with custom field updater
*
* @return table widget
*/
public CellTable<Group> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<Group>(list);
// Cell table
table = new PerunTable<Group>(list);
table.setHyperlinksAllowed(false);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Group> columnSortHandler = new ListHandler<Group>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
if (!session.isVoAdmin(voId)) {
loaderImage.setEmptyResultMessage("You are not manager of any group in this VO.");
} else {
loaderImage.setEmptyResultMessage("VO has no groups.");
}
Column<Group, Group> checkBoxColumn = new Column<Group, Group>(new PerunCheckboxCell<Group>(true, false, coreGroupsCheckable)) {
@Override
public Group getValue(Group object) {
// Get the value from the selection model.
object.setChecked(selectionModel.isSelected(object));
return object;
}
};
// 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 (Group obj : list) {
if (!obj.isCoreGroup()) {
selectionModel.setSelected(obj, value);
}
}
}
});
if (checkable) {
table.addColumn(checkBoxColumn, checkBoxHeader);
}
table.addIdColumn("Group ID", tableFieldUpdater);
table.addNameColumn(tableFieldUpdater);
table.addDescriptionColumn(tableFieldUpdater);
// set row styles based on: isCoreGroup()
table.setRowStyles(new RowStyles<Group>() {
public String getStyleNames(Group row, int rowIndex) {
if (row.isCoreGroup()) {
return "bold";
}
return "";
}
});
return table;
}
use of com.google.gwt.cell.client.CheckboxCell in project perun by CESNET.
the class GetAllRichGroups method getEmptyTable.
/**
* Returns table with groups in hierarchical structure and with custom field updater
*
* @return table widget
*/
public CellTable<RichGroup> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<RichGroup>(list);
// Cell table
table = new PerunTable<RichGroup>(list);
table.setHyperlinksAllowed(false);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<RichGroup> columnSortHandler = new ListHandler<RichGroup>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichGroup>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
if (!session.isVoAdmin(voId)) {
loaderImage.setEmptyResultMessage("You are not manager of any group in this VO.");
} else {
loaderImage.setEmptyResultMessage("VO has no groups.");
}
Column<RichGroup, RichGroup> checkBoxColumn = new Column<RichGroup, RichGroup>(new PerunCheckboxCell<RichGroup>(true, false, coreGroupsCheckable)) {
@Override
public RichGroup getValue(RichGroup object) {
// Get the value from the selection model.
object.setChecked(selectionModel.isSelected(object));
return object;
}
};
// 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 (RichGroup obj : list) {
if (!obj.isCoreGroup()) {
selectionModel.setSelected(obj, value);
}
}
}
});
if (checkable) {
table.addColumn(checkBoxColumn, checkBoxHeader);
}
table.addIdColumn("Group ID", tableFieldUpdater);
// Add a synchronization clicable icon column.
final Column<RichGroup, RichGroup> syncColumn = new Column<RichGroup, RichGroup>(new CustomClickableInfoCellWithImageResource("click")) {
@Override
public RichGroup getValue(RichGroup object) {
return object;
}
@Override
public String getCellStyleNames(Cell.Context context, RichGroup object) {
if (tableFieldUpdater != null) {
return super.getCellStyleNames(context, object) + " pointer image-hover";
} else {
return super.getCellStyleNames(context, object);
}
}
};
syncColumn.setFieldUpdater(new FieldUpdater<RichGroup, RichGroup>() {
@Override
public void update(int index, final RichGroup object, RichGroup value) {
GetEntityById get = new GetEntityById(PerunEntity.RICH_GROUP, object.getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
final RichGroup object = jso.cast();
String name, syncEnabled, syncInterval, syncTimestamp, syncSuccessTimestamp, syncState, authGroup;
name = object.getName();
if (object.isSyncEnabled()) {
syncEnabled = "enabled";
} else {
syncEnabled = "disabled";
}
if (object.getSynchronizationInterval() == null) {
syncInterval = "N/A";
} else {
if (JsonUtils.checkParseInt(object.getSynchronizationInterval())) {
int time = Integer.parseInt(object.getSynchronizationInterval()) * 5 / 60;
if (time == 0) {
time = Integer.parseInt(object.getSynchronizationInterval()) * 5;
syncInterval = time + " minute(s)";
} else {
syncInterval = time + " hour(s)";
}
} else {
syncInterval = object.getSynchronizationInterval();
}
}
if (object.getLastSynchronizationState() == null) {
if (object.getLastSuccessSynchronizationTimestamp() != null) {
syncState = "OK";
} else {
syncState = "Not synced yet";
}
} else {
if (session.isPerunAdmin()) {
syncState = object.getLastSynchronizationState();
} else {
syncState = "Internal Error";
}
}
if (object.getLastSynchronizationTimestamp() == null) {
syncTimestamp = "N/A";
} else {
syncTimestamp = object.getLastSynchronizationTimestamp().split("\\.")[0];
}
if (object.getLastSuccessSynchronizationTimestamp() == null) {
syncSuccessTimestamp = "N/A";
} else {
syncSuccessTimestamp = object.getLastSuccessSynchronizationTimestamp().split("\\.")[0];
}
if (object.getAuthoritativeGroup() != null && object.getAuthoritativeGroup().equals("1")) {
authGroup = "Yes";
} else {
authGroup = "No";
}
String html = "Group name: <b>" + name + "</b><br>";
html += "Synchronization: <b>" + syncEnabled + "</b><br>";
if (object.isSyncEnabled()) {
html += "Last sync. state: <b>" + syncState + "</b><br>";
html += "Last sync. timestamp: <b>" + syncTimestamp + "</b><br>";
html += "Last successful sync. timestamp: <b>" + syncSuccessTimestamp + "</b><br>";
html += "Sync. Interval: <b>" + syncInterval + "</b><br>";
html += "Authoritative group: <b>" + authGroup + "</b><br>";
}
FlexTable layout = new FlexTable();
layout.setWidget(0, 0, new HTML("<p>" + new Image(LargeIcons.INSTANCE.informationIcon())));
layout.setHTML(0, 1, "<p style=\"line-height: 1.2;\">" + html);
layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
layout.getFlexCellFormatter().setStyleName(0, 0, "alert-box-image");
final CustomButton okButton = new CustomButton("Force synchronization", SmallIcons.INSTANCE.arrowRefreshIcon());
okButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ForceGroupSynchronization call = new ForceGroupSynchronization(JsonCallbackEvents.disableButtonEvents(okButton));
call.synchronizeGroup(object.getId());
}
});
okButton.setVisible(object.isSyncEnabled());
if (!session.isVoAdmin(object.getVoId()) && !session.isGroupAdmin(object.getId()))
okButton.setEnabled(false);
final Confirm c = new Confirm("Group synchronization info", layout, okButton, null, true);
c.setHideOnButtonClick(false);
c.setCancelIcon(SmallIcons.INSTANCE.acceptIcon());
c.setCancelButtonText("OK");
c.setCancelClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
c.hide();
}
});
c.show();
}
});
get.retrieveData();
}
;
});
syncColumn.setSortable(true);
columnSortHandler.setComparator(syncColumn, new Comparator<RichGroup>() {
@Override
public int compare(RichGroup o1, RichGroup o2) {
if (o1 != null && o2 != null) {
int o1val = 0;
int o2val = 0;
if (o1.isSyncEnabled())
o1val = 5;
if (o2.isSyncEnabled())
o2val = 5;
if (o1.getAuthoritativeGroup() != null && o1.getAuthoritativeGroup().equalsIgnoreCase("1"))
o1val = o1val + 3;
if (o2.getAuthoritativeGroup() != null && o2.getAuthoritativeGroup().equalsIgnoreCase("1"))
o2val = o2val + 3;
return o1val - o2val;
}
return 0;
}
});
table.addColumn(syncColumn, "Sync");
table.setColumnWidth(syncColumn, "70px");
// set row styles based on: isCoreGroup()
table.setRowStyles(new RowStyles<RichGroup>() {
public String getStyleNames(RichGroup row, int rowIndex) {
if (row.isCoreGroup()) {
return "bold";
}
return "";
}
});
table.addNameColumn(tableFieldUpdater);
table.addDescriptionColumn(tableFieldUpdater);
return table;
}
use of com.google.gwt.cell.client.CheckboxCell in project perun by CESNET.
the class GetMemberGroups method getTable.
/**
* Returns the table with subgroups.
* @return
*/
public CellTable<Group> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<Group>(list);
// Cell table
table = new PerunTable<Group>(list);
table.setHyperlinksAllowed(false);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Group> columnSortHandler = new ListHandler<Group>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("User is not member of any group.");
// checkbox column column
Column<Group, Group> checkBoxColumn = new Column<Group, Group>(new PerunCheckboxCell<Group>(true, false, coreGroupsCheckable)) {
@Override
public Group getValue(Group 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 (Group obj : list) {
if (!obj.isCoreGroup()) {
selectionModel.setSelected(obj, value);
}
}
}
});
if (checkable) {
table.addColumn(checkBoxColumn, checkBoxHeader);
}
table.addIdColumn("Group ID", tableFieldUpdater);
table.addNameColumn(tableFieldUpdater);
table.addDescriptionColumn(tableFieldUpdater);
return table;
}
Aggregations