use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.
the class FindExternalPublications method getEmptyTable.
/**
* Returns table with publications
* @return table
*/
public CellTable<Publication> getEmptyTable() {
// Table data provider.
dataProvider = new ListDataProvider<Publication>(list);
// Cell table
table = new PerunTable<Publication>(list);
table.removeRowCountChangeHandler();
table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Publication> columnSortHandler = new ListHandler<Publication>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage.prepareToSearch("Please select external pub. system and year range to search for publications for import."));
loaderImage.setEmptyResultMessage("No publications found in external system.");
// show checkbox column
if (this.checkable) {
table.addCheckBoxColumn();
}
/*
// CATEGORY COLUMN
ArrayList<String> categories = new ArrayList<String>();
categories.add("Bodované v RIVu");
categories.add("Nebodované v RIVu");
categories.add("Příspěvek do ročenky");
categories.add("Výjimečné výsledky");
categories.add("Jiné");
Column<Publication, String> categoryColumn = new Column<Publication, String>(new SelectionCell(categories)){
@Override
public String getValue(Publication object) {
// category ID as string, 0 if not set
int id = object.getCategoryId();
if (id == 0) {
// set default == 21/Bodované v RIVu to object
object.setCategoryId(21);
}
if (id == 21) {
return "Bodované v RIVu";
} else if (id == 22) {
return "Nebodované v RIVu";
} else if (id == 23) {
return "Výjimečné výsledky";
} else if (id == 24) {
return "Příspěvek do ročenky";
} else if (id == 25) {
return "Jiné";
} else {
return String.valueOf(id); // return ID if no match
}
}
};
categoryColumn.setFieldUpdater(new FieldUpdater<Publication, String>() {
public void update(int index, Publication object, String value) {
int id = 0;
if (value.equalsIgnoreCase("Bodované v RIVu")) {
id = 21;
} else if (value.equalsIgnoreCase("Nebodované v RIVu")) {
id = 22;
} else if (value.equalsIgnoreCase("Příspěvek do ročenky")) {
id = 24;
} else if (value.equalsIgnoreCase("Výjimečné výsledky")) {
id = 23;
} else if (value.equalsIgnoreCase("Jiné")) {
id = 25;
}
object.setCategoryId(id);
selectionModel.setSelected(object, true);
}
});
table.addColumn(categoryColumn, "Category");
// NOT USEFULL => DISABLED
// EXTERNAL ID
TextColumn<Publication> externalIdColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return String.valueOf(object.getExternalId());
};
};
externalIdColumn.setSortable(true);
columnSortHandler.setComparator(externalIdColumn, new PublicationComparator(PublicationComparator.Column.EXTERNAL_ID));
table.addColumn(externalIdColumn, "External Id");
*/
// TITLE COLUMN
TextColumn<Publication> titleColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return object.getTitle();
}
;
};
titleColumn.setSortable(true);
columnSortHandler.setComparator(titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
table.addColumn(titleColumn, "Title");
// AUTHORS COLUMN
TextColumn<Publication> authorColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return object.getAuthorsFormatted();
}
;
};
authorColumn.setSortable(true);
columnSortHandler.setComparator(authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
table.addColumn(authorColumn, "Authors");
// YEAR COLUMN
TextColumn<Publication> yearColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return String.valueOf(object.getYear());
}
;
};
yearColumn.setSortable(true);
columnSortHandler.setComparator(yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
table.addColumn(yearColumn, "Year");
// ISBN COLUMN
TextColumn<Publication> isbnColumn = new TextColumn<Publication>() {
public String getValue(Publication object) {
return object.getIsbn();
}
;
};
isbnColumn.setSortable(true);
columnSortHandler.setComparator(isbnColumn, new PublicationComparator(PublicationComparator.Column.ISBN));
table.addColumn(isbnColumn, "ISBN");
// CITE COLUMN
Column<Publication, String> citaceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {
public String getValue(Publication object) {
return "Cite";
}
}, new FieldUpdater<Publication, String>() {
public void update(int index, Publication object, String value) {
SimplePanel sp = new SimplePanel();
sp.add(new HTML(object.getMain()));
Confirm cf = new Confirm("Cite publication", sp, true);
cf.show();
}
;
});
table.addColumn(citaceColumn, "Cite");
return table;
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.
the class GetAuditMessagesByCount method getTable.
public CellTable<AuditMessage> getTable() {
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<AuditMessage>(list);
// Cell table
table = new PerunTable<AuditMessage>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<AuditMessage> columnSortHandler = new ListHandler<AuditMessage>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AuditMessage>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("No audit messages found.");
if (checkable) {
// checkbox column column
table.addCheckBoxColumn();
}
table.addIdColumn("Message ID", null, 120);
// MESSAGE COLUMN
Column<AuditMessage, String> messageColumn = JsonUtils.addColumn(new CustomTextCell(), new JsonUtils.GetValue<AuditMessage, String>() {
public String getValue(AuditMessage msg) {
return msg.getActor() + ": " + msg.getMessage();
}
}, null);
messageColumn.setSortable(true);
columnSortHandler.setComparator(messageColumn, new Comparator<AuditMessage>() {
public int compare(AuditMessage o1, AuditMessage o2) {
return (o1.getActor() + ": " + o1.getMessage()).compareToIgnoreCase(o2.getActor() + ": " + o2.getMessage());
}
});
// TIME COLUMN
TextColumn<AuditMessage> timeColumn = new TextColumn<AuditMessage>() {
public String getValue(AuditMessage msg) {
return msg.getCreatedAt().substring(0, msg.getCreatedAt().indexOf("."));
}
};
timeColumn.setSortable(true);
columnSortHandler.setComparator(timeColumn, new Comparator<AuditMessage>() {
public int compare(AuditMessage o1, AuditMessage o2) {
return o1.getCreatedAt().compareToIgnoreCase(o2.getCreatedAt());
}
});
table.addColumn(timeColumn, "Created at");
table.setColumnWidth(timeColumn, "180px");
table.addColumn(messageColumn, "Message");
return table;
}
use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler 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 com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.
the class GetVos 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);
// prevent double loading when clicked on vo name
table.setHyperlinksAllowed(false);
// 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);
if (forceAll) {
loaderImage.setEmptyResultMessage("No VOs found.");
} else {
loaderImage.setEmptyResultMessage("You are not manager of any VO.");
}
// columns
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);
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;
}
Aggregations