1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

patch from Bala Torati with small modifications

1. Fix for [Bug 184449] [Template Engine] It should be possible to press "Finish" on the first wizard page for templates having default values assigned
2. Fix for [Bug 184593] [Template Engine] Need a way to add tool-chain associations to existing templates
3. Fix for [Bug 184455] [Template Engine] NPE in template engine tests
This commit is contained in:
Mikhail Sennikovsky 2007-05-10 16:03:53 +00:00
parent 463823931b
commit 13968f3102
22 changed files with 391 additions and 114 deletions

View file

@ -6657,34 +6657,42 @@
<extension
point="org.eclipse.cdt.core.templates">
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringOptionValue"
filterPattern=".*AppendToMBSStringOptionValue"
location="testdata/AppendToMBSStringOptionValue.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.AppendToMBSStringListOptionValues"
filterPattern=".*AppendToMBSStringListOptionValues"
location="testdata/AppendToMBSStringListOptionValues.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.CreateIncludeFolder"
filterPattern=".*CreateIncludeFolder"
location="testdata/CreateIncludeFolder.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.ExcludeResources"
filterPattern=".*ExcludeResources"
location="testdata/ExcludeResources.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.NewManagedProject"
filterPattern=".*NewManagedProject"
location="testdata/NewManagedProject.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSBooleanOptionValue"
filterPattern=".*SetMBSBooleanOptionValue"
location="testdata/SetMBSBooleanOptionValue.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringOptionValue"
filterPattern=".*SetMBSStringOptionValue"
location="testdata/SetMBSStringOptionValue.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>
<template
id="org.eclipse.cdt.managedbuilder.core.tests.templates.SetMBSStringListOptionValues"
filterPattern=".*SetMBSStringListOptionValues"
location="testdata/SetMBSStringListOptionValues.xml"
projectType="org.eclipse.cdt.managedbuilder.core.tests.projectType"/>

View file

@ -3733,35 +3733,48 @@
<extension point="org.eclipse.cdt.core.templates">
<template
id="org.eclipse.cdt.build.core.templates.HelloWorldCCProject"
filterPattern=".*"
location="templates/projecttemplates/HelloWorldCCProject/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
</template>
<template
id="org.eclipse.cdt.build.templates.HelloWorldCAnsiProject"
filterPattern=".*"
location="templates/projecttemplates/HelloWorldCAnsiProject/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
</template>
<template
id="org.eclipse.cdt.build.core.templates.EmptyProject"
filterPattern=".*"
location="templates/projecttemplates/EmptyProject/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
</extension>
<extension
point="org.eclipse.cdt.core.templateAssociations">
<template id="org.eclipse.cdt.build.core.templates.EmptyProject">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
</template>
</extension>
<template id="org.eclipse.cdt.build.core.templates.HelloWorldCAnsiProject">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
</template>
<template id="org.eclipse.cdt.build.core.templates.HelloWorldCCProject">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.macosx.base"/>
<toolChain id="cdt.managedbuild.toolchain.gnu.solaris.base"/>
</template>
</extension>
</plugin>

View file

