Java tutorial
/******************************************************************************* * Copyright (C) 2013 Research In Motion Limited * * 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 *******************************************************************************/ package com.bb.extensions.plugin.unittests.internal.handlers; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.resources.IProject; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.ui.handlers.HandlerUtil; import com.bb.extensions.plugin.unittests.Activator; import com.bb.extensions.plugin.unittests.internal.wizards.install.InstallWizard; /** * @author tallen * */ public class InstallUnitTestsHandler extends AbstractHandler { /* * (non-Javadoc) * * @see * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands. * ExecutionEvent) */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { IProject project = null; ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection(); if (selection != null & selection instanceof IStructuredSelection) { IStructuredSelection strucSelection = (IStructuredSelection) selection; project = (IProject) strucSelection.getFirstElement(); } if (project != null) { Wizard wizard = new InstallWizard(project); WizardDialog dialog = new WizardDialog( Activator.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), wizard); dialog.setHelpAvailable(false); dialog.open(); } return null; } }