/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* 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:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.views;
import java.io.IOException;
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.osgi.framework.Bundle;
import de.innovationgate.eclipse.wgadesigner.WGADesignerPlugin;
public class GettingStarted extends ViewPart {
private Browser _browser;
public GettingStarted() {
// TODO Auto-generated constructor stub
}
private Action _backAction = new Action("Back") {
public void run() {
_browser.back();
}
};
private Action _forwardAction = new Action("Forward") {
public void run() {
_browser.forward();
}
};
@Override
public void createPartControl(Composite parent) {
_browser = new Browser(parent, SWT.NONE);
Bundle plugin = WGADesignerPlugin.getDefault().getBundle();
IPath relativePagePath = new Path("resources/html/gettingStarted/step1.1.html");
URL fileInPlugin = FileLocator.find(plugin, relativePagePath, null);
if (fileInPlugin != null) {
try {
URL pageUrl = FileLocator.toFileURL(fileInPlugin);
_browser.setUrl(pageUrl.toString());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
_backAction.setImageDescriptor(ImageDescriptor.createFromImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_BACK)));
_forwardAction.setImageDescriptor(ImageDescriptor.createFromImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_FORWARD)));
IActionBars actionBars = getViewSite().getActionBars();
actionBars.getToolBarManager().add(_backAction);
actionBars.getToolBarManager().add(_forwardAction);
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}