@ -65,12 +65,14 @@
<extension
point="org.eclipse.cdt.core.templates">
<template
id="org.eclipse.cdt.core.tests.templates.AddFile"
filterPattern=".*AddFile"
isCategory="true"
location="testdata/AddFile.xml"
projectType="org.eclipse.cdt.core.tests.projectType">
</template>
<template
id="org.eclipse.cdt.core.tests.templates.AddFiles"
filterPattern=".*AddFiles"
location="testdata/AddFiles.xml"
projectType="org.eclipse.cdt.core.tests.projectType">
@ -78,30 +80,49 @@
<toolChain id="org.eclipse.cdt.core.tests.toolChain2"/>
</template>
<template
id="org.eclipse.cdt.core.tests.templates.AddLink"
filterPattern=".*AddLink"
location="testdata/AddLink.xml"
projectType="org.eclipse.cdt.core.tests.projectType">
</template>
<template
id="org.eclipse.cdt.core.tests.templates.Append"
filterPattern=".*Append"
location="testdata/Append.xml"
projectType="org.eclipse.cdt.core.tests.projectType"/>
<template
id="org.eclipse.cdt.core.tests.templates.AppendCreate"
filterPattern=".*AppendCreate"
location="testdata/AppendCreate.xml"
projectType="org.eclipse.cdt.core.tests.projectType"/>
<template
id="org.eclipse.cdt.core.tests.templates.Copy"
filterPattern=".*Copy"
location="testdata/Copy.xml"
projectType="org.eclipse.cdt.core.tests.projectType"/>
<template
id="org.eclipse.cdt.core.tests.templates.CreateResourceIdentifier"
filterPattern=".*CreateResourceIdentifier"
location="testdata/CreateResourceIdentifier.xml"
projectType="org.eclipse.cdt.core.tests.projectType"/>
<template
id="org.eclipse.cdt.core.tests.templates.CreateSourceFolder"
filterPattern=".*CreateSourceFolder"
location="testdata/CreateSourceFolder.xml"
projectType="org.eclipse.cdt.core.tests.projectType"/>
</extension>
<extension
point="org.eclipse.cdt.core.templateAssociations">
<template
id="org.eclipse.cdt.core.tests.templates.AddFile">
<toolChain id="org.eclipse.cdt.core.tests.toolChain3"/>
<toolChain id="org.eclipse.cdt.core.tests.toolChain4"/>
</template>
<template
id="org.eclipse.cdt.core.tests.templates.AddFiles">
<toolChain id="org.eclipse.cdt.core.tests.toolChain5"/>
<toolChain id="org.eclipse.cdt.core.tests.toolChain6"/>
</template>
</extension>
</plugin>

View file

@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.failedTests.ASTFailedTests;
import org.eclipse.cdt.core.parser.failedTests.FailedCompleteParseASTTest;
import org.eclipse.cdt.core.parser.failedTests.STLFailedTests;
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
import org.eclipse.cdt.core.tests.templateengine.AllTemplateEngineTests;
import org.eclipse.cdt.internal.index.tests.IndexTests;
import org.eclipse.cdt.internal.pdom.tests.PDOMTests;
@ -91,7 +92,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
suite.addTestSuite(STLFailedTests.class);
suite.addTestSuite(FailedCompleteParseASTTest.class);
// suite.addTest(AllTemplateEngineTests.suite());
suite.addTest(AllTemplateEngineTests.suite());
return suite;
}

View file

