Author: vrubezhny
Date: 2012-10-11 18:16:44 -0400 (Thu, 11 Oct 2012)
New Revision: 44449
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
Log:
JBIDE-12534
Some key combinations don't work in JBT XHTML Editor
Issue is fixed
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2012-10-11
21:20:39 UTC (rev 44448)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2012-10-11
22:16:44 UTC (rev 44449)
@@ -41,7 +41,6 @@
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorInput;
@@ -227,6 +226,14 @@
return true;
}
+
+ /*
+ * The method is @Deprecated and is not consistent with a real
+ * MultiPageEditorPart.pageChange(int newPageIndex) method
+ *
+ * So, this one is removed as of JBIDE-JBIDE-12534
+ *
+
public void superPageChange(int newPageIndex) {
Control control = getControl(visualSourceIndex);
if (control != null) {
@@ -252,7 +259,8 @@
}
}
}
-
+ */
+
@Override
public void pageChange(int newPageIndex) {
selectedPageIndex = newPageIndex;
@@ -323,7 +331,9 @@
commandService.refreshElements(SelectionBarHandler.COMMAND_ID, null);
getSelectionBar().refreshVisibility();
- superPageChange(selectedPageIndex);
+ super.pageChange(selectedPageIndex); // The call to real
super.pageChange(newPageIndex)
+ // is returned back because of JBIDE-12534
+
JspEditorPlugin.getDefault().getPreferenceStore().
setValue(IVpePreferencesPage.DEFAULT_VPE_TAB, selectedPageIndex);
}
@@ -486,22 +496,22 @@
case 0: {
// source/visual mode
setActivePage(selectedPageIndex);
- pageChange(selectedPageIndex);
+// pageChange(selectedPageIndex);
break;
} case 1: {
// source mode
setActivePage(selectedPageIndex);
- pageChange(selectedPageIndex);
+// pageChange(selectedPageIndex);
break;
} case 2: {
// preview mode
setActivePage(selectedPageIndex);
- pageChange(selectedPageIndex);
+// pageChange(selectedPageIndex);
break;
} default: {
// by default we sets source/visual mode
setActivePage(0);
- pageChange(0);
+// pageChange(0);
break;
}
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java 2012-10-11
21:20:39 UTC (rev 44448)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorPart.java 2012-10-11
22:16:44 UTC (rev 44449)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Red Hat, Inc.
+ * Copyright (c) 2011-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -151,8 +151,6 @@
site.setSelectionProvider(new JSPMultiPageSelectionProvider(this));
}
- protected abstract void pageChange(int newPageIndex);
-
private void disposePart(final IWorkbenchPart part) {
SafeRunner.run(new SafeRunnable() {
public void run() {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java 2012-10-11
21:20:39 UTC (rev 44448)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditorSite.java 2012-10-11
22:16:44 UTC (rev 44449)
@@ -1,173 +1,51 @@
/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Copyright (c) 2007-2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is 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:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ * Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.jst.jsp.jspeditor;
-import java.util.ArrayList;
-
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jst.jsp.core.internal.provisional.contenttype.ContentTypeIdForJSP;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorActionBarContributor;
import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IKeyBindingService;
-import org.eclipse.ui.INestableKeyBindingService;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.KeyBindingService;
-import org.eclipse.ui.internal.PopupMenuExtender;
-import org.eclipse.ui.internal.WorkbenchPlugin;
-import org.eclipse.ui.internal.services.IServiceLocatorCreator;
-import org.eclipse.ui.internal.services.IWorkbenchLocationService;
-import org.eclipse.ui.internal.services.ServiceLocator;
-import org.eclipse.ui.internal.services.WorkbenchLocationService;
-import org.eclipse.ui.services.IServiceScopes;
+import org.eclipse.ui.part.MultiPageEditorSite;
/**
*
* @author eskimo(dgolovin(a)exadel.com)
*
*/
-public abstract class JSPMultiPageEditorSite implements IEditorSite {
+public abstract class JSPMultiPageEditorSite extends MultiPageEditorSite {
- private IEditorPart fEditorPart;
-
- private JSPMultiPageEditorPart fEditor;
-
private ISelectionChangedListener fSelChangeListener = null;
-
- //private IKeyBindingService fParentService = null;
-
- private IKeyBindingService fService = null;
-
- private ArrayList fMenuExts;
-
- private final ServiceLocator serviceLocator;
public JSPMultiPageEditorSite(JSPMultiPageEditorPart multiPageEditor,
IEditorPart editor) {
- Assert.isNotNull(multiPageEditor);
- Assert.isNotNull(editor);
- this.fEditor = multiPageEditor;
- this.fEditorPart = editor;
-
- /*
- *
https://issues.jboss.org/browse/JBIDE-11578
- * IDisposable was removed to fix compilation error in Juno.
- */
- this.serviceLocator = (ServiceLocator) ((IServiceLocatorCreator) multiPageEditor
- .getSite().getService(IServiceLocatorCreator.class))
- .createServiceLocator(multiPageEditor.getSite(), null, null);
-
- serviceLocator.registerService(IWorkbenchLocationService.class,
- new WorkbenchLocationService(IServiceScopes.MPESITE_SCOPE,
- getWorkbenchWindow().getWorkbench(),
- getWorkbenchWindow(), multiPageEditor.getSite(), this,
- null, 3));
+ super(multiPageEditor, editor);
}
public void dispose() {
- if (fMenuExts != null) {
- for (int i = 0; i < fMenuExts.size(); i++) {
- ((PopupMenuExtender) fMenuExts.get(i)).dispose();
- }
- fMenuExts = null;
- }
-
- if (fService != null) {
- IKeyBindingService parentService = getEditor().getSite()
- .getKeyBindingService();
- if (parentService instanceof INestableKeyBindingService) {
- INestableKeyBindingService nestableParent = (INestableKeyBindingService)
parentService;
- nestableParent.removeKeyBindingService(this);
- }
- if (fService instanceof KeyBindingService) {
- ((KeyBindingService) fService).dispose();
- }
- fService = null;
- }
+ super.dispose();
+
if (fSelChangeListener != null) {
getSelectionProvider().removeSelectionChangedListener(fSelChangeListener);
fSelChangeListener = null;
}
- if (serviceLocator != null) {
- serviceLocator.dispose();
- }
}
- public IEditorActionBarContributor getActionBarContributor() {
- return null;
- }
-
- public IActionBars getActionBars() {
- return fEditor.getEditorSite().getActionBars();
- }
-
- public ILabelDecorator getDecoratorManager() {
- return getWorkbenchWindow().getWorkbench().getDecoratorManager()
- .getLabelDecorator();
- }
-
- public IEditorPart getEditor() {
- return fEditorPart;
- }
-
public String getId() {
return ContentTypeIdForJSP.ContentTypeID_JSP + ".source"; //$NON-NLS-1$;
}
- public IKeyBindingService getKeyBindingService() {
- if (fService == null) {
- fService = getMultiPageEditor().getEditorSite()
- .getKeyBindingService();
- //fParentService = fService;
- if (fService instanceof INestableKeyBindingService) {
- INestableKeyBindingService nestableService = (INestableKeyBindingService) fService;
- fService = nestableService.getKeyBindingService(this);
-
- } else {
- WorkbenchPlugin
- .log("MultiPageEditorSite.getKeyBindingService() Parent key binding fService
was not an instance of INestableKeyBindingService. It was an instance of " +
fService.getClass().getName() + " instead."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return fService;
- }
-
- public JSPMultiPageEditorPart getMultiPageEditor() {
- return fEditor;
- }
-
- public IWorkbenchPage getPage() {
- return getMultiPageEditor().getSite().getPage();
- }
-
- public String getPluginId() {
- return ""; //$NON-NLS-1$
- }
-
- public String getRegisteredName() {
- return ""; //$NON-NLS-1$
- }
-
protected ISelectionChangedListener getSelectionChangedListener() {
if (fSelChangeListener == null) {
fSelChangeListener = new ISelectionChangedListener() {
@@ -179,10 +57,6 @@
return fSelChangeListener;
}
- public Shell getShell() {
- return getMultiPageEditor().getSite().getShell();
- }
-
public IWorkbenchWindow getWorkbenchWindow() {
if(getMultiPageEditor().getSite() == null) // fix JBIDE-2218
return null; // fix JBIDE-2218
@@ -200,95 +74,20 @@
}
}
- public void registerContextMenu(String menuID, MenuManager menuMgr,
- ISelectionProvider selProvider) {
- if (fMenuExts == null) {
- fMenuExts = new ArrayList(1);
+ protected void handlePostSelectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider parentProvider = getMultiPageEditor().getSite()
+ .getSelectionProvider();
+ if (parentProvider instanceof JSPMultiPageSelectionProvider) {
+ SelectionChangedEvent newEvent = new SelectionChangedEvent(
+ parentProvider, event.getSelection());
+ ((JSPMultiPageSelectionProvider) parentProvider)
+ .firePostSelectionChanged(newEvent);
}
- PopupMenuExtender extender = findMenuExtender(menuMgr, selProvider);
- if (findMenuExtender(menuMgr, selProvider) == null) {
- extender = new PopupMenuExtender(menuID, menuMgr,
- selProvider, fEditorPart);
- fMenuExts.add(extender);
- }else {
- extender.addMenuId(menuID);
- }
}
-
- private PopupMenuExtender findMenuExtender(MenuManager menuMgr,
- ISelectionProvider selProvider) {
- for (int i = 0; fMenuExts != null && i < fMenuExts.size(); i++) {
- PopupMenuExtender extender = (PopupMenuExtender) fMenuExts
- .get(i);
- if (extender.matches(menuMgr, selProvider, fEditorPart))
- return extender;
- }
- return null;
- }
-
- public void registerContextMenu(MenuManager menuManager,
- ISelectionProvider selProvider) {
- getMultiPageEditor().getSite().registerContextMenu(menuManager,
- selProvider);
- }
-
+
public void progressEnd(Job job) {
}
public void progressStart(Job job) {
}
-
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- public IWorkbenchPart getPart() {
- return this.fEditor;
- }
-
- public final void registerContextMenu(final MenuManager menuManager,
- final ISelectionProvider selectionProvider,
- final boolean includeEditorInput) {
- registerContextMenu(getId(), menuManager, selectionProvider,
- includeEditorInput);
- }
-
- public final void registerContextMenu(final String menuId,
- final MenuManager menuManager,
- final ISelectionProvider selectionProvider,
- final boolean includeEditorInput) {
- if (fMenuExts == null) {
- fMenuExts = new ArrayList(1);
- }
- }
-
- public Object getService(Class api) {
- // TODO megration to eclipse 3.2
- return this.serviceLocator.getService(api);
- }
-
- public boolean hasService(Class api) {
- // TODO megration to eclipse 3.2
- return this.serviceLocator.hasService(api);
- }
-
- /**
- * Notifies the multi page editor service that the component within which it
- * exists has become active.
- *
- * @since 3.2
- */
- public final void activate() {
- serviceLocator.activate();
- }
-
- /**
- * Notifies the multi page editor service that the component within which it
- * exists has been deactived.
- *
- * @since 3.2
- */
- public final void deactivate() {
- serviceLocator.deactivate();
- }
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2012-10-11
21:20:39 UTC (rev 44448)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2012-10-11
22:16:44 UTC (rev 44449)
@@ -71,7 +71,6 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.editors.text.ILocationProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -351,10 +350,6 @@
public void createPartControl(Composite parent) {
super.createPartControl(parent);
- IContextService contextService = (IContextService)
getSite().getService(IContextService.class);
- if (contextService != null)
- contextService.activateContext(TEXT_EDITOR_KEYBINDING_SCOPE_ID);
-
StructuredTextOccurrenceStructureProviderRegistry registry = XmlEditorPlugin
.getDefault().getOccurrenceStructureProviderRegistry(
JspEditorPlugin.PLUGIN_ID);