Issue #1578 Changes for non-blocking ProductViewerDlg.

Change-Id: I61e9bf6089795391bb8d396f9ad2cd2602f5ecfb

Former-commit-id: cd1441fba6 [formerly e4df58e3b9 [formerly 9e632efc115011649b365ed80e7bedb8b1ed317a]]
Former-commit-id: e4df58e3b9
Former-commit-id: fd340e6e4c
This commit is contained in:
Roger Ferrel 2013-02-07 16:29:22 -06:00
parent 5905f0a6ac
commit 03223f5aca
2 changed files with 106 additions and 21 deletions

View file

@ -26,6 +26,8 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import com.raytheon.viz.hydrocommon.HydroDisplayManager;
/**
* Action for Product Viewer Dialog.
*
@ -36,6 +38,7 @@ import org.eclipse.ui.PlatformUI;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 6/27/06 lvenable Initial creation.
* 02/07/2013 1578 rferrel Changes for non-blocking ProductViewerDlg.
*
* </pre>
*
@ -43,14 +46,30 @@ import org.eclipse.ui.PlatformUI;
*
*/
public class ProductViewerAction extends AbstractHandler {
/** Instance of the dialog. */
ProductViewerDlg dialog;
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
ProductViewerDlg productViewerDlg = new ProductViewerDlg(shell);
productViewerDlg.open();
String currentLid = HydroDisplayManager.getInstance().getCurrentLid();
if (dialog == null) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
dialog = new ProductViewerDlg(shell);
}
dialog.open();
if (currentLid != null) {
dialog.setLid(currentLid);
}
return null;
}

View file

@ -25,11 +25,14 @@ import java.util.ArrayList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
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.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -61,6 +64,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 12/16/2008 1782 grichard Refreshed Product Viewer.
* 12/11/2009 2488 mpduff Refactored dialog to work as
* in AWIPS 1
* 02/07/2013 1578 rferrel Make dialog non-blocking.
*
* </pre>
*
@ -69,6 +73,10 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*
*/
public class ProductViewerDlg extends CaveSWTDialog {
/**
* Dialog's location and size.
*/
private static Rectangle bounds;
/**
* Font used for the list and text controls.
@ -113,19 +121,24 @@ public class ProductViewerDlg extends CaveSWTDialog {
/**
* ProductInfo data structure list.
*/
private ArrayList<ProductInfo> productInfoList = null;
private java.util.List<ProductInfo> productInfoList = null;
/**
* Contructor.
* Constructor.
*
* @param parent
* Parent shell.
*/
public ProductViewerDlg(Shell parent) {
super(parent);
super(parent, SWT.DIALOG_TRIM, CAVE.DO_NOT_BLOCK);
setText("Product Viewer");
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
@Override
protected Layout constructShellLayout() {
// Create the main layout for the shell.
@ -135,11 +148,44 @@ public class ProductViewerDlg extends CaveSWTDialog {
return mainLayout;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialog#preOpened()
*/
@Override
protected void preOpened() {
super.preOpened();
shell.addShellListener(new ShellAdapter() {
@Override
public void shellClosed(ShellEvent e) {
bounds = shell.getBounds();
}
});
if (bounds != null) {
shell.setBounds(bounds);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
@Override
protected void initializeComponents(Shell shell) {
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
@ -158,15 +204,20 @@ public class ProductViewerDlg extends CaveSWTDialog {
String lid = HydroDisplayManager.getInstance().getCurrentLid();
if ((lid != null) && (lid.length() > 0)) {
setReturnValue(lid);
selectedLocTF.setText(lid);
}
loadProductList();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#shouldOpen()
*/
@Override
protected boolean shouldOpen() {
setReturnValue(false);
return HydroDisplayManager.getInstance().isCurrentLidSelected(shell);
}
@ -267,10 +318,11 @@ public class ProductViewerDlg extends CaveSWTDialog {
gd = new GridData(110, SWT.DEFAULT);
selectedLocTF = new Text(rightComp, SWT.BORDER);
selectedLocTF.setLayoutData(gd);
selectedLocTF.addFocusListener(new FocusAdapter() {
selectedLocTF.addVerifyListener(new VerifyListener() {
@Override
public void focusLost(FocusEvent event) {
selectedLocTF.setText(selectedLocTF.getText().toUpperCase());
public void verifyText(VerifyEvent e) {
e.text = e.text.toUpperCase();
}
});
@ -288,10 +340,11 @@ public class ProductViewerDlg extends CaveSWTDialog {
gd = new GridData(110, SWT.DEFAULT);
prodIdFilterTF = new Text(rightComp, SWT.BORDER);
prodIdFilterTF.setLayoutData(gd);
prodIdFilterTF.addFocusListener(new FocusAdapter() {
prodIdFilterTF.addVerifyListener(new VerifyListener() {
@Override
public void focusLost(FocusEvent event) {
prodIdFilterTF.setText(prodIdFilterTF.getText().toUpperCase());
public void verifyText(VerifyEvent e) {
e.text = e.text.toUpperCase();
}
});
@ -335,6 +388,18 @@ public class ProductViewerDlg extends CaveSWTDialog {
textViewer.setLayoutData(gd);
}
/**
* Set the location value and if needed clear the prod ID filter.
*
* @param lid
*/
public void setLid(String lid) {
if (!selectedLocTF.getText().equals(lid)) {
selectedLocTF.setText(lid);
prodIdFilterTF.setText("");
}
}
/**
* Create the Close button.
*/
@ -353,7 +418,8 @@ public class ProductViewerDlg extends CaveSWTDialog {
closeBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
shell.dispose();
bounds = shell.getBounds();
close();
}
});
}
@ -422,7 +488,7 @@ public class ProductViewerDlg extends CaveSWTDialog {
selectedLocTF.getText());
}
/* Populate the list */
// Populate the list
loadProductListInfo(productInfoList);
}
@ -432,7 +498,7 @@ public class ProductViewerDlg extends CaveSWTDialog {
* @param productInfoList
* List of ProductInfo objects to load into the list widget
*/
private void loadProductListInfo(ArrayList<ProductInfo> productInfoList) {
private void loadProductListInfo(java.util.List<ProductInfo> productInfoList) {
String[] listItems = new String[productInfoList.size()];
for (int i = 0; i < productInfoList.size(); i++) {
listItems[i] = productInfoList.get(i).toString();
@ -445,11 +511,11 @@ public class ProductViewerDlg extends CaveSWTDialog {
* Display the selected item.
*/
private void displaySelectedItem() {
/* Get the data from the list. */
// Get the data from the list.
ProductInfo prodInfo = productInfoList.get(prodInfoListWidget
.getSelectionIndex());
/* Get the text product */
// Get the text product
ProductViewerDataManager dataManager = ProductViewerDataManager
.getInstance();
String product = dataManager.getTextProduct(prodInfo);