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

Change-Id: If2fbef2f2a128ff151525eed4feaf4273fa99855

Former-commit-id: 257bdcaa91 [formerly 656f582e22] [formerly 525a5bb8d1 [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 f96c5a1e28
commit d82d50faf1
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 * Date Ticket# Engineer Description
* ------------ ---------- ----------- -------------------------- * ------------ ---------- ----------- --------------------------
* Apr 11, 2008 Eric Babin Initial Creation * Apr 11, 2008 Eric Babin Initial Creation
* Oct 23, 2012 1287 rferrel Changes for non-blocking FormatterLauncherDialog.
* *
* </pre> * </pre>
* *
@ -56,28 +57,31 @@ public class FormatterlauncherAction extends AbstractHandler {
@Override @Override
public Object execute(ExecutionEvent arg0) throws ExecutionException { public Object execute(ExecutionEvent arg0) throws ExecutionException {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() if (dialog == null || dialog.getShell() == null || dialog.isDisposed()) {
.getShell(); Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
if (dialog == null) {
dialog = new FormatterLauncherDialog(shell); dialog = new FormatterLauncherDialog(shell);
dialog.setBlockOnOpen(true); dialog.setBlockOnOpen(false);
dialog.open();
dialog.dispose();
dialog = null;
} else if (dialog.getShell() == null) {
dialog.open(); dialog.open();
} else { } else {
dialog.getShell().setVisible(true); dialog.bringToTop();
dialog.getShell().setActive();
if (dialog.buttonBar != null) { if (dialog.buttonBar != null) {
dialog.buttonBar.moveAbove(null); dialog.buttonBar.moveAbove(null);
} }
} }
return null; return null;
} }
public static FormatterLauncherDialog getFormatterLauncher() { public static void closeFormatters() {
return dialog; 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 * Sep 16, 2010 6831 ryu Show same product for different areas on a sub-menu
* Nov 22, 2011 8781 mli remove Processor menu * Nov 22, 2011 8781 mli remove Processor menu
* Jul 26, 2012 15165 ryu Set default db source when formatter has no db defined. * 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> * </pre>
* *
@ -98,27 +99,22 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
public class FormatterLauncherDialog extends CaveJFACEDialog implements public class FormatterLauncherDialog extends CaveJFACEDialog implements
IProductTab { IProductTab {
private static final transient IUFStatusHandler statusHandler = UFStatus private final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(FormatterLauncherDialog.class); .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"; private final String PRODUCT_EDITOR = "Product Editor";
/**
* Return object when the shell is disposed.
*/
private Boolean returnObj = null;
/** /**
* Tab folder containing the product tabs. * Tab folder containing the product tabs.
@ -207,6 +203,8 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
private String selectedDataSource = null; private String selectedDataSource = null;
private boolean doClose = false;
/** /**
* Constructor. * Constructor.
* *
@ -273,7 +271,6 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
createProductsMenu(menuBar); createProductsMenu(menuBar);
createDataSourceMenu(menuBar); createDataSourceMenu(menuBar);
// createProcessorMenu(menuBar);
createIssuedByMenu(menuBar); createIssuedByMenu(menuBar);
createHelpMenu(menuBar); createHelpMenu(menuBar);
@ -380,67 +377,12 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
public void widgetSelected(SelectionEvent event) { 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 { } else {
selectedDataSource = DataManager.getCurrentInstance() selectedDataSource = DataManager.getCurrentInstance()
.getParmManager().getMutableDatabase().toString(); .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. * Create the Issued By menu.
* *
@ -932,9 +874,13 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
return null; 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); 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() { private void showViewMessagesDialog() {
viewMessageDialog = new ViewMessagesDialog(getParentShell()); if (viewMessageDialog == null || viewMessageDialog.getShell() == null
|| viewMessageDialog.isDisposed()) {
viewMessageDialog.open(); viewMessageDialog = new ViewMessagesDialog(getParentShell());
viewMessageDialog.setBlockOnOpen(false);
viewMessageDialog.open();
} else {
viewMessageDialog.setMessageItems();
viewMessageDialog.bringToTop();
}
} }
public void dispose() { private void dispose() {
textProductMgr.dispose(); textProductMgr.dispose();
} }
class ViewMessagesDialog extends org.eclipse.swt.widgets.Dialog { class ViewMessagesDialog extends CaveJFACEDialog {
private List messageList; private List messageList;
private Shell shell;
private Display display;
public ViewMessagesDialog(Shell parentShell) { public ViewMessagesDialog(Shell parentShell) {
super(parentShell); super(parentShell);
setShellStyle(SWT.DIALOG_TRIM);
}
display = getParent().getDisplay(); @Override
shell = new Shell(getParent(), SWT.DIALOG_TRIM); protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText("View Messages"); shell.setText("View Messages");
// Create the main layout for the shell. // Create the main layout for the shell.
GridLayout mainLayout = new GridLayout(1, false); GridLayout mainLayout = new GridLayout(1, false);
mainLayout.marginHeight = 2; mainLayout.marginHeight = 2;
@ -1016,31 +965,15 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
gd.heightHint = 320; gd.heightHint = 320;
gd.widthHint = 475; gd.widthHint = 475;
messageList.setLayoutData(gd); messageList.setLayoutData(gd);
setMessageItems();
} }
public void setMessageItems(String[] messageItems) { public void setMessageItems() {
messageList.removeAll();
messageList.setItems(messageItems);
}
public Object open() {
String[] messages = new String[statusMessages.size()]; String[] messages = new String[statusMessages.size()];
statusMessages.toArray(messages); statusMessages.toArray(messages);
messageList.removeAll(); messageList.removeAll();
messageList.setItems(messages); 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; return source;
} }
@Override /**
public boolean close() { * Perform a real close of the dialog instead of just hiding it.
// make clicking the x in the upper right corner just hide the dialog *
// instead of closing it * @return
getShell().setVisible(false); */
return false; 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 @Override
protected void finalize() throws Throwable { public boolean close() {
dispose(); if (doClose) {
super.finalize(); 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() { 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.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelExtent; 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.RGBColors;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor; 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 * Apr 27, 2010 mschenke refactor for common perspective switching
* Jul 7, 2011 #9897 ryu close formatters on perspective close/reset * Jul 7, 2011 #9897 ryu close formatters on perspective close/reset
* Aug 20,2012 #1077 randerso Added support for bgColor setting * Aug 20,2012 #1077 randerso Added support for bgColor setting
* Oct 23, 2012 #1287 rferrel Changes for non-blocking FormattrLauncherDialog.
* </pre> * </pre>
* *
* @author randerso * @author randerso
@ -247,9 +248,7 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
SmartToolJob.shutdown(); SmartToolJob.shutdown();
} }
}).start(); }).start();
if (FormatterlauncherAction.getFormatterLauncher() != null) { FormatterlauncherAction.closeDialog();
FormatterlauncherAction.getFormatterLauncher().closeFormatters();
}
} }
@Override @Override
@ -258,10 +257,7 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
if (IWorkbenchPage.CHANGE_RESET.equals(VizPerspectiveListener if (IWorkbenchPage.CHANGE_RESET.equals(VizPerspectiveListener
.getInstance().getPerspectiveChangeId( .getInstance().getPerspectiveChangeId(
GFEPerspective.ID_PERSPECTIVE))) { GFEPerspective.ID_PERSPECTIVE))) {
if (FormatterlauncherAction.getFormatterLauncher() != null) { FormatterlauncherAction.closeFormatters();
FormatterlauncherAction.getFormatterLauncher()
.closeFormatters();
}
} }
} }