/**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- *
+ * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
* 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:
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ * IBM - Initial API and implementation
+ * Bernd Hufmann - Updated for TMF
**********************************************************************/
+
package org.eclipse.linuxtools.tmf.ui.views.uml2sd.load;
import java.util.ArrayList;
import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
/**
* Manager class for the UML2SD extension point.
* @param viewId the id of the view
*/
public void resetLoader(String viewId) {
- IUml2SDLoader loader = (IUml2SDLoader) fViewLoaderMap.get(viewId);
+ IUml2SDLoader loader = fViewLoaderMap.get(viewId);
if (loader != null) {
loader.dispose();
}
return null;
}
- IWorkbenchPage persp = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ // During Eclipse shutdown the active workbench window is null
+ if (window == null) {
+ return null;
+ }
+
+ IWorkbenchPage persp = window.getActivePage();
SDView sdView = view;
try {
// Search the view corresponding to the viewId
if (sdView == null) {
- IViewReference viewref = (IViewReference) persp.findViewReference(viewId);
+ IViewReference viewref = persp.findViewReference(viewId);
if (viewref != null) {
sdView = (SDView) viewref.getView(false);
}
if ((currentLoader != null) && (currentLoader != loader)) {
if (loader != null) {
- IWorkbenchPage persp = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ // During Eclipse shutdown the active workbench window is null
+ if (window == null) {
+ return;
+ }
+ IWorkbenchPage persp = window.getActivePage();
try {
// Search view corresponding to the viewId
SDView sdview = null;
- IViewReference viewref = (IViewReference) persp.findViewReference(id);
+ IViewReference viewref = persp.findViewReference(id);
if (viewref != null) {
sdview = (SDView) viewref.getView(false);
}
* @return List of extension point configuration elements.
*/
private List<IConfigurationElement> getLoaderConfigurationElements(String viewId) {
- List<IConfigurationElement> list = (List<IConfigurationElement>) fViewLoadersList.get(viewId);
+ List<IConfigurationElement> list = fViewLoadersList.get(viewId);
if (list != null) {
return list;
}
* @param loaderElements The list of loader configuration elements
* @return Extension point configuration element
*/
- private IConfigurationElement getLoaderConfigurationElement(String loaderClassName, List<IConfigurationElement> loaderElements) {
+ private static IConfigurationElement getLoaderConfigurationElement(
+ String loaderClassName, List<IConfigurationElement> loaderElements) {
if (loaderClassName != null && loaderClassName.length() > 0) {
// Find configuration element corresponding to the saved loader
for (Iterator<IConfigurationElement> i = loaderElements.iterator(); i.hasNext();) {
- IConfigurationElement ce = (IConfigurationElement) i.next();
+ IConfigurationElement ce = i.next();
if (ce.getAttribute("class").equals(loaderClassName)) { //$NON-NLS-1$
return ce;
}
* @param loaderElements The list of loader configuration elements
* @return The default extension point configuration element.
*/
- private IConfigurationElement getDefaultLoader(List<IConfigurationElement> loaderElements) {
+ private static IConfigurationElement getDefaultLoader(
+ List<IConfigurationElement> loaderElements) {
// Look for a default loader
for (Iterator<IConfigurationElement> i = loaderElements.iterator(); i.hasNext();) {
- IConfigurationElement ce = (IConfigurationElement) i.next();
+ IConfigurationElement ce = i.next();
if (Boolean.valueOf(ce.getAttribute("default")).booleanValue()) { //$NON-NLS-1$
return ce;
}