Issue #2222 Changes to allow display of all selected data.

Change-Id: I1594f7f3cf888a3de7e6458e5e225eaa4d337adb

Former-commit-id: b49c3147991d87c32aba619521502438c11eb8f6
This commit is contained in:
Roger Ferrel 2013-08-07 12:45:11 -05:00
parent a9f5465c99
commit efed5777e9
5 changed files with 195 additions and 43 deletions

View file

@ -3,6 +3,7 @@ package com.raytheon.uf.viz.archive.data;
import java.io.File;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -38,7 +39,8 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 13, 2013 rferrel Initial creation
* Jul 24, 2012 #2220 rferrel Change to get all data sizes only one time.
* Jul 24, 2013 #2220 rferrel Change to get all data sizes only one time.
* Aug 06, 2013 #2222 rferrel Changes to display all selected data.
*
* </pre>
*
@ -234,8 +236,8 @@ public class SizeJob extends Job {
}
/**
* Check all displayData selection state so only the data in selections are
* set.
* Set the display data's select state and check to see if it needs to be
* requeue.
*
* @param selections
*/
@ -259,14 +261,34 @@ public class SizeJob extends Job {
String displayLabel = displayData.getDisplayLabel();
boolean selected = selectionsList.contains(displayLabel);
if (selected != displayData.isSelected()) {
setSelect(archiveName, categoryName, displayLabel,
selected);
setSelect(displayData, selected);
}
}
}
}
}
/**
* Get list of all selected data.
*
* @return selected
*/
public List<DisplayData> getSelectAll() {
List<DisplayData> selected = new LinkedList<DisplayData>();
for (ArchiveInfo archiveInfo : archiveInfoMap.values()) {
for (String categoryName : archiveInfo.getCategoryNames()) {
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
for (DisplayData displayData : categoryInfo
.getDisplayDataList()) {
if (displayData.isSelected()) {
selected.add(displayData);
}
}
}
}
return selected;
}
/**
* Save selections to the desired file.
*
@ -321,25 +343,16 @@ public class SizeJob extends Job {
}
/**
* Change the selection state and requeue size request.
* Update the selection state and if needed requeue size request.
*
* @param archiveName
* @param categoryName
* @param displayName
* @param selected
* @param displayData
* @param state
*/
public void setSelect(String archiveName, String categoryName,
String displayName, boolean selected) {
for (DisplayData displayData : archiveInfoMap.get(archiveName)
.get(categoryName).getDisplayDataList()) {
if (displayName.equals(displayData.getDisplayLabel())) {
if (displayData.isSelected() != selected) {
displayData.setSelected(selected);
if (displayData.getSize() == DisplayData.UNKNOWN_SIZE) {
requeue(displayData);
}
}
break;
public void setSelect(DisplayData displayData, boolean state) {
if (displayData.isSelected() != state) {
displayData.setSelected(state);
if (displayData.getSize() == DisplayData.UNKNOWN_SIZE) {
requeue(displayData);
}
}
}
@ -351,6 +364,19 @@ public class SizeJob extends Job {
* @param categoryName
*/
public void changeDisplayQueue(String archiveName, String categoryName) {
if (archiveName == null) {
if (displayArchive != null) {
synchronized (this) {
if (!displaySizesComputed.get() && !selectedQueue.isEmpty()) {
requeueRequest.set(true);
stopComputeSize.set(true);
displayArchive = null;
displaySizesComputed.set(true);
}
}
}
return;
}
if (!archiveName.equals(displayArchive)
|| !categoryName.equals(displayCategory)) {
synchronized (this) {
@ -394,8 +420,8 @@ public class SizeJob extends Job {
mainLoop: while (!shutdown.get()) {
DisplayData displayData = null;
if (!displaySizesComputed.get()) {
synchronized (this) {
synchronized (this) {
if (!displaySizesComputed.get()) {
// Get sizes for the current display.
List<DisplayData> displayDatas = archiveInfoMap
.get(displayArchive).get(displayCategory)

View file

@ -74,6 +74,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Jun 10, 2013 1966 rferrel Change to allow Case Creation to extend.
* Jul 24, 2013 2220 rferrel Changes to queue size request for all data.
* Aug 01, 2013 2221 rferrel Changes for select configuration.
* Aug 06, 2013 2222 rferrel Changes to display all selected data.
* </pre>
*
* @author bgonzale
@ -96,7 +97,13 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
protected ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
/**
* Must be set by sub-class prior to creating any components.
* Boolean to indicate when DisplayData is created should its selection be
* set based on the information in the configuration files.
*/
protected boolean setSelect = false;
/**
* Must be set by sub-class prior to creating table.
*/
protected ArchiveConstants.Type type;
@ -111,12 +118,18 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
/** Performs save action button. */
protected Button saveBtn;
/** Optional button to toggle displaying all selected or category */
protected Button showSelectedBtn;
/** Flag set when user wants to close with unsaved modifications. */
protected boolean closeFlag = false;
/** Current select (case/retention) loaded into the dialog. */
protected String selectName = ArchiveConstants.defaultSelectName;
/** Which table is being displayed. */
private boolean showingSelected = true;
/**
* @param parentShell
*/
@ -420,8 +433,6 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
/**
* Populate the category combo based on the archive name and populate the
* table.
*
* @param archiveName
*/
private void populateCategoryCbo() {
initCategoryCbo();
@ -430,6 +441,7 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
private void initCategoryCbo() {
String archiveName = getSelectedArchiveName();
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
categoryCbo.removeAll();
for (String categoryName : manager.getCategoryNames(archiveName)) {
categoryCbo.add(categoryName);
@ -520,6 +532,7 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
setCursorBusy(true);
try {
setShowingSelected(false);
ArchiveInfo archiveInfo = sizeJob.get(archiveName);
@ -601,6 +614,72 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
setTotalSelectedItems(totalSelected);
}
/**
* Creates the showSelectedBtn for sub-classes.
*
* @param actionControlComp
*/
protected void createShowingSelectedBtn(Composite actionControlComp) {
showSelectedBtn = new Button(actionControlComp, SWT.PUSH);
setShowingSelected(false);
showSelectedBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handelShowSelectAll();
}
});
}
/**
* Populate the table with the desired display.
*/
protected void handelShowSelectAll() {
if (showingSelected) {
populateTableComp();
} else {
populateSelectAllTable();
}
}
/**
* Sets the state fo the showing selected flag and updates the label for the
* show selected button.
*
* @param state
*/
private void setShowingSelected(boolean state) {
if (showingSelected != state) {
showingSelected = state;
if (showingSelected) {
showSelectedBtn.setText(" Category ");
showSelectedBtn
.setToolTipText("Change display to show category.");
} else {
showSelectedBtn.setText(" Selected ");
showSelectedBtn
.setToolTipText("Change display to show all case selections");
}
}
}
/**
* Up date the table to display all selected data.
*/
private void populateSelectAllTable() {
setCursorBusy(true);
try {
setShowingSelected(true);
List<DisplayData> slectedData = sizeJob.getSelectAll();
tableComp.populateSelectAll(slectedData);
sizeJob.changeDisplayQueue(null, null);
} finally {
setCursorBusy(false);
}
}
/*
* (non-Javadoc)
*

View file

@ -60,6 +60,7 @@ import com.raytheon.uf.viz.archive.data.SizeJob;
* ------------ ---------- ----------- --------------------------
* May 23, 2013 #1964 lvenable Initial creation
* Jul 24, 2013 #2221 rferrel Changes for select configuration.
* Aug 06, 2013 #2222 rferrel Changes to display all selected data.
*
* </pre>
*
@ -74,6 +75,8 @@ public class ArchiveTableComp extends Composite {
/** Column to display size information,. */
private final int SIZE_COL_INDEX = 1;
private boolean showSelectAll = false;
/** Name of table's archive. */
String archiveName;
@ -92,6 +95,9 @@ public class ArchiveTableComp extends Composite {
/** Size label. */
private Label sizeLbl;
/** Composite for holding the table */
Composite tblComp;
/** The dialog's type. */
private final ArchiveConstants.Type type;
@ -159,11 +165,20 @@ public class ArchiveTableComp extends Composite {
private void createTable() {
GridData gd = null;
table = new Table(this, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL
| SWT.H_SCROLL | SWT.MULTI | SWT.VIRTUAL);
tblComp = new Composite(this, SWT.NONE);
GridLayout gl = new GridLayout(1, false);
gl.marginHeight = 0;
gl.marginWidth = 0;
gl.horizontalSpacing = 0;
tblComp.setLayout(gl);
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
gd.widthHint = 730;
gd.heightHint = 270;
tblComp.setLayoutData(gd);
table = new Table(tblComp, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL
| SWT.H_SCROLL | SWT.MULTI | SWT.VIRTUAL);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
table.setLayoutData(gd);
table.setHeaderVisible(true);
table.setLinesVisible(true);
@ -174,8 +189,15 @@ public class ArchiveTableComp extends Composite {
TableItem item = (TableItem) event.item;
int index = table.indexOf(item);
DisplayData displayData = tableData[index];
item.setText(new String[] { displayData.getDisplayLabel(),
displayData.getSizeLabel() });
String label = null;
if (showSelectAll) {
label = displayData.getArchiveName() + " | "
+ displayData.getCategoryName() + " | "
+ displayData.getDisplayLabel();
} else {
label = displayData.getDisplayLabel();
}
item.setText(new String[] { label, displayData.getSizeLabel() });
item.setChecked(displayData.isSelected());
}
});
@ -296,9 +318,7 @@ public class ArchiveTableComp extends Composite {
TableItem item = table.getItem(index);
if (item.getChecked()) {
++count;
displayData.setSelected(true);
sizeJob.setSelect(archiveName, categoryName,
displayData.getDisplayLabel(), true);
sizeJob.setSelect(displayData, true);
if (tableTotalSize >= 0) {
long diSize = displayData.getSize();
if (diSize < 0) {
@ -308,9 +328,7 @@ public class ArchiveTableComp extends Composite {
}
}
} else {
displayData.setSelected(false);
sizeJob.setSelect(archiveName, categoryName,
displayData.getDisplayLabel(), false);
sizeJob.setSelect(displayData, false);
}
}
List<DisplayData> displayDatas = Arrays.asList(tableData);
@ -437,14 +455,29 @@ public class ArchiveTableComp extends Composite {
}
/**
* Set up table with values in the list.
* Update table display to show data for the desired category.
*
* @param displayDatas
*/
protected void populateTable(String archiveName, String categoryName,
List<DisplayData> displayDatas) {
this.archiveName = archiveName;
this.categoryName = categoryName;
showSelectAll = false;
table.getColumn(0).setText("Label");
populateTable(displayDatas);
}
/**
* Flag table as showing all selected data and update display.
*
* @param displayDatas
*/
protected void populateSelectAll(List<DisplayData> displayDatas) {
showSelectAll = true;
table.getColumn(0).setText("Archive | Category | Label");
populateTable(displayDatas);
}
private void populateTable(List<DisplayData> displayDatas) {
tableData = displayDatas.toArray(new DisplayData[0]);
table.removeAll();
table.setItemCount(tableData.length);
@ -458,7 +491,6 @@ public class ArchiveTableComp extends Composite {
table.setSortColumn(table.getColumn(LABEL_COL_INDEX));
table.setSortDirection(SWT.UP);
table.clearAll();
updateSelectionLabels();
}
/**

View file

@ -70,6 +70,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* and generation of cases.
* Jul 24, 2013 #2220 rferrel Add recompute size button.
* Jul 24, 2013 #2221 rferrel Changes for select configuration.
* Aug 06, 2013 #2222 rferrel Changes to display all selected data.
*
* </pre>
*
@ -161,6 +162,8 @@ public class CaseCreationDlg extends AbstractArchiveDlg {
super(parentShell, SWT.DIALOG_TRIM | SWT.MIN, CAVE.DO_NOT_BLOCK
| CAVE.MODE_INDEPENDENT | CAVE.INDEPENDENT_SHELL);
this.type = Type.Case;
this.setSelect = false;
this.type = Type.Case;
}
/*
@ -453,7 +456,7 @@ public class CaseCreationDlg extends AbstractArchiveDlg {
private void createBottomActionButtons() {
Composite actionControlComp = new Composite(shell, SWT.NONE);
GridLayout gl = new GridLayout(7, false);
GridLayout gl = new GridLayout(8, false);
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
actionControlComp.setLayout(gl);
actionControlComp.setLayoutData(gd);
@ -517,6 +520,8 @@ public class CaseCreationDlg extends AbstractArchiveDlg {
}
});
createShowingSelectedBtn(actionControlComp);
Button sizeBtn = new Button(actionControlComp, SWT.PUSH);
sizeBtn.setText(" Recompute Sizes ");
sizeBtn.addSelectionListener(new SelectionAdapter() {

View file

@ -18,6 +18,7 @@ import com.raytheon.uf.common.util.SizeUtil;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 7, 2013 1966 rferrel Initial creation
* Aug 06, 2013 2222 rferrel Changes to display all selected data.
*
* </pre>
*
@ -45,7 +46,16 @@ public class DisplayData implements Comparable<DisplayData> {
public static final Comparator<DisplayData> LABEL_ORDER = new Comparator<DisplayData>() {
@Override
public int compare(DisplayData o1, DisplayData o2) {
return o1.displayLabel.compareToIgnoreCase(o2.displayLabel);
int result = o1.getArchiveName().compareToIgnoreCase(
o2.getArchiveName());
if (result == 0) {
result = o1.getCategoryName().compareToIgnoreCase(
o2.getCategoryName());
}
if (result == 0) {
result = o1.displayLabel.compareToIgnoreCase(o2.displayLabel);
}
return result;
}
};