| author | ChunQiu Ji | 2011-09-21 20:15:19 (EDT) |
|---|---|---|
| committer | Brian Payton | 2011-09-21 20:15:19 (EDT) |
| commit | 4319f42a60a3c121598307e955551ee6c1722d0e (patch) (side-by-side diff) | |
| tree | 0add60a4bd5b23561f075317fa25f86694b4957e | |
| parent | 4049b69c8ef175b8d95b10e9416821542ff96e0d (diff) | |
| download | org.eclipse.datatools.sqltools-4319f42a60a3c121598307e955551ee6c1722d0e.zip org.eclipse.datatools.sqltools-4319f42a60a3c121598307e955551ee6c1722d0e.tar.gz org.eclipse.datatools.sqltools-4319f42a60a3c121598307e955551ee6c1722d0e.tar.bz2 | |
Checked in change for bug 356865.v201109230800
| -rw-r--r-- | plugins/org.eclipse.datatools.sqltools.result.ui/src/org/eclipse/datatools/sqltools/result/ui/ResultViewUIUtil.java | 139 |
1 files changed, 85 insertions, 54 deletions
diff --git a/plugins/org.eclipse.datatools.sqltools.result.ui/src/org/eclipse/datatools/sqltools/result/ui/ResultViewUIUtil.java b/plugins/org.eclipse.datatools.sqltools.result.ui/src/org/eclipse/datatools/sqltools/result/ui/ResultViewUIUtil.java index 1c34aec..71e583f 100644 --- a/plugins/org.eclipse.datatools.sqltools.result.ui/src/org/eclipse/datatools/sqltools/result/ui/ResultViewUIUtil.java +++ b/plugins/org.eclipse.datatools.sqltools.result.ui/src/org/eclipse/datatools/sqltools/result/ui/ResultViewUIUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 Sybase, Inc. + * Copyright (c) 2005, 2011 Sybase, Inc. 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.datatools.sqltools.result.ui; -import org.eclipse.core.runtime.Assert; import org.eclipse.datatools.sqltools.result.OperationCommand; import org.eclipse.datatools.sqltools.result.ResultsConstants; import org.eclipse.datatools.sqltools.result.internal.ui.utils.Images; @@ -21,7 +20,15 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; -public class ResultViewUIUtil { +public class ResultViewUIUtil +{ + private static ResultViewUIUtil instance = new ResultViewUIUtil(); + private UIRunnable uiRunnable; + + public ResultViewUIUtil() + { + uiRunnable = new UIRunnable(); + } /** * Returns the image of given OperationCommand status @@ -58,57 +65,14 @@ public class ResultViewUIUtil { * @return <code>true</code> if operation succeeds; <code>false</code> otherwise */ static public ResultsView checkResultView() - { - // get the active window - IWorkbenchWindow activeWindow = ResultsViewUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); - - // if can not find the active window, select one from the workbench windows list - if (activeWindow == null) - { - IWorkbenchWindow[] windows = ResultsViewUIPlugin.getDefault().getWorkbench().getWorkbenchWindows(); - for (int i = 0; i < windows.length; i++) - { - activeWindow = windows[0]; - if (activeWindow != null) - { - break; - } - } - if (activeWindow == null) - { - return null; - } - } - - // get the active page in this window - final IWorkbenchPage activePage = getActivePage(activeWindow); - - if (activePage == null) - { - return null; - } - - activeWindow.getShell().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - IViewPart view = activePage.findView(ResultsConstants.SQL_RESULTS_VIEW_ID); - if(activePage.isPartVisible(view)) - { - return; - } - activePage.showView(ResultsConstants.SQL_RESULTS_VIEW_ID, null, IWorkbenchPage.VIEW_VISIBLE); - } - catch (PartInitException ex) - { - ResultsViewUIPlugin.getLogger(null).error("ResultsViewAPI_checkview_error", ex); //$NON-NLS-1$ - } - } - }); - - return (ResultsView)activePage.findView(ResultsConstants.SQL_RESULTS_VIEW_ID); + { + ResultsViewUIPlugin.getDefault().getWorkbench().getDisplay().syncExec(ResultViewUIUtil.instance.uiRunnable); + if ( ResultViewUIUtil.instance.uiRunnable.getActiveWindow() == null || + ResultViewUIUtil.instance.uiRunnable.getActivePage() == null ) + { + return null; + } + return (ResultsView)ResultViewUIUtil.instance.uiRunnable.getActivePage().findView(ResultsConstants.SQL_RESULTS_VIEW_ID); } static private IWorkbenchPage getActivePage(IWorkbenchWindow activeWindow) @@ -132,4 +96,71 @@ public class ResultViewUIUtil { return activePage; } + + private class UIRunnable implements Runnable + { + private IWorkbenchWindow activeWindow = null; + private IWorkbenchPage activePage = null; + + public void run() + { + activeWindow = ResultsViewUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); + + // if can not find the active window, select one from the workbench windows list + if (activeWindow == null) + { + IWorkbenchWindow[] windows = ResultsViewUIPlugin.getDefault().getWorkbench().getWorkbenchWindows(); + for (int i = 0; i < windows.length; i++) + { + activeWindow = windows[0]; + if (activeWindow != null) + { + break; + } + } + if (activeWindow == null) + { + return; + } + } + + // get the active page in this window + activePage = ResultViewUIUtil.getActivePage(activeWindow); + + if (activePage == null) + { + return; + } + + activeWindow.getShell().getDisplay().syncExec(new Runnable() + { + public void run() + { + try + { + IViewPart view = activePage.findView(ResultsConstants.SQL_RESULTS_VIEW_ID); + if(activePage.isPartVisible(view)) + { + return; + } + activePage.showView(ResultsConstants.SQL_RESULTS_VIEW_ID, null, IWorkbenchPage.VIEW_VISIBLE); + } + catch (PartInitException ex) + { + ResultsViewUIPlugin.getLogger(null).error("ResultsViewAPI_checkview_error", ex); //$NON-NLS-1$ + } + } + }); + } + + public IWorkbenchWindow getActiveWindow() + { + return activeWindow; + } + + public IWorkbenchPage getActivePage() + { + return activePage; + } + } } |

