From 96e6d1f7cce144b31373bd6ee02aa83767d9e759 Mon Sep 17 00:00:00 2001 From: Roger Ferrel Date: Wed, 7 Aug 2013 12:45:11 -0500 Subject: [PATCH] Issue #2222 Changes to allow display of all selected data. Change-Id: I1594f7f3cf888a3de7e6458e5e225eaa4d337adb Former-commit-id: f167ec49cd7228fc864e0c606511443621983375 [formerly b49c3147991d87c32aba619521502438c11eb8f6] Former-commit-id: efed5777e9878575876fd398ec749b9610c0151a --- .../raytheon/uf/viz/archive/data/SizeJob.java | 74 ++++++++++------ .../uf/viz/archive/ui/AbstractArchiveDlg.java | 85 ++++++++++++++++++- .../uf/viz/archive/ui/ArchiveTableComp.java | 60 ++++++++++--- .../uf/viz/archive/ui/CaseCreationDlg.java | 7 +- .../uf/common/archive/config/DisplayData.java | 12 ++- 5 files changed, 195 insertions(+), 43 deletions(-) diff --git a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/data/SizeJob.java b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/data/SizeJob.java index ab3148ca66..c672cfbba5 100644 --- a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/data/SizeJob.java +++ b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/data/SizeJob.java @@ -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. * * * @@ -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 getSelectAll() { + List selected = new LinkedList(); + 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 displayDatas = archiveInfoMap .get(displayArchive).get(displayCategory) diff --git a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java index 8ab82e3a20..276d6e176b 100644 --- a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java +++ b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/AbstractArchiveDlg.java @@ -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. * * * @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 slectedData = sizeJob.getSelectAll(); + + tableComp.populateSelectAll(slectedData); + sizeJob.changeDisplayQueue(null, null); + } finally { + setCursorBusy(false); + } + } + /* * (non-Javadoc) * diff --git a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java index ea15de242f..89733688f8 100644 --- a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java +++ b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/ArchiveTableComp.java @@ -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. * * * @@ -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 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 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 displayDatas) { + showSelectAll = true; + table.getColumn(0).setText("Archive | Category | Label"); + populateTable(displayDatas); + } + + private void populateTable(List 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(); } /** diff --git a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/CaseCreationDlg.java b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/CaseCreationDlg.java index 86929c8c6a..2bd6cf5c15 100644 --- a/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/CaseCreationDlg.java +++ b/cave/com.raytheon.uf.viz.archive/src/com/raytheon/uf/viz/archive/ui/CaseCreationDlg.java @@ -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. * * * @@ -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() { diff --git a/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/DisplayData.java b/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/DisplayData.java index 3d03f45163..40a66100e3 100644 --- a/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/DisplayData.java +++ b/edexOsgi/com.raytheon.uf.common.archive/src/com/raytheon/uf/common/archive/config/DisplayData.java @@ -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. * * * @@ -45,7 +46,16 @@ public class DisplayData implements Comparable { public static final Comparator LABEL_ORDER = new Comparator() { @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; } };