Issue #1966 Column sort added; bug fixes to size estimates and saving files.
Change-Id: Idbce325b98281732312205d093ca09bd5313bcaa Former-commit-id:f175b19a93
[formerlyf175b19a93
[formerly 195ba96c259535f00df44767c5dbc8777ece0e4c]] Former-commit-id:c7c27c4cbb
Former-commit-id:cc39af5044
This commit is contained in:
parent
95bf734600
commit
2b36404b6c
9 changed files with 166 additions and 66 deletions
|
@ -7,6 +7,7 @@ Bundle-Activator: com.raytheon.uf.viz.archive.Activator
|
|||
Bundle-Vendor: RAYTHEON
|
||||
Require-Bundle: org.eclipse.ui;bundle-version="3.8.2",
|
||||
org.eclipse.core.runtime,
|
||||
org.apache.commons.lang;bundle-version="2.3.0",
|
||||
com.raytheon.viz.ui;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
|
||||
com.raytheon.uf.common.localization;bundle-version="1.12.1174",
|
||||
|
|
|
@ -183,7 +183,7 @@ public class SizeJob extends Job {
|
|||
|
||||
displayData.setSize(size);
|
||||
|
||||
List<SizeJobRequest> list = new ArrayList<SizeJobRequest>();
|
||||
List<SizeJobRequest> list = new ArrayList<SizeJobRequest>(1);
|
||||
list.add(dirInfo);
|
||||
for (IUpdateListener listener : listeners) {
|
||||
listener.update(list);
|
||||
|
|
|
@ -253,8 +253,6 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
|||
}
|
||||
});
|
||||
|
||||
ArchiveConfigManager.getInstance().reset();
|
||||
|
||||
return comboComp;
|
||||
}
|
||||
|
||||
|
@ -266,17 +264,17 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
|||
@Override
|
||||
protected void preOpened() {
|
||||
super.preOpened();
|
||||
setCursorBusy(true);
|
||||
|
||||
// Setup to display blank dialog with busy cursor while getting data.
|
||||
Job job = new Job("setup") {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
initInfo();
|
||||
VizApp.runAsync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
setCursorBusy(true);
|
||||
initInfo();
|
||||
populateComboBoxes();
|
||||
updateTableComp();
|
||||
}
|
||||
|
@ -362,10 +360,12 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
|||
}
|
||||
|
||||
/**
|
||||
* Populates the archive/category combo boxes and obtains the display data.
|
||||
* Get information from manager for populating combo boxes and set up to get
|
||||
* selected entries sizes. Intended for use on a non-UI thread.
|
||||
*/
|
||||
private void initInfo() {
|
||||
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
|
||||
manager.reset();
|
||||
Calendar startCal = getStart();
|
||||
Calendar endCal = getEnd();
|
||||
String[] archiveNames = manager.getArchiveDataNamesList();
|
||||
|
|
|
@ -19,9 +19,10 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.archive.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
|
@ -31,7 +32,9 @@ import org.eclipse.swt.layout.GridData;
|
|||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
|
@ -60,8 +63,11 @@ import com.raytheon.uf.viz.archive.data.IArchiveTotals;
|
|||
*/
|
||||
public class ArchiveTableComp extends Composite {
|
||||
|
||||
/** Key for getting Display Data. */
|
||||
private final String DISPLAY_DATA_KEY = "displayData";
|
||||
/** Column to display label information. */
|
||||
private final int LABEL_COL_INDEX = 0;
|
||||
|
||||
/** Column to display size information,. */
|
||||
private final int SIZE_COL_INDEX = 1;
|
||||
|
||||
/** Table control. */
|
||||
private Table table;
|
||||
|
@ -86,6 +92,9 @@ public class ArchiveTableComp extends Composite {
|
|||
/** Allows the parent dialog log to update other total displays. */
|
||||
private final IArchiveTotals iArchiveTotals;
|
||||
|
||||
/** Data for the currently display table */
|
||||
private DisplayData[] tableData;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -129,13 +138,25 @@ public class ArchiveTableComp extends Composite {
|
|||
GridData gd = null;
|
||||
|
||||
table = new Table(this, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL
|
||||
| SWT.H_SCROLL | SWT.MULTI);
|
||||
| SWT.H_SCROLL | SWT.MULTI | SWT.VIRTUAL);
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
|
||||
gd.widthHint = 730;
|
||||
gd.heightHint = 270;
|
||||
table.setLayoutData(gd);
|
||||
table.setHeaderVisible(true);
|
||||
table.setLinesVisible(true);
|
||||
table.addListener(SWT.SetData, new Listener() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
TableItem item = (TableItem) event.item;
|
||||
int index = table.indexOf(item);
|
||||
DisplayData displayData = tableData[index];
|
||||
item.setText(new String[] { displayData.getDisplayLabel(),
|
||||
displayData.getSizeLabel() });
|
||||
item.setChecked(displayData.isSelected());
|
||||
}
|
||||
});
|
||||
|
||||
TableColumn pathColumn = new TableColumn(table, SWT.LEFT);
|
||||
pathColumn.setText("Label");
|
||||
|
@ -167,6 +188,17 @@ public class ArchiveTableComp extends Composite {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
Listener sortListener = new Listener() {
|
||||
|
||||
@Override
|
||||
public void handleEvent(Event event) {
|
||||
sortColumn(event);
|
||||
}
|
||||
};
|
||||
|
||||
pathColumn.addListener(SWT.Selection, sortListener);
|
||||
sizeColumn.addListener(SWT.Selection, sortListener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,20 +220,58 @@ public class ArchiveTableComp extends Composite {
|
|||
sizeLbl.setLayoutData(gd);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort table roles by desired column and direction.
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
private void sortColumn(Event e) {
|
||||
TableColumn sortColumn = table.getSortColumn();
|
||||
TableColumn eventColumn = (TableColumn) e.widget;
|
||||
|
||||
int sortDir = table.getSortDirection();
|
||||
int index = eventColumn == table.getColumn(LABEL_COL_INDEX) ? LABEL_COL_INDEX
|
||||
: SIZE_COL_INDEX;
|
||||
|
||||
if (sortColumn == eventColumn) {
|
||||
sortDir = ((sortDir == SWT.UP) ? SWT.DOWN : SWT.UP);
|
||||
} else {
|
||||
table.setSortColumn(eventColumn);
|
||||
sortDir = SWT.UP;
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
case LABEL_COL_INDEX:
|
||||
Arrays.sort(tableData, DisplayData.LABEL_ORDER);
|
||||
if (sortDir == SWT.DOWN) {
|
||||
ArrayUtils.reverse(tableData);
|
||||
}
|
||||
break;
|
||||
case SIZE_COL_INDEX:
|
||||
Arrays.sort(tableData, DisplayData.SIZE_ORDER);
|
||||
if (sortDir == SWT.DOWN) {
|
||||
ArrayUtils.reverse(tableData);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Programmer error should never get here.
|
||||
throw new IndexOutOfBoundsException("Unknown column index.");
|
||||
}
|
||||
table.setSortDirection(sortDir);
|
||||
table.clearAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the selection items labels.
|
||||
*/
|
||||
private void updateSelectionLabels() {
|
||||
TableItem[] itemArray = table.getItems();
|
||||
int count = 0;
|
||||
long tableTotalSize = 0;
|
||||
List<DisplayData> displayDatas = new ArrayList<DisplayData>(
|
||||
itemArray.length);
|
||||
|
||||
for (TableItem ti : itemArray) {
|
||||
DisplayData displayData = (DisplayData) ti
|
||||
.getData(DISPLAY_DATA_KEY);
|
||||
if (ti.getChecked()) {
|
||||
for (int index = 0; index < tableData.length; ++index) {
|
||||
DisplayData displayData = tableData[index];
|
||||
TableItem item = table.getItem(index);
|
||||
if (item.getChecked()) {
|
||||
++count;
|
||||
displayData.setSelected(true);
|
||||
if (tableTotalSize >= 0) {
|
||||
|
@ -215,8 +285,8 @@ public class ArchiveTableComp extends Composite {
|
|||
} else {
|
||||
displayData.setSelected(false);
|
||||
}
|
||||
displayDatas.add(displayData);
|
||||
}
|
||||
List<DisplayData> displayDatas = Arrays.asList(tableData);
|
||||
|
||||
if (selectedLbl != null) {
|
||||
selectedLbl.setText("Table Selected Items: " + count);
|
||||
|
@ -316,55 +386,45 @@ public class ArchiveTableComp extends Composite {
|
|||
updateSelectionLabels();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the current table to see if the size of any entries needs to be
|
||||
* updated.
|
||||
*
|
||||
* @param displayDatas
|
||||
*/
|
||||
public void updateSize(List<DisplayData> displayDatas) {
|
||||
TableItem[] itemArray = table.getItems();
|
||||
|
||||
for (DisplayData displayData : displayDatas) {
|
||||
for (TableItem ti : itemArray) {
|
||||
if (displayData.equals(ti.getData(DISPLAY_DATA_KEY))) {
|
||||
setItemSize(ti);
|
||||
if (tableData != null && tableData.length > 0) {
|
||||
for (DisplayData displayData : displayDatas) {
|
||||
for (int index = 0; index < tableData.length; ++index) {
|
||||
if (displayData.equals(tableData[index])) {
|
||||
table.getItem(index)
|
||||
.setText(displayData.getSizeLabel());
|
||||
table.clear(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateSelectionLabels();
|
||||
}
|
||||
|
||||
updateSelectionLabels();
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO : this is just for display purposes. This will go away when the
|
||||
* functionality is implemented.
|
||||
/**
|
||||
* Set up table with values in the list.
|
||||
*
|
||||
* @param displayDatas
|
||||
*/
|
||||
protected void populateTable(List<DisplayData> displayDataArray) {
|
||||
protected void populateTable(List<DisplayData> displayDatas) {
|
||||
tableData = displayDatas.toArray(new DisplayData[0]);
|
||||
table.removeAll();
|
||||
for (DisplayData displayData : displayDataArray) {
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
item.setData(DISPLAY_DATA_KEY, displayData);
|
||||
item.setChecked(displayData.isSelected());
|
||||
item.setText(0, displayData.getDisplayLabel());
|
||||
table.setItemCount(tableData.length);
|
||||
|
||||
item.setChecked(displayData.isSelected());
|
||||
setItemSize(item);
|
||||
}
|
||||
for (int i = 0; i < 2; i++) {
|
||||
table.getColumn(i).setResizable(false);
|
||||
table.getColumn(i).setMoveable(false);
|
||||
table.getColumn(i).pack();
|
||||
}
|
||||
table.getColumn(0).setWidth(600);
|
||||
updateSelectionLabels();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update table items size column.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
private void setItemSize(TableItem item) {
|
||||
long size = ((DisplayData) item.getData(DISPLAY_DATA_KEY)).getSize();
|
||||
if (size < 0L) {
|
||||
item.setText(1, DisplayData.UNKNOWN_SIZE_LABEL);
|
||||
} else {
|
||||
item.setText(1, SizeUtil.prettyByteSize(size));
|
||||
}
|
||||
table.setSortColumn(table.getColumn(LABEL_COL_INDEX));
|
||||
table.setSortDirection(SWT.UP);
|
||||
table.clearAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ public class GenerateCaseDlg extends CaveSWTDialog {
|
|||
destination.mkdirs();
|
||||
FileUtil.copyDirectory(source, destination);
|
||||
} else {
|
||||
File destParent = caseDir.getParentFile();
|
||||
File destParent = destination.getParentFile();
|
||||
destParent.mkdirs();
|
||||
FileUtil.copyFile(source, destination);
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ public class ArchiveConfig implements Comparable<ArchiveConfig> {
|
|||
|
||||
@Override
|
||||
public int compareTo(ArchiveConfig o) {
|
||||
return getName().compareTo(o.getName());
|
||||
return getName().compareToIgnoreCase(o.getName());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -378,12 +378,12 @@ public class ArchiveConfigManager {
|
|||
* Get a list of directories/files for the desired display label bounded by
|
||||
* the start and end time inclusive.
|
||||
*
|
||||
* @param displayInfo
|
||||
* @param displayData
|
||||
* @param startCal
|
||||
* @param endCal
|
||||
* @return files
|
||||
*/
|
||||
public List<File> getDisplayFiles(DisplayData displayInfo,
|
||||
public List<File> getDisplayFiles(DisplayData displayData,
|
||||
Calendar startCal, Calendar endCal) {
|
||||
long startTime = 0L;
|
||||
if (startCal != null) {
|
||||
|
@ -409,7 +409,7 @@ public class ArchiveConfigManager {
|
|||
cal.add(Calendar.HOUR_OF_DAY, 1);
|
||||
|
||||
long endTime = cal.getTimeInMillis();
|
||||
return getDisplayFiles(displayInfo, startTime, endTime);
|
||||
return getDisplayFiles(displayData, startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -420,8 +420,8 @@ public class ArchiveConfigManager {
|
|||
* @param displayLabel
|
||||
* @return files
|
||||
*/
|
||||
public List<File> getDisplayFiles(DisplayData displayInfo) {
|
||||
return getDisplayFiles(displayInfo, null, null);
|
||||
public List<File> getDisplayFiles(DisplayData displayData) {
|
||||
return getDisplayFiles(displayData, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -435,10 +435,10 @@ public class ArchiveConfigManager {
|
|||
* @param endTime
|
||||
* @return files
|
||||
*/
|
||||
private List<File> getDisplayFiles(DisplayData displayInfo, long startTime,
|
||||
private List<File> getDisplayFiles(DisplayData displayData, long startTime,
|
||||
long endTime) {
|
||||
ArchiveConfig archiveConfig = displayInfo.archiveConfig;
|
||||
CategoryConfig categoryConfig = displayInfo.categoryConfig;
|
||||
ArchiveConfig archiveConfig = displayData.archiveConfig;
|
||||
CategoryConfig categoryConfig = displayData.categoryConfig;
|
||||
|
||||
String[] indexValues = categoryConfig.getDateGroupIndices().split(
|
||||
"\\s*,\\s*");
|
||||
|
@ -452,7 +452,7 @@ public class ArchiveConfigManager {
|
|||
boolean dirOnly = (filePatternStr == null)
|
||||
|| ".*".equals(filePatternStr);
|
||||
|
||||
List<File> dirs = displayInfo.dirs;
|
||||
List<File> dirs = displayData.dirs;
|
||||
|
||||
int beginIndex = archiveConfig.getRootDir().length();
|
||||
|
||||
|
@ -506,7 +506,7 @@ public class ArchiveConfigManager {
|
|||
fileCal.set(year, month, day, hour, 0, 0);
|
||||
long fileTime = fileCal.getTimeInMillis();
|
||||
if ((startTime <= fileTime) && (fileTime < endTime)) {
|
||||
fileList.add(dir);
|
||||
fileList.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ public class CategoryConfig implements Comparable<CategoryConfig> {
|
|||
*/
|
||||
@Override
|
||||
public int compareTo(CategoryConfig o) {
|
||||
return getDisplay().compareTo(o.getDisplay());
|
||||
return getDisplay().compareToIgnoreCase(o.getDisplay());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.raytheon.uf.common.archive.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.util.SizeUtil;
|
||||
|
||||
/**
|
||||
* This class contains the information on directories that are associated with a
|
||||
* display label. Allows a GUI to maintain the state of the display instead of
|
||||
|
@ -23,6 +26,29 @@ import java.util.List;
|
|||
*/
|
||||
public class DisplayData implements Comparable<DisplayData> {
|
||||
|
||||
/** Comparator ordering by size. */
|
||||
public static final Comparator<DisplayData> SIZE_ORDER = new Comparator<DisplayData>() {
|
||||
@Override
|
||||
public int compare(DisplayData o1, DisplayData o2) {
|
||||
int result = 0;
|
||||
long diff = o1.size - o2.size;
|
||||
if (diff < 0L) {
|
||||
result = -1;
|
||||
} else if (diff > 0L) {
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
/** Comparator ordering by label. */
|
||||
public static final Comparator<DisplayData> LABEL_ORDER = new Comparator<DisplayData>() {
|
||||
@Override
|
||||
public int compare(DisplayData o1, DisplayData o2) {
|
||||
return o1.displayLabel.compareToIgnoreCase(o2.displayLabel);
|
||||
}
|
||||
};
|
||||
|
||||
/** Label to use when size not yet known. */
|
||||
public static final String UNKNOWN_SIZE_LABEL = "????";
|
||||
|
||||
|
@ -104,6 +130,19 @@ public class DisplayData implements Comparable<DisplayData> {
|
|||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* The string label for the size.
|
||||
*
|
||||
* @return sizeLabel
|
||||
*/
|
||||
public String getSizeLabel() {
|
||||
String label = UNKNOWN_SIZE_LABEL;
|
||||
if (size >= 0L) {
|
||||
label = SizeUtil.prettyByteSize(size);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the size of the directories' contents.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue