From d01d5fa2840db0f45686da314890f5c797522c17 Mon Sep 17 00:00:00 2001 From: "changhyun1.lee" Date: Tue, 19 Jul 2011 20:45:10 +0900 Subject: [PATCH] [WAC]added getWorkbenchWindow function --- .../src/com/samsung/ide/common/util/ViewUtil.java | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/com.samsung.ide.common/src/com/samsung/ide/common/util/ViewUtil.java b/com.samsung.ide.common/src/com/samsung/ide/common/util/ViewUtil.java index 0a12ee3..8e94bae 100644 --- a/com.samsung.ide.common/src/com/samsung/ide/common/util/ViewUtil.java +++ b/com.samsung.ide.common/src/com/samsung/ide/common/util/ViewUtil.java @@ -39,16 +39,10 @@ public class ViewUtil { @Override public void run() { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IWorkbenchWindow window = getWorkbenchWindow(); if (window == null) { - if (workbench.getWorkbenchWindowCount() == 1) { - window = workbench.getWorkbenchWindows()[0]; - } - } - - if (window == null) return; + } try { window.getActivePage().showView(id); @@ -59,19 +53,13 @@ public class ViewUtil { } public static IViewPart getView(final String id) { - IViewPart view = null; - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + IWorkbenchWindow window = getWorkbenchWindow(); if (window == null) { - if (workbench.getWorkbenchWindowCount() == 1) { - window = workbench.getWorkbenchWindows()[0]; - } - } - - if (window == null) return null; + } + IViewPart view = null; try { view = window.getActivePage().showView(id); } catch (PartInitException e) { @@ -80,4 +68,16 @@ public class ViewUtil { return view; } -} + public static IWorkbenchWindow getWorkbenchWindow() { + IWorkbench workbench = PlatformUI.getWorkbench(); + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + if (window == null) { + if (workbench.getWorkbenchWindowCount() == 1) { + window = workbench.getWorkbenchWindows()[0]; + } + } + + return window; + } + +} \ No newline at end of file -- 2.7.4