Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2013-07-18 11:49:04 -0400
committerTom Schindl2013-07-18 11:49:04 -0400
commita06d26e6be4d521bc0dcc57716a7351f7688559f (patch)
treebac003f30ef7397d39ab2f89dbe9db9a2180b159
parent62b0529ad4b1dfbedb44ff072be064cc9ff6a72d (diff)
downloadorg.eclipse.efxclipse-a06d26e6be4d521bc0dcc57716a7351f7688559f.tar.gz
org.eclipse.efxclipse-a06d26e6be4d521bc0dcc57716a7351f7688559f.tar.xz
org.eclipse.efxclipse-a06d26e6be4d521bc0dcc57716a7351f7688559f.zip
Bug 413260 - The current focus-control should be avaiable through the
IEclipseContext
-rw-r--r--bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java16
-rwxr-xr-xbundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java17
2 files changed, 32 insertions, 1 deletions
diff --git a/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java
new file mode 100644
index 000000000..b9a2a1ddd
--- /dev/null
+++ b/bundles/runtime/org.eclipse.fx.ui.services/src/org/eclipse/fx/ui/services/Constants.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2013 __COMPANY/CONTRIBUTOR__ and others.
+ * All rights reserved. This program and the accompanying materials
+ * are 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:
+ * tomschindl<__EMAIL__> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.fx.ui.services;
+
+public class Constants {
+ public static final String WINDOW_FOCUS_NODE = "efx_WINDOW_FOCUS_NODE";
+ public static final String APP_FOCUS_NODE = "efx_APP_FOCUS_NODE";
+}
diff --git a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
index 233271be0..6e51b6ccb 100755
--- a/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
+++ b/bundles/runtime/org.eclipse.fx.ui.workbench.renderers.fx/src/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java
@@ -62,6 +62,7 @@ import javax.inject.Named;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.translation.TranslationService;
+import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
@@ -76,6 +77,7 @@ import org.eclipse.fx.ui.dialogs.Dialog;
import org.eclipse.fx.ui.dialogs.MessageDialog;
import org.eclipse.fx.ui.dialogs.MessageDialog.QuestionCancelResult;
import org.eclipse.fx.ui.panes.FillLayoutPane;
+import org.eclipse.fx.ui.services.Constants;
import org.eclipse.fx.ui.services.theme.Theme;
import org.eclipse.fx.ui.services.theme.ThemeManager;
import org.eclipse.fx.ui.services.theme.ThemeManager.Registration;
@@ -178,10 +180,14 @@ public class DefWindowRenderer extends BaseWindowRenderer<Stage> {
private boolean undecorated;
+ private IEclipseContext applicationContext;
+
@Inject
- public WWindowImpl(@Named(BaseRenderer.CONTEXT_DOM_ELEMENT) MWindow mWindow, @Optional KeyBindingDispatcher dispatcher) {
+ public WWindowImpl(@Named(BaseRenderer.CONTEXT_DOM_ELEMENT) MWindow mWindow, @Optional KeyBindingDispatcher dispatcher, MApplication application) {
this.mWindow = mWindow;
+ applicationContext = application.getContext();
+
if( mWindow.getPersistedState().get("fx.scene.3d") != null ) {
System.err.println("Usage of deprecated persisted state 'fx.scene.3d' please use 'efx.window.scene.3d' instead.");
this.support3d = Boolean.parseBoolean(mWindow.getPersistedState().get("fx.scene.3d"));
@@ -222,6 +228,10 @@ public class DefWindowRenderer extends BaseWindowRenderer<Stage> {
@Override
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
if( newValue.booleanValue() ) {
+ if( stage.getScene() != null ) {
+ applicationContext.set(Constants.APP_FOCUS_NODE,stage.getScene().getFocusOwner());
+ }
+
activate();
}
}
@@ -284,6 +294,11 @@ public class DefWindowRenderer extends BaseWindowRenderer<Stage> {
@Override
public void changed(ObservableValue<? extends Node> observable, Node oldValue, Node newValue) {
+ modelContext.set(Constants.WINDOW_FOCUS_NODE, newValue);
+ if( stage.isFocused() ) {
+ applicationContext.set(Constants.APP_FOCUS_NODE, newValue);
+ }
+
if (newValue != null) {
final List<WWidget<?>> activationTree = new ArrayList<WWidget<?>>();

Back to the top