Merge "Issue #1966 Working case generation without compression. Changes to Retention to remove compile errors." into development
Former-commit-id:794b9a70f3
[formerly794b9a70f3
[formerly dd8e9aa61642ba6498bbf5871ed6c8372ec468d0]] Former-commit-id:878435ddd9
Former-commit-id:22ac30e0a6
This commit is contained in:
commit
7b3d65eb40
10 changed files with 1238 additions and 228 deletions
|
@ -22,8 +22,9 @@ package com.raytheon.uf.viz.archive.data;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
@ -53,15 +54,16 @@ import com.raytheon.uf.common.util.FileUtil;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DirInfo {
|
public class DirInfo {
|
||||||
|
|
||||||
private static final SizeJob sizeJob = new DirInfo.SizeJob();
|
private static final SizeJob sizeJob = new DirInfo.SizeJob();
|
||||||
|
|
||||||
final private DisplayData displayInfo;
|
final private DisplayData displayInfo;
|
||||||
|
|
||||||
private final List<File> files = new ArrayList<File>();
|
private final List<File> files = new ArrayList<File>();
|
||||||
|
|
||||||
private Calendar startCal;
|
private final Calendar startCal;
|
||||||
|
|
||||||
private Calendar endCal;
|
private final Calendar endCal;
|
||||||
|
|
||||||
public static void clearQueue() {
|
public static void clearQueue() {
|
||||||
sizeJob.clearQueue();
|
sizeJob.clearQueue();
|
||||||
|
@ -79,7 +81,6 @@ public class DirInfo {
|
||||||
this.displayInfo = displayInfo;
|
this.displayInfo = displayInfo;
|
||||||
this.startCal = startCal;
|
this.startCal = startCal;
|
||||||
this.endCal = endCal;
|
this.endCal = endCal;
|
||||||
displayInfo.setSize(-1);
|
|
||||||
DirInfo.sizeJob.queue(this);
|
DirInfo.sizeJob.queue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,29 +88,57 @@ public class DirInfo {
|
||||||
return displayInfo;
|
return displayInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Job to determine the size for a directory and its contents on a non-UI
|
||||||
|
* thread.
|
||||||
|
*/
|
||||||
static private class SizeJob extends Job {
|
static private class SizeJob extends Job {
|
||||||
private LinkedList<DirInfo> queueList = new LinkedList<DirInfo>();
|
private ConcurrentLinkedQueue<DirInfo> queue = new ConcurrentLinkedQueue<DirInfo>();
|
||||||
|
|
||||||
private boolean isShutdown = false;
|
private final ConcurrentLinkedQueue<DisplayData> selectedQueue = new ConcurrentLinkedQueue<ArchiveConfigManager.DisplayData>();
|
||||||
|
|
||||||
|
private final AtomicBoolean stopComputeSize = new AtomicBoolean(false);
|
||||||
|
|
||||||
List<IUpdateListener> listeners = new ArrayList<IUpdateListener>();
|
List<IUpdateListener> listeners = new ArrayList<IUpdateListener>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add entry to queue and if pending selected entries add them to the
|
||||||
|
* queue with same start/end times.
|
||||||
|
*
|
||||||
|
* @param fileInfo
|
||||||
|
*/
|
||||||
protected void queue(DirInfo fileInfo) {
|
protected void queue(DirInfo fileInfo) {
|
||||||
synchronized (queueList) {
|
queue.add(fileInfo);
|
||||||
queueList.add(fileInfo);
|
|
||||||
if (getState() == Job.NONE) {
|
if (getState() == Job.NONE) {
|
||||||
System.out.println("schedule queue size: "
|
schedule();
|
||||||
+ queueList.size());
|
|
||||||
schedule();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear list off pending data but save selected entries still needing
|
||||||
|
* sizes.
|
||||||
|
*/
|
||||||
protected void clearQueue() {
|
protected void clearQueue() {
|
||||||
synchronized (queueList) {
|
List<DirInfo> pending = new ArrayList<DirInfo>();
|
||||||
queueList.clear();
|
|
||||||
if (getState() != Job.NONE) {
|
// Drain queue queue.removeAll() doesn't work.
|
||||||
isShutdown = true;
|
while (!queue.isEmpty()) {
|
||||||
|
pending.add(queue.remove());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getState() != NONE) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save selected items that do not have sizes.
|
||||||
|
for (DirInfo dirInfo : pending) {
|
||||||
|
DisplayData displayData = dirInfo.getDisplayInfo();
|
||||||
|
|
||||||
|
if (displayData.isSelected() && displayData.getSize() < 0L) {
|
||||||
|
if (!selectedQueue.contains(displayData)) {
|
||||||
|
selectedQueue.add(displayData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,66 +150,68 @@ public class DirInfo {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
|
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
|
||||||
System.out.println("starting SizeJob");
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
while (!isShutdown && !queueList.isEmpty()) {
|
|
||||||
List<DirInfo> list = null;
|
|
||||||
synchronized (queueList) {
|
|
||||||
|
|
||||||
list = new ArrayList<DirInfo>(queueList);
|
mainLoop: while (!queue.isEmpty()) {
|
||||||
|
DirInfo dirInfo = queue.remove();
|
||||||
|
|
||||||
queueList.clear();
|
stopComputeSize.set(false);
|
||||||
}
|
DisplayData displayData = dirInfo.displayInfo;
|
||||||
System.out.println("sizeJob Processing: " + list.size());
|
Calendar startCal = dirInfo.startCal;
|
||||||
long t1 = System.currentTimeMillis();
|
Calendar endCal = dirInfo.endCal;
|
||||||
|
|
||||||
for (DirInfo dirInfo : list) {
|
List<File> files = manager.getDisplayFiles(displayData,
|
||||||
long t2 = System.currentTimeMillis();
|
startCal, endCal);
|
||||||
if (isShutdown) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DisplayData displayInfo = dirInfo.displayInfo;
|
|
||||||
Calendar startCal = dirInfo.startCal;
|
|
||||||
Calendar endCal = dirInfo.endCal;
|
|
||||||
displayInfo.setSize(-1);
|
|
||||||
|
|
||||||
List<File> files = manager.getDisplayFiles(displayInfo,
|
// Is size still needed.
|
||||||
startCal, endCal);
|
if (!displayData.isSelected() && stopComputeSize.get()) {
|
||||||
dirInfo.files.clear();
|
continue;
|
||||||
dirInfo.files.addAll(files);
|
|
||||||
long size = 0L;
|
|
||||||
for (File file : dirInfo.files) {
|
|
||||||
if (isShutdown) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (file.isDirectory()) {
|
|
||||||
size += FileUtil.sizeOfDirectory(file);
|
|
||||||
} else {
|
|
||||||
size += file.length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
long t3 = System.currentTimeMillis();
|
|
||||||
System.out.println("-- \"" + displayInfo.getDisplayLabel()
|
|
||||||
+ "\": oldSize: " + displayInfo.getSize()
|
|
||||||
+ ", newSize: " + size + ", time: " + (t3 - t2)
|
|
||||||
+ " ms");
|
|
||||||
displayInfo.setSize(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isShutdown) {
|
dirInfo.files.clear();
|
||||||
for (IUpdateListener listener : listeners) {
|
dirInfo.files.addAll(files);
|
||||||
listener.update(list);
|
long size = 0L;
|
||||||
|
for (File file : dirInfo.files) {
|
||||||
|
|
||||||
|
// Skip when size no longer needed.
|
||||||
|
if (!displayData.isSelected() && stopComputeSize.get()) {
|
||||||
|
continue mainLoop;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
synchronized (queueList) {
|
if (file.isDirectory()) {
|
||||||
isShutdown = false;
|
size += FileUtil.sizeOfDirectory(file);
|
||||||
|
} else {
|
||||||
|
size += file.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
displayData.setSize(size);
|
||||||
|
|
||||||
|
List<DirInfo> list = new ArrayList<DirInfo>();
|
||||||
|
list.add(dirInfo);
|
||||||
|
for (IUpdateListener listener : listeners) {
|
||||||
|
listener.update(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stopComputeSize.get()) {
|
||||||
|
// Place any pending selections at end of the queue.
|
||||||
|
while (!selectedQueue.isEmpty()) {
|
||||||
|
DisplayData data = selectedQueue.remove();
|
||||||
|
new DirInfo(data, startCal, endCal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Ending SizeJob");
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void canceling() {
|
||||||
|
stopComputeSize.set(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,7 @@ package com.raytheon.uf.viz.archive.data;
|
||||||
|
|
||||||
public interface IArchiveTotals {
|
public interface IArchiveTotals {
|
||||||
/**
|
/**
|
||||||
* Total selected items from all tables.
|
* Update total selected items and sizes.
|
||||||
*
|
|
||||||
* @return totalSelectedItems.
|
|
||||||
*/
|
*/
|
||||||
public int getTotalSelectedItems();
|
public void updateTotals();
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,10 +114,13 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
||||||
setupCursor();
|
setupCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see com.raytheon.uf.viz.archive.data.IArchiveTotals#getTotalSelectedItems()
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.uf.viz.archive.data.IArchiveTotals#getTotalSelectedItems()
|
||||||
*/
|
*/
|
||||||
@Override
|
// @Override
|
||||||
public int getTotalSelectedItems() {
|
public int getTotalSelectedItems() {
|
||||||
int totalSelected = 0;
|
int totalSelected = 0;
|
||||||
for (ArchiveInfo archiveInfo : archiveInfoMap.values()) {
|
for (ArchiveInfo archiveInfo : archiveInfoMap.values()) {
|
||||||
|
@ -319,28 +322,6 @@ public abstract class AbstractArchiveDlg extends CaveSWTDialog implements
|
||||||
populateTableComp(getSelectedArchiveName(), getSelectedCategoryName());
|
populateTableComp(getSelectedArchiveName(), getSelectedCategoryName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a separator line to the provided container.
|
|
||||||
*
|
|
||||||
* @param container
|
|
||||||
* Composite.
|
|
||||||
* @param orientation
|
|
||||||
* Vertical or horizontal orientation.
|
|
||||||
*/
|
|
||||||
protected void addSeparator(Composite container, int orientation) {
|
|
||||||
// Separator label
|
|
||||||
GridData gd;
|
|
||||||
|
|
||||||
if (orientation == SWT.HORIZONTAL) {
|
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
|
||||||
} else {
|
|
||||||
gd = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Label sepLbl = new Label(container, SWT.SEPARATOR | orientation);
|
|
||||||
sepLbl.setLayoutData(gd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init busyCursor. On close, make sure that cursor reverts back to unbusy
|
* Init busyCursor. On close, make sure that cursor reverts back to unbusy
|
||||||
* state if it isn't already.
|
* state if it isn't already.
|
||||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
|
||||||
import com.raytheon.uf.common.archive.config.CategoryConfig;
|
import com.raytheon.uf.common.archive.config.CategoryConfig;
|
||||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
import com.raytheon.uf.viz.archive.data.IArchiveTotals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Archive retention dialog.
|
* Archive retention dialog.
|
||||||
|
@ -57,7 +58,8 @@ import com.raytheon.uf.common.status.UFStatus;
|
||||||
* @author lvenable
|
* @author lvenable
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class ArchiveRetentionDlg extends AbstractArchiveDlg {
|
public class ArchiveRetentionDlg extends AbstractArchiveDlg implements
|
||||||
|
IArchiveTotals {
|
||||||
|
|
||||||
private final transient IUFStatusHandler statusHandler = UFStatus
|
private final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(ArchiveRetentionDlg.class);
|
.getHandler(ArchiveRetentionDlg.class);
|
||||||
|
@ -106,7 +108,7 @@ public class ArchiveRetentionDlg extends AbstractArchiveDlg {
|
||||||
*/
|
*/
|
||||||
private void init() {
|
private void init() {
|
||||||
createRetentionControls();
|
createRetentionControls();
|
||||||
addSeparator(shell, SWT.HORIZONTAL);
|
GuiUtil.addSeparator(shell, SWT.HORIZONTAL);
|
||||||
createBottomActionButtons();
|
createBottomActionButtons();
|
||||||
selectionsUpdated();
|
selectionsUpdated();
|
||||||
}
|
}
|
||||||
|
@ -331,7 +333,7 @@ public class ArchiveRetentionDlg extends AbstractArchiveDlg {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void selectionsUpdated() {
|
public void updateTotals() {
|
||||||
ArchiveConfig archive = getSelectedArchive();
|
ArchiveConfig archive = getSelectedArchive();
|
||||||
if (archive != null) {
|
if (archive != null) {
|
||||||
if (minRetentionSpnr != null) {
|
if (minRetentionSpnr != null) {
|
||||||
|
@ -344,4 +346,9 @@ public class ArchiveRetentionDlg extends AbstractArchiveDlg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void selectionsUpdated() {
|
||||||
|
// Not used.
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,9 +71,6 @@ public class ArchiveTableComp extends Composite {
|
||||||
/** Number of selected items label. */
|
/** Number of selected items label. */
|
||||||
private Label selectedLbl;
|
private Label selectedLbl;
|
||||||
|
|
||||||
/** Total selected items for all tables */
|
|
||||||
private Label totalSelectedLbl;
|
|
||||||
|
|
||||||
/** Size label. */
|
/** Size label. */
|
||||||
private Label sizeLbl;
|
private Label sizeLbl;
|
||||||
|
|
||||||
|
@ -85,7 +82,7 @@ public class ArchiveTableComp extends Composite {
|
||||||
/** Current table type. */
|
/** Current table type. */
|
||||||
private TableType tableType = TableType.Retention;
|
private TableType tableType = TableType.Retention;
|
||||||
|
|
||||||
private IArchiveTotals iTotalSelectedSize;
|
private IArchiveTotals iArchiveTotals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -100,7 +97,7 @@ public class ArchiveTableComp extends Composite {
|
||||||
super(parent, 0);
|
super(parent, 0);
|
||||||
|
|
||||||
tableType = type;
|
tableType = type;
|
||||||
this.iTotalSelectedSize = iTotalSelectedSize;
|
this.iArchiveTotals = iTotalSelectedSize;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +169,7 @@ public class ArchiveTableComp extends Composite {
|
||||||
*/
|
*/
|
||||||
private void createTableLabels() {
|
private void createTableLabels() {
|
||||||
Composite lblComp = new Composite(this, SWT.NONE);
|
Composite lblComp = new Composite(this, SWT.NONE);
|
||||||
GridLayout gl = new GridLayout(3, true);
|
GridLayout gl = new GridLayout(2, true);
|
||||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
lblComp.setLayout(gl);
|
lblComp.setLayout(gl);
|
||||||
lblComp.setLayoutData(gd);
|
lblComp.setLayoutData(gd);
|
||||||
|
@ -184,10 +181,6 @@ public class ArchiveTableComp extends Composite {
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
sizeLbl = new Label(lblComp, SWT.NONE);
|
sizeLbl = new Label(lblComp, SWT.NONE);
|
||||||
sizeLbl.setLayoutData(gd);
|
sizeLbl.setLayoutData(gd);
|
||||||
|
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
|
||||||
totalSelectedLbl = new Label(lblComp, SWT.NONE);
|
|
||||||
totalSelectedLbl.setLayoutData(gd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -218,14 +211,13 @@ public class ArchiveTableComp extends Composite {
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedLbl.setText("Table Selected Items: " + count);
|
selectedLbl.setText("Table Selected Items: " + count);
|
||||||
int totalSelectedSize = iTotalSelectedSize.getTotalSelectedItems();
|
|
||||||
totalSelectedLbl.setText("Total Selected Items: " + totalSelectedSize);
|
|
||||||
|
|
||||||
String sizeString = "????";
|
String sizeString = DisplayData.UNKNOWN_SIZE_LABEL;
|
||||||
if (tableTotalSize >= 0) {
|
if (tableTotalSize >= 0) {
|
||||||
sizeString = SizeUtil.prettyByteSize(tableTotalSize);
|
sizeString = SizeUtil.prettyByteSize(tableTotalSize);
|
||||||
}
|
}
|
||||||
sizeLbl.setText("Table Selected Size: " + sizeString);
|
sizeLbl.setText("Table Selected Size: " + sizeString);
|
||||||
|
iArchiveTotals.updateTotals();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -325,6 +317,8 @@ public class ArchiveTableComp extends Composite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSelectionLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -354,7 +348,7 @@ public class ArchiveTableComp extends Composite {
|
||||||
private void setItemSize(TableItem item) {
|
private void setItemSize(TableItem item) {
|
||||||
long size = ((DisplayData) item.getData(DISPLAY_INFO_KEY)).getSize();
|
long size = ((DisplayData) item.getData(DISPLAY_INFO_KEY)).getSize();
|
||||||
if (size < 0L) {
|
if (size < 0L) {
|
||||||
item.setText(1, "????");
|
item.setText(1, DisplayData.UNKNOWN_SIZE_LABEL);
|
||||||
} else {
|
} else {
|
||||||
item.setText(1, SizeUtil.prettyByteSize(size));
|
item.setText(1, SizeUtil.prettyByteSize(size));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
|
||||||
|
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
@ -61,6 +64,7 @@ import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType;
|
||||||
import com.raytheon.uf.viz.core.VizApp;
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
import com.raytheon.viz.ui.dialogs.AwipsCalendar;
|
import com.raytheon.viz.ui.dialogs.AwipsCalendar;
|
||||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
import com.raytheon.viz.ui.dialogs.ICloseCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -103,6 +107,12 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
/** Category combo box. */
|
/** Category combo box. */
|
||||||
private Combo categoryCbo;
|
private Combo categoryCbo;
|
||||||
|
|
||||||
|
/** Action to bring up the case name dialog. */
|
||||||
|
private Button caseNameCreate;
|
||||||
|
|
||||||
|
/** Display the case name. */
|
||||||
|
private Label caseNameLbl;
|
||||||
|
|
||||||
/** Compression check box. */
|
/** Compression check box. */
|
||||||
private Button compressChk;
|
private Button compressChk;
|
||||||
|
|
||||||
|
@ -127,6 +137,12 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
/** Uncompressed file size label. */
|
/** Uncompressed file size label. */
|
||||||
private Label uncompressSizeLbl;
|
private Label uncompressSizeLbl;
|
||||||
|
|
||||||
|
/** Displays total number of items selected from all categories. */
|
||||||
|
private Label totalSelectedItemsLbl;
|
||||||
|
|
||||||
|
/** Button to generate the case. */
|
||||||
|
private Button generateBtn;
|
||||||
|
|
||||||
/** Date format. */
|
/** Date format. */
|
||||||
private SimpleDateFormat dateFmt = new SimpleDateFormat(
|
private SimpleDateFormat dateFmt = new SimpleDateFormat(
|
||||||
"E MMM dd yyyy HH:00 z");
|
"E MMM dd yyyy HH:00 z");
|
||||||
|
@ -137,7 +153,8 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
/** Information for populating the various table displays. */
|
/** Information for populating the various table displays. */
|
||||||
private final Map<String, ArchiveInfo> archiveInfoMap = new HashMap<String, ArchiveInfo>();
|
private final Map<String, ArchiveInfo> archiveInfoMap = new HashMap<String, ArchiveInfo>();
|
||||||
|
|
||||||
private Cursor busyCursor;
|
/** Number of selected items. */
|
||||||
|
private int selectedItemsSize = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
|
@ -162,7 +179,6 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initializeComponents(Shell shell) {
|
protected void initializeComponents(Shell shell) {
|
||||||
busyCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
|
|
||||||
setText("Archive Case Creation");
|
setText("Archive Case Creation");
|
||||||
Composite mainComp = new Composite(shell, SWT.NONE);
|
Composite mainComp = new Composite(shell, SWT.NONE);
|
||||||
GridLayout gl = new GridLayout(1, false);
|
GridLayout gl = new GridLayout(1, false);
|
||||||
|
@ -187,12 +203,12 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
private void init() {
|
private void init() {
|
||||||
DirInfo.addUpdateListener(this);
|
DirInfo.addUpdateListener(this);
|
||||||
createTimeControls();
|
createTimeControls();
|
||||||
addSeparator(shell, SWT.HORIZONTAL);
|
GuiUtil.addSeparator(shell, SWT.HORIZONTAL);
|
||||||
createCaseCompressionControls();
|
createCaseCompressionControls();
|
||||||
addSeparator(shell, SWT.HORIZONTAL);
|
GuiUtil.addSeparator(shell, SWT.HORIZONTAL);
|
||||||
createFileBrowserControls();
|
createFileBrowserControls();
|
||||||
createTable();
|
createTable();
|
||||||
addSeparator(shell, SWT.HORIZONTAL);
|
GuiUtil.addSeparator(shell, SWT.HORIZONTAL);
|
||||||
createBottomActionButtons();
|
createBottomActionButtons();
|
||||||
|
|
||||||
populateComboBoxes();
|
populateComboBoxes();
|
||||||
|
@ -256,7 +272,7 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
caseCompressionComp.setLayoutData(gd);
|
caseCompressionComp.setLayoutData(gd);
|
||||||
|
|
||||||
createComboControls(caseCompressionComp);
|
createComboControls(caseCompressionComp);
|
||||||
addSeparator(caseCompressionComp, SWT.VERTICAL);
|
GuiUtil.addSeparator(caseCompressionComp, SWT.VERTICAL);
|
||||||
createCompressionControls(caseCompressionComp);
|
createCompressionControls(caseCompressionComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,9 +299,7 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
archCfgCbo.addSelectionListener(new SelectionAdapter() {
|
archCfgCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
String archiveName = archCfgCbo.getItem(archCfgCbo
|
populateCategoryCbo(getSelectedArchiveName());
|
||||||
.getSelectionIndex());
|
|
||||||
populateCategoryCbo(archiveName);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -299,13 +313,24 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
categoryCbo.addSelectionListener(new SelectionAdapter() {
|
categoryCbo.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
String archiveName = archCfgCbo.getItem(archCfgCbo
|
populateTableComp();
|
||||||
.getSelectionIndex());
|
|
||||||
String categoryName = categoryCbo.getItem(categoryCbo
|
|
||||||
.getSelectionIndex());
|
|
||||||
populateTableComp(archiveName, categoryName);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
caseNameCreate = new Button(comboComp, SWT.PUSH);
|
||||||
|
caseNameCreate.setText(" Case Name... ");
|
||||||
|
caseNameCreate.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
handleCaseNameSelection();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
caseNameCreate.setToolTipText("Must first select \"Case Location\".");
|
||||||
|
|
||||||
|
gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
|
caseNameLbl = new Label(comboComp, SWT.BORDER);
|
||||||
|
caseNameLbl.setLayoutData(gd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -317,7 +342,7 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
private void createCompressionControls(Composite comp) {
|
private void createCompressionControls(Composite comp) {
|
||||||
Composite compressionComp = new Composite(comp, SWT.NONE);
|
Composite compressionComp = new Composite(comp, SWT.NONE);
|
||||||
GridLayout gl = new GridLayout(1, false);
|
GridLayout gl = new GridLayout(1, false);
|
||||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||||
compressionComp.setLayout(gl);
|
compressionComp.setLayout(gl);
|
||||||
compressionComp.setLayoutData(gd);
|
compressionComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
@ -325,7 +350,7 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
* Uncompressed file size label
|
* Uncompressed file size label
|
||||||
*/
|
*/
|
||||||
Composite compressionLblComp = new Composite(compressionComp, SWT.NONE);
|
Composite compressionLblComp = new Composite(compressionComp, SWT.NONE);
|
||||||
gl = new GridLayout(3, false);
|
gl = new GridLayout(2, false);
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
compressionLblComp.setLayout(gl);
|
compressionLblComp.setLayout(gl);
|
||||||
compressionLblComp.setLayoutData(gd);
|
compressionLblComp.setLayoutData(gd);
|
||||||
|
@ -335,9 +360,15 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
|
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
uncompressSizeLbl = new Label(compressionLblComp, SWT.NONE);
|
uncompressSizeLbl = new Label(compressionLblComp, SWT.NONE);
|
||||||
// uncompressSizeLbl.setText("1024 MB");
|
|
||||||
uncompressSizeLbl.setLayoutData(gd);
|
uncompressSizeLbl.setLayoutData(gd);
|
||||||
updateUncompressSizeLbl();
|
|
||||||
|
Label totSelectedLbl = new Label(compressionLblComp, SWT.NONE);
|
||||||
|
totSelectedLbl.setText("Total Selected Items: ");
|
||||||
|
|
||||||
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
totalSelectedItemsLbl = new Label(compressionLblComp, SWT.NONE);
|
||||||
|
totalSelectedItemsLbl.setLayoutData(gd);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compression controls
|
* Compression controls
|
||||||
*/
|
*/
|
||||||
|
@ -419,6 +450,7 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
handleBrowserSelection();
|
handleBrowserSelection();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
browseBtn.setToolTipText("Select directory to place case.");
|
||||||
|
|
||||||
Label stateLbl = new Label(fileBrowserComp, SWT.NONE);
|
Label stateLbl = new Label(fileBrowserComp, SWT.NONE);
|
||||||
stateLbl.setText("Full - Avaliable:");
|
stateLbl.setText("Full - Avaliable:");
|
||||||
|
@ -456,12 +488,13 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Button generateBtn = new Button(actionControlComp, SWT.PUSH);
|
generateBtn = new Button(actionControlComp, SWT.PUSH);
|
||||||
generateBtn.setText(" Generate ");
|
generateBtn.setText(" Generate ");
|
||||||
|
generateBtn.setEnabled(false);
|
||||||
generateBtn.addSelectionListener(new SelectionAdapter() {
|
generateBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
generateCase();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -477,6 +510,52 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display modal dialog that performs the Generation of the case.
|
||||||
|
*/
|
||||||
|
private void generateCase() {
|
||||||
|
setBusy(true);
|
||||||
|
File targetDir = (File) locationLbl.getData();
|
||||||
|
File caseDir = (File) caseNameLbl.getData();
|
||||||
|
// TODO investigate using just Date or long values for start/end
|
||||||
|
Calendar startCal = TimeUtil.newCalendar();
|
||||||
|
startCal.setTimeInMillis(startDate.getTime());
|
||||||
|
Calendar endCal = TimeUtil.newCalendar();
|
||||||
|
endCal.setTimeInMillis(endDate.getTime());
|
||||||
|
|
||||||
|
List<DisplayData> displayDatas = getSelectedData();
|
||||||
|
boolean doCompress = compressChk.getSelection();
|
||||||
|
boolean doMultiFiles = breakFilesChk.getSelection();
|
||||||
|
int compressSize = fileSizeSpnr.getSelection();
|
||||||
|
String sizeType = fileSizeCbo.getItem(fileSizeCbo.getSelectionIndex());
|
||||||
|
|
||||||
|
// Assume Model dialog.
|
||||||
|
GenerateCaseDlg dialog = new GenerateCaseDlg(shell, targetDir, caseDir,
|
||||||
|
startCal, endCal, displayDatas, doCompress, doMultiFiles,
|
||||||
|
compressSize, sizeType);
|
||||||
|
dialog.addJobChangeListener(new JobChangeAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void done(IJobChangeEvent event) {
|
||||||
|
VizApp.runAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateLocationState();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.open();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable controls based on the compression check box.
|
* Enable/Disable controls based on the compression check box.
|
||||||
*/
|
*/
|
||||||
|
@ -490,6 +569,36 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
breakFilesChk.setEnabled(compressChk.getSelection());
|
breakFilesChk.setEnabled(compressChk.getSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bring up modal dialog to get the case's directory name.
|
||||||
|
*/
|
||||||
|
private void handleCaseNameSelection() {
|
||||||
|
Object o = locationLbl.getData();
|
||||||
|
if (!(o instanceof File)) {
|
||||||
|
MessageDialog.openError(shell, "Error",
|
||||||
|
"Must select \"Case Location\".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File targetDir = (File) o;
|
||||||
|
// Assume modal dialog.
|
||||||
|
CaseNameDialog dialog = new CaseNameDialog(shell, targetDir);
|
||||||
|
dialog.setCloseCallback(new ICloseCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dialogClosed(Object returnValue) {
|
||||||
|
if (returnValue instanceof File) {
|
||||||
|
File caseDir = (File) returnValue;
|
||||||
|
String caseName = caseDir.getAbsolutePath();
|
||||||
|
caseNameLbl.setText(caseName);
|
||||||
|
caseNameLbl.setData(caseDir);
|
||||||
|
checkGenerateButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.open();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable file size controls.
|
* Enable/Disable file size controls.
|
||||||
*
|
*
|
||||||
|
@ -502,6 +611,16 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
fileSizeCbo.setEnabled(enabled);
|
fileSizeCbo.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the generate button will user has entered all needed elements.
|
||||||
|
*/
|
||||||
|
private void checkGenerateButton() {
|
||||||
|
if (generateBtn != null && !generateBtn.isDisposed()) {
|
||||||
|
generateBtn.setEnabled(locationLbl.getData() != null
|
||||||
|
&& caseNameLbl.getData() != null && selectedItemsSize > 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action performed when the file size has changed.
|
* Action performed when the file size has changed.
|
||||||
*/
|
*/
|
||||||
|
@ -541,62 +660,51 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
if (dirName != null) {
|
if (dirName != null) {
|
||||||
locationLbl.setText(trimDirectoryName(dirName));
|
locationLbl.setText(trimDirectoryName(dirName));
|
||||||
locationLbl.setToolTipText(dirName);
|
locationLbl.setToolTipText(dirName);
|
||||||
locationLbl.setData(dirName);
|
locationLbl.setData(new File(dirName));
|
||||||
File dir = new File(dirName);
|
caseNameCreate.setToolTipText(null);
|
||||||
long totSpace = dir.getTotalSpace();
|
caseNameLbl.setText("");
|
||||||
long freeSpace = dir.getUsableSpace();
|
caseNameLbl.setData(null);
|
||||||
long percentFull = (long) Math
|
updateLocationState();
|
||||||
.round(((totSpace - freeSpace) * 100.0) / totSpace);
|
checkGenerateButton();
|
||||||
String state = null;
|
|
||||||
Color bgColor = null;
|
|
||||||
Color fgColor = null;
|
|
||||||
Display display = shell.getDisplay();
|
|
||||||
if (percentFull <= 84) {
|
|
||||||
state = "GOOD";
|
|
||||||
bgColor = display.getSystemColor(SWT.COLOR_GREEN);
|
|
||||||
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
|
|
||||||
} else if (percentFull <= 94) {
|
|
||||||
state = "CAUTION";
|
|
||||||
bgColor = display.getSystemColor(SWT.COLOR_YELLOW);
|
|
||||||
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
|
|
||||||
} else if (percentFull <= 97) {
|
|
||||||
state = "DANGER";
|
|
||||||
bgColor = display.getSystemColor(SWT.COLOR_RED);
|
|
||||||
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
|
|
||||||
} else {
|
|
||||||
state = "FATAL";
|
|
||||||
bgColor = display.getSystemColor(SWT.COLOR_DARK_MAGENTA);
|
|
||||||
fgColor = display.getSystemColor(SWT.COLOR_WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
String text = String.format("%1$3d%% %2$s - %3$s", percentFull,
|
|
||||||
state, SizeUtil.prettyByteSize(freeSpace));
|
|
||||||
locationStateLbl.setText(text);
|
|
||||||
locationStateLbl.setBackground(bgColor);
|
|
||||||
locationStateLbl.setForeground(fgColor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a separator line to the provided container.
|
* Update location's state.
|
||||||
*
|
|
||||||
* @param container
|
|
||||||
* Composite.
|
|
||||||
* @param orientation
|
|
||||||
* Vertical or horizontal orientation.
|
|
||||||
*/
|
*/
|
||||||
private void addSeparator(Composite container, int orientation) {
|
private void updateLocationState() {
|
||||||
// Separator label
|
File dir = (File) locationLbl.getData();
|
||||||
GridData gd;
|
long totSpace = dir.getTotalSpace();
|
||||||
|
long freeSpace = dir.getUsableSpace();
|
||||||
if (orientation == SWT.HORIZONTAL) {
|
long percentFull = (long) Math.round(((totSpace - freeSpace) * 100.0)
|
||||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
/ totSpace);
|
||||||
|
String state = null;
|
||||||
|
Color bgColor = null;
|
||||||
|
Color fgColor = null;
|
||||||
|
Display display = shell.getDisplay();
|
||||||
|
if (percentFull <= 84) {
|
||||||
|
state = "GOOD";
|
||||||
|
bgColor = display.getSystemColor(SWT.COLOR_GREEN);
|
||||||
|
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
|
||||||
|
} else if (percentFull <= 94) {
|
||||||
|
state = "CAUTION";
|
||||||
|
bgColor = display.getSystemColor(SWT.COLOR_YELLOW);
|
||||||
|
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
|
||||||
|
} else if (percentFull <= 97) {
|
||||||
|
state = "DANGER";
|
||||||
|
bgColor = display.getSystemColor(SWT.COLOR_RED);
|
||||||
|
fgColor = display.getSystemColor(SWT.COLOR_BLACK);
|
||||||
} else {
|
} else {
|
||||||
gd = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
|
state = "FATAL";
|
||||||
|
bgColor = display.getSystemColor(SWT.COLOR_DARK_MAGENTA);
|
||||||
|
fgColor = display.getSystemColor(SWT.COLOR_WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Label sepLbl = new Label(container, SWT.SEPARATOR | orientation);
|
String text = String.format("%1$3d%% %2$s - %3$s", percentFull, state,
|
||||||
sepLbl.setLayoutData(gd);
|
SizeUtil.prettyByteSize(freeSpace));
|
||||||
|
locationStateLbl.setText(text);
|
||||||
|
locationStateLbl.setBackground(bgColor);
|
||||||
|
locationStateLbl.setForeground(fgColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -628,8 +736,7 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
|
|
||||||
if (!startDate.equals(date)) {
|
if (!startDate.equals(date)) {
|
||||||
startDate = date;
|
startDate = date;
|
||||||
// TODO update all information not just the current table.
|
resetSizes();
|
||||||
populateTableComp();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (date.before(startDate)) {
|
if (date.before(startDate)) {
|
||||||
|
@ -642,8 +749,7 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
}
|
}
|
||||||
if (!endDate.equals(date)) {
|
if (!endDate.equals(date)) {
|
||||||
endDate = date;
|
endDate = date;
|
||||||
// TODO update all information not just the current table.
|
resetSizes();
|
||||||
populateTableComp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,19 +826,12 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
categoryCbo.add(categoryName);
|
categoryCbo.add(categoryName);
|
||||||
}
|
}
|
||||||
categoryCbo.select(0);
|
categoryCbo.select(0);
|
||||||
String categoryName = categoryCbo.getItem(0);
|
populateTableComp();
|
||||||
populateTableComp(archiveName, categoryName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateTableComp() {
|
private void populateTableComp() {
|
||||||
String archiveName = archCfgCbo.getItem(archCfgCbo.getSelectionIndex());
|
String archiveName = getSelectedArchiveName();
|
||||||
String categoryName = categoryCbo.getItem(categoryCbo
|
String categoryName = getSelectedCategoryName();
|
||||||
.getSelectionIndex());
|
|
||||||
populateTableComp(archiveName, categoryName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateTableComp(String archiveName, String categoryName) {
|
|
||||||
|
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
DirInfo.clearQueue();
|
DirInfo.clearQueue();
|
||||||
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
||||||
|
@ -755,36 +854,30 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
startCal.setTimeInMillis(startDate.getTime());
|
startCal.setTimeInMillis(startDate.getTime());
|
||||||
Calendar endCal = TimeUtil.newCalendar();
|
Calendar endCal = TimeUtil.newCalendar();
|
||||||
endCal.setTimeInMillis(endDate.getTime());
|
endCal.setTimeInMillis(endDate.getTime());
|
||||||
|
List<DisplayData> recomputList = new ArrayList<ArchiveConfigManager.DisplayData>();
|
||||||
for (DisplayData displayInfo : categoryInfo.getDisplayInfoList()) {
|
for (DisplayData displayInfo : categoryInfo.getDisplayInfoList()) {
|
||||||
new DirInfo(displayInfo, startCal, endCal);
|
// Queue unknown sizes first
|
||||||
|
if (displayInfo.getSize() < 0L) {
|
||||||
|
new DirInfo(displayInfo, startCal, endCal);
|
||||||
|
} else {
|
||||||
|
recomputList.add(displayInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recompute sizes
|
||||||
|
for (DisplayData displayData : recomputList) {
|
||||||
|
new DirInfo(displayData, startCal, endCal);
|
||||||
}
|
}
|
||||||
|
|
||||||
tableComp.populateTable(categoryInfo.getDisplayInfoList());
|
tableComp.populateTable(categoryInfo.getDisplayInfoList());
|
||||||
updateUncompressSizeLbl();
|
updateTotals();
|
||||||
setBusy(false);
|
setBusy(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTotalSelectedItems() {
|
|
||||||
int totalSelected = 0;
|
|
||||||
for (ArchiveInfo archiveInfo : archiveInfoMap.values()) {
|
|
||||||
for (String categoryName : archiveInfo.getCategoryNames()) {
|
|
||||||
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
|
|
||||||
for (DisplayData displayInfo : categoryInfo
|
|
||||||
.getDisplayInfoList()) {
|
|
||||||
if (displayInfo.isSelected()) {
|
|
||||||
++totalSelected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
updateUncompressSizeLbl();
|
|
||||||
return totalSelected;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setBusy(boolean state) {
|
private void setBusy(boolean state) {
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
if (state) {
|
if (state) {
|
||||||
cursor = busyCursor;
|
cursor = getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
|
||||||
}
|
}
|
||||||
shell.setCursor(cursor);
|
shell.setCursor(cursor);
|
||||||
}
|
}
|
||||||
|
@ -801,16 +894,37 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
tableComp.updateSize(displayInfos);
|
tableComp.updateSize(displayInfos);
|
||||||
updateUncompressSizeLbl();
|
updateTotals();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the selected archive name.
|
||||||
|
*
|
||||||
|
* @return archiveName
|
||||||
|
*/
|
||||||
|
private String getSelectedArchiveName() {
|
||||||
|
return archCfgCbo.getItem(archCfgCbo.getSelectionIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the selected category name.
|
||||||
|
*
|
||||||
|
* @return categoryName
|
||||||
|
*/
|
||||||
|
private String getSelectedCategoryName() {
|
||||||
|
return categoryCbo.getItem(categoryCbo.getSelectionIndex());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the estimated uncompressed size of selected entries.
|
* Updates the estimated uncompressed size of selected entries.
|
||||||
*/
|
*/
|
||||||
private void updateUncompressSizeLbl() {
|
public void updateTotals() {
|
||||||
long totalSize = 0;
|
long totalSize = 0;
|
||||||
|
int totalSelected = 0;
|
||||||
|
boolean unknownSize = false;
|
||||||
|
|
||||||
for (String archiveName : archiveInfoMap.keySet()) {
|
for (String archiveName : archiveInfoMap.keySet()) {
|
||||||
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
||||||
for (String categoryName : archiveInfo.getCategoryNames()) {
|
for (String categoryName : archiveInfo.getCategoryNames()) {
|
||||||
|
@ -818,19 +932,92 @@ public class CaseCreationDlg extends CaveSWTDialog implements IArchiveTotals,
|
||||||
for (DisplayData displayData : categoryInfo
|
for (DisplayData displayData : categoryInfo
|
||||||
.getDisplayInfoList()) {
|
.getDisplayInfoList()) {
|
||||||
if (displayData.isSelected()) {
|
if (displayData.isSelected()) {
|
||||||
long size = displayData.getSize();
|
++totalSelected;
|
||||||
if (size < 0) {
|
if (!unknownSize) {
|
||||||
// Size still being computed.
|
long size = displayData.getSize();
|
||||||
uncompressSizeLbl.setText("????MB");
|
if (size >= 0) {
|
||||||
return;
|
totalSize += size;
|
||||||
} else {
|
} else {
|
||||||
totalSize += size;
|
unknownSize = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uncompressSizeLbl.setText(SizeUtil.prettyByteSize(totalSize));
|
selectedItemsSize = totalSelected;
|
||||||
|
String sizeMsg = null;
|
||||||
|
if (unknownSize) {
|
||||||
|
sizeMsg = DisplayData.UNKNOWN_SIZE_LABEL;
|
||||||
|
} else {
|
||||||
|
sizeMsg = SizeUtil.prettyByteSize(totalSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
uncompressSizeLbl.setText(sizeMsg);
|
||||||
|
totalSelectedItemsLbl.setText("" + totalSelected);
|
||||||
|
checkGenerateButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset all entries to unknown size, recompute the sizes for the current
|
||||||
|
* display table and and other selected entries.
|
||||||
|
*/
|
||||||
|
private void resetSizes() {
|
||||||
|
List<DisplayData> selectedDatas = new ArrayList<ArchiveConfigManager.DisplayData>();
|
||||||
|
for (String archiveName : archiveInfoMap.keySet()) {
|
||||||
|
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
||||||
|
for (String categoryName : archiveInfo.getCategoryNames()) {
|
||||||
|
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
|
||||||
|
for (DisplayData displayData : categoryInfo
|
||||||
|
.getDisplayInfoList()) {
|
||||||
|
displayData.setSize(DisplayData.UNKNOWN_SIZE);
|
||||||
|
if (displayData.isSelected()) {
|
||||||
|
selectedDatas.add(displayData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
populateTableComp();
|
||||||
|
|
||||||
|
if (selectedDatas.size() > 0) {
|
||||||
|
String archiveName = getSelectedArchiveName();
|
||||||
|
String categoryName = getSelectedCategoryName();
|
||||||
|
Calendar startCal = TimeUtil.newCalendar();
|
||||||
|
startCal.setTimeInMillis(startDate.getTime());
|
||||||
|
Calendar endCal = TimeUtil.newCalendar();
|
||||||
|
startCal.setTimeInMillis(endDate.getTime());
|
||||||
|
|
||||||
|
for (DisplayData displayData : selectedDatas) {
|
||||||
|
if (!displayData.isArchive(archiveName)
|
||||||
|
|| !displayData.isCategory(categoryName)) {
|
||||||
|
new DirInfo(displayData, startCal, endCal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the data information on all selected items; not just the currently
|
||||||
|
* displayed table.
|
||||||
|
*
|
||||||
|
* @return selectedDatas
|
||||||
|
*/
|
||||||
|
private List<DisplayData> getSelectedData() {
|
||||||
|
List<DisplayData> selectedDatas = new ArrayList<ArchiveConfigManager.DisplayData>();
|
||||||
|
for (String archiveName : archiveInfoMap.keySet()) {
|
||||||
|
ArchiveInfo archiveInfo = archiveInfoMap.get(archiveName);
|
||||||
|
for (String categoryName : archiveInfo.getCategoryNames()) {
|
||||||
|
CategoryInfo categoryInfo = archiveInfo.get(categoryName);
|
||||||
|
for (DisplayData displayData : categoryInfo
|
||||||
|
.getDisplayInfoList()) {
|
||||||
|
if (displayData.isSelected()) {
|
||||||
|
selectedDatas.add(displayData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectedDatas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,189 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.archive.ui;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.KeyAdapter;
|
||||||
|
import org.eclipse.swt.events.KeyEvent;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog to obtain and verify a case name.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Jun 5, 2013 1966 rferrel Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author rferrel
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class CaseNameDialog extends CaveSWTDialog {
|
||||||
|
|
||||||
|
/** The location directory. */
|
||||||
|
private File locationDir;
|
||||||
|
|
||||||
|
/** Text field for entering the case name's directory. */
|
||||||
|
private Text caseNameText;
|
||||||
|
|
||||||
|
/** Non-blocking modal constructor. */
|
||||||
|
protected CaseNameDialog(Shell parent, File locationDir) {
|
||||||
|
super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL,
|
||||||
|
CAVE.DO_NOT_BLOCK);
|
||||||
|
this.locationDir = locationDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||||
|
* .eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initializeComponents(Shell shell) {
|
||||||
|
Composite mainComp = new Composite(shell, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout(1, false);
|
||||||
|
gl.marginHeight = 0;
|
||||||
|
gl.marginWidth = 0;
|
||||||
|
gl.horizontalSpacing = 0;
|
||||||
|
mainComp.setLayout(gl);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create layout of the dialog.
|
||||||
|
*/
|
||||||
|
private void init() {
|
||||||
|
setText("Case Name");
|
||||||
|
createFieldsComp();
|
||||||
|
GuiUtil.addSeparator(shell, SWT.HORIZONTAL);
|
||||||
|
createBottomActionButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The xomposite with case name text field.
|
||||||
|
*/
|
||||||
|
private void createFieldsComp() {
|
||||||
|
Composite fieldComp = new Composite(shell, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout(2, false);
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
fieldComp.setLayout(gl);
|
||||||
|
fieldComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
Label nameLbl = new Label(fieldComp, SWT.LEFT);
|
||||||
|
nameLbl.setText("Name: ");
|
||||||
|
|
||||||
|
caseNameText = new Text(fieldComp, SWT.SINGLE);
|
||||||
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
gd.minimumWidth = 200;
|
||||||
|
caseNameText.setLayoutData(gd);
|
||||||
|
caseNameText.addKeyListener(new KeyAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void keyReleased(KeyEvent e) {
|
||||||
|
super.keyReleased(e);
|
||||||
|
if (e.character == SWT.CR || e.character == SWT.KEYPAD_CR) {
|
||||||
|
if (verifySelection()) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The composite with the action buttons.
|
||||||
|
*/
|
||||||
|
private void createBottomActionButtons() {
|
||||||
|
Composite actionControlComp = new Composite(shell, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout(2, false);
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
actionControlComp.setLayout(gl);
|
||||||
|
actionControlComp.setLayoutData(gd);
|
||||||
|
|
||||||
|
Button okBtn = new Button(actionControlComp, SWT.PUSH);
|
||||||
|
okBtn.setText(" OK ");
|
||||||
|
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
if (verifySelection()) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Button cancelBtn = new Button(actionControlComp, SWT.PUSH);
|
||||||
|
cancelBtn.setText(" Cancel ");
|
||||||
|
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the case's directory does not exist and set the return value
|
||||||
|
* when it doesn't exist.
|
||||||
|
*
|
||||||
|
* @return true when case's directory does not exist.
|
||||||
|
*/
|
||||||
|
private boolean verifySelection() {
|
||||||
|
String caseName = caseNameText.getText().trim();
|
||||||
|
if (caseName.length() == 0) {
|
||||||
|
MessageDialog.openError(shell, "Error", "Enter a case name.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
File caseDir = new File(locationDir, caseName);
|
||||||
|
if (caseDir.exists()) {
|
||||||
|
MessageDialog.openError(shell, "Error",
|
||||||
|
"Case already exists choose another name.");
|
||||||
|
caseNameText.selectAll();
|
||||||
|
caseNameText.setFocus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
setReturnValue(caseDir);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,465 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.archive.ui;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.core.runtime.jobs.IJobChangeListener;
|
||||||
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.events.ShellAdapter;
|
||||||
|
import org.eclipse.swt.events.ShellEvent;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.ProgressBar;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import com.raytheon.uf.common.archive.config.ArchiveConfigManager;
|
||||||
|
import com.raytheon.uf.common.archive.config.ArchiveConfigManager.DisplayData;
|
||||||
|
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
|
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||||
|
import com.raytheon.uf.common.util.FileUtil;
|
||||||
|
import com.raytheon.uf.viz.core.VizApp;
|
||||||
|
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to show progress of creating a case.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Jun 3, 2013 1966 rferrel Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author rferrelGenerateJob
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GenerateCaseDlg extends CaveSWTDialog {
|
||||||
|
private final IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(GenerateCaseDlg.class);
|
||||||
|
|
||||||
|
/** Use to display the current state of the case generation. */
|
||||||
|
private Label stateLbl;
|
||||||
|
|
||||||
|
/** Progress bar to indicate activity. */
|
||||||
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
|
/** Stops the case generation leaving it in an unknown state. */
|
||||||
|
private Button cancelBtn;
|
||||||
|
|
||||||
|
/** Active have generation is finish or has an error. */
|
||||||
|
private Button closeBtn;
|
||||||
|
|
||||||
|
/** The main destination directory. */
|
||||||
|
private final File targetDir;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The case's destination directory. Assumed to be a sub-directory of
|
||||||
|
* targetDir.
|
||||||
|
*/
|
||||||
|
private final File caseDir;
|
||||||
|
|
||||||
|
/** Starting time for the case. */
|
||||||
|
private final Calendar startCal;
|
||||||
|
|
||||||
|
/** End time for the case. */
|
||||||
|
private final Calendar endCal;
|
||||||
|
|
||||||
|
/** Data list for the case. */
|
||||||
|
private final List<DisplayData> sourceDataList;
|
||||||
|
|
||||||
|
/** When true compress the case directory. */
|
||||||
|
private final boolean doCompress;
|
||||||
|
|
||||||
|
/** When true break the compress file into multliple files. */
|
||||||
|
private final boolean doMultiFiles;
|
||||||
|
|
||||||
|
/** The compress size for muliple files. */
|
||||||
|
private final int compressSize;
|
||||||
|
|
||||||
|
/** Assumed to be MG or GB to indicate scaling factor for compressSize. */
|
||||||
|
private final String sizeType;
|
||||||
|
|
||||||
|
/** Job to perform the case generation off of the UI thread. */
|
||||||
|
private GenerateJob generateJob;
|
||||||
|
|
||||||
|
/** Shorten case name to use in status message. */
|
||||||
|
private final String caseName;
|
||||||
|
|
||||||
|
/** Listeners to add to the job when scheduled. */
|
||||||
|
private final List<IJobChangeListener> jobListeners = new ArrayList<IJobChangeListener>();
|
||||||
|
|
||||||
|
/** Data manager. */
|
||||||
|
private final ArchiveConfigManager archiveManager = ArchiveConfigManager
|
||||||
|
.getInstance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param parentShell
|
||||||
|
* @param targetDir
|
||||||
|
* @param caseDir
|
||||||
|
* @param startCal
|
||||||
|
* @param endCal
|
||||||
|
* @param sourceList
|
||||||
|
* @param doCompress
|
||||||
|
* @param doMultiFiles
|
||||||
|
* @param compressSize
|
||||||
|
* @param sizeType
|
||||||
|
*/
|
||||||
|
protected GenerateCaseDlg(Shell parentShell, File targetDir, File caseDir,
|
||||||
|
Calendar startCal, Calendar endCal, List<DisplayData> sourceList,
|
||||||
|
boolean doCompress, boolean doMultiFiles, int compressSize,
|
||||||
|
String sizeType) {
|
||||||
|
super(parentShell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL,
|
||||||
|
CAVE.DO_NOT_BLOCK);
|
||||||
|
this.targetDir = targetDir;
|
||||||
|
this.caseDir = caseDir;
|
||||||
|
this.startCal = startCal;
|
||||||
|
this.endCal = endCal;
|
||||||
|
this.sourceDataList = new ArrayList<DisplayData>(sourceList);
|
||||||
|
this.doCompress = doCompress;
|
||||||
|
this.doMultiFiles = doMultiFiles;
|
||||||
|
this.compressSize = compressSize;
|
||||||
|
this.sizeType = sizeType;
|
||||||
|
this.caseName = caseDir.getAbsolutePath().substring(
|
||||||
|
targetDir.getAbsolutePath().length() + 1);
|
||||||
|
setText("Generating - " + caseName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a job listener.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
|
protected void addJobChangeListener(IJobChangeListener listener) {
|
||||||
|
jobListeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remve a job listener.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
|
protected void removeJobChangeListener(IJobChangeListener listener) {
|
||||||
|
jobListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see
|
||||||
|
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||||
|
* .eclipse.swt.widgets.Shell)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initializeComponents(Shell shell) {
|
||||||
|
Composite mainComp = new Composite(shell, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout(1, false);
|
||||||
|
gl.marginHeight = 0;
|
||||||
|
gl.marginWidth = 0;
|
||||||
|
gl.horizontalSpacing = 0;
|
||||||
|
mainComp.setLayout(gl);
|
||||||
|
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up main layout.
|
||||||
|
*/
|
||||||
|
private void init() {
|
||||||
|
createProgress();
|
||||||
|
GuiUtil.addSeparator(shell, SWT.HORIZONTAL);
|
||||||
|
createBottomActionButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The progress component.
|
||||||
|
*/
|
||||||
|
private void createProgress() {
|
||||||
|
Composite progComp = new Composite(shell, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout(1, false);
|
||||||
|
progComp.setLayout(gl);
|
||||||
|
|
||||||
|
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
gd.minimumWidth = 300;
|
||||||
|
stateLbl = new Label(shell, SWT.BORDER | SWT.CENTER);
|
||||||
|
stateLbl.setLayoutData(gd);
|
||||||
|
stateLbl.setText("state of progress goes here.");
|
||||||
|
|
||||||
|
progressBar = new ProgressBar(shell, SWT.DEFAULT);
|
||||||
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
progressBar.setLayoutData(gd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component for the action buttons.
|
||||||
|
*/
|
||||||
|
private void createBottomActionButtons() {
|
||||||
|
Composite actionComp = new Composite(shell, SWT.NONE);
|
||||||
|
GridLayout gl = new GridLayout(2, false);
|
||||||
|
actionComp.setLayout(gl);
|
||||||
|
|
||||||
|
cancelBtn = new Button(actionComp, SWT.PUSH);
|
||||||
|
cancelBtn.setText(" Cancel ");
|
||||||
|
cancelBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
if (generateJob != null && generateJob.getState() != Job.NONE) {
|
||||||
|
generateJob.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
closeBtn = new Button(actionComp, SWT.PUSH);
|
||||||
|
closeBtn.setText(" Close ");
|
||||||
|
closeBtn.setEnabled(false);
|
||||||
|
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void preOpened() {
|
||||||
|
super.preOpened();
|
||||||
|
|
||||||
|
generateJob = new GenerateJob();
|
||||||
|
for (IJobChangeListener listener : jobListeners) {
|
||||||
|
generateJob.addJobChangeListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
generateJob.schedule();
|
||||||
|
shell.addShellListener(new ShellAdapter() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shellClosed(ShellEvent e) {
|
||||||
|
if (generateJob != null && generateJob.getState() != Job.NONE) {
|
||||||
|
e.doit = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow a non-UI thread to update the state label.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* @param tooltip
|
||||||
|
*/
|
||||||
|
private void setStateLbl(final String message, final String tooltip) {
|
||||||
|
VizApp.runAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!stateLbl.isDisposed()) {
|
||||||
|
stateLbl.setText(message);
|
||||||
|
stateLbl.setToolTipText(tooltip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow a non-UI thread to update the progress bar and background of the
|
||||||
|
* state label when there is an error.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* @param state
|
||||||
|
*/
|
||||||
|
private void setProgressBar(final int value, final int state) {
|
||||||
|
VizApp.runAsync(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!progressBar.isDisposed()) {
|
||||||
|
int val = value;
|
||||||
|
if (val < progressBar.getMinimum()) {
|
||||||
|
val = progressBar.getMinimum();
|
||||||
|
} else if (val >= progressBar.getMaximum()) {
|
||||||
|
val = progressBar.getMaximum();
|
||||||
|
closeBtn.setEnabled(true);
|
||||||
|
cancelBtn.setEnabled(false);
|
||||||
|
}
|
||||||
|
progressBar.setSelection(val);
|
||||||
|
progressBar.setState(state);
|
||||||
|
progressBar.setVisible(val != progressBar.getMaximum());
|
||||||
|
Color bgColor = null;
|
||||||
|
if (state == SWT.ERROR) {
|
||||||
|
bgColor = shell.getDisplay().getSystemColor(
|
||||||
|
SWT.COLOR_RED);
|
||||||
|
}
|
||||||
|
stateLbl.setBackground(bgColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void disposed() {
|
||||||
|
if (generateJob != null && generateJob.getState() != Job.NONE) {
|
||||||
|
generateJob.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The performs the work of generating the case on a non-UI thread.
|
||||||
|
*/
|
||||||
|
private class GenerateJob extends Job {
|
||||||
|
boolean shutdown = false;
|
||||||
|
|
||||||
|
public GenerateJob() {
|
||||||
|
super("Generate Job");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
if (monitor.isCanceled()) {
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
setStateLbl("Creating: " + caseDir.getName(),
|
||||||
|
caseDir.getAbsolutePath());
|
||||||
|
if (caseDir.exists()) {
|
||||||
|
setStateLbl("Case exists: " + caseName,
|
||||||
|
caseDir.getAbsolutePath());
|
||||||
|
setProgressBar(100, SWT.ERROR);
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!caseDir.mkdirs()) {
|
||||||
|
setStateLbl("Unable to create case: " + caseName,
|
||||||
|
caseDir.getAbsolutePath());
|
||||||
|
setProgressBar(100, SWT.ERROR);
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shutdown) {
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DisplayData displayData : sourceDataList) {
|
||||||
|
if (shutdown) {
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
setStateLbl(
|
||||||
|
"Copying \"" + displayData.getDisplayLabel() + "\"",
|
||||||
|
null);
|
||||||
|
String rootDir = displayData.getRootDir();
|
||||||
|
int beginIndex = rootDir.length();
|
||||||
|
|
||||||
|
List<File> files = archiveManager.getDisplayFiles(displayData,
|
||||||
|
startCal, endCal);
|
||||||
|
for (File source : files) {
|
||||||
|
if (shutdown) {
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = source.getAbsolutePath();
|
||||||
|
String relativePath = name.substring(beginIndex);
|
||||||
|
|
||||||
|
setStateLbl("Copy: " + relativePath, name);
|
||||||
|
File destination = new File(caseDir, relativePath);
|
||||||
|
try {
|
||||||
|
if (source.isDirectory()) {
|
||||||
|
destination.mkdirs();
|
||||||
|
FileUtil.copyDirectory(source, destination);
|
||||||
|
} else {
|
||||||
|
File destParent = caseDir.getParentFile();
|
||||||
|
destParent.mkdirs();
|
||||||
|
FileUtil.copyFile(source, destination);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
statusHandler.handle(Priority.PROBLEM,
|
||||||
|
e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doCompress) {
|
||||||
|
setProgressBar(100, SWT.NORMAL);
|
||||||
|
setStateLbl("Created: " + caseName, caseDir.getAbsolutePath());
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shutdown) {
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doMultiFiles) {
|
||||||
|
setProgressBar(100, SWT.NORMAL);
|
||||||
|
String message = "Compress into multifiles NYI.";
|
||||||
|
setStateLbl(message, null);
|
||||||
|
} else {
|
||||||
|
setProgressBar(100, SWT.NORMAL);
|
||||||
|
String message = "Compress into one file NYI";
|
||||||
|
setStateLbl(message, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Status.OK_STATUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.core.runtime.jobs.Job#canceling()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void canceling() {
|
||||||
|
shutdown = true;
|
||||||
|
generateJob = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.archive.ui;
|
||||||
|
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Common methods used in the dialogs.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Jun 6, 2013 1966 rferrel Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author rferrel
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class GuiUtil {
|
||||||
|
private GuiUtil() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a separator line to the provided container.
|
||||||
|
*
|
||||||
|
* @param container
|
||||||
|
* Composite.
|
||||||
|
* @param orientation
|
||||||
|
* Vertical or horizontal orientation.
|
||||||
|
*/
|
||||||
|
public static void addSeparator(Composite container, int orientation) {
|
||||||
|
// Separator label
|
||||||
|
GridData gd;
|
||||||
|
|
||||||
|
if (orientation == SWT.HORIZONTAL) {
|
||||||
|
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||||
|
} else {
|
||||||
|
gd = new GridData(SWT.DEFAULT, SWT.FILL, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Label sepLbl = new Label(container, SWT.SEPARATOR | orientation);
|
||||||
|
sepLbl.setLayoutData(gd);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -78,16 +78,21 @@ public class ArchiveConfigManager {
|
||||||
private final IUFStatusHandler statusHandler = UFStatus
|
private final IUFStatusHandler statusHandler = UFStatus
|
||||||
.getHandler(ArchiveConfigManager.class);
|
.getHandler(ArchiveConfigManager.class);
|
||||||
|
|
||||||
|
/** The only instance or this class. */
|
||||||
private final static ArchiveConfigManager instance = new ArchiveConfigManager();
|
private final static ArchiveConfigManager instance = new ArchiveConfigManager();
|
||||||
|
|
||||||
|
/** Localize directory for the archive configuration files. */
|
||||||
public final String ARCHIVE_DIR = "archive";
|
public final String ARCHIVE_DIR = "archive";
|
||||||
|
|
||||||
|
/** Localization manager. */
|
||||||
private IPathManager pathMgr;
|
private IPathManager pathMgr;
|
||||||
|
|
||||||
private final Map<String, LocalizationFile> archiveNameToLocalizationFileMap = new HashMap<String, LocalizationFile>();
|
private final Map<String, LocalizationFile> archiveNameToLocalizationFileMap = new HashMap<String, LocalizationFile>();
|
||||||
|
|
||||||
|
/** Mapping of archive configuration data keyed to the name. */
|
||||||
private final Map<String, ArchiveConfig> archiveMap = new HashMap<String, ArchiveConfig>();
|
private final Map<String, ArchiveConfig> archiveMap = new HashMap<String, ArchiveConfig>();
|
||||||
|
|
||||||
|
/** Get the singleton. */
|
||||||
public final static ArchiveConfigManager getInstance() {
|
public final static ArchiveConfigManager getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
@ -671,19 +676,46 @@ public class ArchiveConfigManager {
|
||||||
* with a display label. Allows a GUI to maintain the state of the display
|
* with a display label. Allows a GUI to maintain the state of the display
|
||||||
* instead of the manager.
|
* instead of the manager.
|
||||||
*/
|
*/
|
||||||
public class DisplayData {
|
public static class DisplayData {
|
||||||
|
|
||||||
|
/** Label to use when size not yet known. */
|
||||||
|
public static final String UNKNOWN_SIZE_LABEL = "????";
|
||||||
|
|
||||||
|
/** A negative value to indicate unknown size. */
|
||||||
|
public static final long UNKNOWN_SIZE = -1L;
|
||||||
|
|
||||||
|
/** The data's archive configuration. */
|
||||||
protected final ArchiveConfig archiveConfig;
|
protected final ArchiveConfig archiveConfig;
|
||||||
|
|
||||||
|
/** The data's category configration. */
|
||||||
protected final CategoryConfig categoryConfig;
|
protected final CategoryConfig categoryConfig;
|
||||||
|
|
||||||
|
/** The display label for this data. */
|
||||||
protected final String displayLabel;
|
protected final String displayLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of directories for the display label matching the category's
|
||||||
|
* directory pattern and found under the archive's root directory.
|
||||||
|
*/
|
||||||
protected final List<File> dirs;
|
protected final List<File> dirs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For use by GUI to indicate. Use to indicate selected for retention or
|
||||||
|
* for placing in a case.
|
||||||
|
*/
|
||||||
private boolean selected = false;
|
private boolean selected = false;
|
||||||
|
|
||||||
private long size = -1L;
|
/** For use by GUI for indicating the size of the directories' contents. */
|
||||||
|
private long size = UNKNOWN_SIZE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param archiveConfig
|
||||||
|
* @param categoryConfig
|
||||||
|
* @param displayLabel
|
||||||
|
* @param dirs
|
||||||
|
*/
|
||||||
public DisplayData(ArchiveConfig archiveConfig,
|
public DisplayData(ArchiveConfig archiveConfig,
|
||||||
CategoryConfig categoryConfig, String displayLabel,
|
CategoryConfig categoryConfig, String displayLabel,
|
||||||
List<File> dirs) {
|
List<File> dirs) {
|
||||||
|
@ -693,36 +725,92 @@ public class ArchiveConfigManager {
|
||||||
this.dirs = dirs;
|
this.dirs = dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is instance selected.
|
||||||
|
*
|
||||||
|
* @return selected
|
||||||
|
*/
|
||||||
public boolean isSelected() {
|
public boolean isSelected() {
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set selected state.
|
||||||
|
*
|
||||||
|
* @param selected
|
||||||
|
*/
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean selected) {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return displayLabel.
|
||||||
|
*/
|
||||||
public String getDisplayLabel() {
|
public String getDisplayLabel() {
|
||||||
return displayLabel;
|
return displayLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The size of the directories' contents.
|
||||||
|
*
|
||||||
|
* @return size
|
||||||
|
*/
|
||||||
public long getSize() {
|
public long getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the size of the directories' contents.
|
||||||
|
*
|
||||||
|
* @param size
|
||||||
|
*/
|
||||||
public void setSize(long size) {
|
public void setSize(long size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The archive's root directory name.
|
||||||
|
*
|
||||||
|
* @return rootDir
|
||||||
|
*/
|
||||||
|
public String getRootDir() {
|
||||||
|
return archiveConfig.getRootDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this is the name of the archive.
|
||||||
|
*
|
||||||
|
* @param archiveName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isArchive(String archiveName) {
|
||||||
|
return archiveConfig.getName().equals(archiveName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this is the name of the category.
|
||||||
|
*
|
||||||
|
* @param categoryName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isCategory(String categoryName) {
|
||||||
|
return categoryConfig.getName().equals(categoryName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the object contains the same data as the instance.
|
||||||
|
*/
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (this == object) {
|
if (this == object) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object instanceof DisplayData) {
|
if (object instanceof DisplayData) {
|
||||||
DisplayData displayInfo = (DisplayData) object;
|
DisplayData displayData = (DisplayData) object;
|
||||||
return (archiveConfig == displayInfo.archiveConfig
|
return (archiveConfig == displayData.archiveConfig
|
||||||
&& categoryConfig == displayInfo.categoryConfig && displayLabel
|
&& categoryConfig == displayData.categoryConfig && displayLabel
|
||||||
.equals(displayInfo.displayLabel));
|
.equals(displayData.displayLabel));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue