Author: yradtsevich
Date: 2010-10-29 10:00:29 -0400 (Fri, 29 Oct 2010)
New Revision: 26133
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/handlers/SelectionBarHandler.java
Log:
https://jira.jboss.org/browse/JBIDE-7430: VPE Selection Bar is not visible at first start
- replaced the method SelectionBarHandler.isEnabled() by the method
SelectionBarHandler.setEnabled(evaluationContext) which fires the command listeners for
every change.
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-29
13:14:27 UTC (rev 26132)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/SelectionBar.java 2010-10-29
14:00:29 UTC (rev 26133)
@@ -185,7 +185,6 @@
toolbar.setLayoutData(toolbarData);
createArrowButton();
- setVisible(toggleSelBarCommand.isEnabled()&&(Boolean)toggleSelBarState.getValue());
return splitter;
}
@@ -208,7 +207,8 @@
* fit in the default-size toolbars (at least under Windows XP).
* This temporary ToolItem is needed to set enough size to the toolbar.*/
ToolItem tempItem = new ToolItem(toolbar, SWT.DROP_DOWN);
- tempItem.setText("foo"); //$NON-NLS-1$
+ tempItem.setText(" "); //$NON-NLS-1$
+ tempItem.setEnabled(false);
this.getParent().layout(true, true);
tempItem.dispose();
}
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-29
13:14:27 UTC (rev 26132)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/selection/bar/handlers/SelectionBarHandler.java 2010-10-29
14:00:29 UTC (rev 26133)
@@ -17,8 +17,8 @@
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.core.expressions.IEvaluationContext;
+import org.eclipse.ui.ISources;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.menus.UIElement;
@@ -29,34 +29,41 @@
*/
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.
*/
public SelectionBarHandler() {
}
-
+
+ @Override
+ public void setEnabled(Object evaluationContext) {
+ boolean enabled = false;
+
+ if (evaluationContext instanceof IEvaluationContext) {
+ IEvaluationContext context = (IEvaluationContext) evaluationContext;
+ Object activeEditor = context.getVariable(ISources.ACTIVE_EDITOR_NAME);
+ if(activeEditor instanceof JSPMultiPageEditor){
+ JSPMultiPageEditor jspEditor = (JSPMultiPageEditor) activeEditor;
+ if(jspEditor.getSelectedPageIndex() != jspEditor.getPreviewIndex()){
+ enabled = true;
+ }
+ }
+ }
+
+ setBaseEnabled(enabled);
+ }
+
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
+ @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
HandlerUtil.toggleCommandState(event.getCommand());
return null;
}
+ @Override
public void updateElement(UIElement element, Map parameters) {
fireHandlerChanged(new HandlerEvent(this, true, false));
}