mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
improve error handling in order to determine why some unit tests are failing on overnight build
This commit is contained in:
parent
eecd9b3834
commit
38595a611f
13 changed files with 129 additions and 97 deletions
|
@ -21,7 +21,7 @@ import junit.framework.TestSuite;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AllTemplateEngineTests extends TestSuite{
|
public class AllTemplateEngineTests extends TestSuite {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
junit.swingui.TestRunner.run(AllTemplateEngineTests.class);
|
junit.swingui.TestRunner.run(AllTemplateEngineTests.class);
|
||||||
|
|
|
@ -13,11 +13,10 @@ package org.eclipse.cdt.core.tests.templateengine;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -28,7 +27,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
|
||||||
public class TestProcesses extends TestCase {
|
public class TestProcesses extends BaseTestCase {
|
||||||
|
|
||||||
private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString();
|
private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString();
|
||||||
private static final String PROJECT_NAME = "TemplateEngineTestsProject"; //$NON-NLS-1$
|
private static final String PROJECT_NAME = "TemplateEngineTestsProject"; //$NON-NLS-1$
|
||||||
|
|
|
@ -15,16 +15,15 @@ import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.SharedDefaults;
|
import org.eclipse.cdt.core.templateengine.SharedDefaults;
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes all the test cases of SharedDefaults backend functionality
|
* Executes all the test cases of SharedDefaults backend functionality
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TestSharedDefaults extends TestCase {
|
public class TestSharedDefaults extends BaseTestCase {
|
||||||
private SharedDefaults sharedDefaults;
|
private SharedDefaults sharedDefaults;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.tests.templateengine;
|
package org.eclipse.cdt.core.tests.templateengine;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the functionality of Tempalte Class.
|
* Test the functionality of Tempalte Class.
|
||||||
*/
|
*/
|
||||||
public class TestTemplateCore extends TestCase {
|
public class TestTemplateCore extends BaseTestCase {
|
||||||
|
|
||||||
public TemplateCore[] templates = null;
|
public TemplateCore[] templates = null;
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.tests.templateengine;
|
package org.eclipse.cdt.core.tests.templateengine;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the functionality of TemplateEngine.
|
* Test the functionality of TemplateEngine.
|
||||||
*/
|
*/
|
||||||
public class TestTemplateEngine extends TestCase {
|
public class TestTemplateEngine extends BaseTestCase {
|
||||||
|
|
||||||
|
|
||||||
TemplateEngine templateEngine = null;
|
TemplateEngine templateEngine = null;
|
||||||
|
|
|
@ -13,16 +13,15 @@ package org.eclipse.cdt.core.tests.templateengine;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
|
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
|
||||||
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the functionality of the ValueStore class.
|
* Test the functionality of the ValueStore class.
|
||||||
*/
|
*/
|
||||||
public class TestValueStore extends TestCase {
|
public class TestValueStore extends BaseTestCase {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
package org.eclipse.cdt.core.templateengine;
|
package org.eclipse.cdt.core.templateengine;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -20,15 +22,12 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
||||||
import org.eclipse.cdt.core.templateengine.process.TemplateProcessHandler;
|
import org.eclipse.cdt.core.templateengine.process.TemplateProcessHandler;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,17 +65,19 @@ public class TemplateCore {
|
||||||
private boolean fireDirtyEvents;
|
private boolean fireDirtyEvents;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* @param templateInfo may not be null
|
||||||
*
|
* @throws TemplateInitializationException
|
||||||
* @param templateInfo
|
|
||||||
* @throws IOException
|
|
||||||
* @throws SAXException
|
|
||||||
* @throws ParserConfigurationException
|
|
||||||
*/
|
*/
|
||||||
|
protected TemplateCore(TemplateInfo templateInfo) throws TemplateInitializationException {
|
||||||
protected TemplateCore(TemplateInfo templateInfo) throws IOException, SAXException, ParserConfigurationException {
|
|
||||||
this.templateInfo = templateInfo;
|
this.templateInfo = templateInfo;
|
||||||
templateDescriptor = new TemplateDescriptor(TemplateEngineHelper.getTemplateResourceURL(templateInfo.getPluginId(), templateInfo.getTemplatePath()), templateInfo.getPluginId());
|
URL descriptorURL;
|
||||||
|
try {
|
||||||
|
descriptorURL= TemplateEngineHelper.getTemplateResourceURL(templateInfo.getPluginId(), templateInfo.getTemplatePath());
|
||||||
|
} catch(IOException ioe) {
|
||||||
|
String msg= MessageFormat.format(TemplateEngineMessages.getString("TemplateCore.InitFailed"), new Object[]{templateInfo.getTemplatePath()}); //$NON-NLS-1$
|
||||||
|
throw new TemplateInitializationException(msg);
|
||||||
|
}
|
||||||
|
templateDescriptor = new TemplateDescriptor(descriptorURL, templateInfo.getPluginId());
|
||||||
valueStore = new ValueStore/*<String, String>*/(this);
|
valueStore = new ValueStore/*<String, String>*/(this);
|
||||||
valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()));
|
valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()));
|
||||||
valueStore.putAll(TemplateEngine.getDefault().getSharedDefaults());
|
valueStore.putAll(TemplateEngine.getDefault().getSharedDefaults());
|
||||||
|
@ -221,14 +222,10 @@ public class TemplateCore {
|
||||||
* Gets the Template
|
* Gets the Template
|
||||||
*
|
*
|
||||||
* @param templateInfo
|
* @param templateInfo
|
||||||
* @throws IOException
|
* @throws TemplateInitializationException
|
||||||
* @throws ProcessFailureException
|
|
||||||
* @throws SAXException
|
|
||||||
* @throws ParserConfigurationException
|
|
||||||
*
|
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static TemplateCore getTemplate(TemplateInfo templateInfo) throws IOException, ProcessFailureException, SAXException, ParserConfigurationException {
|
public static TemplateCore getTemplate(TemplateInfo templateInfo) throws TemplateInitializationException {
|
||||||
synchronized (templateCache) {
|
synchronized (templateCache) {
|
||||||
TemplateCore template = (TemplateCore) templateCache.get(templateInfo);
|
TemplateCore template = (TemplateCore) templateCache.get(templateInfo);
|
||||||
if (template == null) {
|
if (template == null) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.templateengine;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -46,15 +47,22 @@ public class TemplateDescriptor {
|
||||||
/**
|
/**
|
||||||
* Constructor which construct the Document based the URL
|
* Constructor which construct the Document based the URL
|
||||||
* @param descriptorURL
|
* @param descriptorURL
|
||||||
* @throws SAXException
|
* @throws TemplateInitializationException
|
||||||
* @throws IOException
|
|
||||||
* @throws ParserConfigurationException
|
|
||||||
*/
|
*/
|
||||||
public TemplateDescriptor(URL descriptorURL, String id) throws SAXException, IOException, ParserConfigurationException {
|
public TemplateDescriptor(URL descriptorURL, String pluginId) throws TemplateInitializationException {
|
||||||
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(descriptorURL.openStream());
|
String msg= MessageFormat.format(TemplateEngineMessages.getString("TemplateCore.InitFailed"), new Object[]{descriptorURL}); //$NON-NLS-1$
|
||||||
rootElement = document.getDocumentElement();
|
try {
|
||||||
persistVector = new ArrayList/*<String>*/();
|
this.document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(descriptorURL.openStream());
|
||||||
pluginId = id;
|
} catch(ParserConfigurationException pce) {
|
||||||
|
throw new TemplateInitializationException(msg, pce);
|
||||||
|
} catch(IOException ioe) {
|
||||||
|
throw new TemplateInitializationException(msg, ioe);
|
||||||
|
} catch(SAXException se) {
|
||||||
|
throw new TemplateInitializationException(msg, se);
|
||||||
|
}
|
||||||
|
this.rootElement = document.getDocumentElement();
|
||||||
|
this.persistVector = new ArrayList/*<String>*/();
|
||||||
|
this.pluginId = pluginId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,46 +66,54 @@ public class TemplateEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get All the templates, no filtering is done.
|
* Returns all the TemplateCore objects, no filtering is done.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public TemplateCore[] getTemplates() {
|
public TemplateCore[] getTemplates() {
|
||||||
TemplateInfo[] templateInfoArray = getTemplateInfos();
|
TemplateInfo[] templateInfoArray = getTemplateInfos();
|
||||||
List/*<Template>*/ templatesList = new ArrayList/*<Template>*/();
|
List/*<TemplateCore>*/ tcores = new ArrayList/*<TemplateCore>*/();
|
||||||
for (int i=0; i<templateInfoArray.length; i++) {
|
for (int i=0; i<templateInfoArray.length; i++) {
|
||||||
TemplateInfo info = templateInfoArray[i];
|
TemplateInfo info = templateInfoArray[i];
|
||||||
try {
|
try {
|
||||||
templatesList.add(TemplateCore.getTemplate(info));
|
tcores.add(TemplateCore.getTemplate(info));
|
||||||
} catch (Exception e) {
|
} catch (TemplateInitializationException e) {
|
||||||
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (TemplateCore[]) templatesList.toArray(new TemplateCore[templatesList.size()]);
|
return (TemplateCore[]) tcores.toArray(new TemplateCore[tcores.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called by Contianer UIs (Wizard, PropertyPage,
|
* Returns the TemplateCore for the first template defined for the specified parameters, or null
|
||||||
* PreferencePage). Create a Template instance, update the ValueStore, with
|
* if no such definition exists, or if there is an error initializing the template (the error will
|
||||||
* SharedDefaults. This method calls the getTemplate(URL), after getting URL
|
* be logged).
|
||||||
* for the given String TemplateDescriptor.
|
* @param projectType may not be null
|
||||||
*
|
* @param toolChain may be null to indicate no tool-chain filtering
|
||||||
* @param StringTemplateDescriptor,
|
* @param usageFilter a regex in java.util.regex.Pattern format, may be null to indicate no filtering
|
||||||
* TemplateDescriptor name.
|
* @see java.util.regex.Pattern
|
||||||
* @throws IOException
|
* @return
|
||||||
|
*/
|
||||||
|
public TemplateCore getFirstTemplate(String projectType, String toolChain, String usageFilter) {
|
||||||
|
TemplateInfo[] infos= getTemplateInfos(projectType, toolChain, usageFilter);
|
||||||
|
if(infos.length>0) {
|
||||||
|
try {
|
||||||
|
return TemplateCore.getTemplate(infos[0]);
|
||||||
|
} catch(TemplateInitializationException tie) {
|
||||||
|
CCorePlugin.log(tie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Equivalent to calling the overloaded version of getFirstTemplate with null arguments for
|
||||||
|
* toolChain and usageFilter.
|
||||||
|
* @see TemplateEngine#getFirstTemplate(String, String, String)
|
||||||
|
* @return the first TemplateCore object registered, or null if this does not exist
|
||||||
*/
|
*/
|
||||||
public TemplateCore getFirstTemplate(String projectType) {
|
public TemplateCore getFirstTemplate(String projectType) {
|
||||||
return getFirstTemplate(projectType, null, null);
|
return getFirstTemplate(projectType, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TemplateCore getFirstTemplate(String projectType, String toolChain, String usageFilter) {
|
|
||||||
try {
|
|
||||||
return TemplateCore.getTemplate(getTemplateInfos(projectType, toolChain, usageFilter)[0]);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will be called by Contianer UIs (Wizard, PropertyPage,
|
* This method will be called by Contianer UIs (Wizard, PropertyPage,
|
||||||
* PreferencePage). Create a Template instance, update the ValueStore, with
|
* PreferencePage). Create a Template instance, update the ValueStore, with
|
||||||
|
@ -119,7 +127,8 @@ public class TemplateEngine {
|
||||||
TemplateInfo info = templateInfoArray[i];
|
TemplateInfo info = templateInfoArray[i];
|
||||||
try {
|
try {
|
||||||
templatesList.add(TemplateCore.getTemplate(info));
|
templatesList.add(TemplateCore.getTemplate(info));
|
||||||
} catch (Exception e) {
|
} catch (TemplateInitializationException tie) {
|
||||||
|
CCorePlugin.log(tie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (TemplateCore[]) templatesList.toArray(new TemplateCore[templatesList.size()]);
|
return (TemplateCore[]) templatesList.toArray(new TemplateCore[templatesList.size()]);
|
||||||
|
@ -273,6 +282,11 @@ public class TemplateEngine {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an array of template info objects matching the criteria passed as params.
|
* Gets an array of template info objects matching the criteria passed as params.
|
||||||
|
* @param projectType may not be null
|
||||||
|
* @param toolChain may be null to indicate no tool-chain
|
||||||
|
* @param usageFilter a usage string which is matched against the filter from the template, may be null
|
||||||
|
* to indicate no usage filtering
|
||||||
|
* @return an array of template infos (never null)
|
||||||
*/
|
*/
|
||||||
public TemplateInfo[] getTemplateInfos(String projectType, String toolChain, String usageFilter) {
|
public TemplateInfo[] getTemplateInfos(String projectType, String toolChain, String usageFilter) {
|
||||||
List/*<TemplateInfo>*/ templateInfoList = (List/*<TemplateInfo*/) templateInfoMap.get(projectType.trim());
|
List/*<TemplateInfo>*/ templateInfoList = (List/*<TemplateInfo*/) templateInfoMap.get(projectType.trim());
|
||||||
|
@ -315,6 +329,10 @@ public class TemplateEngine {
|
||||||
return getTemplateInfos(projectType, null, null);
|
return getTemplateInfos(projectType, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all TemplateInfo objects known to the TemplateEngine
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public TemplateInfo[] getTemplateInfos() {
|
public TemplateInfo[] getTemplateInfos() {
|
||||||
List/*<TemplateInfo>*/ infoList = new ArrayList/*<TemplateInfo>*/();
|
List/*<TemplateInfo>*/ infoList = new ArrayList/*<TemplateInfo>*/();
|
||||||
for (Iterator i = templateInfoMap.values().iterator(); i.hasNext();) {
|
for (Iterator i = templateInfoMap.values().iterator(); i.hasNext();) {
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007 Symbian Software Limited 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:
|
||||||
|
* Andrew Ferguson (Symbian) - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.core.templateengine;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an exception in initializing a template. Typically this will be caused
|
||||||
|
* by an I/O or XML parsing failure.
|
||||||
|
*/
|
||||||
|
public class TemplateInitializationException extends Exception {
|
||||||
|
private static final long serialVersionUID = -8138820172406447119L;
|
||||||
|
|
||||||
|
public TemplateInitializationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateInitializationException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TemplateInitializationException(String message, Throwable cause) {
|
||||||
|
super(message);
|
||||||
|
initCause(cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,6 +10,7 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
TemplateEngine.internalError=Internal Error:
|
TemplateEngine.internalError=Internal Error:
|
||||||
|
TemplateCore.InitFailed=Failed to initialize: {0}
|
||||||
TemplateEngine.templateEngine=Template Engine
|
TemplateEngine.templateEngine=Template Engine
|
||||||
ProjectCreatedActions.InsufficientInformation=Insufficient information to create new project
|
ProjectCreatedActions.InsufficientInformation=Insufficient information to create new project
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.templateengine;
|
package org.eclipse.cdt.ui.templateengine;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -18,8 +17,6 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -28,12 +25,12 @@ import org.eclipse.jface.wizard.IWizardPage;
|
||||||
import org.eclipse.ui.IWorkbenchWizard;
|
import org.eclipse.ui.IWorkbenchWizard;
|
||||||
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
import org.eclipse.ui.actions.WorkspaceModifyOperation;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.xml.sax.SAXException;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
|
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateInfo;
|
import org.eclipse.cdt.core.templateengine.TemplateInfo;
|
||||||
|
import org.eclipse.cdt.core.templateengine.TemplateInitializationException;
|
||||||
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
import org.eclipse.cdt.core.templateengine.process.ProcessFailureException;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.templateengine.pages.UIPagesProvider;
|
import org.eclipse.cdt.ui.templateengine.pages.UIPagesProvider;
|
||||||
|
@ -56,7 +53,7 @@ public class Template extends TemplateCore {
|
||||||
private UIPagesProvider uiPagesProvider;
|
private UIPagesProvider uiPagesProvider;
|
||||||
private Map/*<String, UIWizardPage>*/ pageMap;
|
private Map/*<String, UIWizardPage>*/ pageMap;
|
||||||
|
|
||||||
public Template(TemplateInfo templateInfo) throws IOException, ProcessFailureException, SAXException, ParserConfigurationException {
|
public Template(TemplateInfo templateInfo) throws TemplateInitializationException {
|
||||||
super(templateInfo);
|
super(templateInfo);
|
||||||
templateDescriptor = getTemplateDescriptor();
|
templateDescriptor = getTemplateDescriptor();
|
||||||
uiElementTreeBuilderManager = new UIElementTreeBuilderManager(new UIElementTreeBuilderHelper(templateDescriptor, templateInfo));
|
uiElementTreeBuilderManager = new UIElementTreeBuilderManager(new UIElementTreeBuilderHelper(templateDescriptor, templateInfo));
|
||||||
|
|
|
@ -13,10 +13,10 @@ package org.eclipse.cdt.ui.templateengine;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateCore;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
import org.eclipse.cdt.core.templateengine.TemplateEngine;
|
||||||
import org.eclipse.cdt.core.templateengine.TemplateInfo;
|
import org.eclipse.cdt.core.templateengine.TemplateInfo;
|
||||||
|
import org.eclipse.cdt.core.templateengine.TemplateInitializationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TemplateEngine is implemented as a Singleton. TemplateEngine is responsible for
|
* TemplateEngine is implemented as a Singleton. TemplateEngine is responsible for
|
||||||
|
@ -30,7 +30,7 @@ public class TemplateEngineUI {
|
||||||
/**
|
/**
|
||||||
* static reference to the Singleton TemplateEngine instance.
|
* static reference to the Singleton TemplateEngine instance.
|
||||||
*/
|
*/
|
||||||
private static TemplateEngineUI TEMPLATE_ENGINE_UI = new TemplateEngineUI();
|
private static final TemplateEngineUI TEMPLATE_ENGINE_UI = new TemplateEngineUI();
|
||||||
|
|
||||||
private TemplateEngineUI() {
|
private TemplateEngineUI() {
|
||||||
}
|
}
|
||||||
|
@ -39,25 +39,6 @@ public class TemplateEngineUI {
|
||||||
return TEMPLATE_ENGINE_UI;
|
return TEMPLATE_ENGINE_UI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will be called by Contianer UIs (Wizard, PropertyPage,
|
|
||||||
* PreferencePage). Create a Template instance, update the ValueStore, with
|
|
||||||
* SharedDefaults. This method calls the getTemplate(URL), after getting URL
|
|
||||||
* for the given String TemplateDescriptor.
|
|
||||||
*/
|
|
||||||
public TemplateCore getFirstTemplate(String projectType) {
|
|
||||||
return getFirstTemplate(projectType, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TemplateCore getFirstTemplate(String projectType, String toolChain, String usageFilter) {
|
|
||||||
try {
|
|
||||||
return new Template(TemplateEngine.getDefault().getTemplateInfos(projectType, toolChain, usageFilter)[0]);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Template[] getTemplates(String projectType, String toolChain, String usageFilter) {
|
public Template[] getTemplates(String projectType, String toolChain, String usageFilter) {
|
||||||
TemplateInfo[] templateInfoArray = TemplateEngine.getDefault().getTemplateInfos(projectType, toolChain, usageFilter);
|
TemplateInfo[] templateInfoArray = TemplateEngine.getDefault().getTemplateInfos(projectType, toolChain, usageFilter);
|
||||||
List/*<Template>*/ templatesList = new ArrayList/*<Template>*/();
|
List/*<Template>*/ templatesList = new ArrayList/*<Template>*/();
|
||||||
|
@ -65,7 +46,8 @@ public class TemplateEngineUI {
|
||||||
TemplateInfo info = templateInfoArray[i];
|
TemplateInfo info = templateInfoArray[i];
|
||||||
try {
|
try {
|
||||||
templatesList.add(new Template(info));
|
templatesList.add(new Template(info));
|
||||||
} catch (Exception e) {
|
} catch (TemplateInitializationException tie) {
|
||||||
|
CCorePlugin.log(tie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (Template[]) templatesList.toArray(new Template[templatesList.size()]);
|
return (Template[]) templatesList.toArray(new Template[templatesList.size()]);
|
||||||
|
@ -80,7 +62,7 @@ public class TemplateEngineUI {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get All the templates, no filtering is done.
|
* Returns all the templates, no filtering is done.
|
||||||
*/
|
*/
|
||||||
public Template[] getTemplates() {
|
public Template[] getTemplates() {
|
||||||
TemplateInfo[] templateInfoArray = TemplateEngine.getDefault().getTemplateInfos();
|
TemplateInfo[] templateInfoArray = TemplateEngine.getDefault().getTemplateInfos();
|
||||||
|
@ -88,7 +70,8 @@ public class TemplateEngineUI {
|
||||||
for (int i=0; i<templateInfoArray.length; i++) {
|
for (int i=0; i<templateInfoArray.length; i++) {
|
||||||
try {
|
try {
|
||||||
templatesList.add(new Template(templateInfoArray[i]));
|
templatesList.add(new Template(templateInfoArray[i]));
|
||||||
} catch (Exception e) {
|
} catch (TemplateInitializationException tie) {
|
||||||
|
CCorePlugin.log(tie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue