From 801abc37a2001263b16c5a45538bbf12858cc88f Mon Sep 17 00:00:00 2001 From: Mike Duff Date: Thu, 27 Feb 2014 11:21:52 -0600 Subject: [PATCH] Issue #2842 - Fix MPE tearoff menu issues, add next/prev hr toolbar buttons Change-Id: Ic16bc87680918a1a462bcd5373e8f92faf6d905d Former-commit-id: 048b3ab40864d13baa7bcd9c8aef04564ec8a5f9 --- .../widgets/tearoff/MenuItemComposite.java | 197 +++++++++++++----- .../widgets/tearoff/TearOffMenuDialog.java | 83 +++++--- cave/com.raytheon.viz.mpe.ui/build.properties | 3 +- cave/com.raytheon.viz.mpe.ui/icons/back0.gif | Bin 0 -> 79 bytes cave/com.raytheon.viz.mpe.ui/icons/fwd0.gif | Bin 0 -> 79 bytes cave/com.raytheon.viz.mpe.ui/plugin.xml | 38 ++++ .../viz/mpe/ui/SaveBestEstimateProvider.java | 12 +- .../viz/mpe/ui/actions/ChooseHour.java | 4 +- .../viz/mpe/ui/actions/ClearMPEData.java | 6 +- .../viz/mpe/ui/actions/DrawPolygonAction.java | 7 +- .../ui/actions/SaveBestEstimateHandler.java | 11 +- .../viz/mpe/ui/actions/SetDisplayField.java | 5 +- .../viz/mpe/ui/actions/TimeLapseAction.java | 5 +- .../ToggleToolbarContributionItem.java | 19 +- 14 files changed, 281 insertions(+), 109 deletions(-) create mode 100644 cave/com.raytheon.viz.mpe.ui/icons/back0.gif create mode 100644 cave/com.raytheon.viz.mpe.ui/icons/fwd0.gif 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 0000000000000000000000000000000000000000..0e1e711ad7f555557e953ae3d74d0815f4d679f1 GIT binary patch literal 79 zcmZ?wbhEHb6k`x$Sjfb%W7#$abDRHQp!k!8k&A(WK?jI|vSJJjObRXiD^I`WUp!|@ eYrxsF3F+~TQzVjN(u + + + + + + + + + + + + + + + + + + + + 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.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(); + } } });