| /******************************************************************************* |
| * Copyright (c) 2012 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.stem.model.ui.wizards; |
| |
| import org.eclipse.core.commands.AbstractHandler; |
| import org.eclipse.core.commands.ExecutionEvent; |
| import org.eclipse.core.commands.ExecutionException; |
| import org.eclipse.core.commands.IHandler; |
| import org.eclipse.jface.viewers.IStructuredSelection; |
| import org.eclipse.jface.viewers.StructuredSelection; |
| import org.eclipse.jface.wizard.WizardDialog; |
| import org.eclipse.stem.model.metamodel.Model; |
| import org.eclipse.ui.INewWizard; |
| import org.eclipse.ui.IWorkbench; |
| import org.eclipse.ui.IWorkbenchWindow; |
| import org.eclipse.ui.handlers.HandlerUtil; |
| |
| public class NewModelProjectWizard extends ModelGeneratorWizard implements INewWizard |
| { |
| Model model; |
| |
| public NewModelProjectWizard() |
| { |
| super(null); |
| } |
| |
| @Override |
| public void addPages() |
| { |
| addPage(new CreatePackagePage()); |
| super.addPages(); |
| } |
| |
| @Override |
| public void init(IWorkbench workbench, IStructuredSelection selection) |
| { |
| setPackage(null); |
| } |
| |
| @Override |
| public boolean performFinish() |
| { |
| return super.performFinish(); |
| } |
| |
| /** |
| * This class is a {@link IHandler} for the command that creates a |
| * {@link NewModelProjectWizard} |
| */ |
| public static class NewModelProjectWizardCommandHandler extends AbstractHandler |
| implements IHandler { |
| /** |
| * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
| */ |
| public Object execute(final ExecutionEvent executionEvent) |
| throws ExecutionException { |
| final IWorkbenchWindow window = HandlerUtil |
| .getActiveWorkbenchWindowChecked(executionEvent); |
| final NewModelProjectWizard wizard = new NewModelProjectWizard(); |
| wizard.init(window.getWorkbench(), StructuredSelection.EMPTY); |
| final WizardDialog wizardDialog = new WizardDialog(window |
| .getShell(), wizard); |
| wizardDialog.open(); |
| return null; |
| } // execute |
| } // NewModelProjectWizardCommandHandler |
| |
| } |