Author: mareshkau
Date: 2010-09-20 14:36:02 -0400 (Mon, 20 Sep 2010)
New Revision: 25035
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
Log:
JBIDE-7059,selection bar menu visabilty has been adjusted
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-09-20 18:34:05 UTC (rev
25034)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/plugin.xml 2010-09-20 18:36:02 UTC (rev
25035)
@@ -429,9 +429,14 @@
<handler
class="org.jboss.tools.jst.jsp.selection.bar.handlers.SelectionBarHandler"
commandId="org.jboss.tools.jst.jsp.commands.showSelectionBar">
- <activeWhen>
- <reference
definitionId="org.jboss.tools.ui.structuredEditor"/>
- </activeWhen>
+ <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>
@@ -918,5 +923,14 @@
</contentType>
</proposalComputer>
</extension>
+ <extension
+ point="org.eclipse.ui.contexts">
+ <context
+ description="Context to allow activate and deactivate selection
bar"
+ id="org.jboss.tools.jst.jsp.selectionBar.context"
+ name="Selection Bar"
+ parentId="org.eclipse.ui.contexts.window">
+ </context>
+ </extension>
</plugin>
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-09-20
18:34:05 UTC (rev 25034)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPMultiPageEditor.java 2010-09-20
18:36:02 UTC (rev 25035)
@@ -50,6 +50,8 @@
import org.eclipse.ui.IPropertyListener;
import org.eclipse.ui.IReusableEditor;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.contexts.IContextActivation;
+import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
import org.eclipse.ui.texteditor.AbstractTextEditor;
@@ -82,6 +84,7 @@
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;
@@ -128,6 +131,8 @@
int selectedPageIndex = 0;
static IVisualEditorFactory visualEditorFactory;
+
+ private IContextActivation selBarContextActivation;
static {
// Fix For JBIDE-2674
@@ -221,6 +226,17 @@
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;
+ }
+
superPageChange(newPageIndex);
JspEditorPlugin.getDefault().getPreferenceStore().
setValue(IVpePreferencesPage.DEFAULT_VPE_TAB, selectedPageIndex);
@@ -823,8 +839,6 @@
public int getVisualSourceIndex() {
return visualSourceIndex;
}
-
-}
class ResourceChangeListener implements IResourceChangeListener {
IEditorPart editorPart;
@@ -949,5 +963,4 @@
}
return null;
}
-
-}
\ No newline at end of file
+}}
\ No newline at end of file
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-09-20
18:34:05 UTC (rev 25034)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java 2010-09-20
18:36:02 UTC (rev 25035)
@@ -20,6 +20,8 @@
import org.eclipse.core.commands.ICommandListener;
import org.eclipse.core.commands.IStateListener;
import org.eclipse.core.commands.State;
+import org.eclipse.core.commands.contexts.ContextManagerEvent;
+import org.eclipse.core.commands.contexts.IContextManagerListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
@@ -52,6 +54,7 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.WorkbenchImages;
@@ -75,11 +78,13 @@
* @author yradtsevich
* @author mareshkau
*/
-public class SelectionBar implements ISelectionChangedListener, IStateListener{
+public class SelectionBar 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";
private Splitter splitter;
@@ -108,6 +113,9 @@
"org.jboss.tools.jst.jsp.commands.showSelectionBar") //$NON-NLS-1$
.getState("org.eclipse.ui.commands.toggleState"); //$NON-NLS-1$
toggleSelBarState.addListener(this);
+ commandService.getCommand(
+ "org.jboss.tools.jst.jsp.commands.showSelectionBar"). //$NON-NLS-1$
+ addCommandListener(this);
}
/**
@@ -648,6 +656,11 @@
public void handleStateChange(State state, Object oldValue) {
setVisible((Boolean)state.getValue());
}
+
+ @Override
+ public void commandChanged(CommandEvent commandEvent) {
+ setVisible(commandEvent.getCommand().isEnabled()&&(Boolean)commandEvent.getCommand().getState("org.eclipse.ui.commands.toggleState").getValue());
//$NON-NLS-1$
+ }
}
/**
Show replies by date