revisited the columns
This commit is contained in:
parent
30cedd9376
commit
f1f1465696
|
@ -64,15 +64,17 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
||||
*/
|
||||
public static enum DISPLAY_FIELD {
|
||||
NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE, INSERTED_BY
|
||||
NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_START_END_DATE, CREATED, CREATED_BY
|
||||
};
|
||||
|
||||
private List<DISPLAY_FIELD> displayFields;
|
||||
private Column<T, Date> startProjectDateColumn;
|
||||
private Column<T, Date> endProjectDateColumn;
|
||||
private TextColumn<T> startEndProjectColumn;
|
||||
// private Column<T, Date> startProjectDateColumn;
|
||||
// private Column<T, Date> endProjectDateColumn;
|
||||
private DISPLAY_FIELD startSortByColumn;
|
||||
private boolean isAsyncronusTable;
|
||||
private TextColumn<T> insertedBy;
|
||||
private Column<T, Date> createdColumn;
|
||||
|
||||
/**
|
||||
* Instantiates a new items table.
|
||||
|
@ -210,20 +212,39 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) {
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_END_DATE)) {
|
||||
|
||||
startEndProjectColumn = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
|
||||
Date dS = (((ConcessioneDV) object).getDataInizioProgetto());
|
||||
Date dE = (((ConcessioneDV) object).getDataFineProgetto());
|
||||
return dtformat.format(dS) + " / " + dtformat.format(dE);
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(startEndProjectColumn, "Start/End Date", false);
|
||||
sortedCellTable.setColumnWidth(startEndProjectColumn, 180, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.CREATED)) {
|
||||
|
||||
DateCell date = new DateCell(dtformat);
|
||||
startProjectDateColumn = new Column<T, Date>(date) {
|
||||
createdColumn = new Column<T, Date>(date) {
|
||||
|
||||
@Override
|
||||
public Date getValue(T object) {
|
||||
if (object == null)
|
||||
return null;
|
||||
|
||||
return (((ConcessioneDV) object).getDataInizioProgetto());
|
||||
return (((ConcessioneDV) object).getCreationTime());
|
||||
}
|
||||
};
|
||||
sortedCellTable.addColumn(startProjectDateColumn, "Project Start Date", true);
|
||||
sortedCellTable.addColumn(createdColumn, "Created", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
|
@ -235,8 +256,8 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
if (o2 == null)
|
||||
return 1;
|
||||
|
||||
Date d1 = (((ConcessioneDV) o1).getDataInizioProgetto());
|
||||
Date d2 = (((ConcessioneDV) o2).getDataInizioProgetto());
|
||||
Date d1 = (((ConcessioneDV) o1).getCreationTime());
|
||||
Date d2 = (((ConcessioneDV) o2).getCreationTime());
|
||||
|
||||
// GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
|
||||
|
||||
|
@ -247,58 +268,14 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
}
|
||||
};
|
||||
GWT.log("date colum sortable");
|
||||
sortedCellTable.setComparator(startProjectDateColumn, c);
|
||||
sortedCellTable.setComparator(createdColumn, c);
|
||||
}
|
||||
|
||||
sortedCellTable.setColumnWidth(startProjectDateColumn, 150, Unit.PX);
|
||||
sortedCellTable.setColumnWidth(createdColumn, 150, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_END_DATE)) {
|
||||
|
||||
DateCell date = new DateCell(dtformat);
|
||||
endProjectDateColumn = new Column<T, Date>(date) {
|
||||
|
||||
@Override
|
||||
public Date getValue(T object) {
|
||||
if (object == null)
|
||||
return null;
|
||||
|
||||
return (((ConcessioneDV) object).getDataFineProgetto());
|
||||
}
|
||||
};
|
||||
sortedCellTable.addColumn(startProjectDateColumn, "Project End Date", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
if (o1 == null)
|
||||
return -1;
|
||||
|
||||
if (o2 == null)
|
||||
return 1;
|
||||
|
||||
Date d1 = (((ConcessioneDV) o1).getDataFineProgetto());
|
||||
Date d2 = (((ConcessioneDV) o2).getDataFineProgetto());
|
||||
|
||||
// GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
|
||||
|
||||
if (d1.after(d2))
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
GWT.log("date colum sortable");
|
||||
sortedCellTable.setComparator(endProjectDateColumn, c);
|
||||
}
|
||||
|
||||
sortedCellTable.setColumnWidth(endProjectDateColumn, 150, Unit.PX);
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.INSERTED_BY)) {
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.CREATED_BY)) {
|
||||
|
||||
// NAME
|
||||
insertedBy = new TextColumn<T>() {
|
||||
|
@ -310,7 +287,7 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(insertedBy, "Inserted by", true);
|
||||
sortedCellTable.addColumn(insertedBy, "Created by", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
|
@ -378,21 +355,6 @@ public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<
|
|||
sortedCellTable.setInitialSortColumn(author);
|
||||
}
|
||||
break;
|
||||
case PROJECT_START_DATE:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) {
|
||||
sortedCellTable.setDefaultSortOrder(startProjectDateColumn, false); // sorts ascending on first
|
||||
// click
|
||||
sortedCellTable.setInitialSortColumn(startProjectDateColumn);
|
||||
GWT.log("sortedCellTable: " + sortedCellTable);
|
||||
}
|
||||
break;
|
||||
case PROJECT_END_DATE:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) {
|
||||
sortedCellTable.setDefaultSortOrder(endProjectDateColumn, false); // sorts ascending on first click
|
||||
sortedCellTable.setInitialSortColumn(endProjectDateColumn);
|
||||
GWT.log("sortedCellTable: " + sortedCellTable);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue