/******************************************************************************* * Copyright © 2000, 2013 IBM Corporation 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * *******************************************************************************/ package org.eclipse.edt.ide.ui.internal.wizards; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.edt.ide.ui.internal.EGLLogger; import org.eclipse.edt.ide.ui.wizards.EGLElementConfiguration; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; public abstract class EGLElementWizard extends Wizard implements INewWizard { EGLElementConfiguration configuration; //MATT - Move this out!!! protected void openResource(final IFile resource) { final IWorkbenchPage activePage; IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window == null) activePage = null; else activePage = window.getActivePage(); if (activePage != null) { final Display display= getShell().getDisplay(); if (display != null) { display.asyncExec(new Runnable() { public void run() { try { IDE.openEditor(activePage, resource, true); } catch (PartInitException e) { EGLLogger.log(this, e.toString()); } } }); } } } /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ public void init(IWorkbench workbench, IStructuredSelection currentSelection) { } public EGLElementConfiguration getConfiguration() { if (configuration == null) configuration = new EGLElementConfiguration(); return configuration; } //MATT - Move this out! protected void selectAndReveal(IResource newResource) { BasicNewResourceWizard.selectAndReveal(newResource, PlatformUI.getWorkbench().getActiveWorkbenchWindow()); } }