diff --git a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/MenuItemComposite.java b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/MenuItemComposite.java index c21d7f2262..8a07838533 100644 --- a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/MenuItemComposite.java +++ b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/MenuItemComposite.java @@ -23,6 +23,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.core.commands.Command; +import org.eclipse.core.commands.CommandEvent; +import org.eclipse.core.commands.ICommandListener; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; @@ -43,7 +46,12 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandService; +import org.eclipse.ui.menus.CommandContributionItem; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuDialog.MenuPathElement; /** @@ -57,6 +65,7 @@ import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuDialog.MenuPathEl * ------------ ---------- ----------- -------------------------- * Sep 15, 2011 mnash Initial creation * Apr 10, 2013 DR 15185 D. Friedman Preserve tear-offs over perspective switches. + * Jev 26, 2014 2842 mpduff Utilize the command listener. * * * @@ -65,6 +74,8 @@ import com.raytheon.uf.viz.ui.menus.widgets.tearoff.TearOffMenuDialog.MenuPathEl */ public class MenuItemComposite extends Composite { + private final IUFStatusHandler statusHandler = UFStatus + .getHandler(MenuItemComposite.class); private boolean separator = false; @@ -85,17 +96,30 @@ public class MenuItemComposite extends Composite { private SelectionListener radioListener = null; + private ICommandListener commandListener; + private List myPath; + /** Enabled color */ + private final Color enabledColor; + + /** Disabled color */ + private final Color disabledColor; + /** * @param parent * @param style */ public MenuItemComposite(Composite parent, int style) { super(parent, style); + enabledColor = Display.getCurrent().getSystemColor(SWT.COLOR_BLACK); + disabledColor = Display.getCurrent() + .getSystemColor(SWT.COLOR_DARK_GRAY); } - // creates both labels and ties them together + /** + * Creates both labels and ties them together + */ public void addLabels(MenuItem it, int labelStyle) { if (it.isDisposed()) { return; @@ -115,6 +139,7 @@ public class MenuItemComposite extends Composite { Collections.reverse(myPath); item = it; + itemPath = new MenuPathElement(it); String[] labels = item.getText().split("\t"); @@ -163,22 +188,21 @@ public class MenuItemComposite extends Composite { createUpdateListener(); } - if (item.isEnabled()) { - // add the listeners to both the first and the second - // control, so the same thing happens if you scroll over either, - // or the MenuItemComposite - MouseTrackAdapter mouseTrackAdapter = getMouseTrackAdapter(); - firstItem.addMouseTrackListener(mouseTrackAdapter); - secondItem.addMouseTrackListener(mouseTrackAdapter); - this.addMouseTrackListener(mouseTrackAdapter); + // add the listeners to both the first and the second + // control, so the same thing happens if you scroll over either, + // or the MenuItemComposite + MouseTrackAdapter mouseTrackAdapter = getMouseTrackAdapter(); + firstItem.addMouseTrackListener(mouseTrackAdapter); + secondItem.addMouseTrackListener(mouseTrackAdapter); + this.addMouseTrackListener(mouseTrackAdapter); - MouseAdapter mouseAdapter = getMouseAdapter(); - firstItem.addMouseListener(mouseAdapter); - secondItem.addMouseListener(mouseAdapter); - this.addMouseListener(mouseAdapter); - } else { - setForeground(Display.getCurrent().getSystemColor( - SWT.COLOR_DARK_GRAY)); + MouseAdapter mouseAdapter = getMouseAdapter(); + firstItem.addMouseListener(mouseAdapter); + secondItem.addMouseListener(mouseAdapter); + this.addMouseListener(mouseAdapter); + + if (!item.isEnabled()) { + setForeground(disabledColor); } } @@ -189,14 +213,68 @@ public class MenuItemComposite extends Composite { * */ private void addItemListeners() { - if (item == null) + if (item == null) { return; + } + if (updateListener != null) { item.addListener(SWT.Modify, updateListener); } if (radioListener != null) { item.addSelectionListener(radioListener); } + + if (item.getData() instanceof CommandContributionItem) { + final Command c = ((ICommandService) PlatformUI.getWorkbench() + .getService(ICommandService.class)) + .getCommand(((CommandContributionItem) item.getData()) + .getCommand().getId()); + + commandListener = new ICommandListener() { + @Override + public void commandChanged(CommandEvent commandEvent) { + if (item.isDisposed() || firstItem.isDisposed() + || secondItem.isDisposed()) { + return; + } + + if (item.getData() instanceof CommandContributionItem) { + CommandContributionItem itm = (CommandContributionItem) item + .getData(); + if (itm.getCommand().getId().equals(c.getId())) { + boolean enabled = true; + if (commandEvent.getCommand().getHandler() != null) { + enabled = commandEvent.getCommand() + .getHandler().isEnabled(); + } else { + enabled = commandEvent.getCommand().isEnabled(); + } + + firstItem.setEnabled(enabled); + secondItem.setEnabled(enabled); + if (enabled) { + setForeground(enabledColor); + } else { + setForeground(disabledColor); + setBackground(Display.getCurrent() + .getSystemColor( + SWT.COLOR_WIDGET_BACKGROUND)); + + // changes the arrow image to the unhighlighted + // version + if (secondItem instanceof Label) { + if (((Label) secondItem).getImage() != null) { + ((Label) secondItem).setImage(arrow); + } + } + } + } + } + } + }; + + c.addCommandListener(commandListener); + } } /** @@ -211,8 +289,8 @@ public class MenuItemComposite extends Composite { for (Control comp : firstItem.getParent().getParent() .getChildren()) { MenuItemComposite composite = (MenuItemComposite) comp; - if (composite.getItem().getText().equals( - ((MenuItem) e.widget).getText())) { + if (composite.getItem().getText() + .equals(((MenuItem) e.widget).getText())) { if (composite.firstItem instanceof Button) { ((Button) composite.firstItem) .setSelection(composite.getItem() @@ -337,14 +415,16 @@ public class MenuItemComposite extends Composite { // we want all the colors to be the same for background // and foreground, so we set that here, this is to tell // the whole thing to be highlighted - setBackground(Display.getCurrent().getSystemColor( - SWT.COLOR_LIST_SELECTION)); - setForeground(Display.getCurrent().getSystemColor( - SWT.COLOR_LIST_SELECTION_TEXT)); - // changes the arrow image to the highlighted version - if (secondItem instanceof Label) { - if (((Label) secondItem).getImage() != null) { - ((Label) secondItem).setImage(highlightedArrow); + if (item.isEnabled()) { + setBackground(Display.getCurrent().getSystemColor( + SWT.COLOR_LIST_SELECTION)); + setForeground(Display.getCurrent().getSystemColor( + SWT.COLOR_LIST_SELECTION_TEXT)); + // changes the arrow image to the highlighted version + if (secondItem instanceof Label) { + if (((Label) secondItem).getImage() != null) { + ((Label) secondItem).setImage(highlightedArrow); + } } } } @@ -354,14 +434,17 @@ public class MenuItemComposite extends Composite { // we want all the colors to be the same for background // and foreground, so we set that here, this is to // unhighlight the whole thing - setBackground(Display.getCurrent().getSystemColor( - SWT.COLOR_WIDGET_BACKGROUND)); - setForeground(Display.getCurrent().getSystemColor( - SWT.COLOR_WIDGET_FOREGROUND)); - // changes the arrow image to the unhighlighted version - if (secondItem instanceof Label) { - if (((Label) secondItem).getImage() != null) { - ((Label) secondItem).setImage(arrow); + if (item.isEnabled()) { + setBackground(Display.getCurrent().getSystemColor( + SWT.COLOR_WIDGET_BACKGROUND)); + + setForeground(Display.getCurrent().getSystemColor( + SWT.COLOR_WIDGET_FOREGROUND)); + // changes the arrow image to the unhighlighted version + if (secondItem instanceof Label) { + if (((Label) secondItem).getImage() != null) { + ((Label) secondItem).setImage(arrow); + } } } } @@ -379,8 +462,10 @@ public class MenuItemComposite extends Composite { MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { - MenuItem item = getItem(); - + final MenuItem item = getItem(); + if (!item.isEnabled()) { + return; + } if (item.getMenu() != null) { // This is item opens a submenu, get the y offset based on // the location of the click @@ -401,7 +486,9 @@ public class MenuItemComposite extends Composite { Event event = new Event(); event.type = SWT.Selection; event.widget = item; - list.handleEvent(event); + if (item.isEnabled()) { + list.handleEvent(event); + } } if (isDisposed()) { @@ -438,11 +525,12 @@ public class MenuItemComposite extends Composite { // check that the radio groups match if (mic.getData("radioGroup").equals( parent.getData("radioGroup"))) { - if (!parent.getItem() + if (!parent + .getItem() .getText() .replaceAll("&", "") - .equals(mic.getItem().getText().replaceAll( - "&", ""))) { + .equals(mic.getItem().getText() + .replaceAll("&", ""))) { mic.getItem().setSelection(false); ((Button) mic.firstItem) .setSelection(false); @@ -452,7 +540,8 @@ public class MenuItemComposite extends Composite { } } } catch (NullPointerException e1) { - e1.printStackTrace(); + statusHandler.error("Error executing menu action.", + e1); } } } @@ -480,6 +569,14 @@ public class MenuItemComposite extends Composite { } } + if (item.getData() instanceof CommandContributionItem) { + ICommandService service = (ICommandService) PlatformUI + .getWorkbench().getService(ICommandService.class); + Command c = service.getCommand(((CommandContributionItem) item + .getData()).getCommand().getId()); + c.removeCommandListener(commandListener); + } + super.dispose(); } @@ -491,10 +588,11 @@ public class MenuItemComposite extends Composite { private MenuItem getItem() { MenuItem item = getItemIfAvailable(); - if (item == null) - throw new IllegalStateException( - String.format("Could not find target of tear-off menu item \"%s\"", - itemPath.getName())); + if (item == null) { + throw new IllegalStateException(String.format( + "Could not find target of tear-off menu item \"%s\"", + itemPath.getName())); + } return item; } @@ -508,10 +606,11 @@ public class MenuItemComposite extends Composite { private MenuItem findItem() { Menu menu = getTargetMenu(); - if (menu != null) + if (menu != null) { return TearOffMenuDialog.findItem(menu, itemPath); - else + } else { return null; + } } private Menu getTargetMenu() { @@ -524,5 +623,5 @@ public class MenuItemComposite extends Composite { public void reconnect() { getItemIfAvailable(); - } + } } \ No newline at end of file diff --git a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuDialog.java b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuDialog.java index ab03d8368d..11a49f7f63 100644 --- a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuDialog.java +++ b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/tearoff/TearOffMenuDialog.java @@ -69,7 +69,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; public class TearOffMenuDialog extends CaveSWTDialog { - private MenuPathElement[] menuPath; + private final MenuPathElement[] menuPath; private Menu menu; @@ -83,6 +83,8 @@ public class TearOffMenuDialog extends CaveSWTDialog { */ ISimulatedTimeChangeListener stcl; + private Listener swtListener; + /** * @param parentShell */ @@ -152,12 +154,15 @@ public class TearOffMenuDialog extends CaveSWTDialog { int y = point.y; shell.setLocation(x, y); - shell.addListener(SWT.Show, new Listener() { + swtListener = new Listener() { @Override public void handleEvent(Event event) { updateItems(); } - }); + + }; + shell.addListener(SWT.Show, swtListener); + menu.addListener(SWT.Show, swtListener); } /* @@ -208,6 +213,9 @@ public class TearOffMenuDialog extends CaveSWTDialog { for (Control control : fullComp.getChildren()) { control.dispose(); } + + shell.removeListener(SWT.Show, swtListener); + menu.removeListener(SWT.Show, swtListener); super.disposed(); } @@ -216,10 +224,12 @@ public class TearOffMenuDialog extends CaveSWTDialog { */ private void updateItems() { Menu menu = getMenuIfAvailable(); - if (menu == null) + if (menu == null) { return; - for (MenuItemComposite mic : getMenuItemComposites()) + } + for (MenuItemComposite mic : getMenuItemComposites()) { mic.reconnect(); + } for (MenuItem item : menu.getItems()) { if (item.getData() instanceof BundleContributionItem) { ((BundleContributionItem) item.getData()).refreshText(); @@ -230,8 +240,9 @@ public class TearOffMenuDialog extends CaveSWTDialog { private List getMenuItemComposites() { List result = new ArrayList(); for (Control c : fullComp.getChildren()) { - if (c instanceof MenuItemComposite) + if (c instanceof MenuItemComposite) { result.add((MenuItemComposite) c); + } } return result; } @@ -243,10 +254,11 @@ public class TearOffMenuDialog extends CaveSWTDialog { */ private static String getCleanMenuItemText(String text) { int pos = text.indexOf('\t'); - if (pos >= 0) + if (pos >= 0) { return text.substring(0, pos); - else + } else { return text; + } } private Menu getMenuIfAvailable() { @@ -256,22 +268,23 @@ public class TearOffMenuDialog extends CaveSWTDialog { return menu; } - /*package*/ Menu getTargetMenu() { + /* package */Menu getTargetMenu() { Menu menu = getMenuIfAvailable(); if (menu == null) { - throw new IllegalStateException( - String.format("Tear-off menu %s is not available", shell.getText())); + throw new IllegalStateException(String.format( + "Tear-off menu %s is not available", shell.getText())); } - if (menu.getItems().length == 0) + if (menu.getItems().length == 0) { tryToFillMenu(menu); + } return menu; } private void tryToFillMenu(Menu menu) { /* - * Menu may not have been created so call listeners. This still does - * not work if all of the menu items need the workbench window to be - * active in order to be enabled. + * Menu may not have been created so call listeners. This still does not + * work if all of the menu items need the workbench window to be active + * in order to be enabled. */ Shell shell = this.shell.getParent().getShell(); @@ -294,14 +307,17 @@ public class TearOffMenuDialog extends CaveSWTDialog { MenuPathElement lastPathElement = null; for (int i = 0; i < menuPath.length; ++i) { MenuItem mi = findItem(container, menuPath[i]); - if (mi == null) + if (mi == null) { return null; + } Menu mim = mi.getMenu(); - if (mim == null) + if (mim == null) { throw new IllegalStateException(String.format( "Could not get target menu \"%s\" in %s", - menuPath[i].getName(), lastPathElement != null ? - '"' + lastPathElement.getName() + '"' : "menu bar")); + menuPath[i].getName(), + lastPathElement != null ? '"' + lastPathElement + .getName() + '"' : "menu bar")); + } tryToFillMenu(mim); container = mim; lastPathElement = menuPath[i]; @@ -310,39 +326,47 @@ public class TearOffMenuDialog extends CaveSWTDialog { } /** - * Identifies a specific item in an SWT menu. It has been observed that + * Identifies a specific item in an SWT menu. It has been observed that * associated data of a menu item maintains the same identity during a CAVE - * session even if the MenuItem is recreated. However, the associated - * data is not always unique. Menu item text is used to differentiate. + * session even if the MenuItem is recreated. However, the associated data + * is not always unique. Menu item text is used to differentiate. */ static class MenuPathElement { Object data; + String cleanText; + public MenuPathElement(MenuItem item) { data = item.getData(); cleanText = getCleanMenuItemText(item.getText()); } + public int getMatchLevel(MenuItem item) { int level = 0; - if (item.getData() == data) + if (item.getData() == data) { ++level; - if (cleanText.equals(item.getText())) + } + if (cleanText.equals(item.getText())) { ++level; + } return level; } + public String getName() { - if (cleanText != null && cleanText.length() > 0) + if (cleanText != null && cleanText.length() > 0) { return cleanText; + } Object value = data; - if (value instanceof MenuManager) + if (value instanceof MenuManager) { value = ((MenuManager) value).getId(); - else if (value instanceof ContributionItem) + } else if (value instanceof ContributionItem) { value = ((ContributionItem) value).getId(); + } return String.valueOf(value); } } - /*package*/ static MenuItem findItem(Menu menu, MenuPathElement pe) { + /* package */static MenuItem findItem(Menu menu, MenuPathElement pe) { MenuItem best = null; int bestLevel = 0; for (MenuItem item : menu.getItems()) { @@ -359,8 +383,9 @@ public class TearOffMenuDialog extends CaveSWTDialog { ArrayList data = new ArrayList(); while (menu != null) { MenuItem mi = menu.getParentItem(); - if (mi == null) + if (mi == null) { break; + } data.add(new MenuPathElement(mi)); menu = menu.getParentMenu(); } diff --git a/cave/com.raytheon.viz.mpe.ui/build.properties b/cave/com.raytheon.viz.mpe.ui/build.properties index 6e2f847b66..8e0e61e4db 100644 --- a/cave/com.raytheon.viz.mpe.ui/build.properties +++ b/cave/com.raytheon.viz.mpe.ui/build.properties @@ -3,4 +3,5 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ plugin.xml,\ - localization/ + localization/,\ + icons/ diff --git a/cave/com.raytheon.viz.mpe.ui/icons/back0.gif b/cave/com.raytheon.viz.mpe.ui/icons/back0.gif new file mode 100644 index 0000000000..0e1e711ad7 Binary files /dev/null and b/cave/com.raytheon.viz.mpe.ui/icons/back0.gif differ diff --git a/cave/com.raytheon.viz.mpe.ui/icons/fwd0.gif b/cave/com.raytheon.viz.mpe.ui/icons/fwd0.gif new file mode 100644 index 0000000000..4a8e2f014b Binary files /dev/null and b/cave/com.raytheon.viz.mpe.ui/icons/fwd0.gif differ diff --git a/cave/com.raytheon.viz.mpe.ui/plugin.xml b/cave/com.raytheon.viz.mpe.ui/plugin.xml index 2e3c0301ac..e2ba296974 100644 --- a/cave/com.raytheon.viz.mpe.ui/plugin.xml +++ b/cave/com.raytheon.viz.mpe.ui/plugin.xml @@ -805,6 +805,44 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/SaveBestEstimateProvider.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/SaveBestEstimateProvider.java index 4fab2f3b9c..6337020f71 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/SaveBestEstimateProvider.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/SaveBestEstimateProvider.java @@ -25,7 +25,7 @@ import java.util.Map; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.ui.AbstractSourceProvider; import org.eclipse.ui.ISources; -import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.services.ISourceProviderService; /** @@ -36,7 +36,8 @@ import org.eclipse.ui.services.ISourceProviderService; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Sep 2, 2010 mschenke Initial creation + * Sep 2, 2010 mschenke Initial creation + * Feb 26, 2014 2842 mpduff Use PlatformUI rather than HandlerUtil. * * * @@ -48,7 +49,7 @@ public class SaveBestEstimateProvider extends AbstractSourceProvider { private static final String[] MENU_ENABLED = new String[] { "com.raytheon.viz.mpe.ui.saveBestEstBottom" }; - private Map sourceMap = new HashMap(); + private final Map sourceMap = new HashMap(); private boolean enabled = false; @@ -88,9 +89,8 @@ public class SaveBestEstimateProvider extends AbstractSourceProvider { } public static SaveBestEstimateProvider getProvider(ExecutionEvent event) { - ISourceProviderService service = (ISourceProviderService) HandlerUtil - .getActiveWorkbenchWindow(event).getService( - ISourceProviderService.class); + ISourceProviderService service = (ISourceProviderService) PlatformUI + .getWorkbench().getService(ISourceProviderService.class); return (SaveBestEstimateProvider) service .getSourceProvider(MENU_ENABLED[0]); } diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ChooseHour.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ChooseHour.java index a1474e32c5..5b3255e6e0 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ChooseHour.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ChooseHour.java @@ -28,6 +28,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.viz.core.IDisplayPane; @@ -44,6 +45,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Sep 23, 2008 randerso Initial creation + * Feb 26, 2014 2842 mpduff Use PlatformUI rather than HandlerUtil. * * * @author randerso @@ -86,7 +88,7 @@ public class ChooseHour extends AbstractHandler { MPEDisplayManager dm = MPEDisplayManager.getInstance(pane); Date currentDate = dm.getCurrentEditDate(); if ((increment == 0) || (currentDate == null)) { - Shell shell = HandlerUtil.getActiveWorkbenchWindow(event) + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getShell(); ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(shell); dialog.open(); diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ClearMPEData.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ClearMPEData.java index b6e7eed1af..0715f6bcb7 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ClearMPEData.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/ClearMPEData.java @@ -22,11 +22,11 @@ package com.raytheon.viz.mpe.ui.actions; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.viz.mpe.ui.TransmitRFCBiasProvider; +import com.raytheon.viz.ui.EditorUtil; /** * MPE Users guide specifies this command should clear all MPE data from screen @@ -39,6 +39,7 @@ import com.raytheon.viz.mpe.ui.TransmitRFCBiasProvider; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 3, 2012 mschenke Initial creation + * Feb 26, 2014 2842 mpduff Use PlatformUI rather than HandlerUtil. * * * @@ -57,7 +58,8 @@ public class ClearMPEData extends FullScreen { */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart editor = HandlerUtil.getActiveEditor(event); + IEditorPart editor = EditorUtil.getActiveEditor(); + if (editor instanceof IDisplayPaneContainer) { IDisplayPaneContainer container = (IDisplayPaneContainer) editor; for (IDisplayPane pane : container.getDisplayPanes()) { diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/DrawPolygonAction.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/DrawPolygonAction.java index 3f6f871d57..2abf09dbd3 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/DrawPolygonAction.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/DrawPolygonAction.java @@ -25,12 +25,12 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource; +import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.input.EditableManager; /** @@ -41,7 +41,8 @@ import com.raytheon.viz.ui.input.EditableManager; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Jul 1, 2009 mpduff Initial creation. + * Jul 01, 2009 mpduff Initial creation. + * Feb 26, 2014 2842 mpduff Use EditorUtil rather than HandlerUtil. * * * @@ -52,7 +53,7 @@ public class DrawPolygonAction extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = HandlerUtil.getActiveEditor(event); + IEditorPart activeEditor = EditorUtil.getActiveEditor(); if (activeEditor instanceof IDisplayPaneContainer) { IDisplayPaneContainer container = (IDisplayPaneContainer) activeEditor; MPEDisplayManager.stopLooping(container); diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveBestEstimateHandler.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveBestEstimateHandler.java index 32ccc245d5..612b0b765a 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveBestEstimateHandler.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SaveBestEstimateHandler.java @@ -29,7 +29,7 @@ import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.PlatformUI; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.DataTime; @@ -40,6 +40,7 @@ import com.raytheon.viz.mpe.ui.Activator; import com.raytheon.viz.mpe.ui.DisplayFieldData; import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource; +import com.raytheon.viz.ui.EditorUtil; /** * Handler class for saving the current best estimate @@ -51,6 +52,7 @@ import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jan 2, 2013 mschenke Initial creation + * Feb 26, 2014 2842 mpduff Use PlatformUI rather than HandlerUtil. * * * @@ -69,14 +71,15 @@ public class SaveBestEstimateHandler extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart part = HandlerUtil.getActiveEditor(event); + IEditorPart part = EditorUtil.getActiveEditor(); if (part instanceof IDisplayPaneContainer) { IDisplayPaneContainer container = (IDisplayPaneContainer) part; IDisplayPane toSave = getPaneToSave(container); if (toSave != null) { MPEDisplayManager.stopLooping(container); - IWorkbenchWindow activeWindow = HandlerUtil - .getActiveWorkbenchWindow(event); + + IWorkbenchWindow activeWindow = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); Shell shell = activeWindow.getShell(); try { shell.setCursor(shell.getDisplay().getSystemCursor( diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SetDisplayField.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SetDisplayField.java index 3797a13078..59a364c357 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SetDisplayField.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/SetDisplayField.java @@ -23,13 +23,13 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.viz.core.IDisplayPane; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.viz.mpe.ui.DisplayFieldData; import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource; +import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.editor.IMultiPaneEditor; /** @@ -42,6 +42,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor; * Oct 27, 2008 randerso Initial creation. * Jul 21, 2009 mpduff Added code to update the Xmrg * data. + * Feb 26, 2014 2842 mpduff Use EditorUtil rather than HandlerUtil. * * * @author randerso @@ -59,7 +60,7 @@ public class SetDisplayField extends AbstractHandler { */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = HandlerUtil.getActiveEditor(event); + IEditorPart activeEditor = EditorUtil.getActiveEditor(); if (activeEditor instanceof IDisplayPaneContainer) { String f = event.getParameter("Field"); return setDisplayField((IDisplayPaneContainer) activeEditor, diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/TimeLapseAction.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/TimeLapseAction.java index 12a18cc117..fef82adc6c 100644 --- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/TimeLapseAction.java +++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/actions/TimeLapseAction.java @@ -23,11 +23,11 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.viz.core.IDisplayPaneContainer; import com.raytheon.viz.mpe.ui.MPEDisplayManager; import com.raytheon.viz.mpe.ui.dialogs.timelapse.TimeLapseDlg; +import com.raytheon.viz.ui.EditorUtil; /** * Time lapse action, can start/stop time lapsing in MPE @@ -39,6 +39,7 @@ import com.raytheon.viz.mpe.ui.dialogs.timelapse.TimeLapseDlg; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 7, 2012 mschenke Initial creation + * Feb 26, 2014 2842 mpduff Use EditorUtil rather than HandlerUtil. * * * @@ -49,7 +50,7 @@ public class TimeLapseAction extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart part = HandlerUtil.getActiveEditor(event); + IEditorPart part = EditorUtil.getActiveEditor(); if (part instanceof IDisplayPaneContainer) { IDisplayPaneContainer container = (IDisplayPaneContainer) part; String hourId = event.getParameter("Hour"); diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java index 9daba6b99b..bdfe005144 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextDisplayModel.java @@ -22,6 +22,7 @@ package com.raytheon.viz.texteditor; import java.util.HashMap; import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -62,6 +63,7 @@ import com.raytheon.viz.texteditor.msgs.ITextWorkstationCallback; * Apr 14, 2010 4734 mhuang Corrected StdTextProduct import * dependency * 05/28/2010 2187 cjeanbap Added StdTextProductFactory functionality. + * 03/18/2014 DR 17174 D. Friedman Return correct 3-letter site IDs in getNnnXxx. * * * @author grichard @@ -78,7 +80,7 @@ public final class TextDisplayModel { private static final Map vtecPpToNnn = new HashMap(); private static final Pattern warningPattern = Pattern - .compile("/[A-Z]\\.([A-Z]{3})\\.\\p{Alnum}{1}(\\p{Alnum}{3})\\.([A-Z]{2}\\.[A-Z]{1})"); + .compile("/[A-Z]\\.([A-Z]{3})\\.(\\p{Alnum}{4})\\.([A-Z]{2}\\.[A-Z]{1})"); private static final Pattern nnnxxxPattern = Pattern .compile("[\\r\\n]+([A-Z]{3})([A-Z]{3})(| WRKWG[0-9])[\\r\\n]+"); @@ -514,29 +516,20 @@ public final class TextDisplayModel { * @return the product category and product designator strings */ public static String[] getNnnXxx(String warning) { - String[] rval = { "nnn", "xxx" }; if (warning != null) { Matcher m = warningPattern.matcher(warning); - if (m.find()) { - if (m.group(1).equals("NEW") - && vtecPpToNnn.containsKey(m.group(3))) { - rval[0] = vtecPpToNnn.get(m.group(3)); - rval[1] = m.group(2); - } else { - m = nnnxxxPattern.matcher(warning); - if (m.find()) { - rval[0] = m.group(1); - rval[1] = m.group(2); - } - } - } else { - m = nnnxxxPattern.matcher(warning); - if (m.find()) { - rval[0] = m.group(1); - rval[1] = m.group(2); + if (m.find() && m.group(1).equals("NEW")) { + String nnn = vtecPpToNnn.get(m.group(3)); + Set siteSet = SiteMap.getInstance().getSite3LetterIds(m.group(2)); + if (nnn != null && siteSet.size() == 1) { + return new String[] { nnn, siteSet.iterator().next() }; } } + m = nnnxxxPattern.matcher(warning); + if (m.find()) { + return new String[] { m.group(1), m.group(2) }; + } } - return rval; + return new String[] { "nnn", "xxx" }; } } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java index 21984552c1..1b6b5af59f 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWarningConstants.java @@ -31,6 +31,8 @@ import java.util.TimeZone; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Dec 8, 2008 1737 grichard Initial creation. + * Mar 14, 2014 DR 17175 D. Friedman Fixed Atlantic and Samoa time zones. + * Add short name map. * * * @author grichard @@ -71,6 +73,8 @@ public final class TextWarningConstants { public static HashMap timeZoneAbbreviationMap = null; + public static HashMap timeZoneShortNameMap = null; + static { // build the abbreviation map timeZoneAbbreviationMap = new HashMap(); @@ -82,8 +86,26 @@ public final class TextWarningConstants { timeZoneAbbreviationMap.put("M", TimeZone.getTimeZone("MST7MDT")); timeZoneAbbreviationMap.put("m", TimeZone.getTimeZone("MST")); timeZoneAbbreviationMap.put("P", TimeZone.getTimeZone("PST8PDT")); - timeZoneAbbreviationMap.put("S", TimeZone.getTimeZone("AST")); - timeZoneAbbreviationMap.put("V", TimeZone.getTimeZone("VST")); + timeZoneAbbreviationMap.put("S", TimeZone.getTimeZone("US/Samoa")); + timeZoneAbbreviationMap.put("V", TimeZone.getTimeZone("America/Puerto_Rico")); + + HashMap t = timeZoneAbbreviationMap; + timeZoneShortNameMap = new HashMap(); + timeZoneShortNameMap.put("AKST", t.get("A")); + timeZoneShortNameMap.put("AKDT", t.get("A")); + timeZoneShortNameMap.put("CST", t.get("C")); + timeZoneShortNameMap.put("CDT", t.get("C")); + timeZoneShortNameMap.put("EST", t.get("E")); + timeZoneShortNameMap.put("EDT", t.get("E")); + timeZoneShortNameMap.put("CHST", t.get("G")); + timeZoneShortNameMap.put("ChST", t.get("G")); + timeZoneShortNameMap.put("HST", t.get("H")); + timeZoneShortNameMap.put("MST", t.get("m")); + timeZoneShortNameMap.put("MDT", t.get("M")); + timeZoneShortNameMap.put("PST", t.get("P")); + timeZoneShortNameMap.put("PDT", t.get("P")); + timeZoneShortNameMap.put("SST", t.get("S")); + timeZoneShortNameMap.put("AST", t.get("V")); } /** diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java index a3c8870531..2224f3104c 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java @@ -334,6 +334,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox; * 20Sep2013 #2394 lvenable Fixed color memory leaks. * 20Nov2013 DR 16777 D. Friedman Check if OUPRequest will work before setting ETN. * 10Dec2013 2601 mpduff Fix NullPointerException. + * 14Mar2014 DR 17175 D. Friedman Get correct time zone for MND header time sync. * * * @author lvenable @@ -5813,11 +5814,15 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener, if (m.find()) { SimpleDateFormat headerFormat = new SimpleDateFormat( "hmm a z EEE MMM d yyyy"); - headerFormat - .setTimeZone(TextWarningConstants.timeZoneAbbreviationMap - .get(m.group(5).substring(0, 1))); - product = product.replace(m.group(1), headerFormat.format(now) - .toUpperCase()); + TimeZone tz = TextWarningConstants.timeZoneShortNameMap + .get(m.group(5)); + if (tz != null) { + headerFormat.setTimeZone(tz); + product = product.replace(m.group(1), headerFormat.format(now) + .toUpperCase()); + } else { + statusHandler.warn("Could not sync MND header time because the time zone could not be determined. Will proceed with save/send."); + } } return product; } diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/TimeConsistentCheck.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/TimeConsistentCheck.java index 79e45035d8..a46997cb23 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/TimeConsistentCheck.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/TimeConsistentCheck.java @@ -41,6 +41,7 @@ import com.raytheon.viz.texteditor.util.VtecUtil; * ------------ ---------- ----------- -------------------------- * Initial creation * Aug 25, 2011 10719 rferrel ugcPtrn now local to file. + * Mar 14, 2014 DR 17175 D. Friedman Get correct time zone from times. * * * @version 1.0 @@ -90,8 +91,12 @@ public class TimeConsistentCheck implements IQCCheck { // Event ending time (second bullet) vs Expiration m = secondBulletPtrn.matcher(body); if (m.find()) { - TimeZone timeZone = TextWarningConstants.timeZoneAbbreviationMap - .get(m.group(4).substring(0, 1)); + TimeZone timeZone = TextWarningConstants.timeZoneShortNameMap + .get(m.group(4)); + if (timeZone == null) { + errorMsg += "Could not determine time zone in second bullet"; + return errorMsg; + } int am_pm = m.group(3).equals("AM") ? Calendar.AM : Calendar.PM; int minute = Integer.parseInt(m.group(2)); int hour = Integer.parseInt(m.group(1)) == 12 ? 0 : Integer @@ -134,8 +139,12 @@ public class TimeConsistentCheck implements IQCCheck { m = thirdBulletPtrn.matcher(body); if (m.find()) { - TimeZone timeZone = TextWarningConstants.timeZoneAbbreviationMap - .get(m.group(4).substring(0, 1)); + TimeZone timeZone = TextWarningConstants.timeZoneShortNameMap + .get(m.group(4)); + if (timeZone == null) { + errorMsg += "Could not determine time zone in third bullet"; + return errorMsg; + } int am_pm = m.group(3).equals("AM") ? Calendar.AM : Calendar.PM; int minute = Integer.parseInt(m.group(2)); int hour = Integer.parseInt(m.group(1)); diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/ToggleToolbarContributionItem.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/ToggleToolbarContributionItem.java index c6fb9af42b..9f641617f4 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/ToggleToolbarContributionItem.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/actions/ToggleToolbarContributionItem.java @@ -7,8 +7,8 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IContributionItem; import org.eclipse.ui.ISources; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.actions.ActionFactory; import org.eclipse.ui.actions.CompoundContributionItem; +import org.eclipse.ui.internal.WorkbenchWindow; import org.eclipse.ui.services.IEvaluationService; import com.raytheon.viz.ui.VizWorkbenchManager; @@ -35,16 +35,15 @@ public class ToggleToolbarContributionItem extends CompoundContributionItem { public void run() { IWorkbenchWindow activeWorkbenchWindow = VizWorkbenchManager .getInstance().getCurrentWindow(); - ActionFactory.IWorkbenchAction toggleToolbar = ActionFactory.TOGGLE_COOLBAR - .create(activeWorkbenchWindow); - toggleToolbar.run(); + // ActionFactory.IWorkbenchAction toggleToolbar = + // ActionFactory.TOGGLE_COOLBAR + // .create(activeWorkbenchWindow); + // toggleToolbar.run(); - // if (activeWorkbenchWindow instanceof WorkbenchWindow) - // { - // WorkbenchWindow window = (WorkbenchWindow) - // activeWorkbenchWindow; - // window.toggleToolbarVisibility(); - // } + if (activeWorkbenchWindow instanceof WorkbenchWindow) { + WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow; + window.toggleToolbarVisibility(); + } } }); diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/ModeListener.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/ModeListener.java index 34e6b1d109..fe17879249 100644 --- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/ModeListener.java +++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/dialogs/ModeListener.java @@ -52,6 +52,7 @@ import com.raytheon.viz.core.mode.CAVEMode; * ---------- ---------- ----------- -------------------------- * 12/20/07 561 Dan Fitch Initial Creation. * 6/7/2013 mnash Implementation for Chris Golden to allow instances to be garbage collected. + * 03/24/14 DR 17186 D. Friedman Do not change colors of most buttons. * * * @author Dan Fitch @@ -107,7 +108,7 @@ public class ModeListener implements PaintListener { .getStyle() & SWT.READ_ONLY) == 0)) && !(control instanceof Table) && !((control instanceof Button) && ((((Button) control) - .getStyle() & SWT.PUSH) != 0))) { + .getStyle() & (SWT.PUSH|SWT.TOGGLE|SWT.CHECK|SWT.RADIO)) != 0))) { Color back = control.getBackground(); Color fore = control.getForeground(); diff --git a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java index 52f1e4fcc5..63cfe9324e 100644 --- a/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java +++ b/edexOsgi/com.raytheon.uf.common.site/src/com/raytheon/uf/common/site/SiteMap.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -60,6 +61,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority; * Apr 09, 2012 DR14765 mhuang Map out correct CCCC site ID for backup * sites. * May 15, 2013 1040 mpduff Add awips_site_list.xml. + * Mar 18, 2014 DR 17173 D. Friedmna Re-implement DR 14765. * * * @@ -93,6 +95,8 @@ public class SiteMap { private final Map> siteTo3LetterSite = new HashMap>(); + private final Set site3to4LetterOverrides = new HashSet(); + private final Map siteMap = new TreeMap(); /** JAXB context */ @@ -163,6 +167,7 @@ public class SiteMap { nationalCategoryMap.clear(); siteTo4LetterSite.clear(); siteTo3LetterSite.clear(); + site3to4LetterOverrides.clear(); siteMap.clear(); // load base afos lookup @@ -311,6 +316,11 @@ public class SiteMap { } } + // Currently, only the 3-letter IDs are used (in + // getSite4LetterId(), but it should be possible + // to also add the 4-letter IDs to this set. + site3to4LetterOverrides.add(site3); + site3To4LetterMap.put(site3, site4); // Add the entry to the reverse lookup map @@ -390,22 +400,17 @@ public class SiteMap { public String getSite4LetterId(String site3LetterId) { String site = siteTo4LetterSite.get(site3LetterId); - // if site not found default to K - if (site == null) { + /* If site not found default to K + 3-letter-ID. + * + * Or, if the 4-letter site ID that was looked up does not + * start with a 'K' and did not come from + * site3LetterTo4LetterOverride.dat, also return + * K + 3-letter-ID. + */ + if (site == null + || (site.length() > 0 && site.charAt(0) != 'K' && + !site3to4LetterOverrides.contains(site3LetterId))) { site = "K" + site3LetterId; - } else { - // DR_14765, in case the site hashed out from combined mapping - // table from both national_category_table and afo_lookup_table - // does not start with K but not from - // site3LetterTo4LetterOerride.dat - // which are starting with P or T - char[] siteChar = site.toCharArray(); - if (siteChar[0] != 'K') { - if (!((siteChar[0] == 'P' && (siteChar[1] == 'A' - || siteChar[1] == 'G' || siteChar[1] == 'H')) || (siteChar[0] == 'T' && siteChar[1] == 'S'))) { - site = "K" + site3LetterId; - } - } } return site; diff --git a/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat b/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat index 8b2f954ef6..d8b94e5aba 100644 --- a/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat +++ b/edexOsgi/com.raytheon.uf.common.site/utility/common_static/base/site3LetterTo4LetterOverride.dat @@ -8,4 +8,4 @@ AFG PAFG AJK PAJK GUM PGUM HFO PHFO -SJU TSJU +SJU TJSJ diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/log/nrldb/.gitignore b/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/log/nrldb/.gitignore new file mode 100644 index 0000000000..e69de29bb2 diff --git a/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/nrldb/.gitignore b/nativeLib/files.native/awipsShare/hydroapps/whfs/local/data/nrldb/.gitignore new file mode 100644 index 0000000000..e69de29bb2