Author: mareshkau
Date: 2010-10-25 12:47:26 -0400 (Mon, 25 Oct 2010)
New Revision: 26036
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
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/selection/bar/SelectionBar.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java
Log:
https://jira.jboss.org/browse/JBIDE-7390
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-10-25 16:39:34 UTC (rev
26035)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-10-25 16:47:26 UTC (rev
26036)
@@ -313,9 +313,23 @@
id="org.jboss.tools.jst.jsp.menus.showSelectionBar"
style="toggle"
mnemonic="S">
- <visibleWhen checkEnabled="false">
- <reference definitionId="org.jboss.tools.ui.structuredEditor"/>
- </visibleWhen>
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeEditorId">
+ <or>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.DocBookEditor">
+ </equals>
+ </or>
+ </with>
+ </visibleWhen>
</command>
</menuContribution>
<menuContribution
@@ -326,9 +340,23 @@
id="org.jboss.tools.jst.jsp.toolbars.showSelectionBar"
style="toggle"
tooltip="%Toggle.Selection.Bar">
- <visibleWhen checkEnabled="false">
- <reference definitionId="org.jboss.tools.ui.structuredEditor"/>
- </visibleWhen>
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeEditorId">
+ <or>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.DocBookEditor">
+ </equals>
+ </or>
+ </with>
+ </visibleWhen>
</command>
</menuContribution>
@@ -352,9 +380,23 @@
commandId="org.jboss.tools.jst.jsp.commands.i18"
id="org.jboss.tools.jst.jsp.menus.i18"
mnemonic="S">
- <visibleWhen checkEnabled="false">
- <reference definitionId="org.jboss.tools.ui.structuredEditor"/>
- </visibleWhen>
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeEditorId">
+ <or>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.DocBookEditor">
+ </equals>
+ </or>
+ </with>
+ </visibleWhen>
</command>
</menuContribution>
<menuContribution
@@ -366,9 +408,23 @@
icon="icons/externalize.png"
id="org.jboss.tools.jst.jsp.toolbars.i18"
tooltip="%Externalize.Selected.Property">
- <visibleWhen checkEnabled="false">
- <reference definitionId="org.jboss.tools.ui.structuredEditor"/>
- </visibleWhen>
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activeEditorId">
+ <or>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.HTMLTextEditor">
+ </equals>
+ <equals
+
value="org.jboss.tools.jst.jsp.jspeditor.DocBookEditor">
+ </equals>
+ </or>
+ </with>
+ </visibleWhen>
</command>
</toolbar>
</menuContribution>
@@ -470,17 +526,6 @@
<handler
class="org.jboss.tools.jst.jsp.selection.bar.handlers.SelectionBarHandler"
commandId="org.jboss.tools.jst.jsp.commands.showSelectionBar">
- <activeWhen>
- <with variable="activeContexts">
- <iterate operator="or">
- <equals
value="org.jboss.tools.jst.jsp.selectionBar.context"/>
- </iterate>
- </with>
- </activeWhen>
-
- <enabledWhen>
- <reference
definitionId="org.jboss.tools.ui.structuredEditor"/>
- </enabledWhen>
</handler>
<handler
class="org.jboss.tools.jst.jsp.i18n.handlers.I18Handler"
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 2010-10-25
16:39:34 UTC (rev 26035)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2010-10-25
16:47:26 UTC (rev 26036)
@@ -25,7 +25,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.draw2d.GridData;
import org.eclipse.gef.ui.views.palette.PalettePage;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
@@ -53,7 +52,6 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
@@ -81,14 +79,12 @@
import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelTreeListenerSWTASync;
-import org.jboss.tools.common.model.util.XModelTreeListenerSWTSync;
import org.jboss.tools.common.text.ext.IMultiPageEditor;
import org.jboss.tools.jst.jsp.JspEditorPlugin;
import org.jboss.tools.jst.jsp.bundle.BundleMap;
import org.jboss.tools.jst.jsp.editor.IVisualEditor;
import org.jboss.tools.jst.jsp.editor.IVisualEditorFactory;
import org.jboss.tools.jst.jsp.preferences.IVpePreferencesPage;
-import org.jboss.tools.jst.jsp.selection.bar.SelectionBar;
import org.jboss.tools.jst.web.tld.VpeTaglibManager;
import org.jboss.tools.jst.web.tld.VpeTaglibManagerProvider;
@@ -138,7 +134,6 @@
static IVisualEditorFactory visualEditorFactory;
- private IContextActivation selBarContextActivation;
//added by Maksim Areshkau, notified externalize command that selection changed
private ISelectionChangedListener externalizeSelectionChangeListener = new
ISelectionChangedListener() {
@@ -245,17 +240,12 @@
visualEditor.setVisualMode(IVisualEditor.PREVIEW_MODE);
}
}
- //fix for JBIDE-7059, author Maksim Areshkau
- IContextService contextService = (IContextService) getSite()
- .getService(IContextService.class);
- if(newPageIndex!=getPreviewIndex()){
- if(selBarContextActivation==null)
- selBarContextActivation =
contextService.activateContext(SelectionBar.SELECTION_BAR_CONTEXT_ID);
- } else if(selBarContextActivation!=null){
- contextService.deactivateContext(selBarContextActivation);
- selBarContextActivation=null;
- }
+ ICommandService commandService = (ICommandService) PlatformUI
+ .getWorkbench().getService(ICommandService.class);
+ commandService.refreshElements("org.jboss.tools.jst.jsp.commands.showSelectionBar",
null); //$NON-NLS-1$
+
+
superPageChange(newPageIndex);
JspEditorPlugin.getDefault().getPreferenceStore().
setValue(IVpePreferencesPage.DEFAULT_VPE_TAB, selectedPageIndex);
@@ -647,10 +637,6 @@
}
IContextService contextService = (IContextService) getSite()
.getService(IContextService.class);
- if(selBarContextActivation!=null){
- contextService.deactivateContext(selBarContextActivation);
- selBarContextActivation=null;
- }
super.dispose();
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java 2010-10-25
16:39:34 UTC (rev 26035)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java 2010-10-25
16:47:26 UTC (rev 26036)
@@ -19,6 +19,7 @@
import org.eclipse.core.commands.ICommandListener;
import org.eclipse.core.commands.IStateListener;
import org.eclipse.core.commands.State;
+import org.eclipse.gef.Handle;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
@@ -52,6 +53,7 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
@@ -75,7 +77,6 @@
*/
public class SelectionBar extends Composite implements ISelectionChangedListener,
IStateListener,ICommandListener{
private static final int SEL_ITEM_RIGHT_MARGIN = 5;
- public static final String
SELECTION_BAR_CONTEXT_ID="org.jboss.tools.jst.jsp.selectionBar.context";
//$NON-NLS-1$
/*
* The main composite that holds all other controls
*/
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java 2010-10-25
16:39:34 UTC (rev 26035)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java 2010-10-25
16:47:26 UTC (rev 26036)
@@ -11,16 +11,37 @@
package org.jboss.tools.jst.jsp.selection.bar.handlers;
+import java.util.Map;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.HandlerEvent;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.menus.UIElement;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
/**
* Selection bar handler
*/
-public class SelectionBarHandler extends AbstractHandler {
+public class SelectionBarHandler extends AbstractHandler implements IElementUpdater{
+
+ @Override
+ public boolean isEnabled() {
+ boolean result=false;
+ IEditorPart activeEditor= PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ if(activeEditor instanceof JSPMultiPageEditor){
+ JSPMultiPageEditor jspEditor = (JSPMultiPageEditor) activeEditor;
+ if(jspEditor.getSelectedPageIndex()!=jspEditor.getPreviewIndex()){
+ result=true;
+ }
+ }
+ return result;
+ }
/**
* The constructor.
*/
@@ -32,14 +53,12 @@
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
-// IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
HandlerUtil.toggleCommandState(event.getCommand());
-// if(!togleState){
-// ((ISelectionBarController)activeEditor).showSelectionBar();
-// }else{
-// ((ISelectionBarController)activeEditor).hideSelectionBar();
-// }
return null;
}
+ public void updateElement(UIElement element, Map parameters) {
+ fireHandlerChanged(new HandlerEvent(this, true, false));
+ }
+
}