aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Rolka2013-12-17 08:43:25 (EST)
committerGerrit Code Review @ Eclipse.org2013-12-18 14:22:27 (EST)
commit1e51dbbe2f05f1283ad283126979a7a0ae1b7667 (patch)
treea96d074e83aab7e134a129d82a347182a2dae0f6
parent80780ebae073f3866a766b8ae5a23066e5cc9478 (diff)
downloadeclipse.platform.ui-1e51dbbe2f05f1283ad283126979a7a0ae1b7667.zip
eclipse.platform.ui-1e51dbbe2f05f1283ad283126979a7a0ae1b7667.tar.gz
eclipse.platform.ui-1e51dbbe2f05f1283ad283126979a7a0ae1b7667.tar.bz2
Bug 424037 - [CSS] Add support for the 'Active (no-focus)' MStackPartrefs/changes/00/19900/4
state Change-Id: I6ec1407bbb6f63d0dc3b8d19268e11c2de4a4200 Signed-off-by: Daniel Rolka <daniel.rolka@pl.ibm.com>
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java40
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java2
2 files changed, 42 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java
index a7dfce9..9dea7fe 100644
--- a/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.renderers.swt/src/org/eclipse/e4/ui/workbench/renderers/swt/WBWRenderer.java
@@ -31,12 +31,14 @@ import org.eclipse.e4.ui.css.swt.resources.SWTResourcesRegistry;
import org.eclipse.e4.ui.internal.workbench.E4Workbench;
import org.eclipse.e4.ui.internal.workbench.PartServiceSaveHandler;
import org.eclipse.e4.ui.internal.workbench.renderers.swt.SWTRenderersMessages;
+import org.eclipse.e4.ui.internal.workbench.swt.CSSConstants;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.MContext;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.basic.MPartStack;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimmedWindow;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
@@ -44,6 +46,7 @@ import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.services.IStylingEngine;
import org.eclipse.e4.ui.workbench.IPresentationEngine;
import org.eclipse.e4.ui.workbench.UIEvents;
+import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ISaveHandler;
import org.eclipse.e4.ui.workbench.modeling.IWindowCloseHandler;
@@ -128,6 +131,9 @@ public class WBWRenderer extends SWTPartRenderer {
private EventHandler sizeHandler;
private EventHandler themeDefinitionChanged;
+ @Inject
+ private EModelService modelService;
+
public WBWRenderer() {
super();
}
@@ -550,8 +556,42 @@ public class WBWRenderer extends SWTPartRenderer {
w.getContext().activate();
}
}
+ updateNonFocusState(SWT.Activate, w);
}
});
+
+ shell.addListener(SWT.Deactivate, new Listener() {
+ public void handleEvent(org.eclipse.swt.widgets.Event event) {
+ updateNonFocusState(SWT.Deactivate, w);
+ }
+ });
+ }
+ }
+
+ private void updateNonFocusState(int event, MWindow win) {
+ MPerspective perspective = modelService.getActivePerspective(win);
+ if (perspective == null) {
+ return;
+ }
+
+ List<MPartStack> stacks = modelService.findElements(perspective, null,
+ MPartStack.class, Arrays.asList(CSSConstants.CSS_ACTIVE_CLASS));
+ if (stacks.isEmpty()) {
+ return;
+ }
+
+ MPartStack stack = stacks.get(0);
+ int tagsCount = stack.getTags().size();
+ boolean hasNonFocusTag = stack.getTags().contains(
+ CSSConstants.CSS_NO_FOCUS_CLASS);
+
+ if (event == SWT.Activate && hasNonFocusTag) {
+ stack.getTags().remove(CSSConstants.CSS_NO_FOCUS_CLASS);
+ } else if (event == SWT.Deactivate && !hasNonFocusTag) {
+ stack.getTags().add(CSSConstants.CSS_NO_FOCUS_CLASS);
+ }
+ if (tagsCount != stack.getTags().size()) {
+ setCSSInfo(stack, stack.getWidget());
}
}
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java
index 31200c2..75c6ce5 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java
@@ -16,6 +16,8 @@ public class CSSConstants {
public static final String CSS_ACTIVE_CLASS = "active";
+ public static final String CSS_NO_FOCUS_CLASS = "noFocus";
+
public static final String CSS_HIGHLIGHTED_CLASS = "highlighted";
public static final String CSS_CONTENT_CHANGE_CLASS = "contentChange";