/******************************************************************************* | |
* Copyright (c) 2010, 2011 Mia-Software and others. | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v2.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v20.html | |
* | |
* Contributors: | |
* Nicolas Bros (Mia-Software) - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.modisco.infra.common.ui.internal.util; | |
import org.eclipse.ui.IWorkbenchPage; | |
import org.eclipse.ui.IWorkbenchPart; | |
import org.eclipse.ui.IWorkbenchWindow; | |
import org.eclipse.ui.PlatformUI; | |
public final class WorkbenchUtils { | |
private WorkbenchUtils() { | |
// utils class | |
} | |
/** @return the active workbench part, or <code>null</code> if none */ | |
public static IWorkbenchPart getActivePart() { | |
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench() | |
.getActiveWorkbenchWindow(); | |
if (activeWorkbenchWindow != null) { | |
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); | |
if (activePage != null) { | |
IWorkbenchPart activePart = activePage.getActivePart(); | |
return activePart; | |
} | |
} | |
return null; | |
} | |
} |