@ -12,10 +12,12 @@ package org.eclipse.cdt.core.tests.templateengine;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import junit.framework.Assert;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
import org.eclipse.cdt.core.templateengine.TemplateEngine;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
@ -61,6 +63,17 @@ public class TemplateEngineTestsHelper {
return url;
}
public static TemplateCore[] getTestTemplates() {
TemplateCore[] templates = TemplateEngine.getDefault().getTemplates();
List testTemplates = new ArrayList();
for (int i =0; i < templates.length; i++) {
if (templates[i].getTemplateType().equals("TestTemplate")) {
testTemplates.add(templates[i]);
}
}
return (TemplateCore[]) testTemplates.toArray(new TemplateCore[testTemplates.size()]);
}
public static int getChildCount(TemplateDescriptor templateDescriptor, String propertyGroupID){
List list = templateDescriptor.getPropertyGroupList();
for (int i = 0, l = list.size(); i < l; i++) {

View file

@ -13,7 +13,6 @@ package org.eclipse.cdt.core.tests.templateengine;
import junit.framework.TestCase;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.TemplateEngine;
/**
* Test the functionality of Tempalte Class.
@ -24,7 +23,7 @@ public class TestTemplateCore extends TestCase {
protected void setUp() throws Exception {
super.setUp();
templates = TemplateEngine.getDefault().getTemplates();
templates = TemplateEngineTestsHelper.getTestTemplates();
}
/*

View file

@ -17,7 +17,6 @@ import junit.framework.TestCase;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
import org.eclipse.cdt.core.templateengine.TemplateEngine;
/**
@ -49,7 +48,7 @@ public class TestValueStore extends TestCase {
*
*/
public void testValueStoreNotNull(){
TemplateCore[] templates = TemplateEngine.getDefault().getTemplates();
TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates();
for (int i=0; i <templates.length; i++) {
Map valueStore = templates[i].getValueStore();
assertNotNull(valueStore);
@ -61,7 +60,7 @@ public class TestValueStore extends TestCase {
* FactoryDefaults. Test the same.
*/
public void testCompareValueStoreWithTemplateDefaluts(){
TemplateCore[] templates = TemplateEngine.getDefault().getTemplates();
TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates();
for (int i=0; i <templates.length; i++) {
Map valueStore = templates[i].getValueStore();
TemplateDescriptor templateDescriptor = templates[i].getTemplateDescriptor();

View file

@ -629,6 +629,7 @@
<extension-point id="templates" name="Templates Extension point"
schema="schema/templates.exsd"/>
<extension-point id="templateProcessTypes" name="Process Types Extension point" schema="schema/templateProcessTypes.exsd"/>
<extension-point id="templateAssociations" name="Template Associations" schema="schema/templateAssociations.exsd"/>
<extension
point="org.eclipse.cdt.core.templateProcessTypes">

View file

@ -0,0 +1,129 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.core">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="templateAssociations" name="Template Associations"/>
</appInfo>
<documentation>
This extension point facilitates adding new toolchains generated from a different plugin to already defined template without modifying template definition.
</documentation>
</annotation>
<element name="extension">
<annotation>
<documentation>
Extension point added to Template Engine plugin. Any plugin, which intends to contribute XML templates to Temaplate Engine has to extend this extension point, and add template element.
</documentation>
</annotation>
<complexType>
<sequence>
<element ref="template" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
Id for the extension in the extender plugin.
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="toolChain">
<complexType>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<element name="template">
<complexType>
<sequence>
<element ref="toolChain" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="id" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
This extension point was added in CDT 4.0
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
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:
Symbian - Initial API and implementation
</documentation>
</annotation>
</schema>

View file

@ -108,6 +108,13 @@ This is an optional attribute.
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>

View file

@ -43,6 +43,7 @@ public class TemplateCore {
private static final String DESCRIPTION = "description"; //$NON-NLS-1$
private static final String LABEL = "label"; //$NON-NLS-1$
private static final String ID = "id"; //$NON-NLS-1$
private static final String TYPE = "type"; //$NON-NLS-1$
private static Map/*<TemplateInfo, Template>*/ templateCache = new HashMap/*<TemplateInfo, Template>*/();
@ -60,6 +61,7 @@ public class TemplateCore {
private String description;
private String label;
private String templateId;
private String templateType;
private boolean fireDirtyEvents;
/**
@ -91,11 +93,9 @@ public class TemplateCore {
*/
public Set/*<String>*/ getAllMissingMacrosInProcesses() {
Set/*<String>*/ set = new TreeSet/*<String>*/(allMacrosInProcesses);
if (set != null) {
for (Iterator iter = set.iterator(); iter.hasNext();) {
if (valueStore.get(iter.next()) != null) {
iter.remove();
}
for (Iterator iter = set.iterator(); iter.hasNext();) {
if (valueStore.get(iter.next()) != null) {
iter.remove();
}
}
return set;
@ -154,6 +154,16 @@ public class TemplateCore {
return templateId;
}
/**
* @return String, which contains the id of the template
*/
public String getTemplateType() {
if (templateType == null) {
templateType = templateDescriptor.getRootElement().getAttribute(TYPE).trim();
}
return templateType;
}
/**
* @return String, which contains the Label
*/

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.core.templateengine;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -40,11 +41,17 @@ import org.w3c.dom.NodeList;
public class TemplateEngine {
public static String TEMPLATES_EXTENSION_ID = CCorePlugin.PLUGIN_ID + ".templates"; //$NON-NLS-1$
public static String TEMPLATE_ASSOCIATIONS_EXTENSION_ID = CCorePlugin.PLUGIN_ID + ".templateAssociations"; //$NON-NLS-1$
/**
* static reference to the Singleton TemplateEngine instance.
*/
private static TemplateEngine TEMPLATE_ENGINE = new TemplateEngine();
private static TemplateEngine TEMPLATE_ENGINE;
static {
TEMPLATE_ENGINE = new TemplateEngine();
TEMPLATE_ENGINE.initializeTemplateInfoMap();
}
/**
* This is a Map <WizardID, TemplateInfo>.
@ -56,7 +63,6 @@ public class TemplateEngine {
*/
private TemplateEngine() {
templateInfoMap = new HashMap/*<String, List<TemplateInfo>>*/();
initializeTemplateInfoMap();
}
/**
@ -190,6 +196,7 @@ public class TemplateEngine {
* extension point "templates"
*/
private void initializeTemplateInfoMap() {
String templateId = null;
String location = null;
String pluginId = null;
String projectType = null;
@ -205,6 +212,7 @@ public class TemplateEngine {
pluginId = extension.getNamespaceIdentifier(); // Plugin-id of the extending plugin.
for(int j=0; j<configElements.length; j++) {
IConfigurationElement config = configElements[j];
templateId = config.getAttribute(TemplateEngineHelper.ID);
location = config.getAttribute(TemplateEngineHelper.LOCATION);
projectType = config.getAttribute(TemplateEngineHelper.PROJECT_TYPE);
filterPattern = config.getAttribute(TemplateEngineHelper.FILTER_PATTERN);
@ -218,7 +226,7 @@ public class TemplateEngine {
toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID));
}
TemplateInfo templateInfo = new TemplateInfo(projectType, filterPattern, location,
TemplateInfo templateInfo = new TemplateInfo(templateId, projectType, filterPattern, location,
pluginId, toolChainIdSet,
usage, extraPagesProvider, isCategory);
if (!templateInfoMap.containsKey(projectType)) {
@ -227,8 +235,42 @@ public class TemplateEngine {
((List/*<TemplateInfo>*/)templateInfoMap.get(projectType)).add(templateInfo);
}
}
// Check for tool Chains added to the templates outside template info definition
addToolChainsToTemplates();
}
private void addToolChainsToTemplates() {
String templateId = null;
TemplateCore[] templates = getTemplates();
IExtension[] extensions = Platform.getExtensionRegistry().getExtensionPoint(TEMPLATE_ASSOCIATIONS_EXTENSION_ID).getExtensions();
for(int i=0; i<extensions.length; i++) {
IExtension extension = extensions[i];
IConfigurationElement[] configElements = extension.getConfigurationElements();
for(int j=0; j<configElements.length; j++) {
IConfigurationElement config = configElements[j];
templateId = config.getAttribute(TemplateEngineHelper.ID);
IConfigurationElement[] toolChainConfigs = config.getChildren(TemplateEngineHelper.TOOL_CHAIN);
Set toolChainIdSet = new HashSet();
for (int k=0; k < toolChainConfigs.length; k++) {
toolChainIdSet.add(toolChainConfigs[k].getAttribute(TemplateEngineHelper.ID));
}
for (int k=0; k < templates.length; k++) {
String id = templates[k].getTemplateInfo().getTemplateId();
if (id == null) {
id = templates[k].getTemplateId();
}
if (id != null && id.equals(templateId)) {
toolChainIdSet.addAll(Arrays.asList(templates[k].getTemplateInfo().getToolChainIds()));
templates[k].getTemplateInfo().setToolChainSet(toolChainIdSet);
}
}
}
}
}
/**
* Gets an array of template info objects matching the criteria passed as params.
*/

View file

@ -27,10 +27,12 @@ public class TemplateInfo {
private String pagesProvider;
private boolean isCategory;
private String icon;
private String templateId;
public TemplateInfo(String projectTypeId, String filterPattern, String templatePath,
public TemplateInfo(String templateId, String projectTypeId, String filterPattern, String templatePath,
String pluginId, Set toolChainIdSet, String usageDescription,
String pagesProvider, boolean isCategory) {
this.templateId = templateId;
this.filterPattern = filterPattern;
this.templatePath = templatePath;
this.pluginId = pluginId;
@ -49,6 +51,14 @@ public class TemplateInfo {
return pluginId;
}
/**
* Returns the Template ID
* @return String contains the template id.
*/
public String getTemplateId() {
return templateId;
}
/**
* Returns the Template path as String.
* @return String containing the path.
@ -90,6 +100,10 @@ public class TemplateInfo {
return (String[]) toolChainIdSet.toArray(new String[toolChainIdSet.size()]);
}
public void setToolChainSet(Set toolChainIdSet) {
this.toolChainIdSet = toolChainIdSet;
}
/**
* @return the isCategory
*/

View file

@ -77,13 +77,10 @@ public class TemplateProcessHandler {
* @return
*/
public Set/*<String>*/ getAllMacros() {
Set/*<String>*/ set = null;
Set/*<String>*/ set = new HashSet/*<String>*/();
for (Iterator i = conditionalProcessGroupList.iterator(); i.hasNext();) {
Set/*<String>*/ subSet = ((ConditionalProcessGroup)i.next()).getAllMacros();
if (subSet != null) {
if (set == null) {
set = new HashSet/*<String>*/();
}
set.addAll(subSet);
}
}

View file

@ -97,6 +97,7 @@ public abstract class UIPage extends DialogPage {
title = name;
uiElement = element;
uiElement.setValues(valueStore);
this.valueStore = valueStore;
//TODO: Check the from which plugin the PLUGIN_ID comes from i.e. from CCorePlugin or CUIPlugin
pageId = CUIPlugin.getPluginId() + "." + //$NON-NLS-1$
@ -131,7 +132,7 @@ public abstract class UIPage extends DialogPage {
* @return HashMap. The data contained in the widgets on this page.
*/
public Map/*<String, String>*/ getPageData() {
return uiComposite.getPageData();
return uiElement.getValues();
}
/**

View file

@ -54,7 +54,7 @@ public class UIWizardPage extends UIPage implements IWizardPage, PatternEventLis
/**
* Indicates whether this page is complete.
*/
private boolean isPageComplete = true;
private boolean isPageComplete;
/**
* That page that was shown right before this page became visible. null if none.
@ -63,8 +63,6 @@ public class UIWizardPage extends UIPage implements IWizardPage, PatternEventLis
private IWizardPage nextPage = null;
private Map valueStore;
/**
* Title of the page, Page Name and UIElement group are the parameters.
*
@ -79,7 +77,7 @@ public class UIWizardPage extends UIPage implements IWizardPage, PatternEventLis
super(title, uiElement, valueStore);
name = pageName;
validInvalid = new HashMap/*<Object, String>*/();
this.valueStore = valueStore;
isPageComplete = uiElement.isValid();
}
/**
@ -219,7 +217,7 @@ public class UIWizardPage extends UIPage implements IWizardPage, PatternEventLis
* @return boolean, true if this page is complete, otherwise false.
*/
public boolean isPageComplete() {
return isPageComplete && getComposite() != null;
return isPageComplete;
}
/**
@ -268,8 +266,6 @@ public class UIWizardPage extends UIPage implements IWizardPage, PatternEventLis
public void createControl(Composite parent) {
super.createControl(parent);
(super.getComposite()).addPatternListener(this);
(super.getComposite()).getUIElement().setValues(valueStore);
// Page complete is set true of false, based on Mandatory attribute
// and Widgets contents.

View file

@ -14,6 +14,8 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@ -35,22 +37,24 @@ public class UIBooleanWidget extends InputUIElement {
/**
* Attributes associated with this widget.
*/
UIAttributes/*<String, String>*/ uiAttribute;
protected UIAttributes/*<String, String>*/ uiAttribute;
/**
* Boolean widget.
*/
Button button;
protected Button button;
/**
* Label of this widget.
*/
Label label;
protected Label label;
/**
* Composite to which this widget control is added.
*/
UIComposite uiComposite;
protected UIComposite uiComposite;
private boolean booleanValue;
/**
* Constructor.
@ -61,6 +65,7 @@ public class UIBooleanWidget extends InputUIElement {
public UIBooleanWidget(UIAttributes/*<String, String>*/ uiAttribute) {
super(uiAttribute);
this.uiAttribute = uiAttribute;
this.booleanValue = false;
}
/**
@ -69,8 +74,7 @@ public class UIBooleanWidget extends InputUIElement {
public Map/*<String, String>*/ getValues() {
Map/*<String, String>*/ retMap = new HashMap/*<String, String>*/();
Boolean isCheck = new Boolean(button.getSelection());
retMap.put(uiAttribute.get(InputUIElement.ID), isCheck.toString());
retMap.put(uiAttribute.get(InputUIElement.ID), new Boolean(booleanValue).toString());
return retMap;
}
@ -81,11 +85,7 @@ public class UIBooleanWidget extends InputUIElement {
* @param valueMap
*/
public void setValues(Map/*<String, String>*/ valueMap) {
String val = (String) valueMap.get(uiAttribute.get(InputUIElement.ID));
Boolean bool = new Boolean(val);
if (val != null) {
button.setSelection(bool.booleanValue());
}
booleanValue = new Boolean((String) valueMap.get(uiAttribute.get(InputUIElement.ID))).booleanValue();
}
/**
@ -116,6 +116,12 @@ public class UIBooleanWidget extends InputUIElement {
booleanConatiner.setLayoutData(gridcData);
button = new Button(booleanConatiner, SWT.CHECK);
button.setData(".uid", uiAttribute.get(UIElement.ID)); //$NON-NLS-1$
button.setSelection(new Boolean(booleanValue).booleanValue());
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
booleanValue = button.getSelection();
}
});
}
/**
@ -130,7 +136,7 @@ public class UIBooleanWidget extends InputUIElement {
boolean retVal = true;
String mandatory = (String) uiAttribute.get(InputUIElement.MANDATORY);
if ((button.getSelection() == false) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
if (!booleanValue && mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE)) {
retVal = false;
}
return retVal;

View file

@ -32,15 +32,11 @@ import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
*/
public class UIBrowseWidget extends UITextWidget implements ModifyListener {
/**
* Attributes associated with this widget.
*/
UIAttributes/*<String, String>*/ uiAttribute;
/**
* Browse Button of this widget.
*/
Button button;
protected Button button;
/**
* Constructor.
@ -51,6 +47,7 @@ public class UIBrowseWidget extends UITextWidget implements ModifyListener {
public UIBrowseWidget(UIAttributes/*<String, String>*/ uiAttribute) {
super(uiAttribute);
this.uiAttribute = uiAttribute;
this.textValue = (String) uiAttribute.get(InputUIElement.DEFAULT);
}
/**
@ -83,10 +80,7 @@ public class UIBrowseWidget extends UITextWidget implements ModifyListener {
text = new Text(textConatiner, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.addModifyListener(this);
// set Default values
if (uiAttribute.get(InputUIElement.DEFAULT) != null)
text.setText((String) uiAttribute.get(InputUIElement.DEFAULT));
text.setText(textValue);
button = new Button(textConatiner, SWT.PUSH | SWT.LEFT);
button.setText(InputUIElement.BROWSELABEL);
@ -95,7 +89,8 @@ public class UIBrowseWidget extends UITextWidget implements ModifyListener {
public void widgetSelected(SelectionEvent event) {
String fileName = new FileDialog(uiComposite.getShell()).open();
if (fileName != null) {
text.setText(fileName.toString());
textValue = fileName.toString();
text.setText(textValue);
}
}
});

View file

@ -16,6 +16,8 @@ import java.util.Map;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
@ -35,32 +37,32 @@ public class UISelectWidget extends InputUIElement {
/**
* Attributes associated with this widget.
*/
UIAttributes/*<String, String>*/ uiAttribute;
protected UIAttributes/*<String, String>*/ uiAttribute;
/**
* Select widget.
*/
Combo combo;
protected Combo combo = null;
/**
* Label of this widget.
*/
Label label;
protected Label label;
/**
* Composite to which this widget control is added.
*/
UIComposite uiComposite;
protected UIComposite uiComposite;
/**
* Map contains the values of Select Widget
*/
HashMap/*<String, String>*/ itemMap;
protected HashMap/*<String, String>*/ itemMap;
/**
* Default value of Select Widget
*/
String itemSelected;
protected String itemSelected;
/**
* Constructor for Select Widget.
@ -70,20 +72,16 @@ public class UISelectWidget extends InputUIElement {
*/
public UISelectWidget(UIAttributes/*<String, String>*/ attribute, HashMap/*<String, String>*/ itemMap,
String itemSelected) {
super(attribute);
uiAttribute = attribute;
this.itemMap = itemMap;
this.itemSelected = itemSelected;
}
/**
* @return Boolean value contained in the Boolean Widget.
*/
public Map/*<String, String>*/ getValues() {
Map/*<String, String>*/ retMap = new HashMap/*<String, String>*/();
retMap.put(uiAttribute.get(InputUIElement.ID), itemMap.get(combo.getItem(combo.getSelectionIndex())));
retMap.put(uiAttribute.get(InputUIElement.ID), itemSelected);
return retMap;
}
@ -94,17 +92,17 @@ public class UISelectWidget extends InputUIElement {
* @param valueMap
*/
public void setValues(Map/*<String, String>*/ valueMap) {
String val = (String) valueMap.get(uiAttribute.get(InputUIElement.ID));
if (val != null)
val = val.trim();
String[] items = combo.getItems();
int index = 0;
for (int i = 0; i < items.length; i++)
if (itemMap.get(items[i]).equals(val))
index = i;
combo.select(index);
itemSelected = (String) valueMap.get(uiAttribute.get(InputUIElement.ID));
if (combo != null) {
String[] items = combo.getItems();
for (int i=0; i < items.length; i++) {
if (items[i].equals(itemSelected)) {
combo.select(i);
break;
}
}
}
}
/**
@ -149,6 +147,14 @@ public class UISelectWidget extends InputUIElement {
combo.select(index);
combo.setData(".uid", uiAttribute.get(UIElement.ID)); //$NON-NLS-1$
combo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
itemSelected = combo.getItem(combo.getSelectionIndex());
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
/**
@ -163,9 +169,8 @@ public class UISelectWidget extends InputUIElement {
boolean retVal = true;
String mandatory = (String) uiAttribute.get(InputUIElement.MANDATORY);
if (((combo.getText() == null) || (combo.getText().equals("")) //$NON-NLS-1$
|| (combo.getText().trim().length() < 1)) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
if ((itemSelected == null || itemSelected.equals("") //$NON-NLS-1$
|| itemSelected.trim().length() < 1) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
retVal = false;
}
return retVal;

View file

@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
import java.util.Arrays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -20,6 +22,7 @@ import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
import org.eclipse.cdt.utils.ui.controls.FileListControl;
import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener;
/**
@ -69,6 +72,13 @@ public class UISpecialListWidget extends UIStringListWidget {
flcComposite.setLayoutData(gridData);
fileListControl = new FileListControl(flcComposite, (String) uiAttribute.get(InputUIElement.WIDGETLABEL), 1);
fileListControl.setList((String[])itemsList.toArray());
fileListControl.setSelection(0);
fileListControl.addChangeListener(new IFileListChangeListener(){
public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) {
itemsList.addAll(Arrays.asList(newValue));
}
});
}
/**

View file

@ -1,5 +1,4 @@
/*******************************************************************************
* 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
@ -10,7 +9,10 @@
*******************************************************************************/
package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
@ -25,6 +27,7 @@ import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
import org.eclipse.cdt.utils.ui.controls.FileListControl;
import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener;
/**
@ -37,22 +40,24 @@ public class UIStringListWidget extends InputUIElement {
/**
* Attributes associated with this widget.
*/
UIAttributes/*<String, String>*/ uiAttribute;
protected UIAttributes/*<String, String>*/ uiAttribute;
/**
* StringList widget.
*/
FileListControl fileListControl;
protected FileListControl fileListControl;
/**
* Label of this widget.
*/
Label label;
protected Label label;
/**
* Composite to which this widget control is added.
*/
UIComposite uiComposite;
protected UIComposite uiComposite;
protected List itemsList;
/**
* Constructor.
@ -63,6 +68,7 @@ public class UIStringListWidget extends InputUIElement {
public UIStringListWidget(UIAttributes/*<String, String>*/ attribute) {
super(attribute);
uiAttribute = attribute;
itemsList = new ArrayList();
}
/**
@ -70,12 +76,10 @@ public class UIStringListWidget extends InputUIElement {
*/
public Map/*<String, String>*/ getValues() {
Map/*<String, String>*/ retMap = new HashMap/*<String, String>*/();
String[] items = fileListControl.getItems();
String itemString = new String();
for (int i = 0; i < items.length; i++)
itemString = itemString + items[i] + "|"; //$NON-NLS-1$
for (int i = 0; i < itemsList.size(); i++) {
itemString = itemString + itemsList.get(i) + "|"; //$NON-NLS-1$
}
retMap.put(uiAttribute.get(InputUIElement.ID), itemString);
return retMap;
@ -87,19 +91,14 @@ public class UIStringListWidget extends InputUIElement {
* @param valueMap
*/
public void setValues(Map/*<String, String>*/ valueMap) {
String items = (String) valueMap.get(uiAttribute.get(InputUIElement.ID));
if (items != null) {
items = items.trim();
StringTokenizer st = new StringTokenizer(items, "|"); //$NON-NLS-1$
String[] itemList = new String[st.countTokens()];
for (int i = 0; st.hasMoreTokens(); i++)
itemList[i] = st.nextToken();
fileListControl.setList(itemList);
fileListControl.setSelection(0);
for (int i = 0; st.hasMoreTokens(); i++) {
itemsList.add(st.nextToken());
}
}
}
@ -133,6 +132,14 @@ public class UIStringListWidget extends InputUIElement {
flcComposite.setLayoutData(gridData);
fileListControl = new FileListControl(flcComposite, (String) uiAttribute.get(InputUIElement.WIDGETLABEL), 0);
fileListControl.setList((String[])itemsList.toArray());
fileListControl.setSelection(0);
fileListControl.addChangeListener(new IFileListChangeListener(){
public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) {
itemsList.addAll(Arrays.asList(newValue));
}
});
}
/**
@ -147,8 +154,7 @@ public class UIStringListWidget extends InputUIElement {
boolean retVal = true;
String mandatory = (String) uiAttribute.get(InputUIElement.MANDATORY);
if ((fileListControl.getItems() == null) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
if ((itemsList == null || itemsList.size() == 0) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
retVal = false;
}
return retVal;

View file

@ -50,7 +50,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
/**
* Attributes associated with this widget.
*/
private UIAttributes/*<String, String>*/ uiAttribute;
protected UIAttributes/*<String, String>*/ uiAttribute;
/**
* Text widget.
@ -67,6 +67,8 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
* Composite to which this widget control is added. Classes extending this class, should make sure that they initialize this from the respective class createWidgets method.
*/
protected UIComposite uiComposite;
protected String textValue;
/**
* Constructor.
@ -77,6 +79,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
public UITextWidget(UIAttributes/*<String, String>*/ uiAttribute) {
super(uiAttribute);
this.uiAttribute = uiAttribute;
this.textValue = new String();
}
/**
@ -84,7 +87,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
*/
public Map/*<String, String>*/ getValues() {
Map/*<String, String>*/ retMap = new HashMap/*<String, String>*/();
retMap.put(uiAttribute.get(InputUIElement.ID), text.getText());
retMap.put(uiAttribute.get(InputUIElement.ID), textValue);
return retMap;
}
@ -108,7 +111,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
val = subString;
}
val = val.trim();
text.setText(val);
textValue = val;
}
}
@ -141,6 +144,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
text = getTextWidget((String) uiAttribute.get(UIElement.TYPE));
text.addModifyListener(this);
text.setData(".uid", uiAttribute.get(UIElement.ID)); //$NON-NLS-1$
text.setText(textValue);
}
/**
@ -213,17 +217,17 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
// other classes, having Text widget. They can just make use of
// modifyText,
// evaluatePattern and isValid.
String inputText = text.getText();
textValue = text.getText();
if ((patternValue == null) || (inputText == null))
if ((patternValue == null) || (textValue == null))
return;
String mandatory = (String) attribute.get(InputUIElement.MANDATORY);
if ((mandatory == null || !mandatory.equalsIgnoreCase("true")) && inputText.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
if ((mandatory == null || !mandatory.equalsIgnoreCase("true")) && textValue.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
return;
}
evaluatePattern(label.getText(), inputText, patternValue);
evaluatePattern(label.getText(), textValue, patternValue);
}
/**
@ -261,8 +265,8 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
String mandatory = (String) uiAttribute.get(InputUIElement.MANDATORY);
if (((mandatory != null) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE)))
&& ((text.getText() == null) || (text.getText().equals("")) || //$NON-NLS-1$
(text.getText().trim().length() < 1))) {
&& ((textValue == null) || (textValue.equals("")) || //$NON-NLS-1$
(textValue.trim().length() < 1))) {
retVal = false;
}