1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.ide.eclipse.adt.internal.wizards.templates; 17 18 import org.eclipse.core.resources.IProject; 19 import org.eclipse.jface.viewers.IStructuredSelection; 20 import org.eclipse.jface.wizard.IWizardPage; 21 import org.eclipse.ui.IWorkbench; 22 23 import java.io.File; 24 25 /** 26 * Template wizard which creates parameterized templates 27 */ 28 public class TemplateTestWizard extends NewTemplateWizard { 29 private TemplateTestPage mSelectionPage; 30 private IProject mProject; 31 32 /** Creates a new wizard for testing template definitions in a local directory */ 33 public TemplateTestWizard() { 34 super(""); 35 } 36 37 @Override 38 public void init(IWorkbench workbench, IStructuredSelection selection) { 39 super.init(workbench, selection); 40 if (mValues != null) { 41 mProject = mValues.project; 42 } 43 44 mMainPage = null; 45 mValues = null; 46 47 mSelectionPage = new TemplateTestPage(); 48 } 49 50 @Override 51 public void addPages() { 52 addPage(mSelectionPage); 53 } 54 55 @Override 56 public IWizardPage getNextPage(IWizardPage page) { 57 if (page == mSelectionPage) { 58 File file = mSelectionPage.getLocation(); 59 if (file != null && file.exists()) { 60 if (mValues == null) { 61 mValues = new NewTemplateWizardState(); 62 mValues.setTemplateLocation(file); 63 mValues.project = mProject; 64 hideBuiltinParameters(); 65 66 mMainPage = new NewTemplatePage(mValues, true); 67 addPage(mMainPage); 68 } else { 69 mValues.setTemplateLocation(file); 70 } 71 72 return mMainPage; 73 } 74 } 75 76 return super.getNextPage(page); 77 } 78 } 79