| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.uruma.util; |
| 17 | |
|
| 18 | |
import org.eclipse.swt.widgets.Display; |
| 19 | |
import org.eclipse.swt.widgets.Shell; |
| 20 | |
import org.seasar.framework.container.S2Container; |
| 21 | |
import org.seasar.framework.container.factory.SingletonS2ContainerFactory; |
| 22 | |
import org.seasar.uruma.context.ApplicationContext; |
| 23 | |
import org.seasar.uruma.context.WidgetHandle; |
| 24 | |
import org.seasar.uruma.context.WindowContext; |
| 25 | |
import org.seasar.uruma.core.UrumaConstants; |
| 26 | |
import org.seasar.uruma.rcp.UrumaService; |
| 27 | |
import org.seasar.uruma.rcp.util.UrumaServiceUtil; |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | 0 | public class ShellUtil { |
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
public static Shell getShell() { |
| 41 | 0 | UrumaService service = UrumaServiceUtil.getService(); |
| 42 | 0 | if (service != null) { |
| 43 | 0 | return service.getWorkbench().getActiveWorkbenchWindow().getShell(); |
| 44 | |
} else { |
| 45 | 0 | S2Container container = SingletonS2ContainerFactory.getContainer(); |
| 46 | 0 | ApplicationContext context = (ApplicationContext) container |
| 47 | |
.getComponent(ApplicationContext.class); |
| 48 | 0 | WindowContext wContext = context.getWindowContexts().iterator() |
| 49 | |
.next(); |
| 50 | 0 | WidgetHandle handle = wContext |
| 51 | |
.getWidgetHandle(UrumaConstants.SHELL_CID); |
| 52 | 0 | if (handle != null) { |
| 53 | 0 | return handle.<Shell> getCastWidget(); |
| 54 | |
} else { |
| 55 | 0 | return Display.getCurrent().getActiveShell(); |
| 56 | |
} |
| 57 | |
} |
| 58 | |
} |
| 59 | |
} |