use of cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell in project perun by CESNET.
the class GetAllowedGroups 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);
loaderImage.setEmptyResultMessage("No groups are allowed to access/use this facility.");
if (checkable) {
table.addCheckBoxColumn();
}
table.addIdColumn("Group ID", tableFieldUpdater);
table.addNameColumn(tableFieldUpdater);
table.addDescriptionColumn(tableFieldUpdater);
Column<Group, String> vosColumn = new Column<Group, String>(new CustomClickableTextCell()) {
@Override
public String getValue(Group group) {
for (VirtualOrganization v : vos) {
if (group.getVoId() == v.getId()) {
return v.getName();
}
}
return String.valueOf(group.getVoId());
}
};
vosColumn.setFieldUpdater(tableFieldUpdater);
columnSortHandler.setComparator(vosColumn, new Comparator<Group>() {
@Override
public int compare(Group o1, Group o2) {
return o1.getVoId() - o2.getVoId();
}
});
vosColumn.setSortable(true);
table.addColumn(vosColumn, "Virtual organization");
return table;
}
use of cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell in project perun by CESNET.
the class GetBlacklistWithDescription method getTable.
/**
* Returns the table widget with VOs.
* @return The table Widget
*/
public CellTable<Pair<User, String>> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<Pair<User, String>>(list);
// Cell table
table = new PerunTable<Pair<User, String>>(list);
// prevent double loading when clicked on vo name
table.setHyperlinksAllowed(false);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Pair<User, String>> columnSortHandler = new ListHandler<Pair<User, String>>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Pair<User, String>>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("Blacklist is empty.");
// columns
if (checkable) {
table.addCheckBoxColumn();
}
Column<Pair<User, String>, String> idColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Pair<User, String>, String>() {
public String getValue(Pair<User, String> object) {
return String.valueOf(object.getLeft().getId());
}
}, tableFieldUpdater);
idColumn.setSortable(true);
// comparator
columnSortHandler.setComparator(idColumn, new Comparator<Pair<User, String>>() {
@Override
public int compare(Pair<User, String> o1, Pair<User, String> o2) {
return o1.getLeft().getId() - o2.getLeft().getId();
}
});
// adding columns
table.addColumn(idColumn, "User ID");
table.setColumnWidth(idColumn, "150px");
Column<Pair<User, String>, String> nameColumn = JsonUtils.addColumn(new CustomClickableTextCell(), new JsonUtils.GetValue<Pair<User, String>, String>() {
@Override
public String getValue(Pair<User, String> object) {
return object.getLeft().getFullNameWithTitles();
}
}, tableFieldUpdater);
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new Comparator<Pair<User, String>>() {
public int compare(Pair<User, String> o1, Pair<User, String> o2) {
return o1.getLeft().getFullName().compareToIgnoreCase(o2.getLeft().getFullName());
}
});
table.addColumn(nameColumn, "Name");
table.setColumnWidth(nameColumn, "40%");
// Type column
TextColumn<Pair<User, String>> reasonColumn = new TextColumn<Pair<User, String>>() {
@Override
public String getValue(Pair<User, String> pair) {
return pair.getRight();
}
};
// sort type column
reasonColumn.setSortable(true);
columnSortHandler.setComparator(reasonColumn, new Comparator<Pair<User, String>>() {
public int compare(Pair<User, String> o1, Pair<User, String> o2) {
return o1.getRight().compareToIgnoreCase(o2.getRight());
}
});
// Add columns to table
table.addColumn(reasonColumn, "Reason");
table.setColumnWidth(reasonColumn, "50%");
return table;
}
use of cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell in project perun by CESNET.
the class GetServicesPackages method getEmptyTable.
/**
* Returns empty table of ServicePackages
*
* @return empty table widget
*/
public CellTable<ServicesPackage> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<ServicesPackage>(list);
// Cell table
table = new PerunTable<ServicesPackage>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<ServicesPackage> columnSortHandler = new ListHandler<ServicesPackage>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ServicesPackage>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("There are no services packages.");
// checkbox column column
if (checkable) {
table.addCheckBoxColumn();
}
table.addIdColumn("ServicesPackage Id", tableFieldUpdater, 110);
if (!editable) {
table.addNameColumn(tableFieldUpdater);
table.addDescriptionColumn(tableFieldUpdater);
} else {
// NAME COLUMN
final Column<ServicesPackage, String> nameColumn = new Column<ServicesPackage, String>(new TextInputCell()) {
public String getValue(ServicesPackage object) {
return object.getName();
}
};
nameColumn.setFieldUpdater(new FieldUpdater<ServicesPackage, String>() {
@Override
public void update(int i, final ServicesPackage object, final String s) {
object.setName(s.trim());
selectionModel.setSelected(object, true);
}
});
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new Comparator<ServicesPackage>() {
public int compare(ServicesPackage o1, ServicesPackage o2) {
return o1.getName().compareTo(o2.getName());
}
});
// DESCRIPTION COLUMN
final Column<ServicesPackage, String> descriptionColumn = new Column<ServicesPackage, String>(new TextInputCell()) {
public String getValue(ServicesPackage object) {
return object.getDescription();
}
};
descriptionColumn.setFieldUpdater(new FieldUpdater<ServicesPackage, String>() {
@Override
public void update(int i, final ServicesPackage object, final String s) {
object.setDescription(s.trim());
selectionModel.setSelected(object, true);
}
});
descriptionColumn.setSortable(true);
columnSortHandler.setComparator(descriptionColumn, new Comparator<ServicesPackage>() {
public int compare(ServicesPackage o1, ServicesPackage o2) {
return o1.getDescription().compareTo(o2.getDescription());
}
});
// Link COLUMN
final Column<ServicesPackage, String> linkColumn = new Column<ServicesPackage, String>(new CustomClickableTextCell()) {
public String getValue(ServicesPackage object) {
return "View services in package";
}
};
linkColumn.setFieldUpdater(tableFieldUpdater);
table.addColumn(nameColumn, "Name");
table.setColumnWidth(nameColumn, "250px");
table.addColumn(descriptionColumn, "Description");
table.setColumnWidth(descriptionColumn, "250px");
table.addColumn(linkColumn, "Manage services");
}
return table;
}
use of cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell in project perun by CESNET.
the class GetApplicationsForUser method getTable.
/**
* Returns just the celltable
* @return
*/
public CellTable<Application> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<Application>(list);
// Cell table
table = new PerunTable<Application>(list);
table.removeRowCountChangeHandler();
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Application> columnSortHandler = new ListHandler<Application>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Application>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("You have no applications submitted.");
// columns
if (checkable) {
table.addCheckBoxColumn();
}
table.addIdColumn("App ID", tableFieldUpdater, 100);
// DATE COLUMN
Column<Application, String> dateColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {
public String getValue(Application object) {
// return only day
return object.getCreatedAt().split(" ")[0];
}
}, tableFieldUpdater);
dateColumn.setSortable(true);
columnSortHandler.setComparator(dateColumn, new Comparator<Application>() {
public int compare(Application arg0, Application arg1) {
return arg0.getCreatedAt().compareToIgnoreCase(arg1.getCreatedAt());
}
});
table.addColumn(dateColumn, "Created date");
table.setColumnWidth(dateColumn, "150px");
// Type column
Column<Application, String> typeColumn = new Column<Application, String>(new CustomClickableTextCell()) {
@Override
public String getValue(Application object) {
return object.getTranslatedType(object.getType());
}
@Override
public String getCellStyleNames(Cell.Context context, Application object) {
if (tableFieldUpdater != null) {
return super.getCellStyleNames(context, object) + " pointer";
} else {
return super.getCellStyleNames(context, object);
}
}
};
typeColumn.setFieldUpdater(tableFieldUpdater);
typeColumn.setSortable(true);
columnSortHandler.setComparator(typeColumn, new Comparator<Application>() {
public int compare(Application arg0, Application arg1) {
return (arg0.getType()).compareToIgnoreCase(arg1.getType());
}
});
table.addColumn(typeColumn, "Type");
table.setColumnWidth(typeColumn, "60px");
// State column
Column<Application, String> stateColumn = new Column<Application, String>(new CustomClickableTextCell()) {
@Override
public String getValue(Application object) {
return object.getTranslatedState(object.getState());
}
@Override
public String getCellStyleNames(Cell.Context context, Application object) {
if (tableFieldUpdater != null) {
return super.getCellStyleNames(context, object) + " pointer";
} else {
return super.getCellStyleNames(context, object);
}
}
};
stateColumn.setFieldUpdater(tableFieldUpdater);
stateColumn.setSortable(true);
columnSortHandler.setComparator(stateColumn, new Comparator<Application>() {
public int compare(Application arg0, Application arg1) {
return (arg0.getTranslatedState(arg0.getState())).compareToIgnoreCase(arg1.getTranslatedState(arg1.getState()));
}
});
table.addColumn(stateColumn, "State");
table.setColumnWidth(stateColumn, "120px");
// VO COLUMN
Column<Application, String> voColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {
public String getValue(Application object) {
return object.getVo().getName();
}
}, tableFieldUpdater);
voColumn.setSortable(true);
columnSortHandler.setComparator(voColumn, new Comparator<Application>() {
public int compare(Application arg0, Application arg1) {
return (arg0.getVo().getName()).compareToIgnoreCase(arg1.getVo().getName());
}
});
table.addColumn(voColumn, "Virtual organization");
// GROUP COLUMN
Column<Application, String> groupColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {
public String getValue(Application object) {
if (object.getGroup() != null) {
return object.getGroup().getName();
} else {
return "---";
}
}
}, tableFieldUpdater);
groupColumn.setSortable(true);
columnSortHandler.setComparator(groupColumn, new Comparator<Application>() {
public int compare(Application arg0, Application arg1) {
String name1 = "";
String name2 = "";
if (arg0.getGroup() != null) {
name1 = arg0.getGroup().getName();
} else {
name1 = "---";
}
if (arg1.getGroup() != null) {
name2 = arg1.getGroup().getName();
} else {
name2 = "---";
}
return (name1).compareToIgnoreCase(name2);
}
});
table.addColumn(groupColumn, "Group");
// FED INFO COLUMN
/*
Column<Application, String> fedInfoColumn = JsonUtils.addColumn(
new ClickableTextCell() {
@Override
public void render(
com.google.gwt.cell.client.Cell.Context context,
SafeHtml value, SafeHtmlBuilder sb) {
if (value != null) {
sb.appendHtmlConstant("<div class=\"customClickableTextCell\">");
sb.append(value);
sb.appendHtmlConstant("</div>");
}
}
},
new JsonUtils.GetValue<Application, String>() {
public String getValue(Application object) {
return object.getFedInfo();
}
}, tableFieldUpdater);
fedInfoColumn.setSortable(true);
columnSortHandler.setComparator(fedInfoColumn, new Comparator<Application>(){
public int compare(Application arg0, Application arg1) {
return (arg0.getFedInfo()).compareToIgnoreCase(arg1.getFedInfo());
}
});
table.addColumn(fedInfoColumn, "Federation information");
*/
table.setRowStyles(new RowStyles<Application>() {
public String getStyleNames(Application application, int i) {
if ("NEW".equalsIgnoreCase(application.getState())) {
return "rowgreen";
} else if ("VERIFIED".equalsIgnoreCase(application.getState())) {
return "rowyellow";
} else if ("APPROVED".equalsIgnoreCase(application.getState())) {
return "rowdarkgreen";
} else if ("REJECTED".equalsIgnoreCase(application.getState())) {
return "rowred";
}
return "";
}
});
return table;
}
use of cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell in project perun by CESNET.
the class JsonUtils method addColumn.
/**
* Returns a column with a header and with automatic cell selection
*
* @param <R> the row type
* @param getter the value getter for the cell
* @param fieldUpdater Field updater - on click action
*/
public static <R> Column<R, String> addColumn(final GetValue<R, String> getter, final FieldUpdater<R, String> fieldUpdater) {
Cell<String> cell;
if (fieldUpdater == null) {
cell = new TextCell();
} else {
cell = new CustomClickableTextCell();
}
Column<R, String> column = new Column<R, String>(cell) {
@Override
public String getValue(R object) {
return getter.getValue(object);
}
@Override
public String getCellStyleNames(Cell.Context context, R object) {
if (fieldUpdater != null) {
return super.getCellStyleNames(context, object) + " pointer";
} else {
return super.getCellStyleNames(context, object);
}
}
};
if (fieldUpdater != null) {
column.setFieldUpdater(fieldUpdater);
}
return column;
}
Aggregations