diff options
Diffstat (limited to 'experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java')
-rw-r--r-- | experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java new file mode 100644 index 000000000..3684388fc --- /dev/null +++ b/experimental/swt/org.eclipse.fx.runtime.swt.e4/src/org/eclipse/fx/runtime/swt/e4/internal/SWTActiveShellFunction.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2015 EM-SOFTWARE 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: + * Christoph Keimel <c.keimel@emsw.de> - initial API and implementation + *******************************************************************************/ + +package org.eclipse.fx.runtime.swt.e4.internal; + +import javafx.stage.Stage; + +import org.eclipse.e4.core.contexts.ContextFunction; +import org.eclipse.e4.core.contexts.IEclipseContext; +import org.eclipse.e4.ui.services.IServiceConstants; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class SWTActiveShellFunction extends ContextFunction { + @Override + public Object compute(IEclipseContext context) { + Object active = context.get(IServiceConstants.ACTIVE_SHELL); + if (active != null && active instanceof Stage) { + return new Shell((Stage)active); + } + return Display.getCurrent().getActiveShell(); + } +} |