Issue #2842 - Fix MPE tearoff menu issues, add next/prev hr toolbar buttons

Change-Id: Ic16bc87680918a1a462bcd5373e8f92faf6d905d

Former-commit-id: 048b3ab40864d13baa7bcd9c8aef04564ec8a5f9
This commit is contained in:
Mike Duff 2014-02-27 11:21:52 -06:00
parent 3f86a80d7e
commit 801abc37a2
14 changed files with 281 additions and 109 deletions

View file

@ -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.
*
* </pre>
*
@ -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<String> 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,7 +188,6 @@ 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
@ -176,9 +200,9 @@ public class MenuItemComposite extends Composite {
firstItem.addMouseListener(mouseAdapter);
secondItem.addMouseListener(mouseAdapter);
this.addMouseListener(mouseAdapter);
} else {
setForeground(Display.getCurrent().getSystemColor(
SWT.COLOR_DARK_GRAY));
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,6 +415,7 @@ 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
if (item.isEnabled()) {
setBackground(Display.getCurrent().getSystemColor(
SWT.COLOR_LIST_SELECTION));
setForeground(Display.getCurrent().getSystemColor(
@ -348,14 +427,17 @@ public class MenuItemComposite extends Composite {
}
}
}
}
@Override
public void mouseExit(MouseEvent e) {
// 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
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
@ -365,6 +447,7 @@ public class MenuItemComposite extends Composite {
}
}
}
}
};
return trackAdapter;
}
@ -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,8 +486,10 @@ public class MenuItemComposite extends Composite {
Event event = new Event();
event.type = SWT.Selection;
event.widget = item;
if (item.isEnabled()) {
list.handleEvent(event);
}
}
if (isDisposed()) {
return;
@ -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\"",
if (item == null) {
throw new IllegalStateException(String.format(
"Could not find target of tear-off menu item \"%s\"",
itemPath.getName()));
}
return item;
}
@ -508,11 +606,12 @@ 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() {
return getDialog().getTargetMenu();

View file

@ -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,9 +240,10 @@ public class TearOffMenuDialog extends CaveSWTDialog {
private List<MenuItemComposite> getMenuItemComposites() {
List<MenuItemComposite> result = new ArrayList<MenuItemComposite>();
for (Control c : fullComp.getChildren()) {
if (c instanceof MenuItemComposite)
if (c instanceof MenuItemComposite) {
result.add((MenuItemComposite) c);
}
}
return result;
}
@ -243,11 +254,12 @@ 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() {
if (menu == null || menu.isDisposed()) {
@ -259,19 +271,20 @@ public class TearOffMenuDialog extends CaveSWTDialog {
/* 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];
@ -312,32 +328,40 @@ public class TearOffMenuDialog extends CaveSWTDialog {
/**
* 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);
}
}
@ -359,8 +383,9 @@ public class TearOffMenuDialog extends CaveSWTDialog {
ArrayList<MenuPathElement> data = new ArrayList<MenuPathElement>();
while (menu != null) {
MenuItem mi = menu.getParentItem();
if (mi == null)
if (mi == null) {
break;
}
data.add(new MenuPathElement(mi));
menu = menu.getParentMenu();
}

View file

@ -3,4 +3,5 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
localization/
localization/,\
icons/

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 B

View file

@ -805,6 +805,44 @@
</parameter>
</command>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=hydrocommon-1">
<toolbar
id="com.raytheon.viz.mpe.ui.toolbar.mpecontrol">
<command
commandId="com.raytheon.viz.mpe.ui.actions.chooseHourPrev"
icon="icons/back0.gif"
label="Previous Hour"
style="push"
tooltip="Previous Hour">
<visibleWhen>
<reference
definitionId="com.raytheon.viz.inMPEActionSet">
</reference>
</visibleWhen>
<parameter
name="increment"
value="-1">
</parameter>
</command>
<command
commandId="com.raytheon.viz.mpe.ui.actions.chooseHourNext"
icon="icons/fwd0.gif"
label="Next Hour"
style="push"
tooltip="Next Hour">
<visibleWhen>
<reference
definitionId="com.raytheon.viz.inMPEActionSet">
</reference>
</visibleWhen>
<parameter
name="increment"
value="1">
</parameter>
</command>
</toolbar>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">

View file

@ -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;
/**
@ -37,6 +37,7 @@ import org.eclipse.ui.services.ISourceProviderService;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 2, 2010 mschenke Initial creation
* Feb 26, 2014 2842 mpduff Use PlatformUI rather than HandlerUtil.
*
* </pre>
*
@ -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<String, Boolean> sourceMap = new HashMap<String, Boolean>();
private final Map<String, Boolean> sourceMap = new HashMap<String, Boolean>();
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]);
}

View file

@ -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.
* </pre>
*
* @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();

View file

@ -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.
*
* </pre>
*
@ -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()) {

View file

@ -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.
*
* </pre>
*
@ -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);

View file

@ -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.
*
* </pre>
*
@ -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(

View file

@ -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.
* </pre>
*
* @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,

View file

@ -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.
*
* </pre>
*
@ -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");

View file

@ -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();
}
}
});