[101529] Editor Source menu broken - There is no Source menu for the XSD Editor. This will also fix the Undo/Redo actions.
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java
index 06ec006..9e28558 100644
--- a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/XSDActionBarContributor.java
@@ -23,6 +23,7 @@
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
@@ -32,16 +33,20 @@
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.RetargetTextEditorAction;
+import org.eclipse.wst.sse.ui.internal.ISourceViewerActionBarContributor;
+import org.eclipse.wst.sse.ui.internal.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.actions.StructuredTextEditorActionConstants;
import org.eclipse.wst.xsd.ui.internal.actions.ISchemaEditorActionConstants;
import org.eclipse.wst.xsd.ui.internal.actions.ReloadDependenciesAction;
+import org.eclipse.wst.xsd.ui.internal.actions.SourcePageActionContributor;
import org.eclipse.wst.xsd.ui.internal.refactor.actions.RefactorActionGroup;
public class XSDActionBarContributor extends MultiPageEditorActionBarContributor
{
protected XSDEditor xsdEditor;
protected XSDTextEditor textEditor;
-
+ protected IEditorActionBarContributor sourceViewerActionContributor = null;
+
protected ReloadDependenciesAction reloadDependenciesAction;
protected List fPartListeners= new ArrayList();
@@ -56,6 +61,8 @@
public XSDActionBarContributor()
{
super();
+
+ sourceViewerActionContributor = new SourcePageActionContributor();
// Reload Dependencies
reloadDependenciesAction = new ReloadDependenciesAction(XSDEditorPlugin.getXSDString("_UI_MENU_RELOAD_DEPENDENCIES"));
@@ -95,8 +102,36 @@
public void setActivePage(IEditorPart activeEditor)
{
updateActions();
+
+ if (activeEditor != null && activeEditor instanceof StructuredTextEditor)
+ {
+ activateSourcePage(activeEditor, true);
+ }
+ else
+ {
+ activateSourcePage(xsdEditor, false);
+ }
+
+ IActionBars actionBars = getActionBars();
+ if (actionBars != null) {
+ // update menu bar and tool bar
+ actionBars.updateActionBars();
+ }
+
+ updateAction(IWorkbenchActionConstants.UNDO, ITextEditorActionConstants.UNDO, true);
+ updateAction(IWorkbenchActionConstants.REDO, ITextEditorActionConstants.REDO, true);
+
getActionBars().updateActionBars();
}
+
+ protected void activateSourcePage(IEditorPart activeEditor, boolean state)
+ {
+ if (sourceViewerActionContributor != null && sourceViewerActionContributor instanceof ISourceViewerActionBarContributor)
+ {
+ sourceViewerActionContributor.setActiveEditor(activeEditor);
+ ((ISourceViewerActionBarContributor) sourceViewerActionContributor).setViewerSpecificContributionsEnabled(state);
+ }
+ }
protected void updateAction(String globalActionId, String textEditorActionId, boolean enable)
{
@@ -166,8 +201,6 @@
*/
public void setActiveEditor(IEditorPart targetEditor)
{
- super.setActiveEditor(targetEditor);
-
if (targetEditor instanceof XSDEditor)
{
xsdEditor = (XSDEditor) targetEditor;
@@ -176,12 +209,16 @@
textEditor = ((XSDEditor)targetEditor).getXSDTextEditor();
if (textEditor != null)
{
-
- renameElementAction.setAction(getAction(textEditor, ISchemaEditorActionConstants.RETARGET_RENAME_ELEMENT_ACTION_ID));
+
+ renameElementAction.setAction(getAction(textEditor, ISchemaEditorActionConstants.RETARGET_RENAME_ELEMENT_ACTION_ID));
updateActions();
getActionBars().updateActionBars();
}
}
+ super.setActiveEditor(targetEditor);
+
+ updateAction(IWorkbenchActionConstants.UNDO, ITextEditorActionConstants.UNDO, true);
+ updateAction(IWorkbenchActionConstants.REDO, ITextEditorActionConstants.REDO, true);
}
public void init(IActionBars bars, IWorkbenchPage page)
@@ -195,7 +232,24 @@
// register actions that have a dynamic editor.
bars.setGlobalActionHandler(ISchemaEditorActionConstants.RETARGET_RELOAD_DEPENDENCIES_ACTION_ID, reloadDependenciesAction);
-
+
+ initSourceViewerActionContributor(bars);
+
super.init(bars, page);
}
+
+ protected void initSourceViewerActionContributor(IActionBars actionBars) {
+ if (sourceViewerActionContributor != null)
+ sourceViewerActionContributor.init(actionBars, getPage());
+ }
+
+
+ public void dispose()
+ {
+ super.dispose();
+
+ if (sourceViewerActionContributor != null)
+ sourceViewerActionContributor.dispose();
+ }
+
}
diff --git a/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SourcePageActionContributor.java b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SourcePageActionContributor.java
new file mode 100644
index 0000000..8bc62ca
--- /dev/null
+++ b/bundles/org.eclipse.wst.xsd.ui/src/org/eclipse/wst/xsd/ui/internal/actions/SourcePageActionContributor.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.wst.xsd.ui.internal.actions;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.wst.xml.ui.internal.actions.ActionContributorXML;
+
+
+/**
+ * SourcePageActionContributor
+ *
+ * This class is for multi page editor's source page contributor.
+ *
+ *
+ */
+public class SourcePageActionContributor extends ActionContributorXML {
+
+ private IActionBars fBars;
+
+ /**
+ * This method calls:
+ * <ul>
+ * <li><code>contributeToMenu</code> with <code>bars</code>' menu manager</li>
+ * <li><code>contributeToToolBar</code> with <code>bars</code>' tool bar
+ * manager</li>
+ * <li><code>contributeToStatusLine</code> with <code>bars</code>' status line
+ * manager</li>
+ * </ul>
+ * The given action bars are also remembered and made accessible via
+ * <code>getActionBars</code>.
+ *
+ * @param bars the action bars
+ *
+ */
+ public void init(IActionBars bars) {
+ fBars = bars;
+ contributeToMenu(bars.getMenuManager());
+ contributeToToolBar(bars.getToolBarManager());
+ contributeToStatusLine(bars.getStatusLineManager());
+ }
+
+ /**
+ * Returns this contributor's action bars.
+ *
+ * @return the action bars
+ */
+ public IActionBars getActionBars() {
+ return fBars;
+ }
+}
\ No newline at end of file