Issue #1287 Changes for non-blocking FormatterLauncherDialog and code cleanup.

Change-Id: If2fbef2f2a128ff151525eed4feaf4273fa99855

Former-commit-id: 656f582e22 [formerly 656f582e22 [formerly 936092efc2f69ab3e2060334fddd630100da4157]]
Former-commit-id: 525a5bb8d1
Former-commit-id: cc5ef23f23
This commit is contained in:
Roger Ferrel 2012-10-23 12:40:48 -05:00
parent ed86da12d7
commit 38bc6ea4e9
3 changed files with 91 additions and 134 deletions

View file

@ -35,6 +35,7 @@ import com.raytheon.viz.gfe.dialogs.FormatterLauncherDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Apr 11, 2008 Eric Babin Initial Creation
* Oct 23, 2012 1287 rferrel Changes for non-blocking FormatterLauncherDialog.
*
* </pre>
*
@ -56,28 +57,31 @@ public class FormatterlauncherAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
if (dialog == null) {
if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
dialog = new FormatterLauncherDialog(shell);
dialog.setBlockOnOpen(true);
dialog.open();
dialog.dispose();
dialog = null;
} else if (dialog.getShell() == null) {
dialog.setBlockOnOpen(false);
dialog.open();
} else {
dialog.getShell().setVisible(true);
dialog.getShell().setActive();
dialog.bringToTop();
if (dialog.buttonBar != null) {
dialog.buttonBar.moveAbove(null);
}
}
return null;
}
public static FormatterLauncherDialog getFormatterLauncher() {
return dialog;
public static void closeFormatters() {
if (dialog != null && dialog.getShell() != null && !dialog.isDisposed()) {
dialog.closeFormatters();
}
}
public static void closeDialog() {
if (dialog != null && dialog.getShell() != null && !dialog.isDisposed()) {
dialog.closeDialog();
}
dialog = null;
}
}

View file

@ -89,6 +89,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
* Sep 16, 2010 6831 ryu Show same product for different areas on a sub-menu
* Nov 22, 2011 8781 mli remove Processor menu
* Jul 26, 2012 15165 ryu Set default db source when formatter has no db defined.
* Oct 23, 2012 1287 rferrel Changes for non-blocking dialogs and code clean up.
*
* </pre>
*
@ -98,27 +99,22 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
public class FormatterLauncherDialog extends CaveJFACEDialog implements
IProductTab {
private static final transient IUFStatusHandler statusHandler = UFStatus
private final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(FormatterLauncherDialog.class);
private static final String BASELINE = "Baseline";
private final String BASELINE = "Baseline";
private static final String CIVIL_EMERGENCY = "CivilEmergency";
private final String CIVIL_EMERGENCY = "CivilEmergency";
private static final String HAZARD = "Hazard";
private final String HAZARD = "Hazard";
private static final String BASELINE_HAZARD = BASELINE + HAZARD;
private final String BASELINE_HAZARD = BASELINE + HAZARD;
private static final String REGION = "Region";
private final String REGION = "Region";
private static final String OTHERS = "";
private final String OTHERS = "";
private static final String PRODUCT_EDITOR = "Product Editor";
/**
* Return object when the shell is disposed.
*/
private Boolean returnObj = null;
private final String PRODUCT_EDITOR = "Product Editor";
/**
* Tab folder containing the product tabs.
@ -207,6 +203,8 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
private String selectedDataSource = null;
private boolean doClose = false;
/**
* Constructor.
*
@ -273,7 +271,6 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
createProductsMenu(menuBar);
createDataSourceMenu(menuBar);
// createProcessorMenu(menuBar);
createIssuedByMenu(menuBar);
createHelpMenu(menuBar);
@ -380,67 +377,12 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
public void widgetSelected(SelectionEvent event) {
}
});
//
// // Set selected data source to official database name
// try {
// ServerResponse<java.util.List<DatabaseID>> sr = DataManager
// .getCurrentInstance().getClient().getOfficialDBName();
// selectedDataSource = sr.getPayload().get(0).toString();
// } catch (GFEServerException e) {
// UFStatus.handle(Priority.PROBLEM, Activator.PLUGIN_ID,
// StatusConstants.CATEGORY_GFE,
// StatusConstants.SUBCATEGORY_TEXTFORMATTER,
// "Unable to determine official db", e);
// }
} else {
selectedDataSource = DataManager.getCurrentInstance()
.getParmManager().getMutableDatabase().toString();
}
}
/**
* Create the Processor menu.
*
* @param menuBar
* Menu bar.
*/
/*
private void createProcessorMenu(Menu menuBar) {
// -------------------------------------
// Create the Processor menu
// -------------------------------------
MenuItem processorMenuItem = new MenuItem(menuBar, SWT.CASCADE);
processorMenuItem.setText("&Processor");
// Create the Processor menu item with a Products "dropdown" menu
Menu processorMenu = new Menu(menuBar);
processorMenuItem.setMenu(processorMenu);
// ------------------------------------------------------
// Create all the items in the Processor dropdown menu
// ------------------------------------------------------
// Server menu item
MenuItem serverMI = new MenuItem(processorMenu, SWT.RADIO);
serverMI.setText("Server");
serverMI.setSelection(true);
serverMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
}
});
// Local menu item
MenuItem localMI = new MenuItem(processorMenu, SWT.RADIO);
localMI.setText("Local");
localMI.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
}
});
}
*/
/**
* Create the Issued By menu.
*
@ -932,9 +874,13 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
return null;
}
public void createHideButton() {
/**
* Have the Hide button act like an OK button so it will call the close
* method when selected.
*/
private void createHideButton() {
Composite bar = (Composite) super.createButtonBar(top);
createButton(bar, IDialogConstants.CLIENT_ID, "Hide", false);
createButton(bar, IDialogConstants.OK_ID, "Hide", false);
}
/**
@ -976,31 +922,34 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
}
private void showViewMessagesDialog() {
viewMessageDialog = new ViewMessagesDialog(getParentShell());
viewMessageDialog.open();
if (viewMessageDialog == null || viewMessageDialog.getShell() == null
|| viewMessageDialog.isDisposed()) {
viewMessageDialog = new ViewMessagesDialog(getParentShell());
viewMessageDialog.setBlockOnOpen(false);
viewMessageDialog.open();
} else {
viewMessageDialog.setMessageItems();
viewMessageDialog.bringToTop();
}
}
public void dispose() {
private void dispose() {
textProductMgr.dispose();
}
class ViewMessagesDialog extends org.eclipse.swt.widgets.Dialog {
class ViewMessagesDialog extends CaveJFACEDialog {
private List messageList;
private Shell shell;
private Display display;
public ViewMessagesDialog(Shell parentShell) {
super(parentShell);
setShellStyle(SWT.DIALOG_TRIM);
}
display = getParent().getDisplay();
shell = new Shell(getParent(), SWT.DIALOG_TRIM);
@Override
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("View Messages");
// Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 2;
@ -1016,31 +965,15 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
gd.heightHint = 320;
gd.widthHint = 475;
messageList.setLayoutData(gd);
setMessageItems();
}
public void setMessageItems(String[] messageItems) {
messageList.removeAll();
messageList.setItems(messageItems);
}
public Object open() {
public void setMessageItems() {
String[] messages = new String[statusMessages.size()];
statusMessages.toArray(messages);
messageList.removeAll();
messageList.setItems(messages);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return returnObj;
}
}
@ -1093,18 +1026,42 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
return source;
}
@Override
public boolean close() {
// make clicking the x in the upper right corner just hide the dialog
// instead of closing it
getShell().setVisible(false);
return false;
/**
* Perform a real close of the dialog instead of just hiding it.
*
* @return
*/
public boolean closeDialog() {
doClose = true;
return close();
}
/**
* This hides the fromat launcher dialog and any dialogs it creates.
*/
public void hideDialog() {
if (viewMessageDialog != null) {
viewMessageDialog.hide();
}
hide();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#close()
*/
@Override
protected void finalize() throws Throwable {
dispose();
super.finalize();
public boolean close() {
if (doClose) {
dispose();
return super.close();
}
// make clicking the x in the upper right corner just hide the dialog
// instead of closing it
hideDialog();
return false;
}
public void closeFormatters() {

View file

@ -48,8 +48,8 @@ import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
@ -88,6 +88,7 @@ import com.raytheon.viz.ui.perspectives.VizPerspectiveListener;
* Apr 27, 2010 mschenke refactor for common perspective switching
* Jul 7, 2011 #9897 ryu close formatters on perspective close/reset
* Aug 20,2012 #1077 randerso Added support for bgColor setting
* Oct 23, 2012 #1287 rferrel Changes for non-blocking FormattrLauncherDialog.
* </pre>
*
* @author randerso
@ -247,9 +248,7 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
SmartToolJob.shutdown();
}
}).start();
if (FormatterlauncherAction.getFormatterLauncher() != null) {
FormatterlauncherAction.getFormatterLauncher().closeFormatters();
}
FormatterlauncherAction.closeDialog();
}
@Override
@ -258,10 +257,7 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
if (IWorkbenchPage.CHANGE_RESET.equals(VizPerspectiveListener
.getInstance().getPerspectiveChangeId(
GFEPerspective.ID_PERSPECTIVE))) {
if (FormatterlauncherAction.getFormatterLauncher() != null) {
FormatterlauncherAction.getFormatterLauncher()
.closeFormatters();
}
FormatterlauncherAction.closeFormatters();
}
}