Issue #1964 - inital GUI creation
Change-Id: I47d58880066fa2ef284e8911390163624b873381 Former-commit-id:ae020d3960
[formerlyae020d3960
[formerly 07b027704c069d95fcbdf58a70561618d2c52ec4]] Former-commit-id:c3328077c8
Former-commit-id:9a72abf083
This commit is contained in:
parent
9b90237bcf
commit
eb7c8a4d93
5 changed files with 1289 additions and 23 deletions
|
@ -3,6 +3,10 @@ package com.raytheon.uf.viz.archive;
|
|||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.viz.archive.ui.CaseCreationDlg;
|
||||
|
||||
/**
|
||||
* Action to bring up the Archive Case Creation dialog..
|
||||
|
@ -21,7 +25,7 @@ import org.eclipse.core.commands.ExecutionException;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class ArchiveCaseCreationDialogAction extends AbstractHandler {
|
||||
// ArchiveCaseCreationDialog dialog;
|
||||
private CaseCreationDlg dialog;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -32,16 +36,15 @@ public class ArchiveCaseCreationDialogAction extends AbstractHandler {
|
|||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
// if (dialog == null || dialog.isDiposed()) {
|
||||
// Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
// .getShell();
|
||||
// dialog = new ArchiveCaseCreationDialog(shell);
|
||||
// dialog.open();
|
||||
// } else {
|
||||
// dialog.bringToTop();
|
||||
// }
|
||||
// dialog.open();
|
||||
System.out.println("ArchiveCaseCreationDialogAction NYI.");
|
||||
if (dialog == null || dialog.isDisposed()) {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
dialog = new CaseCreationDlg(shell);
|
||||
dialog.open();
|
||||
} else {
|
||||
dialog.bringToTop();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,10 @@ package com.raytheon.uf.viz.archive;
|
|||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.viz.archive.ui.ArchiveRetentionDlg;
|
||||
|
||||
/**
|
||||
* Action to display the Archive Retention dialog.
|
||||
|
@ -21,7 +25,7 @@ import org.eclipse.core.commands.ExecutionException;
|
|||
* @version 1.0
|
||||
*/
|
||||
public class ArchiveRetentionDialogAction extends AbstractHandler {
|
||||
// ArchiveRetentionDialog dialog;
|
||||
private ArchiveRetentionDlg dialog;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -32,17 +36,15 @@ public class ArchiveRetentionDialogAction extends AbstractHandler {
|
|||
*/
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
// if (dialog == null || dialog.isDiposed()) {
|
||||
// Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
// .getShell();
|
||||
// dialog = new ArchiveRetentionDialog(shell);
|
||||
// dialog.open();
|
||||
// } else {
|
||||
// dialog.bringToTop();
|
||||
// }
|
||||
// dialog.open();
|
||||
System.out.println("ArchiveRetentionDialogAction NYI.");
|
||||
return null;
|
||||
if (dialog == null || dialog.isDisposed()) {
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
dialog = new ArchiveRetentionDlg(shell);
|
||||
dialog.open();
|
||||
} else {
|
||||
dialog.bringToTop();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,349 @@
|
|||
/**
|
||||
* 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.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.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Spinner;
|
||||
|
||||
import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
* Archive retention dialog.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 23, 2013 #1964 lvenable Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ArchiveRetentionDlg extends CaveSWTDialog {
|
||||
|
||||
/** Table composite that holds the table controls. */
|
||||
private ArchiveTableComp tableComp;
|
||||
|
||||
/** Archive config combo box. */
|
||||
private Combo archCfgCbo;
|
||||
|
||||
/** Category combo box. */
|
||||
private Combo categoryCbo;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parentShell
|
||||
* Parent shell.
|
||||
*/
|
||||
public ArchiveRetentionDlg(Shell parentShell) {
|
||||
super(parentShell, SWT.DIALOG_TRIM | SWT.MIN, CAVE.DO_NOT_BLOCK
|
||||
| CAVE.MODE_INDEPENDENT | CAVE.INDEPENDENT_SHELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
mainLayout.marginHeight = 2;
|
||||
mainLayout.marginWidth = 2;
|
||||
|
||||
return mainLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setText("Archive Retention");
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize method to create all of the composite & controls.
|
||||
*/
|
||||
private void init() {
|
||||
createRetentionControls();
|
||||
createTable();
|
||||
addSeparator(shell, SWT.HORIZONTAL);
|
||||
createBottomActionButtons();
|
||||
|
||||
// TODO : Remove this when functionality is implemented
|
||||
populateComboBoxes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the retention controls.
|
||||
*/
|
||||
private void createRetentionControls() {
|
||||
Composite retentionComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(5, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
retentionComp.setLayout(gl);
|
||||
retentionComp.setLayoutData(gd);
|
||||
|
||||
/*
|
||||
* Top row of controls.
|
||||
*/
|
||||
Label archCfgLbl = new Label(retentionComp, SWT.NONE);
|
||||
archCfgLbl.setText("Archive Config: ");
|
||||
|
||||
gd = new GridData(200, SWT.DEFAULT);
|
||||
archCfgCbo = new Combo(retentionComp, SWT.VERTICAL | SWT.DROP_DOWN
|
||||
| SWT.BORDER | SWT.READ_ONLY);
|
||||
archCfgCbo.setLayoutData(gd);
|
||||
archCfgCbo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
/*
|
||||
* TODO - add code to update the category combo box
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalIndent = 20;
|
||||
Label minRetentionLbl = new Label(retentionComp, SWT.NONE);
|
||||
minRetentionLbl.setText("Minimum Retention: ");
|
||||
minRetentionLbl.setLayoutData(gd);
|
||||
|
||||
gd = new GridData(60, SWT.DEFAULT);
|
||||
final Spinner minRetentionSpnr = new Spinner(retentionComp, SWT.BORDER);
|
||||
minRetentionSpnr.setIncrement(1);
|
||||
minRetentionSpnr.setPageIncrement(5);
|
||||
minRetentionSpnr.setMaximum(Integer.MAX_VALUE);
|
||||
minRetentionSpnr.setMinimum(1);
|
||||
minRetentionSpnr.setLayoutData(gd);
|
||||
|
||||
final Combo minRetentionCbo = new Combo(retentionComp, SWT.VERTICAL
|
||||
| SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
|
||||
minRetentionCbo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleRetentionSelection(minRetentionCbo, minRetentionSpnr);
|
||||
}
|
||||
});
|
||||
minRetentionCbo.add("Hours");
|
||||
minRetentionCbo.add("Days");
|
||||
minRetentionCbo.select(0);
|
||||
minRetentionCbo.setData(minRetentionCbo.getItem(minRetentionCbo
|
||||
.getSelectionIndex()));
|
||||
|
||||
/*
|
||||
* Bottom row of controls.
|
||||
*/
|
||||
Label catLbl = new Label(retentionComp, SWT.NONE);
|
||||
catLbl.setText("Category: ");
|
||||
|
||||
gd = new GridData(200, SWT.DEFAULT);
|
||||
categoryCbo = new Combo(retentionComp, SWT.VERTICAL | SWT.DROP_DOWN
|
||||
| SWT.BORDER | SWT.READ_ONLY);
|
||||
categoryCbo.setLayoutData(gd);
|
||||
categoryCbo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
/*
|
||||
* TODO - add code to update the information in the table
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalIndent = 20;
|
||||
Label extRetentionLbl = new Label(retentionComp, SWT.NONE);
|
||||
extRetentionLbl.setText("Extended Retention: ");
|
||||
extRetentionLbl.setLayoutData(gd);
|
||||
|
||||
gd = new GridData(60, SWT.DEFAULT);
|
||||
final Spinner extRetentionSpnr = new Spinner(retentionComp, SWT.BORDER);
|
||||
extRetentionSpnr.setIncrement(1);
|
||||
extRetentionSpnr.setPageIncrement(5);
|
||||
extRetentionSpnr.setMaximum(Integer.MAX_VALUE);
|
||||
extRetentionSpnr.setMinimum(1);
|
||||
extRetentionSpnr.setLayoutData(gd);
|
||||
|
||||
final Combo extRetentionCbo = new Combo(retentionComp, SWT.VERTICAL
|
||||
| SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
|
||||
extRetentionCbo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleRetentionSelection(extRetentionCbo, extRetentionSpnr);
|
||||
}
|
||||
});
|
||||
extRetentionCbo.add("Hours");
|
||||
extRetentionCbo.add("Days");
|
||||
extRetentionCbo.select(0);
|
||||
extRetentionCbo.setData(extRetentionCbo.getItem(extRetentionCbo
|
||||
.getSelectionIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the table control.
|
||||
*/
|
||||
private void createTable() {
|
||||
tableComp = new ArchiveTableComp(shell, TableType.Case);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the bottom action buttons.
|
||||
*/
|
||||
private void createBottomActionButtons() {
|
||||
|
||||
Composite actionControlComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(3, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
actionControlComp.setLayout(gl);
|
||||
actionControlComp.setLayoutData(gd);
|
||||
|
||||
Button calcSizeBtn = new Button(actionControlComp, SWT.PUSH);
|
||||
calcSizeBtn.setText(" Calculate Sizes ");
|
||||
calcSizeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
// TODO : add calculate size functionality
|
||||
}
|
||||
});
|
||||
|
||||
Button saveBtn = new Button(actionControlComp, SWT.PUSH);
|
||||
saveBtn.setText(" Save... ");
|
||||
saveBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
// TODO : add save functionality
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
||||
Button closeBtn = new Button(actionControlComp, SWT.PUSH);
|
||||
closeBtn.setText(" Close ");
|
||||
closeBtn.setLayoutData(gd);
|
||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the retention selection for both minimum and extended retention.
|
||||
*
|
||||
* @param comboBox
|
||||
* Retention combo box.
|
||||
* @param spinner
|
||||
* Retention spinner.
|
||||
*/
|
||||
private void handleRetentionSelection(Combo comboBox, Spinner spinner) {
|
||||
// If the selection didn't change then just return.
|
||||
if (comboBox.getItem(comboBox.getSelectionIndex()).equals(
|
||||
(String) comboBox.getData())) {
|
||||
return;
|
||||
}
|
||||
|
||||
int time = 0;
|
||||
|
||||
if (comboBox.getItem(comboBox.getSelectionIndex()).equals("Hours")) {
|
||||
time = convertTime(true, spinner.getSelection());
|
||||
} else {
|
||||
time = convertTime(false, spinner.getSelection());
|
||||
}
|
||||
|
||||
spinner.setSelection(time);
|
||||
comboBox.setData(comboBox.getItem(comboBox.getSelectionIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Covert time from either hours to days or days to hours.
|
||||
*
|
||||
* @param daysToHours
|
||||
* Flag indicating how to convert the time.
|
||||
* @param time
|
||||
* Time to be converted.
|
||||
* @return The converted time.
|
||||
*/
|
||||
private int convertTime(boolean daysToHours, int time) {
|
||||
int convertedTime = 0;
|
||||
|
||||
if (daysToHours) {
|
||||
convertedTime = time * 24;
|
||||
} else {
|
||||
convertedTime = time / 24;
|
||||
}
|
||||
|
||||
return convertedTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a separator line to the provided container.
|
||||
*
|
||||
* @param container
|
||||
* Composite.
|
||||
* @param orientation
|
||||
* Vertical or horizontal orientation.
|
||||
*/
|
||||
private 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);
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* TEST METHODS - to be removed when functionality is implemented.
|
||||
* ******************************************************
|
||||
*/
|
||||
private void populateComboBoxes() {
|
||||
archCfgCbo.add("Raw");
|
||||
archCfgCbo.add("Processed");
|
||||
archCfgCbo.select(0);
|
||||
|
||||
categoryCbo.add("Radar");
|
||||
categoryCbo.add("Point");
|
||||
categoryCbo.add("Satellite");
|
||||
categoryCbo.select(0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
/**
|
||||
* 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.events.MouseAdapter;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
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.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.swt.widgets.MenuItem;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
|
||||
/**
|
||||
* Archive table composite that contains the SWT table.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 23, 2013 #1964 lvenable Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ArchiveTableComp extends Composite {
|
||||
|
||||
/** Table control. */
|
||||
private Table table;
|
||||
|
||||
/** Popup menu. */
|
||||
private Menu popupMenu;
|
||||
|
||||
/** Number of selected items label. */
|
||||
private Label selectedLbl;
|
||||
|
||||
/** Size label. */
|
||||
private Label sizeLbl;
|
||||
|
||||
/** Table type enumeration. */
|
||||
public enum TableType {
|
||||
Retention, Case
|
||||
};
|
||||
|
||||
/** Current table type. */
|
||||
private TableType tableType = TableType.Retention;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parent
|
||||
* Parent composite.
|
||||
* @param type
|
||||
* Table type.
|
||||
*/
|
||||
public ArchiveTableComp(Composite parent, TableType type) {
|
||||
super(parent, 0);
|
||||
|
||||
tableType = type;
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize composites and controls.
|
||||
*/
|
||||
private void init() {
|
||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
GridLayout gl = new GridLayout(1, true);
|
||||
gl.verticalSpacing = 2;
|
||||
gl.marginHeight = 2;
|
||||
gl.marginWidth = 2;
|
||||
this.setLayout(gl);
|
||||
this.setLayoutData(gd);
|
||||
|
||||
createTable();
|
||||
createTableLabels();
|
||||
|
||||
updateSelectionLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the table control.
|
||||
*/
|
||||
private void createTable() {
|
||||
table = new Table(this, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL
|
||||
| SWT.H_SCROLL | SWT.MULTI);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, true);
|
||||
gd.widthHint = 730;
|
||||
gd.heightHint = 270;
|
||||
table.setLayoutData(gd);
|
||||
table.setHeaderVisible(true);
|
||||
table.setLinesVisible(true);
|
||||
|
||||
TableColumn pathColumn = new TableColumn(table, SWT.CENTER);
|
||||
pathColumn.setText("Path");
|
||||
|
||||
TableColumn sizeColumn = new TableColumn(table, SWT.CENTER);
|
||||
if (tableType == TableType.Retention) {
|
||||
sizeColumn.setText("Current Size (MB)");
|
||||
} else if (tableType == TableType.Case) {
|
||||
sizeColumn.setText("Size (MB)");
|
||||
}
|
||||
|
||||
populateTable();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
table.getColumn(i).setResizable(false);
|
||||
table.getColumn(i).setMoveable(false);
|
||||
table.getColumn(i).pack();
|
||||
}
|
||||
|
||||
table.getColumn(1).setWidth(100);
|
||||
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseDown(MouseEvent me) {
|
||||
if (me.button == 3) {
|
||||
createPopupMenu(table);
|
||||
popupMenu.setVisible(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
table.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateSelectionLabel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the table labels.
|
||||
*/
|
||||
private void createTableLabels() {
|
||||
Composite lblComp = new Composite(this, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(2, true);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
lblComp.setLayout(gl);
|
||||
lblComp.setLayoutData(gd);
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
selectedLbl = new Label(lblComp, SWT.NONE);
|
||||
selectedLbl.setLayoutData(gd);
|
||||
|
||||
/*
|
||||
* TODO : keep for future use. This will be used to show the total size
|
||||
* of the selected items in the table.
|
||||
*/
|
||||
// gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
// sizeLbl = new Label(lblComp, SWT.NONE);
|
||||
// sizeLbl.setLayoutData(gd);
|
||||
// sizeLbl.setText("Size of Selected items: 0" + sizeSuffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the selection items label.
|
||||
*/
|
||||
private void updateSelectionLabel() {
|
||||
TableItem[] itemArray = table.getItems();
|
||||
int count = 0;
|
||||
|
||||
for (TableItem ti : itemArray) {
|
||||
if (ti.getChecked()) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
selectedLbl.setText("Selected Items: " + count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the table popup menu.
|
||||
*
|
||||
* @param parent
|
||||
* Parent control.
|
||||
*/
|
||||
private void createPopupMenu(Control parent) {
|
||||
if (popupMenu != null) {
|
||||
popupMenu.dispose();
|
||||
}
|
||||
|
||||
popupMenu = new Menu(parent);
|
||||
|
||||
MenuItem checkSelectedItem = new MenuItem(popupMenu, SWT.NONE);
|
||||
checkSelectedItem.setText("Check selected rows");
|
||||
checkSelectedItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleCheckSelectedRow(true);
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem uncheckSelectedItem = new MenuItem(popupMenu, SWT.NONE);
|
||||
uncheckSelectedItem.setText("Uncheck selected rows");
|
||||
uncheckSelectedItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleCheckSelectedRow(false);
|
||||
}
|
||||
});
|
||||
|
||||
new MenuItem(popupMenu, SWT.SEPARATOR);
|
||||
|
||||
MenuItem checkAllItem = new MenuItem(popupMenu, SWT.NONE);
|
||||
checkAllItem.setText("Check all rows");
|
||||
checkAllItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleCheckAll(true);
|
||||
}
|
||||
});
|
||||
|
||||
MenuItem uncheckAllItem = new MenuItem(popupMenu, SWT.NONE);
|
||||
uncheckAllItem.setText("Uncheck all rows");
|
||||
uncheckAllItem.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleCheckAll(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Set the pop-up menu as the pop-up for the shell
|
||||
parent.setMenu(popupMenu);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action performed when the item in the table is checked/unchecked.
|
||||
*
|
||||
* @param check
|
||||
* Checked flag.
|
||||
*/
|
||||
private void handleCheckSelectedRow(boolean check) {
|
||||
TableItem[] itemArray = table.getSelection();
|
||||
|
||||
for (TableItem ti : itemArray) {
|
||||
ti.setChecked(check);
|
||||
}
|
||||
|
||||
updateSelectionLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check or uncheck all of the table items.
|
||||
*
|
||||
* @param check
|
||||
* Flag indicating check or uncheck all items.
|
||||
*/
|
||||
private void handleCheckAll(boolean check) {
|
||||
TableItem[] itemArray = table.getItems();
|
||||
|
||||
for (TableItem ti : itemArray) {
|
||||
ti.setChecked(check);
|
||||
}
|
||||
|
||||
updateSelectionLabel();
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO : this is just for display purposes. This will go away when the
|
||||
* functionality is implemented.
|
||||
*/
|
||||
private void populateTable() {
|
||||
for (int i = 0; i < 150; i++) {
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
item.setText(0,
|
||||
"/home/lvenable/caveData/configuration/base/com.raytheon.uf.viz.gisdatastore/"
|
||||
+ i + " ");
|
||||
if (i % 5 == 0) {
|
||||
item.setChecked(true);
|
||||
}
|
||||
item.setText(1, "?????");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,609 @@
|
|||
/**
|
||||
* 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.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.MessageBox;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Spinner;
|
||||
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.viz.archive.ui.ArchiveTableComp.TableType;
|
||||
import com.raytheon.viz.ui.dialogs.AwipsCalendar;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* Case creation dialog.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 23, 2013 #1964 lvenable Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
* @version 1.0
|
||||
*/
|
||||
public class CaseCreationDlg extends CaveSWTDialog {
|
||||
|
||||
/** Table control */
|
||||
private ArchiveTableComp tableComp;
|
||||
|
||||
/** Start time label. */
|
||||
private Label startTimeLbl;
|
||||
|
||||
/** End time label. */
|
||||
private Label endTimeLbl;
|
||||
|
||||
/** Start date. */
|
||||
private Date startDate;
|
||||
|
||||
/** End date. */
|
||||
private Date endDate;
|
||||
|
||||
/** Archive configuration combo box. */
|
||||
private Combo archCfgCbo;
|
||||
|
||||
/** Category combo box. */
|
||||
private Combo categoryCbo;
|
||||
|
||||
/** Compression check box. */
|
||||
private Button compressChk;
|
||||
|
||||
/** Break files check box. */
|
||||
private Button breakFilesChk;
|
||||
|
||||
/** File size spinner control. */
|
||||
private Spinner fileSizeSpnr;
|
||||
|
||||
/** File size combo box. */
|
||||
private Combo fileSizeCbo;
|
||||
|
||||
/** Maximum file size label. */
|
||||
private Label maxFileSizeLbl;
|
||||
|
||||
/** Directory location label. */
|
||||
private Label locationLbl;
|
||||
|
||||
/** Uncompressed file size label. */
|
||||
private Label uncompressSizeLbl;
|
||||
|
||||
/** Date format. */
|
||||
private SimpleDateFormat dateFmt = new SimpleDateFormat(
|
||||
"E MMM dd yyyy HH:00 z");
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param parentShell
|
||||
* Parent shell.
|
||||
*/
|
||||
public CaseCreationDlg(Shell parentShell) {
|
||||
super(parentShell, SWT.DIALOG_TRIM | SWT.MIN, CAVE.DO_NOT_BLOCK
|
||||
| CAVE.MODE_INDEPENDENT | CAVE.INDEPENDENT_SHELL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
// Create the main layout for the shell.
|
||||
GridLayout mainLayout = new GridLayout(1, false);
|
||||
mainLayout.marginHeight = 2;
|
||||
mainLayout.marginWidth = 2;
|
||||
|
||||
return mainLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
setText("Case Creation");
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize method to create all of the composite & controls.
|
||||
*/
|
||||
private void init() {
|
||||
|
||||
createTimeControls();
|
||||
addSeparator(shell, SWT.HORIZONTAL);
|
||||
createCaseCompressionControls();
|
||||
addSeparator(shell, SWT.HORIZONTAL);
|
||||
createFileBrowserControls();
|
||||
createTable();
|
||||
addSeparator(shell, SWT.HORIZONTAL);
|
||||
createBottomActionButtons();
|
||||
|
||||
populateComboBoxes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the time controls.
|
||||
*/
|
||||
private void createTimeControls() {
|
||||
Composite timeComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(4, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
timeComp.setLayout(gl);
|
||||
timeComp.setLayoutData(gd);
|
||||
|
||||
Button startBtn = new Button(timeComp, SWT.PUSH);
|
||||
startBtn.setText(" Start Time... ");
|
||||
startBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
displayDateTimeControls(true);
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(220, SWT.DEFAULT);
|
||||
startTimeLbl = new Label(timeComp, SWT.BORDER);
|
||||
startTimeLbl.setLayoutData(gd);
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalIndent = 20;
|
||||
Button endBtn = new Button(timeComp, SWT.PUSH);
|
||||
endBtn.setText(" End Time... ");
|
||||
endBtn.setLayoutData(gd);
|
||||
endBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
displayDateTimeControls(false);
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(220, SWT.DEFAULT);
|
||||
endTimeLbl = new Label(timeComp, SWT.BORDER);
|
||||
endTimeLbl.setLayoutData(gd);
|
||||
|
||||
Date date = TimeUtil.newDate();
|
||||
startDate = date;
|
||||
endDate = date;
|
||||
startTimeLbl.setText(dateFmt.format(startDate));
|
||||
endTimeLbl.setText(dateFmt.format(endDate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the case compression controls.
|
||||
*/
|
||||
private void createCaseCompressionControls() {
|
||||
Composite caseCompressionComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(3, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
caseCompressionComp.setLayout(gl);
|
||||
caseCompressionComp.setLayoutData(gd);
|
||||
|
||||
createComboControls(caseCompressionComp);
|
||||
addSeparator(caseCompressionComp, SWT.VERTICAL);
|
||||
createCompressionControls(caseCompressionComp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Archive and Category combo controls.
|
||||
*
|
||||
* @param comp
|
||||
* Composite to put the controls in.
|
||||
*/
|
||||
private void createComboControls(Composite comp) {
|
||||
Composite comboComp = new Composite(comp, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(2, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
comboComp.setLayout(gl);
|
||||
comboComp.setLayoutData(gd);
|
||||
|
||||
Label archCfgLbl = new Label(comboComp, SWT.NONE);
|
||||
archCfgLbl.setText("Archive Config: ");
|
||||
|
||||
gd = new GridData(200, SWT.DEFAULT);
|
||||
archCfgCbo = new Combo(comboComp, SWT.VERTICAL | SWT.DROP_DOWN
|
||||
| SWT.BORDER | SWT.READ_ONLY);
|
||||
archCfgCbo.setLayoutData(gd);
|
||||
archCfgCbo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
/*
|
||||
* TODO - add code to update the category combo box
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
Label catLbl = new Label(comboComp, SWT.NONE);
|
||||
catLbl.setText("Category: ");
|
||||
|
||||
gd = new GridData(200, SWT.DEFAULT);
|
||||
categoryCbo = new Combo(comboComp, SWT.VERTICAL | SWT.DROP_DOWN
|
||||
| SWT.BORDER | SWT.READ_ONLY);
|
||||
categoryCbo.setLayoutData(gd);
|
||||
categoryCbo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
/*
|
||||
* TODO - add code to update the information in the table
|
||||
*/
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the compression controls.
|
||||
*
|
||||
* @param comp
|
||||
* Composite to put the control in.
|
||||
*/
|
||||
private void createCompressionControls(Composite comp) {
|
||||
Composite compressionComp = new Composite(comp, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(1, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
compressionComp.setLayout(gl);
|
||||
compressionComp.setLayoutData(gd);
|
||||
|
||||
/*
|
||||
* Uncompressed file size label
|
||||
*/
|
||||
Composite compressionLblComp = new Composite(compressionComp, SWT.NONE);
|
||||
gl = new GridLayout(3, false);
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
compressionLblComp.setLayout(gl);
|
||||
compressionLblComp.setLayoutData(gd);
|
||||
|
||||
Label uncompressLbl = new Label(compressionLblComp, SWT.NONE);
|
||||
uncompressLbl.setText("Uncompressed Case Size: ");
|
||||
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
uncompressSizeLbl = new Label(compressionLblComp, SWT.NONE);
|
||||
uncompressSizeLbl.setText("1024 MB");
|
||||
uncompressSizeLbl.setLayoutData(gd);
|
||||
|
||||
/*
|
||||
* Compression controls
|
||||
*/
|
||||
compressChk = new Button(compressionComp, SWT.CHECK);
|
||||
compressChk.setText("Compress Files");
|
||||
compressChk.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleCompressSelection();
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData();
|
||||
gd.horizontalIndent = 20;
|
||||
breakFilesChk = new Button(compressionComp, SWT.CHECK);
|
||||
breakFilesChk.setText("Break into multiple files");
|
||||
breakFilesChk.setLayoutData(gd);
|
||||
breakFilesChk.setEnabled(false);
|
||||
breakFilesChk.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleBreakFilesSelection(breakFilesChk.getSelection());
|
||||
}
|
||||
});
|
||||
|
||||
Composite maxFileSizeComp = new Composite(compressionComp, SWT.NONE);
|
||||
gl = new GridLayout(3, false);
|
||||
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
gd.horizontalIndent = 20;
|
||||
maxFileSizeComp.setLayout(gl);
|
||||
maxFileSizeComp.setLayoutData(gd);
|
||||
|
||||
maxFileSizeLbl = new Label(maxFileSizeComp, SWT.NONE);
|
||||
maxFileSizeLbl.setText("Max File Size: ");
|
||||
maxFileSizeLbl.setEnabled(false);
|
||||
|
||||
gd = new GridData(60, SWT.DEFAULT);
|
||||
fileSizeSpnr = new Spinner(maxFileSizeComp, SWT.BORDER);
|
||||
fileSizeSpnr.setIncrement(1);
|
||||
fileSizeSpnr.setPageIncrement(50);
|
||||
fileSizeSpnr.setMaximum(2000);
|
||||
fileSizeSpnr.setMinimum(500);
|
||||
fileSizeSpnr.setLayoutData(gd);
|
||||
fileSizeSpnr.setEnabled(false);
|
||||
|
||||
fileSizeCbo = new Combo(maxFileSizeComp, SWT.VERTICAL | SWT.DROP_DOWN
|
||||
| SWT.BORDER | SWT.READ_ONLY);
|
||||
fileSizeCbo.setEnabled(false);
|
||||
fileSizeCbo.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleFileSizeChangeSelection();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the file browser controls.
|
||||
*/
|
||||
private void createFileBrowserControls() {
|
||||
Composite fileBrowserComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(4, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
fileBrowserComp.setLayout(gl);
|
||||
fileBrowserComp.setLayoutData(gd);
|
||||
|
||||
Label caseLbl = new Label(fileBrowserComp, SWT.NONE);
|
||||
caseLbl.setText("Case Location: ");
|
||||
|
||||
gd = new GridData(300, SWT.DEFAULT);
|
||||
locationLbl = new Label(fileBrowserComp, SWT.BORDER);
|
||||
locationLbl.setLayoutData(gd);
|
||||
|
||||
Button browseBtn = new Button(fileBrowserComp, SWT.PUSH);
|
||||
browseBtn.setText(" Browse... ");
|
||||
browseBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
handleBrowserSelection();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the table control.
|
||||
*/
|
||||
private void createTable() {
|
||||
tableComp = new ArchiveTableComp(shell, TableType.Case);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the bottom action buttons.
|
||||
*/
|
||||
private void createBottomActionButtons() {
|
||||
|
||||
Composite actionControlComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(3, false);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
|
||||
actionControlComp.setLayout(gl);
|
||||
actionControlComp.setLayoutData(gd);
|
||||
|
||||
Button exportBtn = new Button(actionControlComp, SWT.PUSH);
|
||||
exportBtn.setText(" Export Case Config... ");
|
||||
exportBtn.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Button generateBtn = new Button(actionControlComp, SWT.PUSH);
|
||||
generateBtn.setText(" Generate ");
|
||||
generateBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
gd = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false);
|
||||
Button closeBtn = new Button(actionControlComp, SWT.PUSH);
|
||||
closeBtn.setText(" Close ");
|
||||
closeBtn.setLayoutData(gd);
|
||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable controls based on the compression check box.
|
||||
*/
|
||||
private void handleCompressSelection() {
|
||||
if (compressChk.getSelection()) {
|
||||
handleBreakFilesSelection(breakFilesChk.getSelection());
|
||||
} else {
|
||||
handleBreakFilesSelection(false);
|
||||
}
|
||||
|
||||
breakFilesChk.setEnabled(compressChk.getSelection());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable/Disable file size controls.
|
||||
*
|
||||
* @param enabled
|
||||
* Enabled flag.
|
||||
*/
|
||||
private void handleBreakFilesSelection(boolean enabled) {
|
||||
maxFileSizeLbl.setEnabled(enabled);
|
||||
fileSizeSpnr.setEnabled(enabled);
|
||||
fileSizeCbo.setEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action performed when the file size has changed.
|
||||
*/
|
||||
private void handleFileSizeChangeSelection() {
|
||||
/*
|
||||
* If the same item was selected just return.
|
||||
*/
|
||||
if (fileSizeCbo.getItem(fileSizeCbo.getSelectionIndex()).equals(
|
||||
(String) fileSizeCbo.getData())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fileSizeCbo.getItem(fileSizeCbo.getSelectionIndex()).equals("MB")) {
|
||||
fileSizeSpnr.setIncrement(1);
|
||||
fileSizeSpnr.setPageIncrement(50);
|
||||
fileSizeSpnr.setMaximum(2000);
|
||||
fileSizeSpnr.setMinimum(500);
|
||||
fileSizeSpnr.setSelection(500);
|
||||
} else {
|
||||
fileSizeSpnr.setIncrement(1);
|
||||
fileSizeSpnr.setPageIncrement(5);
|
||||
fileSizeSpnr.setMinimum(1);
|
||||
fileSizeSpnr.setMaximum(10);
|
||||
fileSizeSpnr.setSelection(1);
|
||||
}
|
||||
|
||||
fileSizeCbo
|
||||
.setData(fileSizeCbo.getItem(fileSizeCbo.getSelectionIndex()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the directory browser dialog.
|
||||
*/
|
||||
private void handleBrowserSelection() {
|
||||
DirectoryDialog dlg = new DirectoryDialog(shell, SWT.OPEN);
|
||||
String dirName = dlg.open();
|
||||
if (dirName != null) {
|
||||
locationLbl.setText(trimDirectoryName(dirName));
|
||||
locationLbl.setToolTipText(dirName);
|
||||
locationLbl.setData(dirName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a separator line to the provided container.
|
||||
*
|
||||
* @param container
|
||||
* Composite.
|
||||
* @param orientation
|
||||
* Vertical or horizontal orientation.
|
||||
*/
|
||||
private 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the date/time controls.
|
||||
*
|
||||
* @param startTimeFlag
|
||||
* True for start time, false for end time.
|
||||
*/
|
||||
private void displayDateTimeControls(boolean startTimeFlag) {
|
||||
AwipsCalendar ac = new AwipsCalendar(shell, 1);
|
||||
Date date = (Date) ac.open();
|
||||
|
||||
if (startTimeFlag) {
|
||||
if (date.after(endDate)) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
||||
| SWT.OK);
|
||||
mb.setText("Date Error");
|
||||
mb.setMessage("The selected start date is after the end date. Resetting.");
|
||||
mb.open();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (date.before(startDate)) {
|
||||
MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
|
||||
| SWT.OK);
|
||||
mb.setText("Date Error");
|
||||
mb.setMessage("The selected end date is before the start date. Resetting.");
|
||||
mb.open();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (startTimeFlag) {
|
||||
startTimeLbl.setText(dateFmt.format(date));
|
||||
} else {
|
||||
endTimeLbl.setText(dateFmt.format(date));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the directory name if it is too long to fit in the label. The
|
||||
* beginning of the path will be replaced with "...".
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private String trimDirectoryName(String str) {
|
||||
Point strExtent;
|
||||
Point ellipseExt;
|
||||
|
||||
GC gc = new GC(shell);
|
||||
gc.setFont(locationLbl.getFont());
|
||||
|
||||
ellipseExt = gc.stringExtent("...");
|
||||
int labelWidth = locationLbl.getBounds().width - (5 + ellipseExt.x);
|
||||
|
||||
strExtent = gc.stringExtent(str);
|
||||
|
||||
if (strExtent.x > labelWidth) {
|
||||
while (strExtent.x > labelWidth) {
|
||||
str = str.substring(2);
|
||||
strExtent = gc.stringExtent(str);
|
||||
}
|
||||
str = "..." + str;
|
||||
}
|
||||
|
||||
gc.dispose();
|
||||
return str;
|
||||
}
|
||||
|
||||
/********************************************************
|
||||
* TEST METHODS ******************************************************
|
||||
*/
|
||||
private void populateComboBoxes() {
|
||||
archCfgCbo.add("Raw");
|
||||
archCfgCbo.add("Processed");
|
||||
archCfgCbo.select(0);
|
||||
|
||||
categoryCbo.add("Radar");
|
||||
categoryCbo.add("Point");
|
||||
categoryCbo.add("Satellite");
|
||||
categoryCbo.select(0);
|
||||
|
||||
fileSizeCbo.add("MB");
|
||||
fileSizeCbo.add("GB");
|
||||
fileSizeCbo.select(0);
|
||||
fileSizeCbo
|
||||
.setData(fileSizeCbo.getItem(fileSizeCbo.getSelectionIndex()));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue