Issue #1891 Fix sorting in pending subscription table
Amend: Rename getRowData() to getDisplayData() Change-Id: Icc433f289d87273524468d0cf4e1bc799df134aa Former-commit-id:d9544f3b73
[formerly b37624ebadc626e3dc30f669881d0b7bb87a7c45] Former-commit-id:36cdd94a65
This commit is contained in:
parent
08a08803fe
commit
f7505eefc2
7 changed files with 129 additions and 103 deletions
|
@ -82,6 +82,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
|
|||
* Oct 05, 2012 1241 djohnson Replace RegistryManager calls with registry handler calls.
|
||||
* Jan 10, 2013 1346 mpduff Add additional information to the dataset details output.
|
||||
* Feb 15, 2013 1638 mschenke Moved Util.EOL into FileUtil
|
||||
* Apr 10, 2013 1891 djohnson Declare variable as List.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -513,7 +514,7 @@ public class BrowserTableComp extends TableComp implements IDialogClosed {
|
|||
|
||||
tableData.sortData();
|
||||
|
||||
ArrayList<BrowserTableRowData> btrdArray = tableData.getDataArray();
|
||||
List<BrowserTableRowData> btrdArray = tableData.getDataArray();
|
||||
|
||||
for (BrowserTableRowData btrd : btrdArray) {
|
||||
TableItem ti = new TableItem(this.table, SWT.NONE);
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.swt.widgets.Display;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 14, 2012 lvenable Initial creation
|
||||
* Apr 10, 2013 1891 djohnson Add reverse().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -51,12 +52,12 @@ public class SortImages {
|
|||
/**
|
||||
* Parent composite.
|
||||
*/
|
||||
private Composite parent;
|
||||
private final Composite parent;
|
||||
|
||||
/**
|
||||
* Parent display.
|
||||
*/
|
||||
private Display parentDisplay;
|
||||
private final Display parentDisplay;
|
||||
|
||||
/**
|
||||
* Array of sort images.
|
||||
|
@ -67,7 +68,25 @@ public class SortImages {
|
|||
* Sort direction enumeration that identifies which image to use.
|
||||
*/
|
||||
public enum SortDirection {
|
||||
ASCENDING, DESCENDING
|
||||
ASCENDING {
|
||||
@Override
|
||||
public SortDirection reverse() {
|
||||
return SortDirection.DESCENDING;
|
||||
}
|
||||
},
|
||||
DESCENDING {
|
||||
@Override
|
||||
public SortDirection reverse() {
|
||||
return SortDirection.ASCENDING;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reverse the sorting direction.
|
||||
*
|
||||
* @return the reverse direction
|
||||
*/
|
||||
public abstract SortDirection reverse();
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,11 +50,12 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 13, 2012 687 lvenable Initial creation
|
||||
* Jun 27, 2012 702 jpiatt Updates for subscription groups.
|
||||
* Aug 15, 2012 430 jpiatt Modified sort.
|
||||
* Aug 30, 2012 1120 jpiatt Added clickSort flag.
|
||||
* Jan 07, 2013 1437 bgonzale updateSortDirection method now returns direction.
|
||||
* Jun 13, 2012 687 lvenable Initial creation
|
||||
* Jun 27, 2012 702 jpiatt Updates for subscription groups.
|
||||
* Aug 15, 2012 430 jpiatt Modified sort.
|
||||
* Aug 30, 2012 1120 jpiatt Added clickSort flag.
|
||||
* Jan 07, 2013 1437 bgonzale updateSortDirection method now returns direction.
|
||||
* Apr 10, 2013 1891 djohnson Fix sorting.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -75,16 +76,16 @@ public abstract class TableComp extends Composite implements
|
|||
private final Composite parentComp;
|
||||
|
||||
/** Selected table column. */
|
||||
protected TableColumn sortedColumn = null;
|
||||
protected TableColumn sortedColumn;
|
||||
|
||||
/** Sort direction map. */
|
||||
protected HashMap<String, SortDirection> sortDirectionMap = new HashMap<String, SortDirection>();
|
||||
protected Map<String, SortDirection> sortDirectionMap = new HashMap<String, SortDirection>();
|
||||
|
||||
/** Table configuration. */
|
||||
private final TableCompConfig tableConfig;
|
||||
|
||||
/** Configuration changed flag. */
|
||||
protected boolean configChange = false;
|
||||
protected boolean configChange;
|
||||
|
||||
/**
|
||||
* Flag indicating if an observer should be added to the Notification
|
||||
|
@ -207,17 +208,7 @@ public abstract class TableComp extends Composite implements
|
|||
}
|
||||
|
||||
if (table.getItemCount() > 0) {
|
||||
// Only change image if table is re-opened
|
||||
if (!configChange) {
|
||||
sortedColumn.setImage(sortImages.getImage(sortDir));
|
||||
} else if (sortDir == SortDirection.ASCENDING) {
|
||||
sortedColumn.setImage(sortImages
|
||||
.getImage(SortDirection.ASCENDING));
|
||||
} else {
|
||||
sortedColumn.setImage(sortImages
|
||||
.getImage(SortDirection.DESCENDING));
|
||||
}
|
||||
|
||||
sortedColumn.setImage(sortImages.getImage(sortDir));
|
||||
}
|
||||
|
||||
packColumns();
|
||||
|
@ -269,13 +260,8 @@ public abstract class TableComp extends Composite implements
|
|||
.get(sortedColumn.getText());
|
||||
|
||||
if (clickSort) {
|
||||
if (sortDirection == SortDirection.DESCENDING) {
|
||||
sortDirection = SortDirection.ASCENDING;
|
||||
} else {
|
||||
sortDirection = SortDirection.DESCENDING;
|
||||
}
|
||||
sortDirection = sortDirection.reverse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sortDirectionMap.put(sortedColumn.getText(), sortDirection);
|
||||
|
|
|
@ -28,7 +28,8 @@ package com.raytheon.uf.viz.datadelivery.common.ui;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 6, 2012 lvenable Initial creation
|
||||
* Jun 06, 2012 lvenable Initial creation
|
||||
* Apr 10, 2013 1891 djohnson Declare variable as List.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,7 +50,7 @@ public class TableDataManager<T extends ITableData<T>> implements ISortTable {
|
|||
/**
|
||||
* Array of data.
|
||||
*/
|
||||
private final ArrayList<T> tableData;
|
||||
private final List<T> tableData;
|
||||
|
||||
/**
|
||||
* Column name.
|
||||
|
@ -93,7 +94,7 @@ public class TableDataManager<T extends ITableData<T>> implements ISortTable {
|
|||
*
|
||||
* @return The data array.
|
||||
*/
|
||||
public ArrayList<T> getDataArray() {
|
||||
public List<T> getDataArray() {
|
||||
return tableData;
|
||||
}
|
||||
|
||||
|
|
|
@ -512,7 +512,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
*/
|
||||
private String getCellText(String name, SubscriptionManagerRowData rd) {
|
||||
SubColumnNames subColumn = SubColumnNames.fromDisplayString(name);
|
||||
return subColumn.getRowData(rd);
|
||||
return subColumn.getDisplayData(rd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.subscription.approve;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -74,6 +73,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
|
|||
* Dec 19, 2012 1413 bgonzale In the notificationArrived method, check for approved or
|
||||
* denied pending messages.
|
||||
* Apr 05, 2013 1841 djohnson Refresh entire table on receiving a notification of the correct type.
|
||||
* Apr 10, 2013 1891 djohnson Move logic to get column display text to the column definition, fix sorting.
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -200,28 +200,9 @@ public class SubApprovalTableComp extends TableComp {
|
|||
* @return Cell text string.
|
||||
*/
|
||||
private String getCellText(String columnName, SubscriptionApprovalRowData rd) {
|
||||
String returnValue = null;
|
||||
|
||||
if (columnName.equals(PendingSubColumnNames.NAME.getColumnName())) {
|
||||
returnValue = rd.getSubName();
|
||||
} else if (columnName.equals(PendingSubColumnNames.OWNER
|
||||
.getColumnName())) {
|
||||
returnValue = rd.getOwner();
|
||||
} else if (columnName.equals(PendingSubColumnNames.CHANGE_ID
|
||||
.getColumnName())) {
|
||||
returnValue = rd.getChangeOwner();
|
||||
} else if (columnName.equals(PendingSubColumnNames.OFFICE
|
||||
.getColumnName())) {
|
||||
returnValue = rd.getOfficeId();
|
||||
} else if (columnName.equals(PendingSubColumnNames.DESCRIPTION
|
||||
.getColumnName())) {
|
||||
returnValue = rd.getDescription();
|
||||
} else if (columnName.equals(PendingSubColumnNames.ACTION
|
||||
.getColumnName())) {
|
||||
returnValue = rd.getAction();
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
PendingSubColumnNames column = PendingSubColumnNames
|
||||
.valueOfColumnName(columnName);
|
||||
return column.getDisplayData(rd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -361,16 +342,11 @@ public class SubApprovalTableComp extends TableComp {
|
|||
|
||||
pendingSubData.sortData();
|
||||
|
||||
ArrayList<SubscriptionApprovalRowData> sardArray = pendingSubData
|
||||
List<SubscriptionApprovalRowData> sardArray = pendingSubData
|
||||
.getDataArray();
|
||||
|
||||
for (SubscriptionApprovalRowData sard : sardArray) {
|
||||
TableItem ti = new TableItem(this.table, SWT.NONE);
|
||||
ti.setText(0, sard.getSubName());
|
||||
ti.setText(1, sard.getOwner());
|
||||
ti.setText(2, sard.getChangeOwner());
|
||||
ti.setText(3, sard.getOfficeId());
|
||||
ti.setText(4, sard.getDescription());
|
||||
convertRowDataToTableItem(table.getColumns(), sard);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,16 +369,11 @@ public class SubApprovalTableComp extends TableComp {
|
|||
*/
|
||||
@Override
|
||||
protected void createColumns() {
|
||||
String[] columns = new String[PendingSubColumnNames.values().length];
|
||||
TableColumn tc;
|
||||
final PendingSubColumnNames[] columnNames = PendingSubColumnNames.values();
|
||||
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
columns[i] = PendingSubColumnNames.values()[i].getColumnName();
|
||||
}
|
||||
|
||||
for (int i = 0; i < columns.length; i++) {
|
||||
tc = new TableColumn(table, SWT.LEFT);
|
||||
tc.setText(columns[i]);
|
||||
for (int i = 0; i < columnNames.length; i++) {
|
||||
TableColumn tc = new TableColumn(table, SWT.LEFT);
|
||||
tc.setText(columnNames[i].getColumnName());
|
||||
|
||||
tc.setResizable(true);
|
||||
|
||||
|
@ -413,6 +384,8 @@ public class SubApprovalTableComp extends TableComp {
|
|||
}
|
||||
});
|
||||
|
||||
sortDirectionMap.put(tc.getText(), SortDirection.ASCENDING);
|
||||
|
||||
if (i == 0) {
|
||||
sortedColumn = tc;
|
||||
}
|
||||
|
@ -434,16 +407,7 @@ public class SubApprovalTableComp extends TableComp {
|
|||
|
||||
for (SubscriptionApprovalRowData rd : this.pendingSubData
|
||||
.getDataArray()) {
|
||||
int idx = 0;
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
for (TableColumn column : columns) {
|
||||
String text = getCellText(column.getText(), rd);
|
||||
if (text == null) {
|
||||
item.setText(idx++, "");
|
||||
} else {
|
||||
item.setText(idx++, text);
|
||||
}
|
||||
}
|
||||
convertRowDataToTableItem(columns, rd);
|
||||
}
|
||||
|
||||
if (sortedColumn == null) {
|
||||
|
@ -456,6 +420,20 @@ public class SubApprovalTableComp extends TableComp {
|
|||
updateColumnSortImage();
|
||||
}
|
||||
|
||||
private void convertRowDataToTableItem(TableColumn[] columns,
|
||||
SubscriptionApprovalRowData rd) {
|
||||
int idx = 0;
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
for (TableColumn column : columns) {
|
||||
String text = getCellText(column.getText(), rd);
|
||||
if (text == null) {
|
||||
item.setText(idx++, "");
|
||||
} else {
|
||||
item.setText(idx++, text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.requests.ThriftClient;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerRowData;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.approve.SubscriptionApprovalRowData;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
|
@ -68,7 +69,8 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Jan 14, 2013 1286 djohnson Fix IndexOutOfBounds exception from getMaxLatency.
|
||||
* Jan 22, 2013 1519 djohnson Correct getMaxLatency() calculations.
|
||||
* Jan 30, 2013 1543 djohnson Use List instead of ArrayList.
|
||||
* Apr 08, 2013 1826 djohnson Add getRowData() method to subscription columns.
|
||||
* Apr 08, 2013 1826 djohnson Add getDisplayData() method to subscription columns.
|
||||
* Apr 10, 2013 1891 djohnson Add getDisplayData() method to pending subscription columns.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -167,42 +169,42 @@ public class DataDeliveryUtils {
|
|||
/** Column Name */
|
||||
NAME("Name", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return rd.getName();
|
||||
}
|
||||
},
|
||||
/** Column Owner */
|
||||
OWNER("Owner", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return rd.getOwner();
|
||||
}
|
||||
},
|
||||
/** Column Status */
|
||||
STATUS("Status", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return rd.getStatus();
|
||||
}
|
||||
},
|
||||
/** Column Priority */
|
||||
PRIORITY("Priority", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return String.valueOf(rd.getPriority());
|
||||
}
|
||||
},
|
||||
/** Column Description */
|
||||
DESCRIPTION("Description", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return rd.getDescription();
|
||||
}
|
||||
},
|
||||
/** Column Subscription Start */
|
||||
SUBSCRIPTION_START("Subscription Start", "Date subscription will begin") {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
Date date = rd.getSubscriptionStart();
|
||||
if (date != null) {
|
||||
return formatMMddyyyyHH(date);
|
||||
|
@ -214,7 +216,7 @@ public class DataDeliveryUtils {
|
|||
SUBSCRIPTION_EXPIRATION("Subscription Expiration",
|
||||
"Date subscription will expire") {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
Date date = rd.getSubscriptionEnd();
|
||||
if (date == null) {
|
||||
return "No Expiration";
|
||||
|
@ -226,7 +228,7 @@ public class DataDeliveryUtils {
|
|||
/** Column Active Period Start */
|
||||
ACTIVE_START("Active Period Start", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
Date date = rd.getActiveStart();
|
||||
if (date != null) {
|
||||
return formatMMddHH(date);
|
||||
|
@ -237,7 +239,7 @@ public class DataDeliveryUtils {
|
|||
/** Column Active Period Start */
|
||||
ACTIVE_END("Active Period End", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
Date date = rd.getActiveEnd();
|
||||
if (date != null) {
|
||||
return formatMMddHH(date);
|
||||
|
@ -248,28 +250,28 @@ public class DataDeliveryUtils {
|
|||
/** Column Office Id */
|
||||
OFFICE_ID("Office ID", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return rd.getOfficeId();
|
||||
}
|
||||
},
|
||||
/** Column Full Dataset */
|
||||
FULL_DATA_SET("Full Dataset", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return rd.getFullDataSet().toString();
|
||||
}
|
||||
},
|
||||
/** Column Data Size */
|
||||
DATA_SIZE("Data Size", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return String.valueOf(rd.getDataSetSize());
|
||||
}
|
||||
},
|
||||
/** Column Group Name */
|
||||
GROUP_NAME("Group Name", null) {
|
||||
@Override
|
||||
public String getRowData(SubscriptionManagerRowData rd) {
|
||||
public String getDisplayData(SubscriptionManagerRowData rd) {
|
||||
return rd.getGroupName();
|
||||
}
|
||||
};
|
||||
|
@ -308,7 +310,7 @@ public class DataDeliveryUtils {
|
|||
return columnName;
|
||||
}
|
||||
|
||||
public abstract String getRowData(SubscriptionManagerRowData rd);
|
||||
public abstract String getDisplayData(SubscriptionManagerRowData rd);
|
||||
|
||||
/**
|
||||
* @param name
|
||||
|
@ -386,17 +388,47 @@ public class DataDeliveryUtils {
|
|||
*/
|
||||
public static enum PendingSubColumnNames {
|
||||
/** Subscription name */
|
||||
NAME("Subscription Name", null),
|
||||
NAME("Subscription Name", null) {
|
||||
@Override
|
||||
public String getDisplayData(SubscriptionApprovalRowData rd) {
|
||||
return rd.getSubName();
|
||||
}
|
||||
},
|
||||
/** Requested Action */
|
||||
ACTION("Action", null),
|
||||
ACTION("Action", null) {
|
||||
@Override
|
||||
public String getDisplayData(SubscriptionApprovalRowData rd) {
|
||||
return rd.getAction();
|
||||
}
|
||||
},
|
||||
/** Subscription owner */
|
||||
OWNER("Owner", null),
|
||||
OWNER("Owner", null) {
|
||||
@Override
|
||||
public String getDisplayData(SubscriptionApprovalRowData rd) {
|
||||
return rd.getOwner();
|
||||
}
|
||||
},
|
||||
/** Change ID */
|
||||
CHANGE_ID("Requested Change", null),
|
||||
CHANGE_ID("Requested Change", null) {
|
||||
@Override
|
||||
public String getDisplayData(SubscriptionApprovalRowData rd) {
|
||||
return rd.getChangeOwner();
|
||||
}
|
||||
},
|
||||
/** Office ID */
|
||||
OFFICE("Office Id", null),
|
||||
OFFICE("Office Id", null) {
|
||||
@Override
|
||||
public String getDisplayData(SubscriptionApprovalRowData rd) {
|
||||
return rd.getOfficeId();
|
||||
}
|
||||
},
|
||||
/** Description */
|
||||
DESCRIPTION("Description", null);
|
||||
DESCRIPTION("Description", null) {
|
||||
@Override
|
||||
public String getDisplayData(SubscriptionApprovalRowData rd) {
|
||||
return rd.getDescription();
|
||||
}
|
||||
};
|
||||
|
||||
private final String columnName;
|
||||
|
||||
|
@ -440,6 +472,15 @@ public class DataDeliveryUtils {
|
|||
// default to NAME.
|
||||
return NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data this column displays for the row.
|
||||
*
|
||||
* @param rd
|
||||
* the row data
|
||||
* @return the display value
|
||||
*/
|
||||
public abstract String getDisplayData(SubscriptionApprovalRowData rd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue