1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Apply patch for 215823 for Mark Espiritu, and fix generics warnings in template engine

This commit is contained in:
Andrew Ferguson 2008-01-15 11:40:08 +00:00
parent c18ff521d9
commit 100ce28bcd
16 changed files with 264 additions and 284 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -31,7 +31,7 @@ public class AllTemplateEngineTests extends TestSuite {
* Since the TemplateEngine consists of UI(Wizard). * Since the TemplateEngine consists of UI(Wizard).
* A TestWizard is created to which the dynamically generated * A TestWizard is created to which the dynamically generated
* UIPages are added. The Wizard is launched from here. * UIPages are added. The Wizard is launched from here.
* The TestCases created to test the TemplateEngine is initialized here. * The TestCases created to test the TemplateEngine is initialised here.
* @return * @return
* *
* @since 4.0 * @since 4.0
@ -45,6 +45,7 @@ public class AllTemplateEngineTests extends TestSuite {
suite.addTestSuite(TestValueStore.class); suite.addTestSuite(TestValueStore.class);
suite.addTestSuite(TestSharedDefaults.class); suite.addTestSuite(TestSharedDefaults.class);
suite.addTestSuite(TestProcesses.class); suite.addTestSuite(TestProcesses.class);
suite.addTestSuite(TestTemplateEngineBugs.class);
//$JUnit-END$ //$JUnit-END$
return suite; return suite;

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* 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 Implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.core.templateengine.process.ProcessHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
public class TestTemplateEngineBugs extends BaseTestCase {
public void testBug215283() {
assertEquals(set("a"), ProcessHelper.getReplaceKeys("$(a)"));
assertEquals(set("a","b"), ProcessHelper.getReplaceKeys("$(a)$(b)"));
assertEquals(set("a","b","cc","ddd"), ProcessHelper.getReplaceKeys("$(a)$(b)$(cc)$(ddd)"));
assertEquals(set("aaa","b","c","dd"), ProcessHelper.getReplaceKeys("$(aaa)$(b)$(c)$(dd)"));
assertEquals(set("a"), ProcessHelper.getReplaceKeys("($(a))"));
assertEquals(set("a","b"), ProcessHelper.getReplaceKeys("$(b)$(a)"));
assertEquals(set("a"), ProcessHelper.getReplaceKeys(" \n$(a)"));
assertEquals(set("a"), ProcessHelper.getReplaceKeys("$(a) "));
}
private Set<String> set(String ... s) {
HashSet<String> result= new HashSet<String>();
result.addAll(Arrays.asList(s));
return result;
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -14,7 +14,6 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -35,8 +34,7 @@ import org.w3c.dom.Node;
/** /**
* Processes the shared default values. Updates and Persists new key - value (default) pair * Processes the shared default values. Updates and Persists new key - value (default) pair
*/ */
public class SharedDefaults extends HashMap<String, String> {
public class SharedDefaults extends HashMap/*<String, String>*/ {
private static final long serialVersionUID = 0000000000L; private static final long serialVersionUID = 0000000000L;
public Document document; public Document document;
@ -46,9 +44,9 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
/** /**
* HashMap's for persistence * HashMap's for persistence
*/ */
private HashMap/*<String, String>*/ sharedDefaultsMap; private HashMap<String, String> sharedDefaultsMap;
private HashMap/*<String, String>*/ persistDataMap; private HashMap<String, String> persistDataMap;
private HashMap/*<String, String>*/ tableDataMap; private HashMap<String, String> tableDataMap;
/** /**
* Two XML files here supports to provide consistent writing of data into * Two XML files here supports to provide consistent writing of data into
@ -96,9 +94,9 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
*/ */
public SharedDefaults() { public SharedDefaults() {
sharedDefaultsMap = new HashMap/*<String, String>*/(); sharedDefaultsMap = new HashMap<String, String>();
persistDataMap = new HashMap/*<String, String>*/(); persistDataMap = new HashMap<String, String>();
tableDataMap = new HashMap/*<String, String>*/(); tableDataMap = new HashMap<String, String>();
// The conditional controls here is provided to have consistent // The conditional controls here is provided to have consistent
// data storage in the file during System crash or // data storage in the file during System crash or
@ -129,15 +127,15 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
if (length == 0) { if (length == 0) {
parsedXML = createDefaultXMLFormat(parsedXML); parsedXML = createDefaultXMLFormat(parsedXML);
} }
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURL().openStream()); document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURI().toURL().openStream());
} catch (Exception exp) { } catch (Exception exp) {
TemplateEngineUtil.log(exp); TemplateEngineUtil.log(exp);
} }
List/*<Element>*/ sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement());
int listSize = sharedElementList.size(); int listSize = sharedElementList.size();
for (int i = 0; i < listSize; i++) { for (int i = 0; i < listSize; i++) {
Element xmlElement = (Element) sharedElementList.get(i); Element xmlElement = sharedElementList.get(i);
key = xmlElement.getAttribute(TemplateEngineHelper.ID); key = xmlElement.getAttribute(TemplateEngineHelper.ID);
value = xmlElement.getAttribute(TemplateEngineHelper.VALUE); value = xmlElement.getAttribute(TemplateEngineHelper.VALUE);
if (key != null && !key.trim().equals("")) { //$NON-NLS-1$ if (key != null && !key.trim().equals("")) { //$NON-NLS-1$
@ -152,7 +150,7 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
* @param sharedMap * @param sharedMap
*/ */
public void updateShareDefaultsMap(Map/*<String, String>*/ sharedMap) { public void updateShareDefaultsMap(Map<String, String> sharedMap) {
sharedDefaultsMap.putAll(sharedMap); sharedDefaultsMap.putAll(sharedMap);
persistSharedValueMap(); persistSharedValueMap();
} }
@ -174,7 +172,7 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
* @return HashMap * @return HashMap
*/ */
public Map/*<String, String>*/ getSharedDefaultsMap() { public Map<String, String> getSharedDefaultsMap() {
return sharedDefaultsMap; return sharedDefaultsMap;
} }
@ -198,20 +196,19 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
* @param updateName * @param updateName
* @param updateValue * @param updateValue
*/ */
public void updateToBackEndStorage(String updateName, String updateValue) { public void updateToBackEndStorage(String updateName, String updateValue) {
try { try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURL().openStream()); document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURI().toURL().openStream());
} catch (Exception exp) { } catch (Exception exp) {
TemplateEngineUtil.log(exp); TemplateEngineUtil.log(exp);
} }
persistDataMap.putAll(sharedDefaultsMap); persistDataMap.putAll(sharedDefaultsMap);
List/*<Element>*/ sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement());
int elementListSize = sharedElementList.size(); int elementListSize = sharedElementList.size();
for (int i = 0; i < elementListSize; i++) { for (int i = 0; i < elementListSize; i++) {
Element xmlElement = (Element) sharedElementList.get(i); Element xmlElement = sharedElementList.get(i);
String name = xmlElement.getAttribute(TemplateEngineHelper.ID); String name = xmlElement.getAttribute(TemplateEngineHelper.ID);
if (updateName.equals(name)) { if (updateName.equals(name)) {
@ -228,18 +225,17 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
* @param deleteName * @param deleteName
*/ */
public void deleteBackEndStorage(String[] deleteName) { public void deleteBackEndStorage(String[] deleteName) {
try { try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURL().openStream()); document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(parsedXML.toURI().toURL().openStream());
} catch (Exception exp) { } catch (Exception exp) {
TemplateEngineUtil.log(exp); TemplateEngineUtil.log(exp);
} }
List/*<Element>*/ sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement()); List<Element> sharedElementList = TemplateEngine.getChildrenOfElement(document.getDocumentElement());
int elementListSize = sharedElementList.size(); int elementListSize = sharedElementList.size();
for (int i = 0; i < elementListSize; i++) { for (int i = 0; i < elementListSize; i++) {
Element xmlElement = (Element) sharedElementList.get(i); Element xmlElement = sharedElementList.get(i);
String name = xmlElement.getAttribute(TemplateEngineHelper.ID); String name = xmlElement.getAttribute(TemplateEngineHelper.ID);
for (int k = 0; k < deleteName.length; k++) { for (int k = 0; k < deleteName.length; k++) {
@ -312,11 +308,10 @@ public class SharedDefaults extends HashMap/*<String, String>*/ {
} }
Node rootElement = d.appendChild(d.createElement("SharedRoot")); //$NON-NLS-1$ Node rootElement = d.appendChild(d.createElement("SharedRoot")); //$NON-NLS-1$
for(Iterator i = sharedDefaultsMap.keySet().iterator(); i.hasNext(); ) { for(String key : sharedDefaultsMap.keySet()) {
String key = (String) i.next();
Element element = (Element) rootElement.appendChild(d.createElement("SharedProperty")); //$NON-NLS-1$ Element element = (Element) rootElement.appendChild(d.createElement("SharedProperty")); //$NON-NLS-1$
element.setAttribute(TemplateEngineHelper.ID, key); element.setAttribute(TemplateEngineHelper.ID, key);
element.setAttribute(TemplateEngineHelper.VALUE, (String) sharedDefaultsMap.get(key)); element.setAttribute(TemplateEngineHelper.VALUE, sharedDefaultsMap.get(key));
} }
DOMSource domSource = new DOMSource(d); DOMSource domSource = new DOMSource(d);

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,7 +13,6 @@ 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.text.MessageFormat;
import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -45,18 +44,18 @@ public class TemplateCore {
private static final String ID = "id"; //$NON-NLS-1$ private static final String ID = "id"; //$NON-NLS-1$
private static final String TYPE = "type"; //$NON-NLS-1$ private static final String TYPE = "type"; //$NON-NLS-1$
private static Map/*<TemplateInfo, Template>*/ templateCache = new HashMap/*<TemplateInfo, Template>*/(); private static Map<TemplateInfo, TemplateCore> templateCache = new HashMap<TemplateInfo, TemplateCore>();
public static final Comparator/*<Template>*/ TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR = new Comparator/*<Template>*/() { public static final Comparator<TemplateCore> TEMPLATE_ID_CASE_INSENSITIVE_COMPARATOR = new Comparator<TemplateCore>() {
public int compare(Object/*Template*/ t1, Object/*Template*/ t2) { public int compare(TemplateCore t1, TemplateCore t2) {
return String.CASE_INSENSITIVE_ORDER.compare(((TemplateCore)t1).getTemplateId(), ((TemplateCore)t2).getTemplateId()); return String.CASE_INSENSITIVE_ORDER.compare(t1.getTemplateId(), t2.getTemplateId());
} }
}; };
private TemplateDescriptor templateDescriptor; private TemplateDescriptor templateDescriptor;
private Map/*<String, String>*/ valueStore; private Map<String, String> valueStore;
private TemplateInfo templateInfo; private TemplateInfo templateInfo;
private Set/*<String>*/ allMacrosInProcesses; private Set<String> allMacrosInProcesses;
private TemplateProcessHandler processHandler; private TemplateProcessHandler processHandler;
private String description; private String description;
private String label; private String label;
@ -80,7 +79,7 @@ public class TemplateCore {
if(descriptorURL==null) if(descriptorURL==null)
throw new TemplateInitializationException("Unable to load project template. Location URL is null for "+templateInfo.getTemplateId()); //$NON-NLS-1$ throw new TemplateInitializationException("Unable to load project template. Location URL is null for "+templateInfo.getTemplateId()); //$NON-NLS-1$
templateDescriptor = new TemplateDescriptor(descriptorURL, templateInfo.getPluginId()); templateDescriptor = new TemplateDescriptor(descriptorURL, templateInfo.getPluginId());
valueStore = new ValueStore/*<String, String>*/(this); valueStore = new ValueStore<String>(this);
valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement())); valueStore.putAll(templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()));
valueStore.putAll(TemplateEngine.getSharedDefaults()); valueStore.putAll(TemplateEngine.getSharedDefaults());
valueStore.put("projectType", templateInfo.getProjectType()); //$NON-NLS-1$ valueStore.put("projectType", templateInfo.getProjectType()); //$NON-NLS-1$
@ -95,9 +94,9 @@ public class TemplateCore {
* Returns All Missing Macros In Processes. * Returns All Missing Macros In Processes.
* @return Set * @return Set
*/ */
public Set/*<String>*/ getAllMissingMacrosInProcesses() { public Set<String> getAllMissingMacrosInProcesses() {
Set/*<String>*/ set = new TreeSet/*<String>*/(allMacrosInProcesses); Set<String> set = new TreeSet<String>(allMacrosInProcesses);
for (Iterator iter = set.iterator(); iter.hasNext();) { for (Iterator<String> iter = set.iterator(); iter.hasNext();) {
if (valueStore.get(iter.next()) != null) { if (valueStore.get(iter.next()) != null) {
iter.remove(); iter.remove();
} }
@ -109,7 +108,7 @@ public class TemplateCore {
* return the ValueStore maintained by this Template. * return the ValueStore maintained by this Template.
* @return ValueStore. * @return ValueStore.
*/ */
public Map/*<String, String>*/ getValueStore() { public Map<String, String> getValueStore() {
return valueStore; return valueStore;
} }
@ -119,7 +118,7 @@ public class TemplateCore {
* *
* @return Vector of IDs. * @return Vector of IDs.
*/ */
public List/*<String>*/ getPersistTrueIDs() { public List<String> getPersistTrueIDs() {
return templateDescriptor.getPersistTrueIDs(); return templateDescriptor.getPersistTrueIDs();
} }
@ -229,7 +228,7 @@ public class TemplateCore {
*/ */
public static TemplateCore getTemplate(TemplateInfo templateInfo) throws TemplateInitializationException { public static TemplateCore getTemplate(TemplateInfo templateInfo) throws TemplateInitializationException {
synchronized (templateCache) { synchronized (templateCache) {
TemplateCore template = (TemplateCore) templateCache.get(templateInfo); TemplateCore template = templateCache.get(templateInfo);
if (template == null) { if (template == null) {
template = new TemplateCore(templateInfo); template = new TemplateCore(templateInfo);
templateCache.put(templateInfo, template); templateCache.put(templateInfo, template);
@ -238,7 +237,7 @@ public class TemplateCore {
} }
} }
private static class ValueStore/*<K, V>*/ extends HashMap/*<K, V>*/ { private static class ValueStore<K> extends HashMap<K,String> {
private static final long serialVersionUID = -4523467333437879406L; private static final long serialVersionUID = -4523467333437879406L;
private TemplateCore template; private TemplateCore template;
@ -246,26 +245,24 @@ public class TemplateCore {
this.template = template; this.template = template;
} }
public Object/*V*/ put(Object/*K*/ key, Object/*V*/ value) { public String put(K key, String value) {
value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), (String)value); value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), value);
Object/*V*/ v = super.put(key, value); String v = super.put(key, value);
template.setDirty(); template.setDirty();
return v; return v;
} }
public void putAll(Map/*<? extends K, ? extends V>*/ map) { public void putAll(Map<? extends K, ? extends String> map) {
Collection keys = map.keySet(); for(K key : map.keySet()) {
for (Iterator iterator = keys.iterator(); iterator.hasNext();) { String value = map.get(key);
Object key = iterator.next(); value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), value);
Object value = map.get(key);
value = TemplateEngineHelper.externalizeTemplateString(template.getTemplateInfo(), (String) value);
super.put(key, value); super.put(key, value);
} }
template.setDirty(); template.setDirty();
} }
public Object/*V*/ remove(Object key) { public String remove(Object key) {
Object/*V*/ v = super.remove(key); String v = super.remove(key);
template.setDirty(); template.setDirty();
return v; return v;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -41,7 +41,7 @@ public class TemplateDescriptor {
private Document document; private Document document;
private Element rootElement; private Element rootElement;
private List/*<String>*/ persistVector; private List<String> persistVector;
private String pluginId; private String pluginId;
/** /**
@ -61,7 +61,7 @@ public class TemplateDescriptor {
throw new TemplateInitializationException(msg, se); throw new TemplateInitializationException(msg, se);
} }
this.rootElement = document.getDocumentElement(); this.rootElement = document.getDocumentElement();
this.persistVector = new ArrayList/*<String>*/(); this.persistVector = new ArrayList<String>();
this.pluginId = pluginId; this.pluginId = pluginId;
} }
@ -71,12 +71,12 @@ public class TemplateDescriptor {
* *
* @return default values with keys * @return default values with keys
*/ */
public Map/*<String, String>*/ getTemplateDefaults(Element rootElement) { public Map<String, String> getTemplateDefaults(Element rootElement) {
Map/*<String, String>*/ templateDefaults = new HashMap/*<String, String>*/(); Map<String, String> templateDefaults = new HashMap<String, String>();
Element propertyGroupElement; Element propertyGroupElement;
List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(rootElement); List<Element> children = TemplateEngine.getChildrenOfElement(rootElement);
for (int i = 0, l = children.size(); i < l; i++) { for (int i = 0, l = children.size(); i < l; i++) {
propertyGroupElement = (Element) children.get(i); propertyGroupElement = children.get(i);
if (isNestedElement(propertyGroupElement)) { if (isNestedElement(propertyGroupElement)) {
templateDefaults = getTemplateDefaults(propertyGroupElement); templateDefaults = getTemplateDefaults(propertyGroupElement);
} }
@ -93,12 +93,12 @@ public class TemplateDescriptor {
private boolean isNestedElement(Element element){ private boolean isNestedElement(Element element){
boolean result=false; boolean result=false;
if (element!=null){ if (element!=null){
List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(element); List<Element> children = TemplateEngine.getChildrenOfElement(element);
String elementName = element.getNodeName(); String elementName = element.getNodeName();
Element testElement; Element testElement;
String testElementName = null; String testElementName = null;
if (children.size() > 0){ if (children.size() > 0){
testElement = (Element) children.get(0); testElement = children.get(0);
testElementName=testElement.getNodeName(); testElementName=testElement.getNodeName();
} }
if(elementName.equals(testElementName)) if(elementName.equals(testElementName))
@ -116,14 +116,14 @@ public class TemplateDescriptor {
* root element of type JDOM Element * root element of type JDOM Element
* @return list of property-group elements * @return list of property-group elements
*/ */
public List getPropertyGroupList() { public List<Element> getPropertyGroupList() {
List resultList = null; List<Element> resultList = null;
List/*<Element>*/ list = new ArrayList/*<Element>*/(); List<Element> list = new ArrayList<Element>();
resultList = list; resultList = list;
if (rootElement != null) { if (rootElement != null) {
List/*<Element>*/ tempList = TemplateEngine.getChildrenOfElement(rootElement); List<Element> tempList = TemplateEngine.getChildrenOfElement(rootElement);
for (int i = 0, l = tempList.size(); i < l; i++) { for (int i = 0, l = tempList.size(); i < l; i++) {
Element nextPropertyGroup = (Element) tempList.get(i); Element nextPropertyGroup = tempList.get(i);
String nextPGName = nextPropertyGroup.getNodeName(); String nextPGName = nextPropertyGroup.getNodeName();
if (nextPGName.equalsIgnoreCase(PROPERTY_GROUP)) { if (nextPGName.equalsIgnoreCase(PROPERTY_GROUP)) {
list.add(nextPropertyGroup); list.add(nextPropertyGroup);
@ -151,9 +151,9 @@ public class TemplateDescriptor {
return rootElement; return rootElement;
} else { } else {
String nextPGElementName = null; String nextPGElementName = null;
List/*<Element>*/ propertyGroupList = TemplateEngine.getChildrenOfElement(rootElement); List<Element> propertyGroupList = TemplateEngine.getChildrenOfElement(rootElement);
for (int i = 0, l = propertyGroupList.size(); i < l; i++) { for (int i = 0, l = propertyGroupList.size(); i < l; i++) {
Element nextPGElement = (Element) propertyGroupList.get(i); Element nextPGElement = propertyGroupList.get(i);
if (isNestedElement(nextPGElement)) if (isNestedElement(nextPGElement))
nextPGElementName = nextPGElement.getNodeName(); nextPGElementName = nextPGElement.getNodeName();
if (nextPGElementName.equalsIgnoreCase(PROPERTY_GROUP) && isNestedElement(nextPGElement)) { if (nextPGElementName.equalsIgnoreCase(PROPERTY_GROUP) && isNestedElement(nextPGElement)) {
@ -173,10 +173,10 @@ public class TemplateDescriptor {
* @param propertyGroupElement * @param propertyGroupElement
* traverse the complex property-group element * traverse the complex property-group element
*/ */
private void propertyElements(Map/*<String, String>*/ defaults, Element propertyGroupElement) { private void propertyElements(Map<String, String> defaults, Element propertyGroupElement) {
List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(propertyGroupElement); List<Element> children = TemplateEngine.getChildrenOfElement(propertyGroupElement);
for (int i = 0, l = children.size(); i < l; i++) { for (int i = 0, l = children.size(); i < l; i++) {
Element propertyElement = (Element) children.get(i); Element propertyElement = children.get(i);
String key = propertyElement.getAttribute(ID); String key = propertyElement.getAttribute(ID);
String value = propertyElement.getAttribute(DEFAULT); String value = propertyElement.getAttribute(DEFAULT);
if (key != null && !key.equals("")) { //$NON-NLS-1$ if (key != null && !key.equals("")) { //$NON-NLS-1$
@ -202,7 +202,7 @@ public class TemplateDescriptor {
* *
* @return Vector. * @return Vector.
*/ */
public List/*<String>*/ getPersistTrueIDs() { public List<String> getPersistTrueIDs() {
return persistVector; return persistVector;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -15,7 +15,6 @@ import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
@ -35,7 +34,7 @@ import org.w3c.dom.NodeList;
/** /**
* TemplateEngine is implemented as a Singleton. TemplateEngine is responsible for * TemplateEngine is implemented as a Singleton. TemplateEngine is responsible for
* creating SharedDefaults and initializing the SharedDefaults. Template instances * creating SharedDefaults and initialising the SharedDefaults. Template instances
* are obtained from TemplateEngine. * are obtained from TemplateEngine.
* *
* @since 4.0 * @since 4.0
@ -53,13 +52,13 @@ public class TemplateEngine {
/** /**
* This is a Map <WizardID, TemplateInfo>. * This is a Map <WizardID, TemplateInfo>.
*/ */
private Map/*<String, List<TemplateInfo>>*/ templateInfoMap; private Map<String, List<TemplateInfo>> templateInfoMap;
/** /**
* TemplateEngine constructor, create and initialise SharedDefaults. * TemplateEngine constructor, create and initialise SharedDefaults.
*/ */
private TemplateEngine() { private TemplateEngine() {
templateInfoMap = new LinkedHashMap/*<String, List<TemplateInfo>>*/(); templateInfoMap = new LinkedHashMap<String, List<TemplateInfo>>();
initializeTemplateInfoMap(); initializeTemplateInfoMap();
} }
@ -68,7 +67,7 @@ public class TemplateEngine {
*/ */
public TemplateCore[] getTemplates() { public TemplateCore[] getTemplates() {
TemplateInfo[] templateInfoArray = getTemplateInfos(); TemplateInfo[] templateInfoArray = getTemplateInfos();
List/*<TemplateCore>*/ tcores = new ArrayList/*<TemplateCore>*/(); 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 {
@ -77,7 +76,7 @@ public class TemplateEngine {
CCorePlugin.log(CCorePlugin.createStatus(e.getMessage(), e)); CCorePlugin.log(CCorePlugin.createStatus(e.getMessage(), e));
} }
} }
return (TemplateCore[]) tcores.toArray(new TemplateCore[tcores.size()]); return tcores.toArray(new TemplateCore[tcores.size()]);
} }
/** /**
@ -120,7 +119,7 @@ public class TemplateEngine {
*/ */
public TemplateCore[] getTemplates(String projectType, String toolChain, String usageFilter) { public TemplateCore[] getTemplates(String projectType, String toolChain, String usageFilter) {
TemplateInfo[] templateInfoArray = getTemplateInfos(projectType, toolChain, usageFilter); TemplateInfo[] templateInfoArray = getTemplateInfos(projectType, toolChain, usageFilter);
List/*<Template>*/ templatesList = new ArrayList/*<Template>*/(); List<TemplateCore> templatesList = 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 {
@ -129,7 +128,7 @@ public class TemplateEngine {
CCorePlugin.log(tie); CCorePlugin.log(tie);
} }
} }
return (TemplateCore[]) templatesList.toArray(new TemplateCore[templatesList.size()]); return templatesList.toArray(new TemplateCore[templatesList.size()]);
} }
public TemplateCore[] getTemplates(String projectType, String toolChain) { public TemplateCore[] getTemplates(String projectType, String toolChain) {
@ -157,7 +156,7 @@ public class TemplateEngine {
* *
* @return * @return
*/ */
public static Map/*<String, String>*/ getSharedDefaults() { public static Map<String, String> getSharedDefaults() {
return SharedDefaults.getInstance().getSharedDefaultsMap(); return SharedDefaults.getInstance().getSharedDefaultsMap();
} }
@ -173,11 +172,9 @@ public class TemplateEngine {
* @param aSharedValue * @param aSharedValue
*/ */
public void updateSharedDefaults(TemplateCore template) { public void updateSharedDefaults(TemplateCore template) {
Map/*<String, String>*/ tobePersisted = new HashMap/*<String, String>*/(); Map<String, String> tobePersisted = new HashMap<String, String>();
Map/*<String, String>*/ valueStore = template.getValueStore(); Map<String, String> valueStore = template.getValueStore();
for(String key : template.getPersistTrueIDs()) {
for (Iterator i = template.getPersistTrueIDs().iterator(); i.hasNext();) {
String key = (String) i.next();
tobePersisted.put(key, valueStore.get(key)); tobePersisted.put(key, valueStore.get(key));
} }
SharedDefaults.getInstance().updateShareDefaultsMap(tobePersisted); SharedDefaults.getInstance().updateShareDefaultsMap(tobePersisted);
@ -236,7 +233,7 @@ public class TemplateEngine {
} }
IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN); IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN);
Set toolChainIdSet = new LinkedHashSet(); Set<String> toolChainIdSet = new LinkedHashSet<String>();
for (int k=0; k < toolChainConfigs.length; k++) { for (int k=0; k < toolChainConfigs.length; k++) {
toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID)); toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID));
} }
@ -245,9 +242,9 @@ public class TemplateEngine {
pluginId, toolChainIdSet, pluginId, toolChainIdSet,
extraPagesProvider, isCategory); extraPagesProvider, isCategory);
if (!templateInfoMap.containsKey(projectType)) { if (!templateInfoMap.containsKey(projectType)) {
templateInfoMap.put(projectType, new ArrayList/*<TemplateInfo>*/()); templateInfoMap.put(projectType, new ArrayList<TemplateInfo>());
} }
((List/*<TemplateInfo>*/)templateInfoMap.get(projectType)).add(templateInfo); (templateInfoMap.get(projectType)).add(templateInfo);
} }
} }
// Check for tool Chains added to the templates outside template info definition // Check for tool Chains added to the templates outside template info definition
@ -267,7 +264,7 @@ public class TemplateEngine {
templateId = config.getAttribute(TemplateEngineHelper.ID); templateId = config.getAttribute(TemplateEngineHelper.ID);
IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN); IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN);
Set toolChainIdSet = new LinkedHashSet(); Set<String> toolChainIdSet = new LinkedHashSet<String>();
for (int k=0; k < toolChainConfigs.length; k++) { for (int k=0; k < toolChainConfigs.length; k++) {
toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID)); toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID));
} }
@ -295,12 +292,11 @@ public class TemplateEngine {
* @return an array of TemplateInfo objects (never null) * @return an array of TemplateInfo objects (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 = templateInfoMap.get(projectType.trim());
List/*<TemplateInfo>*/ matchedTemplateInfoList = new ArrayList/*<TemplateInfo>*/(); List<TemplateInfo> matchedTemplateInfoList = new ArrayList<TemplateInfo>();
if (templateInfoList != null) { if (templateInfoList != null) {
for (Iterator i = templateInfoList.iterator(); i.hasNext(); ) { for(TemplateInfo templateInfo : templateInfoList) {
TemplateInfo templateInfo = (TemplateInfo) i.next();
String filterPattern = templateInfo.getFilterPattern(); String filterPattern = templateInfo.getFilterPattern();
String[] toolChains = templateInfo.getToolChainIds(); String[] toolChains = templateInfo.getToolChainIds();
@ -324,7 +320,7 @@ public class TemplateEngine {
} }
} }
} }
return (TemplateInfo[]) matchedTemplateInfoList.toArray(new TemplateInfo[matchedTemplateInfoList.size()]); return matchedTemplateInfoList.toArray(new TemplateInfo[matchedTemplateInfoList.size()]);
} }
public TemplateInfo[] getTemplateInfos(String projectType, String toolChain) { public TemplateInfo[] getTemplateInfos(String projectType, String toolChain) {
@ -340,12 +336,11 @@ public class TemplateEngine {
* @return * @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(List<TemplateInfo> infos : templateInfoMap.values()) {
infoList.addAll((List/*<TemplateInfo>*/)i.next()); infoList.addAll(infos);
} }
return infoList.toArray(new TemplateInfo[infoList.size()]);
return (TemplateInfo[]) infoList.toArray(new TemplateInfo[infoList.size()]);
} }
@ -354,7 +349,7 @@ public class TemplateEngine {
* *
* @return * @return
*/ */
public Map/*<String, List<TemplateInfo>>*/ getTemplateInfoMap() { public Map<String, List<TemplateInfo>> getTemplateInfoMap() {
return templateInfoMap; return templateInfoMap;
} }
@ -375,13 +370,13 @@ public class TemplateEngine {
* *
* @since 4.0 * @since 4.0
*/ */
public static List/*<Element>*/ getChildrenOfElement(Element element) { public static List<Element> getChildrenOfElement(Element element) {
List/*<Element>*/ list = new ArrayList/*<Element>*/(); List<Element> list = new ArrayList<Element>();
NodeList children = element.getChildNodes(); NodeList children = element.getChildNodes();
for (int i = 0, l = children.getLength(); i < l; i++) { for (int i = 0, l = children.getLength(); i < l; i++) {
Node child = children.item(i); Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) { if (child.getNodeType() == Node.ELEMENT_NODE) {
list.add(child); list.add((Element) child);
} }
} }
return list; return list;
@ -396,13 +391,13 @@ public class TemplateEngine {
* *
* @since 4.0 * @since 4.0
*/ */
public static List/*<Element>*/ getChildrenOfElementByTag(Element element, String tag) { public static List<Element> getChildrenOfElementByTag(Element element, String tag) {
List/*<Element>*/ list = new ArrayList/*<Element>*/(); List<Element> list = new ArrayList<Element>();
NodeList children = element.getChildNodes(); NodeList children = element.getChildNodes();
for (int i = 0, l = children.getLength(); i < l; i++) { for (int i = 0, l = children.getLength(); i < l; i++) {
Node child = children.item(i); Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(tag)) { if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals(tag)) {
list.add(child); list.add((Element) child);
} }
} }
return list; return list;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,7 +11,6 @@
package org.eclipse.cdt.core.templateengine; package org.eclipse.cdt.core.templateengine;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -22,7 +21,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
public class TemplateEngineUtil { public class TemplateEngineUtil {
public static void log(Throwable t) { public static void log(Throwable t) {
if (t == null) { if (t == null) {
return; return;
@ -34,10 +32,9 @@ public class TemplateEngineUtil {
ResourcesPlugin.getPlugin().getLog().log(((CoreException) t).getStatus()); ResourcesPlugin.getPlugin().getLog().log(((CoreException) t).getStatus());
} if (t instanceof ProcessFailureException) { } if (t instanceof ProcessFailureException) {
do { do {
List/*<IStatus>*/ statuses = ((ProcessFailureException) t).getStatuses(); List<IStatus> statuses = ((ProcessFailureException) t).getStatuses();
if (statuses != null) { if (statuses != null) {
for(Iterator i = statuses.iterator(); i.hasNext(); ) { for(IStatus status : statuses) {
IStatus status = (IStatus) i.next();
ResourcesPlugin.getPlugin().getLog().log(status); ResourcesPlugin.getPlugin().getLog().log(status);
} }
} }
@ -47,5 +44,4 @@ public class TemplateEngineUtil {
ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, t.getMessage() == null ? t.toString() : t.getMessage() , t)); ResourcesPlugin.getPlugin().getLog().log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.OK, t.getMessage() == null ? t.toString() : t.getMessage() , t));
} }
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -21,12 +21,12 @@ public class TemplateInfo {
private String filterPattern; private String filterPattern;
private String templatePath; private String templatePath;
private String pluginId; private String pluginId;
private Set toolChainIdSet; private Set<String> toolChainIdSet;
private Object pagesProvider; /* IPagesAfterTemplateSelectionProvider */ private Object pagesProvider; /*IPagesAfterTemplateSelectionProvider*/
private boolean isCategory; private boolean isCategory;
private String icon; private String icon;
private String templateId; private String templateId;
private List configs; private List<?> configs; /*This seems to be used for storing build-system specific configurations*/
/** /**
* *
@ -40,7 +40,7 @@ public class TemplateInfo {
* @param isCategory * @param isCategory
*/ */
public TemplateInfo(String templateId, String projectTypeId, String filterPattern, String templatePath, public TemplateInfo(String templateId, String projectTypeId, String filterPattern, String templatePath,
String pluginId, Set toolChainIdSet, String pluginId, Set<String> toolChainIdSet,
Object extraPagesProvider, boolean isCategory) { Object extraPagesProvider, boolean isCategory) {
this.templateId = templateId; this.templateId = templateId;
this.filterPattern = filterPattern; this.filterPattern = filterPattern;
@ -99,18 +99,18 @@ public class TemplateInfo {
* @return the toolChainIds * @return the toolChainIds
*/ */
public String[] getToolChainIds() { public String[] getToolChainIds() {
return (String[]) toolChainIdSet.toArray(new String[toolChainIdSet.size()]); return toolChainIdSet.toArray(new String[toolChainIdSet.size()]);
} }
public void setToolChainSet(Set toolChainIdSet) { public void setToolChainSet(Set<String> toolChainIdSet) {
this.toolChainIdSet = toolChainIdSet; this.toolChainIdSet = toolChainIdSet;
} }
public List getConfigurations() { public List<?> getConfigurations() {
return configs; return configs;
} }
public void setConfigurations(List configs) { public void setConfigurations(List<?> configs) {
this.configs = configs; this.configs = configs;
} }
@ -144,7 +144,6 @@ public class TemplateInfo {
} }
/* /*
* (non-Javadoc)
* @see java.lang.Object#hashCode() * @see java.lang.Object#hashCode()
*/ */
public int hashCode() { public int hashCode() {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -13,7 +13,6 @@ package org.eclipse.cdt.core.templateengine.process;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -40,12 +39,12 @@ import org.w3c.dom.Element;
public class ConditionalProcessGroup { public class ConditionalProcessGroup {
private TemplateCore template; private TemplateCore template;
private Set/*<String>*/ macros; private Set<String> macros;
private String conditionString; private String conditionString;
private String lValue; private String lValue;
private String rValue; private String rValue;
private Operator op; private Operator op;
private List/*<Process>*/ processes; private List<Process> processes;
private String id; private String id;
/** /**
@ -106,7 +105,7 @@ public class ConditionalProcessGroup {
private void collectMacros(String value) { private void collectMacros(String value) {
if (value != null) { if (value != null) {
if (macros == null) { if (macros == null) {
macros = new HashSet/*<String>*/(); macros = new HashSet<String>();
} }
macros.addAll(ProcessHelper.getReplaceKeys(value)); macros.addAll(ProcessHelper.getReplaceKeys(value));
} }
@ -125,15 +124,15 @@ public class ConditionalProcessGroup {
} }
/** /**
* Creates the Proccess from the process Elements. * Creates the Process from the process Elements.
* @param template * @param template
* @param processElements * @param processElements
*/ */
private void createProcessObjects(TemplateCore template, List/*<Element>*/ processElements) { private void createProcessObjects(TemplateCore template, List<Element> processElements) {
this.template = template; this.template = template;
this.processes = new ArrayList/*<Process>*/(processElements.size()); this.processes = new ArrayList<Process>(processElements.size());
for (int j = 0, l = processElements.size(); j < l; j++) { for (int j = 0, l = processElements.size(); j < l; j++) {
Element processElem = (Element) processElements.get(j); Element processElem = processElements.get(j);
if (processElem.getNodeName().equals(TemplateDescriptor.PROCESS)) { if (processElem.getNodeName().equals(TemplateDescriptor.PROCESS)) {
String processId = id + "--> Process " + (j + 1) + " (" + processElem.getAttribute(Process.ELEM_TYPE) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String processId = id + "--> Process " + (j + 1) + " (" + processElem.getAttribute(Process.ELEM_TYPE) + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
processes.add(new Process(template, processElem, processId)); processes.add(new Process(template, processElem, processId));
@ -153,8 +152,7 @@ public class ConditionalProcessGroup {
* @return boolean, as true if the Processes are ready to process * @return boolean, as true if the Processes are ready to process
*/ */
private boolean areProcessesReady() { private boolean areProcessesReady() {
for(Iterator i = processes.iterator(); i.hasNext(); ) { for(Process process : processes) {
Process process = (Process) i.next();
if (!process.isReadyToProcess()) { if (!process.isReadyToProcess()) {
return false; return false;
} }
@ -168,9 +166,8 @@ public class ConditionalProcessGroup {
*/ */
private boolean areMacrosForConditionEvaluationExpandable() { private boolean areMacrosForConditionEvaluationExpandable() {
if (macros != null) { if (macros != null) {
Map/*<String, String>*/ valueStore = template.getValueStore(); Map<String, String> valueStore = template.getValueStore();
for(Iterator i = macros.iterator(); i.hasNext(); ) { for(String value : macros) {
String value = (String) i.next();
if (valueStore.get(value) == null) { if (valueStore.get(value) == null) {
return false; return false;
} }
@ -190,13 +187,12 @@ public class ConditionalProcessGroup {
if (!areMacrosForConditionEvaluationExpandable()) { if (!areMacrosForConditionEvaluationExpandable()) {
return false; return false;
} }
Map/*<String, String>*/ valueStore = template.getValueStore(); Map<String, String> valueStore = template.getValueStore();
String lValue = this.lValue; String lValue = this.lValue;
String rValue = this.rValue; String rValue = this.rValue;
for(Iterator i = macros.iterator(); i.hasNext(); ) { for(String value : macros) {
String value = (String) i.next(); lValue = lValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, valueStore.get(value));
lValue = lValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, (String) valueStore.get(value)); rValue = rValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, valueStore.get(value));
rValue = rValue.replaceAll(ProcessHelper.START_PATTERN + value + ProcessHelper.END_PATTERN, (String) valueStore.get(value));
} }
if(op.equals(Operator.EQUALS)) { if(op.equals(Operator.EQUALS)) {
return lValue.equals(rValue); return lValue.equals(rValue);
@ -213,18 +209,17 @@ public class ConditionalProcessGroup {
* @return List contains the IStatus. * @return List contains the IStatus.
* @throws ProcessFailureException * @throws ProcessFailureException
*/ */
public List/*<IStatus>*/ process(IProgressMonitor monitor) throws ProcessFailureException { public List<IStatus> process(IProgressMonitor monitor) throws ProcessFailureException {
if (!areMacrosForConditionEvaluationExpandable()) { if (!areMacrosForConditionEvaluationExpandable()) {
throw new ProcessFailureException(getUnexpandableMacroMessage()); throw new ProcessFailureException(getUnexpandableMacroMessage());
} }
if (!isConditionValueTrue()) { if (!isConditionValueTrue()) {
List/*<IStatus>*/ statuses = new ArrayList/*<IStatus>*/(1); List<IStatus> statuses = new ArrayList<IStatus>(1);
statuses.add(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.INFO, TemplateEngineMessages.getString("ConditionalProcessGroup.notExecuting") + id, null)); //$NON-NLS-1$ statuses.add(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.INFO, TemplateEngineMessages.getString("ConditionalProcessGroup.notExecuting") + id, null)); //$NON-NLS-1$
return statuses; return statuses;
} }
List/*<IStatus>*/ statuses = new ArrayList/*<IStatus>*/(processes.size()); List<IStatus> statuses = new ArrayList<IStatus>(processes.size());
for(Iterator i = processes.iterator(); i.hasNext(); ) { for(Process process : processes) {
Process process = (Process) i.next();
try { try {
statuses.add(process.process(monitor)); statuses.add(process.process(monitor));
} catch (ProcessFailureException e) { } catch (ProcessFailureException e) {
@ -240,9 +235,8 @@ public class ConditionalProcessGroup {
*/ */
private String getUnexpandableMacroMessage() { private String getUnexpandableMacroMessage() {
if (macros != null) { if (macros != null) {
Map/*<String, String>*/ valueStore = template.getValueStore(); Map<String, String> valueStore = template.getValueStore();
for(Iterator i = macros.iterator(); i.hasNext(); ) { for(String value : macros) {
String value = (String) i.next();
if (valueStore.get(value) == null) { if (valueStore.get(value) == null) {
return TemplateEngineMessages.getString("ConditionalProcessGroup.unexpandableMacro") + value; //$NON-NLS-1$ return TemplateEngineMessages.getString("ConditionalProcessGroup.unexpandableMacro") + value; //$NON-NLS-1$
} }
@ -255,7 +249,7 @@ public class ConditionalProcessGroup {
* Returns the Macros as a Set. * Returns the Macros as a Set.
* @return Set, contains macros * @return Set, contains macros
*/ */
public Set/*<String>*/ getMacros() { public Set<String> getMacros() {
return macros; return macros;
} }
@ -263,18 +257,17 @@ public class ConditionalProcessGroup {
* Returns All Macros as a Set. * Returns All Macros as a Set.
* @return Set, contains macros * @return Set, contains macros
*/ */
public Set/*<String>*/ getAllMacros() { public Set<String> getAllMacros() {
Set/*<String>*/ set = null; Set<String> set = null;
if (macros != null) { if (macros != null) {
set = new HashSet/*<String>*/(); set = new HashSet<String>();
set.addAll(macros); set.addAll(macros);
} }
for(Iterator i = processes.iterator(); i.hasNext(); ) { for(Process process : processes) {
Process process = (Process) i.next(); Set<String> subSet = process.getMacros();
Set/*<String>*/ subSet = process.getMacros();
if (subSet != null) { if (subSet != null) {
if (set == null) { if (set == null) {
set = new HashSet/*<String>*/(); set = new HashSet<String>();
} }
set.addAll(subSet); set.addAll(subSet);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -61,14 +61,14 @@ public class Process {
* @param element * @param element
*/ */
private void buildArgs(TemplateCore template, Element element) { private void buildArgs(TemplateCore template, Element element) {
List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(element); List<Element> children = TemplateEngine.getChildrenOfElement(element);
ProcessParameter[] params = processRunner.getProcessParameters(); ProcessParameter[] params = processRunner.getProcessParameters();
List/*<ProcessArgument>*/ list = new ArrayList/*<ProcessArgument>*/(params.length); List<ProcessArgument> list = new ArrayList<ProcessArgument>(params.length);
int childIndex = 0; int childIndex = 0;
for(int i=0; i<params.length; i++) { for(int i=0; i<params.length; i++) {
ProcessParameter param = params[i]; ProcessParameter param = params[i];
boolean childrenRemain = childIndex < children.size(); boolean childrenRemain = childIndex < children.size();
Element child = (Element) (childrenRemain ? children.get(childIndex) : null); Element child = (childrenRemain ? children.get(childIndex) : null);
if (param.isExternal() && (!childrenRemain || !param.getName().equals(child.getAttribute(ProcessArgument.ELEM_NAME)))) { if (param.isExternal() && (!childrenRemain || !param.getName().equals(child.getAttribute(ProcessArgument.ELEM_NAME)))) {
list.add(new ProcessArgument(template, param)); list.add(new ProcessArgument(template, param));
} else if (childrenRemain) { } else if (childrenRemain) {
@ -77,9 +77,9 @@ public class Process {
} }
} }
while (childIndex < children.size()) { while (childIndex < children.size()) {
list.add(new ProcessArgument(template, (Element) children.get(childIndex++))); list.add(new ProcessArgument(template, children.get(childIndex++)));
} }
args = (ProcessArgument[]) list.toArray(new ProcessArgument[list.size()]); args = list.toArray(new ProcessArgument[list.size()]);
} }
/** /**
@ -178,15 +178,15 @@ public class Process {
* Returns the Macros. * Returns the Macros.
* @return * @return
*/ */
public Set/*<String>*/ getMacros() { public Set<String> getMacros() {
Set/*<String>*/ set = null; Set<String> set = null;
if (args != null) { if (args != null) {
for(int i=0; i<args.length; i++) { for(int i=0; i<args.length; i++) {
ProcessArgument arg = args[i]; ProcessArgument arg = args[i];
Set/*<String>*/ subSet = arg.getMacros(); Set<String> subSet = arg.getMacros();
if (subSet != null) { if (subSet != null) {
if (set == null) { if (set == null) {
set = new HashSet/*<String>*/(); set = new HashSet<String>();
} }
set.addAll(subSet); set.addAll(subSet);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -11,16 +11,13 @@
package org.eclipse.cdt.core.templateengine.process; package org.eclipse.cdt.core.templateengine.process;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
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.w3c.dom.Element; import org.w3c.dom.Element;
/** /**
* ProcessArgument class responsible for constructing process Arguments by taking info from Template. * ProcessArgument class responsible for constructing process Arguments by taking info from Template.
*/ */
@ -47,7 +44,7 @@ public class ProcessArgument {
private TemplateCore template; private TemplateCore template;
private Set/*<String>*/ macros; private Set<String> macros;
private boolean resolved; private boolean resolved;
private ProcessParameter externalParam; private ProcessParameter externalParam;
@ -66,21 +63,21 @@ public class ProcessArgument {
collectMacros(simpleValue); collectMacros(simpleValue);
} else if (elemName.equals(ELEM_SIMPLE_ARRAY)) { } else if (elemName.equals(ELEM_SIMPLE_ARRAY)) {
type = ProcessParameter.SIMPLE_ARRAY; type = ProcessParameter.SIMPLE_ARRAY;
List/*<Element>*/ valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT); List<Element> valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT);
simpleValueArray = new String[valueElements.size()]; simpleValueArray = new String[valueElements.size()];
for (int i = 0, l = valueElements.size(); i < l; i++) { for (int i = 0, l = valueElements.size(); i < l; i++) {
simpleValueArray[i] = ((Element)valueElements.get(i)).getAttribute(ELEM_VALUE); simpleValueArray[i] = (valueElements.get(i)).getAttribute(ELEM_VALUE);
collectMacros(simpleValueArray[i]); collectMacros(simpleValueArray[i]);
} }
} else if (elemName.equals(ELEM_COMPLEX)) { } else if (elemName.equals(ELEM_COMPLEX)) {
type = ProcessParameter.COMPLEX; type = ProcessParameter.COMPLEX;
List/*<Element>*/ children = TemplateEngine.getChildrenOfElement(elem); List<Element> children = TemplateEngine.getChildrenOfElement(elem);
complexValue = new ProcessArgument[children.size()]; complexValue = new ProcessArgument[children.size()];
for (int i = 0, l = children.size(); i < l; i++) { for (int i = 0, l = children.size(); i < l; i++) {
complexValue[i] = new ProcessArgument(template, (Element) children.get(i)); complexValue[i] = new ProcessArgument(template, children.get(i));
Set/*<String>*/ subMacros = complexValue[i].getMacros(); Set<String> subMacros = complexValue[i].getMacros();
if (macros == null) { if (macros == null) {
macros = new HashSet/*<String>*/(); macros = new HashSet<String>();
} }
if (subMacros != null) { if (subMacros != null) {
macros.addAll(subMacros); macros.addAll(subMacros);
@ -88,18 +85,18 @@ public class ProcessArgument {
} }
} else if (elemName.equals(ELEM_COMPLEX_ARRAY)) { } else if (elemName.equals(ELEM_COMPLEX_ARRAY)) {
type = ProcessParameter.COMPLEX_ARRAY; type = ProcessParameter.COMPLEX_ARRAY;
List/*<Element>*/ valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT); List<Element> valueElements = TemplateEngine.getChildrenOfElementByTag(elem, ELEM_ELEMENT);
complexValueArray = new ProcessArgument[valueElements.size()][]; complexValueArray = new ProcessArgument[valueElements.size()][];
for (int i = 0, l = valueElements.size(); i < l; i++) { for (int i = 0, l = valueElements.size(); i < l; i++) {
List/*<Element>*/ children = TemplateEngine.getChildrenOfElement((Element)valueElements.get(i)); List<Element> children = TemplateEngine.getChildrenOfElement(valueElements.get(i));
complexValueArray[i] = new ProcessArgument[children.size()]; complexValueArray[i] = new ProcessArgument[children.size()];
for (int j = 0, l2 = children.size(); j < l2; j++) { for (int j = 0, l2 = children.size(); j < l2; j++) {
complexValueArray[i][j] = new ProcessArgument(template, (Element) children.get(j)); complexValueArray[i][j] = new ProcessArgument(template, children.get(j));
Set/*<String>*/ subMacros = complexValueArray[i][j].getMacros(); Set<String> subMacros = complexValueArray[i][j].getMacros();
if (subMacros != null) { if (subMacros != null) {
if (macros == null) { if (macros == null) {
macros = new HashSet/*<String>*/(); macros = new HashSet<String>();
} }
macros.addAll(subMacros); macros.addAll(subMacros);
} }
@ -116,7 +113,7 @@ public class ProcessArgument {
this.template = template; this.template = template;
name = param.getName(); name = param.getName();
type = param.getType(); type = param.getType();
macros = new HashSet/*<String>*/(); macros = new HashSet<String>();
macros.add(name); macros.add(name);
simpleValue = ProcessHelper.getReplaceMarker(name); simpleValue = ProcessHelper.getReplaceMarker(name);
this.externalParam = param; this.externalParam = param;
@ -131,7 +128,7 @@ public class ProcessArgument {
return; return;
} }
if (macros == null) { if (macros == null) {
macros = new HashSet/*<String>*/(); macros = new HashSet<String>();
} }
macros.addAll(ProcessHelper.getReplaceKeys(value)); macros.addAll(ProcessHelper.getReplaceKeys(value));
} }
@ -242,9 +239,8 @@ public class ProcessArgument {
if (macros == null || macros.size() == 0) { if (macros == null || macros.size() == 0) {
return true; return true;
} }
Map/*<String, String>*/ valueStore = template.getValueStore(); Map<String, String> valueStore = template.getValueStore();
for(Iterator i = macros.iterator(); i.hasNext(); ) { for(String macro : macros) {
String macro = (String) i.next();
if (valueStore.get(macro) == null) { if (valueStore.get(macro) == null) {
return false; return false;
} }
@ -283,9 +279,8 @@ public class ProcessArgument {
if (macros == null || macros.size() == 0) { if (macros == null || macros.size() == 0) {
return null; return null;
} }
Map/*<String, String>*/ valueStore = template.getValueStore(); Map<String, String> valueStore = template.getValueStore();
for(Iterator i = macros.iterator(); i.hasNext(); ) { for(String macro : macros) {
String macro = (String) i.next();
if (valueStore.get(macro) == null) { if (valueStore.get(macro) == null) {
return macro; return macro;
} }
@ -319,7 +314,7 @@ public class ProcessArgument {
* Returns the Macros as Set. * Returns the Macros as Set.
* @return Set, contains the Macros. * @return Set, contains the Macros.
*/ */
public Set/*<String>*/ getMacros() { public Set<String> getMacros() {
return macros; return macros;
} }
@ -328,11 +323,11 @@ public class ProcessArgument {
* *
*/ */
public void resolve() { public void resolve() {
Map/*<String, String>*/ valueStore = template.getValueStore(); Map<String, String> valueStore = template.getValueStore();
switch (type) { switch (type) {
case ProcessParameter.SIMPLE: case ProcessParameter.SIMPLE:
if (externalParam != null) { if (externalParam != null) {
resolvedSimpleValue = (String) template.getValueStore().get(name); resolvedSimpleValue = template.getValueStore().get(name);
} else { } else {
resolvedSimpleValue = simpleValue; resolvedSimpleValue = simpleValue;
if (macros != null && !macros.isEmpty()) { if (macros != null && !macros.isEmpty()) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,12 +12,14 @@ package org.eclipse.cdt.core.templateengine.process;
import java.util.List; import java.util.List;
import org.eclipse.core.runtime.IStatus;
public class ProcessFailureException extends Exception { public class ProcessFailureException extends Exception {
private static final long serialVersionUID = 1766239661286962870L; private static final long serialVersionUID = 1766239661286962870L;
private List/*<IStatus>*/ statuses; private List<IStatus> statuses;
/** /**
* Constructor based on the msg. * Constructor based on the message.
* @param msg * @param msg
*/ */
public ProcessFailureException(String msg) { public ProcessFailureException(String msg) {
@ -25,7 +27,7 @@ public class ProcessFailureException extends Exception {
} }
/** /**
* Constructor based on the msg and cause. * Constructor based on the message and cause.
* @param cause * @param cause
*/ */
public ProcessFailureException(Throwable cause) { public ProcessFailureException(Throwable cause) {
@ -33,7 +35,7 @@ public class ProcessFailureException extends Exception {
} }
/** /**
* Constructor based on the msg and cause. * Constructor based on the message and cause.
* @param msg * @param msg
* @param cause * @param cause
*/ */
@ -42,16 +44,16 @@ public class ProcessFailureException extends Exception {
} }
/** /**
* Constructor based on the msg and causes. * Constructor based on the message and causes.
* @param msg * @param msg
* @param statuses * @param statuses
*/ */
public ProcessFailureException(String msg, List/*<IStatus>*/ statuses) { public ProcessFailureException(String msg, List<IStatus> statuses) {
super(msg); super(msg);
this.statuses = statuses; this.statuses = statuses;
} }
public ProcessFailureException(String msg, Throwable cause, List/*<IStatus>*/ statuses) { public ProcessFailureException(String msg, Throwable cause, List<IStatus> statuses) {
super(msg, cause); super(msg, cause);
this.statuses = statuses; this.statuses = statuses;
} }
@ -60,7 +62,7 @@ public class ProcessFailureException extends Exception {
* Returns the Statuses. * Returns the Statuses.
* @return List, contains the IStatus. * @return List, contains the IStatus.
*/ */
public List/*<IStatus>*/ getStatuses() { public List<IStatus> getStatuses() {
return statuses; return statuses;
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Bala Torati (Symbian) - Initial API and implementation * Bala Torati (Symbian) - Initial API and implementation
* Mark Espiritu (VastSystems) - bug 215283
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.templateengine.process; package org.eclipse.cdt.core.templateengine.process;
@ -71,24 +72,18 @@ public class ProcessHelper {
* $(item), vector contains 'item' as one item. , ) is the end pattern. * $(item), vector contains 'item' as one item. , ) is the end pattern.
* *
* @param str, * @param str,
* A given string may contains replace markers. * A given string possibly containing markers.
* @param pattern * @return the set of names occurring within markers
* start pattern (e.g., $( is the start pattern)
* @param endPat
* end pattern (e.g., ) is the end pattern)
* @return a set of all replace marker strings.
*
* @since 4.0 * @since 4.0
*/ */
public static Set/*<String>*/ getReplaceKeys(String str) { public static Set<String> getReplaceKeys(String str) {
int start = 0; Set<String> replaceStrings = new HashSet<String>();
int end = 0; int start= 0, end= 0;
Set/*<String>*/ replaceStrings = new HashSet/*<String>*/();
while ((start = str.indexOf(START_PATTERN, start)) >= 0) { while ((start = str.indexOf(START_PATTERN, start)) >= 0) {
end = str.indexOf(END_PATTERN, start); end = str.indexOf(END_PATTERN, start);
if (end != -1) { if (end != -1) {
replaceStrings.add(str.substring(start + START_PATTERN.length(), end)); replaceStrings.add(str.substring(start + START_PATTERN.length(), end));
start = end + START_PATTERN.length(); start = end + END_PATTERN.length();
} else } else
start++; start++;
} }
@ -177,7 +172,7 @@ public class ProcessHelper {
/** /**
* Returns the Macro Value after Exanding the Macros. * Returns the Macro Value after expanding the Macros.
* @param string * @param string
* @param macros * @param macros
* @param valueStore * @param valueStore
@ -185,41 +180,19 @@ public class ProcessHelper {
* *
* @since 4.0 * @since 4.0
*/ */
public static String getValueAfterExpandingMacros(String string, Set/*<String>*/ macros, Map/*<String, String>*/ valueStore) { public static String getValueAfterExpandingMacros(String string, Set<String> macros, Map<String, String> valueStore) {
for (Iterator i = macros.iterator(); i.hasNext();) { for (Iterator<String> i = macros.iterator(); i.hasNext();) {
String key = (String) i.next(); String key = i.next();
String value = (String) valueStore.get(key); String value = valueStore.get(key);
if (value != null) { if (value != null) {
string = replace(START_PATTERN + key + END_PATTERN, value, string); string = string.replace(START_PATTERN + key + END_PATTERN, value);
} }
} }
return string; return string;
} }
/**
* This is equivalent to Java 5.0 version of
* String.replace(CharSequence target, CharSequence replacement) method.
* @since 4.0
*/
private static String replace(String target, String replacement, String string) {
try {
StringBuffer stringBuffer = new StringBuffer(string);
int index = string.length();
int offset = target.length();
while ((index=string.lastIndexOf(target, index-1)) != -1) {
stringBuffer.replace(index, index+offset, replacement);
}
return stringBuffer.toString();
} catch (StringIndexOutOfBoundsException e) {
return string;
}
}
/** /**
* Consturct and Return the Replacment Markers * Construct and return the replacement markers
* after adding the patterns to the macro. * after adding the patterns to the macro.
* @param macro * @param macro
* @return * @return

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -23,7 +23,6 @@ import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint; import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
/** /**
* Factory class for creating the Process Runners. * Factory class for creating the Process Runners.
*/ */
@ -37,18 +36,18 @@ public class ProcessRunnerFactory {
instance = new ProcessRunnerFactory(); instance = new ProcessRunnerFactory();
} }
private Map/*<String, ProcessRunner>*/ processRunnerMap; private Map<String, ProcessRunner> processRunnerMap;
private ProcessRunnerFactory() { private ProcessRunnerFactory() {
initializeProcessRunners(); initializeProcessRunners();
} }
/** /**
* initializes the process runners. * Initialises the process runners.
* *
*/ */
private synchronized void initializeProcessRunners() { private synchronized void initializeProcessRunners() {
processRunnerMap = new HashMap/*<String, ProcessRunner>*/(); processRunnerMap = new HashMap<String, ProcessRunner>();
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_PROCESSES); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(EXTENSION_POINT_PROCESSES);
IExtension[] extensions = point.getExtensions(); IExtension[] extensions = point.getExtensions();
for(int i=0; i<extensions.length; i++) { for(int i=0; i<extensions.length; i++) {
@ -61,21 +60,20 @@ public class ProcessRunnerFactory {
if (processType != null) { if (processType != null) {
try { try {
ProcessRunner runner = (ProcessRunner) element.createExecutableExtension(ELEM_PROCESS_RUNNER); ProcessRunner runner = (ProcessRunner) element.createExecutableExtension(ELEM_PROCESS_RUNNER);
List/*<ProcessParameter>*/ params = null; List<ProcessParameter> params = null;
IConfigurationElement[] elementChildren = element.getChildren(); IConfigurationElement[] elementChildren = element.getChildren();
for (int k=0; k<elementChildren.length; k++) { for (int k=0; k<elementChildren.length; k++) {
if (params == null) { if (params == null) {
params = new ArrayList/*<ProcessParameter>*/(); params = new ArrayList<ProcessParameter>();
} }
params.add(new ProcessParameter(elementChildren[k])); params.add(new ProcessParameter(elementChildren[k]));
} }
if (params != null) { if (params != null) {
runner.setProcessParameters((ProcessParameter[])params.toArray(new ProcessParameter[params.size()])); runner.setProcessParameters(params.toArray(new ProcessParameter[params.size()]));
} }
processRunnerMap.put(prefix + processType, runner); processRunnerMap.put(prefix + processType, runner);
} catch (CoreException e) { } catch (CoreException e) {
TemplateEngineUtil.log(e); TemplateEngineUtil.log(e);
// TemplateEngine.showError(e.getMessage(), e);
} }
} }
} }
@ -83,7 +81,7 @@ public class ProcessRunnerFactory {
} }
/** /**
* Process Runners Factory instace. * Process Runners Factory instance.
* @return * @return
*/ */
public static ProcessRunnerFactory getDefault() { public static ProcessRunnerFactory getDefault() {
@ -96,6 +94,6 @@ public class ProcessRunnerFactory {
* @return * @return
*/ */
public ProcessRunner getProcessRunner(String processType) { public ProcessRunner getProcessRunner(String processType) {
return (ProcessRunner) processRunnerMap.get(processType); return processRunnerMap.get(processType);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -12,7 +12,6 @@ package org.eclipse.cdt.core.templateengine.process;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -30,7 +29,7 @@ import org.w3c.dom.Element;
public class TemplateProcessHandler { public class TemplateProcessHandler {
private TemplateCore template; private TemplateCore template;
private List/*<ConditionalProcessGroup>*/ conditionalProcessGroupList; private List<ConditionalProcessGroup> conditionalProcessGroupList;
public TemplateProcessHandler(TemplateCore template) { public TemplateProcessHandler(TemplateCore template) {
this.template = template; this.template = template;
@ -38,20 +37,19 @@ public class TemplateProcessHandler {
} }
/** /**
* initializes the template descriptor and Root Elements. * Initialises the template descriptor and Root Elements.
*
*/ */
private void initialize() { private void initialize() {
TemplateDescriptor desc = template.getTemplateDescriptor(); TemplateDescriptor desc = template.getTemplateDescriptor();
Element root = desc.getRootElement(); Element root = desc.getRootElement();
conditionalProcessGroupList = new ArrayList/*<ConditionalProcessGroup>*/(); conditionalProcessGroupList = new ArrayList<ConditionalProcessGroup>();
List/*<Element>*/ nodeList = TemplateEngine.getChildrenOfElementByTag(root, TemplateDescriptor.IF); List<Element> nodeList = TemplateEngine.getChildrenOfElementByTag(root, TemplateDescriptor.IF);
for (int j = 0, l = nodeList.size(); j < l; j++) { for (int j = 0, l = nodeList.size(); j < l; j++) {
conditionalProcessGroupList.add(new ConditionalProcessGroup(template, (Element) nodeList.get(j), j + 1)); conditionalProcessGroupList.add(new ConditionalProcessGroup(template, nodeList.get(j), j + 1));
} }
//Collect all free-hanging processes in one ConditionalProcessGroup object with condition true. //Collect all free-hanging processes in one ConditionalProcessGroup object with condition true.
nodeList = TemplateEngine.getChildrenOfElementByTag(root, TemplateDescriptor.PROCESS); nodeList = TemplateEngine.getChildrenOfElementByTag(root, TemplateDescriptor.PROCESS);
conditionalProcessGroupList.add(new ConditionalProcessGroup(template, (Element[]) nodeList.toArray(new Element[nodeList.size()]))); conditionalProcessGroupList.add(new ConditionalProcessGroup(template, nodeList.toArray(new Element[nodeList.size()])));
} }
/** /**
@ -61,25 +59,25 @@ public class TemplateProcessHandler {
* @throws ProcessFailureException * @throws ProcessFailureException
*/ */
public IStatus[] processAll(IProgressMonitor monitor) throws ProcessFailureException { public IStatus[] processAll(IProgressMonitor monitor) throws ProcessFailureException {
List/*<IStatus>*/ allStatuses = new ArrayList/*<IStatus>*/(); List<IStatus> allStatuses = new ArrayList<IStatus>();
for (Iterator i = conditionalProcessGroupList.iterator(); i.hasNext();) { for(ConditionalProcessGroup cpg : conditionalProcessGroupList) {
try { try {
allStatuses.addAll(((ConditionalProcessGroup)i.next()).process(monitor)); allStatuses.addAll(cpg.process(monitor));
} catch (ProcessFailureException e) { } catch (ProcessFailureException e) {
throw new ProcessFailureException(e.getMessage(), e, allStatuses); throw new ProcessFailureException(e.getMessage(), e, allStatuses);
} }
} }
return (IStatus[]) allStatuses.toArray(new IStatus[allStatuses.size()]); return allStatuses.toArray(new IStatus[allStatuses.size()]);
} }
/** /**
* Returns all macros * Returns all macros
* @return * @return
*/ */
public Set/*<String>*/ getAllMacros() { public Set<String> getAllMacros() {
Set/*<String>*/ set = new HashSet/*<String>*/(); Set<String> set = new HashSet<String>();
for (Iterator i = conditionalProcessGroupList.iterator(); i.hasNext();) { for(ConditionalProcessGroup cpg : conditionalProcessGroupList) {
Set/*<String>*/ subSet = ((ConditionalProcessGroup)i.next()).getAllMacros(); Set<String> subSet = cpg.getAllMacros();
if (subSet != null) { if (subSet != null) {
set.addAll(subSet); set.addAll(subSet);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 Symbian Software Limited and others. * Copyright (c) 2007, 2008 Symbian Software Limited and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -104,14 +104,14 @@ public class CreateSourceFolder extends ProcessRunner {
for(int i=0; i < configs.length; i++){ for(int i=0; i < configs.length; i++){
ICConfigurationDescription config = configs[i]; ICConfigurationDescription config = configs[i];
ICSourceEntry[] entries = config.getSourceEntries(); ICSourceEntry[] entries = config.getSourceEntries();
Set set = new HashSet(); Set<ICSourceEntry> set = new HashSet<ICSourceEntry>();
for (int j=0; j < entries.length; j++) { for (int j=0; j < entries.length; j++) {
if(new Path(entries[j].getValue()).segmentCount() == 1) if(new Path(entries[j].getValue()).segmentCount() == 1)
continue; continue;
set.add(entries[j]); set.add(entries[j]);
} }
set.add(newEntry); set.add(newEntry);
config.setSourceEntries((ICSourceEntry[])set.toArray(new ICSourceEntry[set.size()])); config.setSourceEntries(set.toArray(new ICSourceEntry[set.size()]));
} }
CCorePlugin.getDefault().setProjectDescription(projectHandle, description, false, monitor); CCorePlugin.getDefault().setProjectDescription(projectHandle, description, false, monitor);
@ -126,7 +126,7 @@ public class CreateSourceFolder extends ProcessRunner {
*/ */
private void createFolder(String targetPath, IProgressMonitor monitor, IPath projPath, ICProject cProject) throws CModelException { private void createFolder(String targetPath, IProgressMonitor monitor, IPath projPath, ICProject cProject) throws CModelException {
IPathEntry[] entries = cProject.getRawPathEntries(); IPathEntry[] entries = cProject.getRawPathEntries();
List/*<IPathEntry>*/ newEntries = new ArrayList/*<IPathEntry>*/(entries.length + 1); List<IPathEntry> newEntries = new ArrayList<IPathEntry>(entries.length + 1);
int projectEntryIndex= -1; int projectEntryIndex= -1;
IPath path = projPath.append(targetPath); IPath path = projPath.append(targetPath);
@ -151,7 +151,7 @@ public class CreateSourceFolder extends ProcessRunner {
newEntries.add(CoreModel.newSourceEntry(path)); newEntries.add(CoreModel.newSourceEntry(path));
} }
cProject.setRawPathEntries((IPathEntry[])newEntries.toArray(new IPathEntry[newEntries.size()]), monitor); cProject.setRawPathEntries(newEntries.toArray(new IPathEntry[newEntries.size()]), monitor);
} }
} }