| 1 |
/** |
| 2 |
* Copyright (c) 2006 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v2.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v20.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM - Initial API and implementation |
| 10 |
*/ |
| 11 |
package org.eclipse.emf.cheatsheets.actions; |
| 12 |
|
| 13 |
import org.eclipse.core.runtime.CoreException; |
| 14 |
import org.eclipse.core.runtime.IPath; |
| 15 |
import org.eclipse.core.runtime.Path; |
| 16 |
import org.eclipse.ui.INewWizard; |
| 17 |
import org.eclipse.ui.cheatsheets.ICheatSheetAction; |
| 18 |
import org.eclipse.ui.cheatsheets.ICheatSheetManager; |
| 19 |
|
| 20 |
import org.eclipse.emf.importer.ui.EMFModelWizard; |
| 21 |
|
| 22 |
|
| 23 |
/** |
| 24 |
* <p>Action that opens the new EMF model wizard. |
| 25 |
* @since 2.2.0 |
| 26 |
*/ |
| 27 |
public class OpenEMFModelWizardAction extends AbstractOpenWizardAction implements ICheatSheetAction |
| 28 |
{ |
| 29 |
protected IPath path; |
| 30 |
protected String descriptorID; |
| 31 |
|
| 32 |
/** |
| 33 |
* Execute the action |
| 34 |
* @param params Array of parameters - index 0: path of the genmodel, index 1: model importer descriptor ID |
| 35 |
* @param manager Cheatsheet Manager |
| 36 |
*/ |
| 37 |
public void run(String[] params, ICheatSheetManager manager) |
| 38 |
{ |
| 39 |
if (params.length > 0 && params[0] != null) |
| 40 |
{ |
| 41 |
path = new Path(params[0]).makeAbsolute(); |
| 42 |
descriptorID = params[1]; |
| 43 |
} |
| 44 |
run(); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Create a new wizard |
| 49 |
* @exception CoreException |
| 50 |
*/ |
| 51 |
@Override |
| 52 |
protected final INewWizard createWizard() throws CoreException |
| 53 |
{ |
| 54 |
EMFModelWizard wizard = createEMFModelWizard(); |
| 55 |
if (path != null) |
| 56 |
{ |
| 57 |
wizard.setDefaultPath(path); |
| 58 |
wizard.setDefaultModelImporterDescriptorID(descriptorID); |
| 59 |
} |
| 60 |
return wizard; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Create a new EMF model wizard |
| 65 |
* @return EMF model wizard |
| 66 |
*/ |
| 67 |
protected EMFModelWizard createEMFModelWizard() |
| 68 |
{ |
| 69 |
return new EMFModelWizard(); |
| 70 |
} |
| 71 |
} |