Merge "Issue #821 Fixed editor menu so plugin.xml action contribution items are created every time the menu is shown to make sure any submenus are recreated in the action." into development
Former-commit-id:ed08428483
[formerlyed08428483
[formerly 41f21e357b6aacc42ff01a93a85f50c68c2c890b]] Former-commit-id:24a4ef99a7
Former-commit-id:afd37ef8b8
This commit is contained in:
commit
0b604f9b5d
2 changed files with 16 additions and 33 deletions
|
@ -9,10 +9,8 @@ import org.eclipse.core.runtime.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.action.ActionContributionItem;
|
import org.eclipse.jface.action.ActionContributionItem;
|
||||||
import org.eclipse.jface.action.GroupMarker;
|
import org.eclipse.jface.action.GroupMarker;
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.action.IContributionItem;
|
import org.eclipse.jface.action.IContributionItem;
|
||||||
import org.eclipse.jface.action.MenuManager;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.jface.action.Separator;
|
import org.eclipse.jface.action.Separator;
|
||||||
|
@ -162,6 +160,8 @@ public class VizEditorSystemMenu implements ISystemMenu {
|
||||||
|
|
||||||
private ActionFactory.IWorkbenchAction openAgain;
|
private ActionFactory.IWorkbenchAction openAgain;
|
||||||
|
|
||||||
|
private Menu lastShown;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the standard view menu
|
* Create the standard view menu
|
||||||
*
|
*
|
||||||
|
@ -231,10 +231,6 @@ public class VizEditorSystemMenu implements ISystemMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// loop through and add all the actions
|
|
||||||
for (Action act : userContributionActions) {
|
|
||||||
menuManager.add(act);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +247,10 @@ public class VizEditorSystemMenu implements ISystemMenu {
|
||||||
*/
|
*/
|
||||||
public void show(Control parent, Point displayCoordinates,
|
public void show(Control parent, Point displayCoordinates,
|
||||||
IPresentablePart currentSelection) {
|
IPresentablePart currentSelection) {
|
||||||
|
if (lastShown != null) {
|
||||||
|
lastShown.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
closeOthers.setTarget(currentSelection);
|
closeOthers.setTarget(currentSelection);
|
||||||
closeAll.update();
|
closeAll.update();
|
||||||
restore.update();
|
restore.update();
|
||||||
|
@ -260,38 +260,21 @@ public class VizEditorSystemMenu implements ISystemMenu {
|
||||||
maximize.update();
|
maximize.update();
|
||||||
close.setTarget(currentSelection);
|
close.setTarget(currentSelection);
|
||||||
|
|
||||||
// loop through all the contributed actions and update them as necessary
|
MenuManager toShow = new MenuManager(menuManager.getMenuText(),
|
||||||
List<ContributedEditorMenuAction> shouldBeShown = new ArrayList<ContributedEditorMenuAction>();
|
menuManager.getId());
|
||||||
List<ContributedEditorMenuAction> shouldBeHidden = new ArrayList<ContributedEditorMenuAction>();
|
for (IContributionItem item : menuManager.getItems()) {
|
||||||
|
toShow.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
for (ContributedEditorMenuAction action : userContributionActions) {
|
for (ContributedEditorMenuAction action : userContributionActions) {
|
||||||
action.setPart(currentSelection);
|
|
||||||
if (action.shouldBeVisible()) {
|
if (action.shouldBeVisible()) {
|
||||||
shouldBeShown.add(action);
|
action.setPart(currentSelection);
|
||||||
} else {
|
toShow.add(new ActionContributionItem(action));
|
||||||
shouldBeHidden.add(action);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IContributionItem item : menuManager.getItems()) {
|
Menu aMenu = lastShown = toShow.createContextMenu(parent);
|
||||||
if (item instanceof ActionContributionItem) {
|
toShow.update(true);
|
||||||
IAction action = ((ActionContributionItem) item).getAction();
|
|
||||||
if (shouldBeShown.contains(action)) {
|
|
||||||
shouldBeShown.remove(action);
|
|
||||||
} else if (shouldBeHidden.contains(action)) {
|
|
||||||
menuManager.remove(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldBeShown.size() > 0) {
|
|
||||||
for (ContributedEditorMenuAction action : shouldBeShown) {
|
|
||||||
menuManager.add(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Menu aMenu = menuManager.createContextMenu(parent);
|
|
||||||
menuManager.update(true);
|
|
||||||
aMenu.setLocation(displayCoordinates.x, displayCoordinates.y);
|
aMenu.setLocation(displayCoordinates.x, displayCoordinates.y);
|
||||||
aMenu.setVisible(true);
|
aMenu.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,7 @@ public abstract class AbstractVizPerspectiveManager implements
|
||||||
|
|
||||||
protected void deactivateContexts(ContextManager manager) {
|
protected void deactivateContexts(ContextManager manager) {
|
||||||
manager.deactivateContexts(this);
|
manager.deactivateContexts(this);
|
||||||
if (page != null) {
|
if (page != null && page.getActivePart() != null) {
|
||||||
manager.deactivateContexts(page.getActivePart());
|
manager.deactivateContexts(page.getActivePart());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue