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

222954: apply fix

This commit is contained in:
Andrew Ferguson 2008-03-18 15:26:50 +00:00
parent 3333dfaa52
commit b75b0925fe
24 changed files with 408 additions and 431 deletions

View file

@ -242,8 +242,8 @@ public class TemplateEngineHelper {
}
public static String externalizeTemplateString(String pluginId, String location, String key) {
String value = key;
if (key.startsWith(STRING_EXTERNALIZATION_MARKER)) {
String value= null;
if (key != null && key.startsWith(STRING_EXTERNALIZATION_MARKER)) {
try {
value = location != null ? getValueFromProperties(pluginId, location, key.substring(1)) : null;
if (value == null) {
@ -253,18 +253,13 @@ public class TemplateEngineHelper {
value = key;
e.printStackTrace();
}
if (value == null) {
value = key;
}
}
return value;
return value == null ? key : value;
}
private static String getValueFromProperties(String pluginId, String propertiesFile, String key) throws IOException {
String value = null;
Bundle b = Platform.getBundle(pluginId);
// URL url= b.getResource(propertiesFile);
URL url= getResourceURL(b, propertiesFile);
if (url != null) {
InputStream in= url.openStream();

View file

@ -114,6 +114,11 @@
pagesAfterTemplateSelectionProvider="org.eclipse.cdt.ui.tests.templateengine.TestExtraPagesProvider"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
<template
id="org.eclipse.cdt.ui.tests.testWidgets"
location="resources/projectTemplates/testWidgets/template.xml"
projectType="org.eclipse.cdt.build.core.buildArtefactType.exe">
</template>
</extension>

View file

@ -0,0 +1,22 @@
#include <iostream>
using namespace std;
int main() {
cout << "$(projectName)" << endl;
cout << "$(TestWidget1)" << endl;
cout << "$(TestWidget2)" << endl;
cout << "$(TestWidget3)" << endl;
cout << "$(TestWidget4)" << endl;
cout << "$(TestWidget5)" << endl;
cout << "$(TestWidget6)" << endl;
cout << "$(TestWidget7)" << endl;
cout << "$(TestWidget8)" << endl;
cout << "$(TestWidget9)" << endl;
cout << "$(TestWidget10)" << endl;
cout << "$(TestWidget11)" << endl;
cout << "$(TestWidget12)" << endl;
cout << "$(TestWidget13)" << endl;
cout << "$(TestWidget14)" << endl;
return 0;
}

View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<template type="ProjTempl" version="1.0" supplier="Eclipse.org" revision="1.0" author="Symbian Software Ltd."
copyright="Copyright (c) 2008 Symbian Software Ltd. 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"
id="TestWidgets" label="TestWidgetsLabel" description="TestWidgetsDescription"
help="help.html">
<property-group id="basics" label="basicsLabel" description="basicsDescription" type="PAGES-ONLY" help="help.html">
<property id="TestWidget1" label="InputWidget1" description="InputWidget1Description" type="input" mandatory="true" pattern=".+"/>
<property id="TestWidget2" label="InputWidget2" description="InputWidget2Description" type="input" default="InputWidget2Default" mandatory="false"/>
<property id="TestWidget3" label="MultilineWidget1" description="MultilineWidget1Description" type="multiline" mandatory="true" pattern=".+"/>
<property id="TestWidget4" label="MultilineWidget2" description="MultilineWidget2Description" type="multiline" default="Multiline2Default" mandatory="false"/>
<property id="TestWidget5" label="SelectWidget1" description="SelectWidget1Description" type="select" default="0" mandatory="false" persist="false">
<item label="Include" name="1"/>
<item label="Exclude" name="0"/>
</property>
<property id="TestWidget6" label="SelectWidget2" description="SelectWidget2Description" type="select" default="-1" mandatory="true" persist="false">
<item label="" value="-1"/>
<item label="Include" value="1"/>
<item label="Exclude" value="0"/>
</property>
</property-group>
<property-group id="basics2" label="basicsLabel2" description="basicsDescription2" type="PAGES-ONLY" help="help.html">
<property id="TestWidget7" label="BooleanWidget1" description="BooleanWidget1Description" type="boolean" default="false"/>
<property id="TestWidget8" label="BooleanWidget2" description="BooleanWidget2Description" type="boolean" default="true"/>
<property id="TestWidget9" label="StringListWidget1" description="StringListWidget1Description" type="stringlist" mandatory="true"/>
<property id="TestWidget10" label="StringListWidget2" description="StringListWidget2Description" type="stringlist" default="StringList2Default" mandatory="false"/>
<property id="TestWidget11" label="SpecialListWidget1" description="SpecialListWidget1Description" type="speciallist" mandatory="true"/>
<property id="TestWidget12" label="SpecialListWidget2" description="SpecialListWidget2Description" type="speciallist" default="SpecialList2Default" mandatory="false"/>
<property id="TestWidget13" label="BrowseWidget1" description="BrowseWidget1Description" type="browse" default="Browse1Default" mandatory="true" pattern=".+"/>
<property id="TestWidget14" label="BrowseWidget2" description="BrowseWidget2Description" type="browse" default="Browse2Default" mandatory="false"/>
</property-group>
<process type="org.eclipse.cdt.managedbuilder.core.NewManagedProject">
<simple name="name" value="$(projectName)" />
<simple name="artifactExtension" value="exe" />
<simple name="isCProject" value="true" />
</process>
<process type="org.eclipse.cdt.core.CreateSourceFolder">
<simple name="projectName" value="$(projectName)"/>
<simple name="path" value="src"/>
</process>
<process type="org.eclipse.cdt.core.AddFiles">
<simple name="projectName" value="$(projectName)"/>
<complex-array name="files">
<element>
<simple name="source" value="hello.cpp"/>
<simple name="target" value="src/hello.cpp"/>
<simple name="replaceable" value="true"/>
</element>
</complex-array>
</process>
</template>

View file

@ -301,7 +301,7 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage
return true;
}
} catch (CoreException e) {
CUIPlugin.getDefault().log(e);
CUIPlugin.log(e);
currentCProject= null;
}
@ -314,7 +314,7 @@ public class ProjectSelectionPage extends WizardPage implements IWizardDataPage
try {
projects= CoreModel.create(workspaceRoot).getCProjects();
} catch (CModelException e) {
CUIPlugin.getDefault().log(e);
CUIPlugin.log(e);
projects= new ICProject[0];
}

View file

@ -16,7 +16,7 @@ import java.util.EventObject;
*
* PatternEvent class instances are created, when there is an unexpected input
* in the InputUIElement. Which results in a mismatch to the pattern of input
* data exptected. This has to be updated in the UIPage. To do this,
* data expected. This has to be updated in the UIPage. To do this,
* PatternEvent is fired. For which, the UIPage will be the registered listener.
* Here UIPage stands for WizardPage.
*

View file

@ -35,6 +35,10 @@ ProjectSelectionPage.8=The project does not exist
ProjectSelectionPage.9=Please select a CDT project
ProjectSelectionPage.10=Project Selection
ProjectSelectionPage.11=Choose a Project
UIElementTreeBuilderHelper.InvalidEmptyLabel=Invalid item element in <property> with id="{0}": attributes 'label' and 'value' must be present.
UIElementTreeBuilderHelper.InvalidNonUniqueValue=Mappings between labels and values in not reversible for <property> with id="{0}"
UIElementTreeBuilderHelper.UnknownWidgetType0=Unknown widget type: {0}
UISelectWidget_ErrorNoneSelected0=Please choose a value for {0}
UITextWidget.0=\ Project already exists in workspace.
SimpleElementException.0=This Operation not supported on InputUIElement

View file

@ -17,9 +17,7 @@ import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.templateengine.TemplateEngineUtil;
@ -27,7 +25,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
/**
*
* The UIPage extends DialogPage, it implements the createControl() abstract
@ -35,13 +32,11 @@ import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
* UIComposite, which extends a SWT composite. The SWT widgets are added to
* UIComposite.
*/
public abstract class UIPage extends DialogPage {
/**
* The Composite belonging to this page. The SWT widgets are added to this Composite. UIComposite instance is the top level control of this page. This top level control is initialized in createControl method.
*/
private UIComposite uiComposite;
protected UIComposite uiComposite;
/**
* resources ID which will be displayed as F1 help in Title area.
@ -51,12 +46,12 @@ public abstract class UIPage extends DialogPage {
/**
* The UIElement (group), to which this page corresponds. Every UIElement group corresponds to a UIPage. The children of this goup are UIElement's (SWT widgets). Which are added to the UIComposite.
*/
private UIElement uiElement;
protected final UIElement uiElement;
/**
* ValueStore for this instance of Template.
*/
private Map<String, String> valueStore;
protected final Map<String, String> valueStore;
/**
* Title set for this WizardPage.
@ -103,27 +98,6 @@ public abstract class UIPage extends DialogPage {
pageId = CUIPlugin.getPluginId() + "." + (uiElement.getAttributes()).get(UIElement.ID); //$NON-NLS-1$
}
/**
* Creates the top level control for this dialog page under the given parent
* composite.
*
* @param parent
* the parent composite
*/
public void createControl(Composite parent) {
initializeDialogUnits(parent);
uiComposite = new UIComposite(parent, uiElement, valueStore);
// set the focus so that InfoPop is displayed when F1 is Pressed.
uiComposite.setFocus();
setControl(uiComposite);
// Setting InfoPop help context ID(plugin-id+ContextID).
PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), pageId);
}
/**
* The data contained in the Input elements (SWT widgets), on this page is
* extracted and put into an HashMap. The same is returned.
@ -144,7 +118,6 @@ public abstract class UIPage extends DialogPage {
return uiComposite;
}
// This method is provided for unit tesing the UIComposite instance.
/**
*
* This returns UICompostie as UIComposite instance. Unlike the getControl.
@ -154,5 +127,4 @@ public abstract class UIPage extends DialogPage {
public UIComposite getComposite() {
return uiComposite;
}
}

View file

@ -93,9 +93,9 @@ public class UIPagesProvider {
}
else {
if ((hasChildUIElement(uiElement))) {
String title = uiElement.getAttributes().get(UIElement.TITLE);
String label = uiElement.getAttributes().get(UIElement.TITLE);
String description = (uiElement.getAttributes()).get(UIElement.DESCRIPTION);
UIWizardPage uiPage = new UIWizardPage(title, description, uiElement, valueStore);
UIWizardPage uiPage = new UIWizardPage(label, description, uiElement, valueStore);
pageMap.put((uiElement.getAttributes()).get(UIElement.ID), uiPage);
addToOrderVector((uiElement.getAttributes()).get(UIElement.ID));

View file

@ -27,6 +27,7 @@ import org.eclipse.cdt.ui.templateengine.IWizardDataPage;
import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
import org.eclipse.cdt.ui.templateengine.event.PatternEventListener;
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
/**
@ -108,7 +109,7 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven
}
/**
* Retruns the dialog setting for this wizard page. null, if none exists.
* Returns the dialog setting for this wizard page. null, if none exists.
*
* @return IDialogSettings, if Wizard is not set null.
*/
@ -258,25 +259,35 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven
/**
* Creates the top level control for this dialog page under the given parent
* composite. call the super createControl, get the Composite and set this
* page as PatternEventListener.
* composite.
*
* @param parent
* the parent composite
*/
public void createControl(Composite parent) {
super.createControl(parent);
(super.getComposite()).addPatternListener(this);
initializeDialogUnits(parent);
uiComposite = new UIComposite(parent, uiElement, valueStore);
uiComposite.addPatternListener(this);
uiElement.createWidgets(uiComposite);
// set the focus so that InfoPop is displayed when F1 is Pressed.
uiComposite.setFocus();
setControl(uiComposite);
// Setting InfoPop help context ID(plugin-id+ContextID).
PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), pageId);
// Page complete is set true of false, based on Mandatory attribute
// and Widgets contents.
setPageComplete(super.getComposite().isValid());
setPageComplete(uiComposite.isValid());
PlatformUI.getWorkbench().getHelpSystem().setHelp(super.getControl(), pageId);
}
/**
* This method is implemented to handle the PatternEvent's generated by SWT
* widges contained in this page. When the user enters data violating the
* widgets contained in this page. When the user enters data violating the
* pattern of data expected by this SWT widgets, a PatternEvent is fired to
* the Container. Which has to reflect the same as an ErrorMeesage. Get the
* source of the PatternEvent, and the error String causing the
@ -285,15 +296,15 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven
*/
public void patternPerformed(PatternEvent patternEvent) {
if (!patternEvent.getValid()) {
validInvalid.put(patternEvent.getSource(), patternEvent.toString());
setErrorMessage(getErrorString());
setPageComplete(validInvalid.isEmpty() && super.getComposite().isValid());
setPageComplete(validInvalid.isEmpty() && uiComposite.isValid());
} else {
validInvalid.remove(patternEvent.getSource());
setPageComplete(validInvalid.isEmpty() && super.getComposite().isValid());
setPageComplete(validInvalid.isEmpty() && uiComposite.isValid());
if (validInvalid.isEmpty()) {
setErrorMessage(null);
} else {
@ -306,7 +317,7 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven
/**
* Iterate through the validInvalid HashMap, formulate the error string
* retrun the same. This will ensure that the proper error string is
* return the same. This will ensure that the proper error string is
* updated.
*
* @return
@ -321,6 +332,5 @@ public class UIWizardPage extends UIPage implements IWizardDataPage, PatternEven
}
return message;
}
}

View file

@ -18,8 +18,8 @@ import java.util.Map;
import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
/**
* The GenericUIElementGroup extends UIElement, implements the default behaviour
* expected from UIElementGroup. This gives behaviour expected for PAGES-ONLY
* The GenericUIElementGroup extends UIElement, implements the default behavior
* expected from UIElementGroup. This gives behavior expected for PAGES-ONLY
* type. Any other type of UIElement groups can override the definitions given
* to methods in this class.
*
@ -47,12 +47,12 @@ public class GenericUIElementGroup extends UIElement {
private List<UIElement> childList;
/**
* Call UIElement constructor by passing Attributes as param.
* Call UIElement constructor by passing Attributes as parameter.
*
* @param attribute
* @param attributes
*/
public GenericUIElementGroup(UIGroupTypeEnum type, UIAttributes/*<String, String>*/ attribute) {
super(attribute);
public GenericUIElementGroup(UIGroupTypeEnum type, UIAttributes attributes) {
super(attributes);
this.type = type;
this.childList = new ArrayList<UIElement>();
}
@ -98,11 +98,8 @@ public class GenericUIElementGroup extends UIElement {
}
}
/**
* dispose the Widget, releasing any resources occupied by this widget. The
* same is called on the child list.
*
* @see UIElement
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#disposeWidget()
*/
public void disposeWidget() {
int childCount = getChildCount();

View file

@ -20,28 +20,40 @@ import org.eclipse.cdt.ui.templateengine.SimpleElementException;
*
*/
public abstract class InputUIElement extends UIElement {
public static final String INPUTTYPE = new String("input"); //$NON-NLS-1$
public static final String MULTILINETYPE = new String("multiline"); //$NON-NLS-1$
public static final String SELECTTYPE = new String("select"); //$NON-NLS-1$
public static final String BOOLEANTYPE = new String("boolean"); //$NON-NLS-1$
public static final String BROWSETYPE = new String("browse"); //$NON-NLS-1$
public static final String STRINGLISTTYPE = new String("stringlist"); //$NON-NLS-1$
public static final String SPECIALLISTTYPE = new String("speciallist"); //$NON-NLS-1$
public static final String MANDATORY = new String("mandatory"); //$NON-NLS-1$
public static final String INPUTPATTERN = new String("pattern"); //$NON-NLS-1$
public static final String DEFAULT = new String("default"); //$NON-NLS-1$
public static final String WIDGETLABEL = new String("label"); //$NON-NLS-1$
public static final String BROWSELABEL = new String(" Browse.. "); //$NON-NLS-1$
public static final String CONTENTS = new String(" contents"); //$NON-NLS-1$
public static final String ISINVALID = new String(" is Invalid. "); //$NON-NLS-1$
public static final String CHECKPROJECT = new String("checkproject"); //$NON-NLS-1$
public static final String NULL = new String("null"); //$NON-NLS-1$
public static final String SIZE = new String("size"); //$NON-NLS-1$
public static final String HIDDEN = new String("hidden"); //$NON-NLS-1$
public static final String NAME = new String("name"); //$NON-NLS-1$
public static final String SELECTED = new String("selected"); //$NON-NLS-1$
public static final String INPUTTYPE= "input"; //$NON-NLS-1$
public static final String MULTILINETYPE= "multiline"; //$NON-NLS-1$
public static final String SELECTTYPE= "select"; //$NON-NLS-1$
public static final String BOOLEANTYPE= "boolean"; //$NON-NLS-1$
public static final String BROWSETYPE= "browse"; //$NON-NLS-1$
public static final String STRINGLISTTYPE= "stringlist"; //$NON-NLS-1$
public static final String SPECIALLISTTYPE= "speciallist"; //$NON-NLS-1$
public static final String MANDATORY= "mandatory"; //$NON-NLS-1$
public static final String INPUTPATTERN="pattern"; //$NON-NLS-1$
public static final String DEFAULT= "default"; //$NON-NLS-1$
public static final String WIDGETLABEL= "label"; //$NON-NLS-1$
public static final String BROWSELABEL= " Browse.. "; //$NON-NLS-1$
public static final String CONTENTS= " contents"; //$NON-NLS-1$
public static final String ISINVALID= " is Invalid. "; //$NON-NLS-1$
public static final String CHECKPROJECT= "checkproject"; //$NON-NLS-1$
public static final String NULL= "null"; //$NON-NLS-1$
public static final String SIZE= "size"; //$NON-NLS-1$
public static final String HIDDEN= "hidden"; //$NON-NLS-1$
/**
* The string appearing in the Combo box
*/
public static final String COMBOITEM_LABEL= "label"; //$NON-NLS-1$
/**
* Alternative attribute name for the value stored when the corresponding Combo item is selected.
* See <a href="https://bugs.eclipse.org/222954">Bugzilla 222954</a>.
*/
public static final String COMBOITEM_NAME= "name"; //$NON-NLS-1$
/**
* Preferred attribute name for the value stored when the corresponding Combo item is selected.
*/
public static final String COMBOITEM_VALUE= "value"; //$NON-NLS-1$
protected InputUIElement(UIAttributes uiAttribute) {
super(uiAttribute);

View file

@ -17,12 +17,16 @@ import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite;
/**
* UIElement describes the abstract behaviour expected from GenericUIElementGroup and
* UIElement describes the abstract behavior expected from GenericUIElementGroup and
* InputUIElement. Some of the methods are meaningful to group Element. They will throw
* SimpleElementException when invoked on InputUIElement.
*/
public abstract class UIElement {
public static final String ID = "id"; //$NON-NLS-1$
public static final String TYPE = "type"; //$NON-NLS-1$
public static final String DESCRIPTION = "description"; //$NON-NLS-1$
public static final String TITLE = "label"; //$NON-NLS-1$
public static final String IMAGELOCATION = "image"; //$NON-NLS-1$
/**
* Parent of this UIElement
@ -32,16 +36,10 @@ public abstract class UIElement {
/**
* Attributes of this UIElement
*/
protected UIAttributes/*<String, String>*/ attribute;
public static final String ID = "id"; //$NON-NLS-1$
public static final String TYPE = "type"; //$NON-NLS-1$
public static final String DESCRIPTION = "description"; //$NON-NLS-1$
public static final String TITLE = "label"; //$NON-NLS-1$
public static final String IMAGELOCATION = "image"; //$NON-NLS-1$
protected UIAttributes uiAttributes;
public UIElement(UIAttributes/*<String, String> */uiAttribute) {
attribute = uiAttribute;
public UIElement(UIAttributes uiAttributes) {
this.uiAttributes = uiAttributes;
}
/**
@ -62,7 +60,7 @@ public abstract class UIElement {
* get the attributes of this UIElement
*/
public UIAttributes getAttributes() {
return attribute;
return uiAttributes;
}
/**

View file

@ -10,8 +10,10 @@
*******************************************************************************/
package org.eclipse.cdt.ui.templateengine.uitree;
import java.util.HashMap;
import java.text.MessageFormat;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@ -19,8 +21,9 @@ import org.w3c.dom.Node;
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
import org.eclipse.cdt.core.templateengine.TemplateEngine;
import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
import org.eclipse.cdt.core.templateengine.TemplateInfo;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.templateengine.Messages;
import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIBooleanWidget;
import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIBrowseWidget;
import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UISelectWidget;
@ -33,15 +36,12 @@ import org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UITextWidget;
* UIElement. The UIElement can be a simple UI Widget or a group.
*/
public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper {
/**
* TemplateDescriptor representing the TemplaeDescriptor XML.
*/
private TemplateDescriptor templateDescriptor = null;
private TemplateInfo templateInfo;
private Element element;
/**
* Constructor, takes an TemplateDescriptor instance as parameter.
*
@ -70,20 +70,15 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper {
* @return UIElement.
*/
public UIElement getUIElement(Element element) {
this.element = element;
UIElement retUIElement = null;
UIAttributes/*<String, String>*/ uiAttributes = new UIAttributes/*<String, String>*/(templateInfo);
UIAttributes uiAttributes = new UIAttributes(templateInfo);
NamedNodeMap list = element.getAttributes();
for (int i = 0, s = list.getLength(); i < s; i++) {
for (int i=0; i<list.getLength(); i++) {
Node attribute = list.item(i);
uiAttributes.put(attribute.getNodeName(), attribute.getNodeValue());
}
retUIElement = getUIWidget(uiAttributes);
return retUIElement;
return getUIWidget(element, uiAttributes);
}
/**
@ -94,89 +89,63 @@ public class UIElementTreeBuilderHelper implements IUIElementTreeBuilderHelper {
* @param uiAttributes
* @return UIElement.
*/
private UIElement getUIWidget(UIAttributes/*<String, String>*/ uiAttributes) {
private UIElement getUIWidget(Element element, UIAttributes uiAttributes) {
UIElement widgetElement= null;
String id= uiAttributes.get(InputUIElement.ID);
String type= uiAttributes.get(InputUIElement.TYPE);
UIElement widgetElement = null;
String itemName = null;
String itemValue = null;
String itemSelected = null;
String nameStr = null;
String valueStr = null;
String selected = null;
if (new Boolean(uiAttributes.get(InputUIElement.HIDDEN)).booleanValue())
if (type == null || type.length()==0 ) {
return null;
if (type.equalsIgnoreCase("") || type == null) //$NON-NLS-1$
return null;
// UIWidgets
if (type.equalsIgnoreCase(InputUIElement.INPUTTYPE)) {
widgetElement = new UITextWidget(uiAttributes);
}
if (type.equalsIgnoreCase(InputUIElement.MULTILINETYPE)) {
widgetElement = new UITextWidget(uiAttributes);
}
if (type.equalsIgnoreCase(InputUIElement.SELECTTYPE)) {
HashMap<String, String> itemMap = new HashMap<String, String>();
List<Element> itemList = TemplateEngine.getChildrenOfElement(element);
for (int i = 0, l = itemList.size(); i < l; i++) {
Element itemElement = itemList.get(i);
NamedNodeMap itemAttrList = itemElement.getAttributes();
for (int j = 0, l1 = itemAttrList.getLength(); j < l1; j++) {
Node itemAttr = itemAttrList.item(j);
itemName = itemAttr.getNodeName();
itemValue = itemAttr.getNodeValue();
if (itemName.equals(InputUIElement.TITLE)) {
selected = itemValue;
nameStr = new String(itemValue);
} else if (itemName.equals(InputUIElement.NAME))
valueStr = new String(itemValue);
if (itemName.equals(InputUIElement.SELECTED))
if (itemValue.equals(TemplateEngineHelper.BOOLTRUE))
itemSelected = selected;
itemMap.put(nameStr, valueStr);
}
}
widgetElement = new UISelectWidget(uiAttributes, itemMap, itemSelected);
}
if (type.equalsIgnoreCase(InputUIElement.BOOLEANTYPE)) {
widgetElement = new UIBooleanWidget(uiAttributes);
}
if (type.equalsIgnoreCase(InputUIElement.BROWSETYPE)) {
widgetElement = new UIBrowseWidget(uiAttributes);
}
if (type.equalsIgnoreCase(InputUIElement.STRINGLISTTYPE)) {
widgetElement = new UIStringListWidget(uiAttributes);
}
if (type.equalsIgnoreCase(InputUIElement.SPECIALLISTTYPE)) {
if (new Boolean(uiAttributes.get(InputUIElement.HIDDEN)).booleanValue()) {
return null;
}
if (type.equalsIgnoreCase(InputUIElement.INPUTTYPE)) {
widgetElement = new UITextWidget(uiAttributes);
} else if (type.equalsIgnoreCase(InputUIElement.MULTILINETYPE)) {
widgetElement = new UITextWidget(uiAttributes);
} else if (type.equalsIgnoreCase(InputUIElement.SELECTTYPE)) {
String defaultValue= element.getAttribute(InputUIElement.DEFAULT);
Map<String,String> value2name= new LinkedHashMap<String,String>();
for(Element item : TemplateEngine.getChildrenOfElement(element)) {
String label= item.getAttribute(InputUIElement.COMBOITEM_LABEL); // item displayed in Combo
String value= item.getAttribute(InputUIElement.COMBOITEM_NAME); // value stored when its selected
if(value.length() == 0) {
value= item.getAttribute(InputUIElement.COMBOITEM_VALUE);
}
if(label==null || value==null) {
String msg= Messages.getString("UIElementTreeBuilderHelper.InvalidEmptyLabel"); //$NON-NLS-1$
CUIPlugin.log(MessageFormat.format(msg, id), null);
} else {
if(value2name.put(value, label)!=null) {
String msg= Messages.getString("UIElementTreeBuilderHelper.InvalidNonUniqueValue"); //$NON-NLS-1$
CUIPlugin.log(MessageFormat.format(msg, id), null);
}
}
}
widgetElement = new UISelectWidget(uiAttributes, value2name, defaultValue);
} else if (type.equalsIgnoreCase(InputUIElement.BOOLEANTYPE)) {
String defaultValue= element.getAttribute(InputUIElement.DEFAULT);
boolean b= Boolean.parseBoolean(defaultValue);
widgetElement = new UIBooleanWidget(uiAttributes, b);
} else if (type.equalsIgnoreCase(InputUIElement.BROWSETYPE)) {
widgetElement = new UIBrowseWidget(uiAttributes);
} else if (type.equalsIgnoreCase(InputUIElement.STRINGLISTTYPE)) {
widgetElement = new UIStringListWidget(uiAttributes);
} else if (type.equalsIgnoreCase(InputUIElement.SPECIALLISTTYPE)) {
widgetElement = new UISpecialListWidget(uiAttributes);
}
// PAGES(Groups).
if (type.equalsIgnoreCase(UIGroupTypeEnum.PAGES_ONLY.getId())) {
} else if (type.equalsIgnoreCase(UIGroupTypeEnum.PAGES_ONLY.getId())) {
widgetElement = new SimpleUIElementGroup(uiAttributes);
}
if (type.equalsIgnoreCase(UIGroupTypeEnum.PAGES_TAB.getId())) {
} else if (type.equalsIgnoreCase(UIGroupTypeEnum.PAGES_TAB.getId())) {
// Note: This is not implemented now as we haven't found a use case
// for generating UI pages as TABS in a single page.
} else {
String msg= MessageFormat.format(Messages.getString("UIElementTreeBuilderHelper.UnknownWidgetType0"), type); //$NON-NLS-1$
CUIPlugin.log(msg, null);
}
return widgetElement;

View file

@ -47,7 +47,7 @@ import org.eclipse.cdt.ui.templateengine.SimpleElementException;
public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager {
/**
* referenc to iUIElementTreeBuilderHelper, which returns UIElement for Element.
* reference to iUIElementTreeBuilderHelper, which returns UIElement for Element.
*/
private UIElementTreeBuilderHelper uiElementTreeBuilderHelper;
@ -75,9 +75,9 @@ public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager
}
if ((uiParent != null) && (uiParent instanceof GenericUIElementGroup)) {
List/*<Element>*/ childList = TemplateEngine.getChildrenOfElement(element);
List<Element> childList = TemplateEngine.getChildrenOfElement(element);
for (int listIndex = 0, l = childList.size(); listIndex < l; listIndex++) {
UIElement uiElement = uiElementTreeBuilderHelper.getUIElement((Element) childList.get(listIndex));
UIElement uiElement = uiElementTreeBuilderHelper.getUIElement(childList.get(listIndex));
if (uiElement != null) {
uiElement.setParent(uiParent);
} else {
@ -88,7 +88,7 @@ public class UIElementTreeBuilderManager implements IUIElementTreeBuilderManager
} catch (SimpleElementException exp) {
TemplateEngineUtil.log(exp);
}
createUIElementTree(uiElement, (Element) childList.get(listIndex));
createUIElementTree(uiElement, childList.get(listIndex));
}
}
}

View file

@ -22,7 +22,6 @@ import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
@ -31,14 +30,7 @@ import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
/**
* This gives a Label and Boolean widget.
*/
public class UIBooleanWidget extends InputUIElement {
/**
* Attributes associated with this widget.
*/
protected UIAttributes/*<String, String>*/ uiAttribute;
/**
* Boolean widget.
*/
@ -59,64 +51,54 @@ public class UIBooleanWidget extends InputUIElement {
/**
* Constructor.
*
* @param uiAttribute
* @param uiAttributes
* attribute associated with this widget.
*/
public UIBooleanWidget(UIAttributes/*<String, String>*/ uiAttribute) {
super(uiAttribute);
this.uiAttribute = uiAttribute;
this.booleanValue = false;
public UIBooleanWidget(UIAttributes uiAttributes, boolean defaultValue) {
super(uiAttributes);
this.booleanValue= defaultValue;
}
/**
* @return HashMap which contains the values in the Boolean Widget.
*/
public Map<String, String> getValues() {
Map<String, String> retMap = new HashMap<String, String>();
retMap.put(uiAttribute.get(InputUIElement.ID), new Boolean(booleanValue).toString());
return retMap;
Map<String, String> values = new HashMap<String, String>();
values.put(uiAttributes.get(InputUIElement.ID), Boolean.toString(booleanValue));
return values;
}
/**
* Set the Boolean widget with new value.
*
* @param valueMap
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#setValues(java.util.Map)
*/
@Override
public void setValues(Map<String, String> valueMap) {
booleanValue = new Boolean(valueMap.get(uiAttribute.get(InputUIElement.ID))).booleanValue();
booleanValue = new Boolean(valueMap.get(uiAttributes.get(InputUIElement.ID))).booleanValue();
}
/**
* create a Label and Boolean widget, add it to UIComposite. set Layout for
* the widgets to be added to UIComposite. set required parameters to the
* Widgets.
*
* @param uiComposite
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#createWidgets(org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite)
*/
public void createWidgets(UIComposite uiComposite) {
GridData gridData = null;
this.uiComposite = uiComposite;
label = new Label(uiComposite, SWT.LEFT);
label.setText(uiAttribute.get(InputUIElement.WIDGETLABEL));
label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
if (uiAttribute.get(InputUIElement.DESCRIPTION) != null){
String tipText = uiAttribute.get(UIElement.DESCRIPTION);
if (uiAttributes.get(InputUIElement.DESCRIPTION) != null){
String tipText = uiAttributes.get(UIElement.DESCRIPTION);
tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
label.setToolTipText(tipText);
}
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
Composite booleanConatiner = new Composite(uiComposite, SWT.NONE);
Composite booleanContainer = new Composite(uiComposite, SWT.NONE);
GridData gridcData = new GridData(GridData.FILL_HORIZONTAL);
booleanConatiner.setLayout(new GridLayout());
booleanConatiner.setLayoutData(gridcData);
button = new Button(booleanConatiner, SWT.CHECK);
button.setData(".uid", uiAttribute.get(UIElement.ID)); //$NON-NLS-1$
booleanContainer.setLayout(new GridLayout());
booleanContainer.setLayoutData(gridcData);
button = new Button(booleanContainer, SWT.CHECK);
button.setData(".uid", uiAttributes.get(UIElement.ID)); //$NON-NLS-1$
button.setSelection(new Boolean(booleanValue).booleanValue());
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@ -125,31 +107,23 @@ public class UIBooleanWidget extends InputUIElement {
});
}
/**
* Based on the stae of this Widget return true or false. This return value
* will be used by the UIPage to update its(UIPage) state. Return value
* depends on the value contained in Boolean Widget. If boolean value
* contained is false and Mandatory value from attributes.
*
* @return boolean.
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#isValid()
*/
public boolean isValid() {
boolean retVal = true;
String mandatory = uiAttribute.get(InputUIElement.MANDATORY);
if (!booleanValue && mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE)) {
retVal = false;
boolean retVal= true;
String mandatory= uiAttributes.get(InputUIElement.MANDATORY);
if (!booleanValue && Boolean.parseBoolean(mandatory)) {
retVal= false;
}
return retVal;
}
/**
* call the dispose method on the widgets. This is to ensure that the
* widgets are properly disposed.
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#disposeWidget()
*/
public void disposeWidget() {
label.dispose();
button.dispose();
}
}

View file

@ -46,7 +46,6 @@ public class UIBrowseWidget extends UITextWidget implements ModifyListener {
*/
public UIBrowseWidget(UIAttributes uiAttribute) {
super(uiAttribute);
this.uiAttribute = uiAttribute;
this.textValue = uiAttribute.get(InputUIElement.DEFAULT);
}
@ -61,11 +60,11 @@ public class UIBrowseWidget extends UITextWidget implements ModifyListener {
uiComposite = composite;
label = new Label(uiComposite, SWT.NONE | SWT.LEFT);
label.setText(uiAttribute.get(InputUIElement.WIDGETLABEL));
label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
// set the tool tip text
if (uiAttribute.get(UIElement.DESCRIPTION) != null){
String tipText = uiAttribute.get(UIElement.DESCRIPTION);
if (uiAttributes.get(UIElement.DESCRIPTION) != null){
String tipText = uiAttributes.get(UIElement.DESCRIPTION);
tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$, //$NON-NLS-2$
label.setToolTipText(tipText);
}

View file

@ -25,7 +25,7 @@ import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
/**
* By extending Composite we can create our own Container. UIComposite can act
* as the brdige between the UIPage and the UIWidgets contained in that page.
* as the bridge between the UIPage and the UIWidgets contained in that page.
* The PatternEvents generated by the UIWidgets will be fired to the UIPage
* which is a PatternEventListener.
*/
@ -33,7 +33,7 @@ import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
public class UIComposite extends Composite {
/**
* The gruop UIElement corresponding to this UIPage.
* The group UIElement corresponding to this UIPage.
*/
private UIElement uiElement;
@ -59,7 +59,6 @@ public class UIComposite extends Composite {
this.setLayoutData(new GridData(GridData.FILL_BOTH));
this.uiElement = uiElement;
this.uiElement.createWidgets(this);
}
/**

View file

@ -11,58 +11,46 @@
package org.eclipse.cdt.ui.templateengine.uitree.uiwidgets;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
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;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.ui.templateengine.Messages;
import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
/**
* This gives a Label and Combo widget.
*/
public class UISelectWidget extends InputUIElement {
/**
* Attributes associated with this widget.
*/
protected UIAttributes uiAttribute;
/**
* Select widget.
*/
protected Combo combo = null;
/**
* Label of this widget.
*/
protected Label label;
protected Combo combo;
/**
* Composite to which this widget control is added.
* Mapping from values stored by this combo, to their associated names in UI
*/
protected UIComposite uiComposite;
protected Map<String, String> value2name;
/**
* Map contains the values of Select Widget
* The default name to select
*/
protected HashMap/*<String, String>*/ itemMap;
protected String defaultValue;
/**
* Default value of Select Widget
* The currently selected name. May be null.
*/
protected String itemSelected;
protected String currentValue;
/**
* Constructor for Select Widget.
@ -70,34 +58,32 @@ public class UISelectWidget extends InputUIElement {
* @param attribute
* attribute associated with this widget.
*/
public UISelectWidget(UIAttributes/*<String, String>*/ attribute, HashMap/*<String, String>*/ itemMap,
String itemSelected) {
public UISelectWidget(UIAttributes attribute, Map<String, String> value2name, String defaultValue) {
super(attribute);
uiAttribute = attribute;
this.itemMap = itemMap;
this.itemSelected = itemSelected;
this.value2name= value2name;
this.defaultValue= defaultValue;
}
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#getValues()
*/
public Map<String, String> getValues() {
Map<String, String> retMap = new HashMap<String, String>();
retMap.put(uiAttribute.get(InputUIElement.ID), itemSelected);
return retMap;
Map<String, String> values = new HashMap<String, String>();
if(currentValue != null) {
values.put(uiAttributes.get(InputUIElement.ID), currentValue);
}
return values;
}
/**
* Set the Text widget with new value.
*
* @param valueMap
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#setValues(java.util.Map)
*/
public void setValues(Map<String, String> valueMap) {
itemSelected = valueMap.get(uiAttribute.get(InputUIElement.ID));
defaultValue= valueMap.get(uiAttributes.get(InputUIElement.ID));
if (combo != null) {
String[] items = combo.getItems();
String[] items= combo.getItems();
for (int i=0; i < items.length; i++) {
if (items[i].equals(itemSelected)) {
if (items[i].equals(defaultValue)) {
combo.select(i);
break;
}
@ -105,84 +91,73 @@ public class UISelectWidget extends InputUIElement {
}
}
/**
* create a Label and Text widget, add it to UIComposite. set Layout for the
* widgets to be added to UIComposite. set required parameters to the
* Widgets.
*
* @param composite
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#createWidgets(org.eclipse.cdt.ui.templateengine.uitree.uiwidgets.UIComposite)
*/
public void createWidgets(UIComposite composite) {
GridData gridData = null;
uiComposite = composite;
public void createWidgets(final UIComposite uiComposite) {
label= new Label(uiComposite, SWT.LEFT);
label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
label = new Label(composite, SWT.LEFT);
label.setText(uiAttribute.get(InputUIElement.WIDGETLABEL));
Composite comboComposite = new Composite(uiComposite, SWT.NONE);
comboComposite.setLayout(GridLayoutFactory.swtDefaults().create());
comboComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
gridData = new GridData();
gridData.horizontalAlignment = GridData.FILL;
gridData.grabExcessHorizontalSpace = true;
combo= new Combo(comboComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
combo.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
combo.setData(".uid", uiAttributes.get(UIElement.ID)); //$NON-NLS-1$
Composite comboComposite = new Composite(composite, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
comboComposite.setLayout(new GridLayout());
comboComposite.setLayoutData(gridData);
combo = new Combo(comboComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
Set keySet = itemMap.keySet();
Iterator mapIterator = keySet.iterator();
int index = 0;
int i = 0;
while (mapIterator.hasNext()) {
String key = (String) mapIterator.next();
combo.add(key);
if (itemSelected.equals(key))
index = i;
i++;
}
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());
// populate combo
int index= 0, defaultIndex= 0;
for(String name : value2name.values()) {
combo.add(name);
if(name.equals(defaultValue)) {
defaultIndex= index;
}
public void widgetDefaultSelected(SelectionEvent e) {
index++;
}
combo.select(defaultIndex);
combo.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
currentValue= getValue(combo.getItem(combo.getSelectionIndex()));
uiComposite.firePatternEvent(createPatternEvent());
}
});
uiComposite.firePatternEvent(createPatternEvent());
}
private PatternEvent createPatternEvent() {
String msg= MessageFormat.format(Messages.getString("UISelectWidget_ErrorNoneSelected0"), new String[] {label.getText()}); //$NON-NLS-1$
return new PatternEvent(this, msg, isValid());
}
/**
* Based on the stae of this Widget return true or false. This return value
* will be used by the UIPage to update its(UIPage) state. Return value
* depends on the value contained in Select Widget. If value contained is
* null, "" and Mandatory value from attributes.
*
* @return boolean.
* @return whether this widget has been set to a valid state. For this
* widget type that means whether the user has selected a non-empty string name.
*/
public boolean isValid() {
boolean retVal = true;
String mandatory = uiAttribute.get(InputUIElement.MANDATORY);
if ((itemSelected == null || itemSelected.equals("") //$NON-NLS-1$
|| itemSelected.trim().length() < 1) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
retVal = false;
if(Boolean.parseBoolean(uiAttributes.get(InputUIElement.MANDATORY))) {
retVal= currentValue!= null && currentValue.trim().length()>0;
}
return retVal;
}
/**
* call the dispose method on the widgets. This is to ensure that the
* widgets are properly disposed.
private String getValue(String name) {
for(String value : value2name.keySet()) {
if(value2name.get(value).equals(name)) {
return value;
}
}
throw new IllegalStateException();
}
/*
* @see org.eclipse.cdt.ui.templateengine.uitree.UIElement#disposeWidget()
*/
public void disposeWidget() {
label.dispose();
combo.dispose();
}
}

View file

@ -30,7 +30,6 @@ import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener;
*
*/
public class UISpecialListWidget extends UIStringListWidget {
/**
* Constructor.
*
@ -39,7 +38,6 @@ public class UISpecialListWidget extends UIStringListWidget {
*/
public UISpecialListWidget(UIAttributes attribute) {
super(attribute);
uiAttribute = attribute;
}
/**
@ -47,38 +45,40 @@ public class UISpecialListWidget extends UIStringListWidget {
* widgets to be added to UIComposite. set required parameters to the
* Widgets.
*
* @param composite
* @param uiComposite
*/
public void createWidgets(UIComposite composite) {
public void createWidgets(final UIComposite uiComposite) {
GridData gridData = null;
uiComposite = composite;
label = new Label(composite, SWT.LEFT);
label.setText(uiAttribute.get(InputUIElement.WIDGETLABEL));
label = new Label(uiComposite, SWT.LEFT);
label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
GridData gd = new GridData();
gd.verticalAlignment = SWT.BEGINNING;
gd.verticalIndent = 5;
label.setLayoutData(gd);
if (uiAttribute.get(InputUIElement.DESCRIPTION) != null){
String tipText = uiAttribute.get(UIElement.DESCRIPTION);
if (uiAttributes.get(InputUIElement.DESCRIPTION) != null){
String tipText = uiAttributes.get(UIElement.DESCRIPTION);
tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$, //$NON-NLS-2$
label.setToolTipText(tipText);
}
Composite flcComposite = new Composite(composite, SWT.NONE);
Composite flcComposite = new Composite(uiComposite, SWT.NONE);
gridData = new GridData(GridData.FILL_HORIZONTAL);
flcComposite.setLayout(new GridLayout());
flcComposite.setLayoutData(gridData);
fileListControl = new FileListControl(flcComposite, uiAttribute.get(InputUIElement.WIDGETLABEL), 1);
fileListControl.setList((String[])itemsList.toArray());
fileListControl = new FileListControl(flcComposite, uiAttributes.get(InputUIElement.WIDGETLABEL), 1);
fileListControl.setList(itemsList.toArray(new String[itemsList.size()]));
fileListControl.setSelection(0);
fileListControl.addChangeListener(new IFileListChangeListener(){
public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) {
itemsList.clear();
itemsList.addAll(Arrays.asList(newValue));
uiComposite.firePatternEvent(createPatternEvent());
}
});
uiComposite.firePatternEvent(createPatternEvent());
}
/**

View file

@ -24,7 +24,10 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.core.templateengine.TemplateEngineHelper;
import org.eclipse.cdt.ui.templateengine.event.PatternEvent;
import org.eclipse.cdt.ui.templateengine.uitree.InputUIElement;
import org.eclipse.cdt.ui.templateengine.uitree.UIAttributes;
import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
@ -36,14 +39,7 @@ import org.eclipse.cdt.utils.ui.controls.IFileListChangeListener;
* This gives a Label and StringList Widget.
*
*/
public class UIStringListWidget extends InputUIElement {
/**
* Attributes associated with this widget.
*/
protected UIAttributes/*<String, String>*/ uiAttribute;
/**
* StringList widget.
*/
@ -54,11 +50,6 @@ public class UIStringListWidget extends InputUIElement {
*/
protected Label label;
/**
* Composite to which this widget control is added.
*/
protected UIComposite uiComposite;
protected List<String> itemsList;
/**
@ -69,7 +60,6 @@ public class UIStringListWidget extends InputUIElement {
*/
public UIStringListWidget(UIAttributes attribute) {
super(attribute);
uiAttribute = attribute;
itemsList = new ArrayList<String>();
}
@ -82,7 +72,7 @@ public class UIStringListWidget extends InputUIElement {
for (int i = 0; i < itemsList.size(); i++) {
itemString = itemString + itemsList.get(i) + "|"; //$NON-NLS-1$
}
retMap.put(uiAttribute.get(InputUIElement.ID), itemString);
retMap.put(uiAttributes.get(InputUIElement.ID), itemString);
return retMap;
}
@ -92,8 +82,8 @@ public class UIStringListWidget extends InputUIElement {
*
* @param valueMap
*/
public void setValues(Map/*<String, String>*/ valueMap) {
String items = (String) valueMap.get(uiAttribute.get(InputUIElement.ID));
public void setValues(Map valueMap) {
String items = (String) valueMap.get(uiAttributes.get(InputUIElement.ID));
if (items != null) {
items = items.trim();
@ -109,22 +99,21 @@ public class UIStringListWidget extends InputUIElement {
* for the widgets to be added to UIComposite. set required parameters to
* the Widgets.
*
* @param composite
* @param uiComposite
*/
public void createWidgets(UIComposite composite) {
public void createWidgets(final UIComposite uiComposite) {
GridData gridData = null;
uiComposite = composite;
label = new Label(composite, SWT.LEFT);
label.setText(uiAttribute.get(InputUIElement.WIDGETLABEL));
label = new Label(uiComposite, SWT.LEFT);
label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
GridData gd = new GridData();
gd.verticalAlignment = SWT.BEGINNING;
gd.verticalIndent = 5;
label.setLayoutData(gd);
if (uiAttribute.get(InputUIElement.DESCRIPTION) != null){
String tipText = uiAttribute.get(UIElement.DESCRIPTION);
if (uiAttributes.get(InputUIElement.DESCRIPTION) != null){
String tipText = uiAttributes.get(UIElement.DESCRIPTION);
tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$, $NON-NLS-2$
label.setToolTipText(tipText);
}
@ -133,15 +122,23 @@ public class UIStringListWidget extends InputUIElement {
flcComposite.setLayout(new GridLayout());
flcComposite.setLayoutData(gridData);
fileListControl = new FileListControl(flcComposite, uiAttribute.get(InputUIElement.WIDGETLABEL), 0);
fileListControl.setList((String[])itemsList.toArray());
fileListControl = new FileListControl(flcComposite, uiAttributes.get(InputUIElement.WIDGETLABEL), 0);
fileListControl.setList(itemsList.toArray(new String[itemsList.size()]));
fileListControl.setSelection(0);
fileListControl.addChangeListener(new IFileListChangeListener(){
public void fileListChanged(FileListControl fileList, String oldValue[], String newValue[]) {
itemsList.clear();
itemsList.addAll(Arrays.asList(newValue));
uiComposite.firePatternEvent(createPatternEvent());
}
});
uiComposite.firePatternEvent(createPatternEvent());
}
protected PatternEvent createPatternEvent() {
String msg= MessageFormat.format("Please add an item to {0}", new String[] {label.getText()}); //$NON-NLS-1$
return new PatternEvent(this, msg, isValid());
}
/**
@ -154,7 +151,7 @@ public class UIStringListWidget extends InputUIElement {
*/
public boolean isValid() {
boolean retVal = true;
String mandatory = uiAttribute.get(InputUIElement.MANDATORY);
String mandatory = uiAttributes.get(InputUIElement.MANDATORY);
if ((itemsList == null || itemsList.size() == 0) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))) {
retVal = false;

View file

@ -45,10 +45,6 @@ import org.eclipse.cdt.ui.templateengine.uitree.UIElement;
* but should set the same for UITextWidget(super).
*/
public class UITextWidget extends InputUIElement implements ModifyListener {
/**
* Attributes associated with this widget.
*/
protected UIAttributes uiAttribute;
/**
* Text widget.
@ -76,7 +72,6 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
*/
public UITextWidget(UIAttributes uiAttribute) {
super(uiAttribute);
this.uiAttribute = uiAttribute;
this.textValue = new String();
}
@ -85,7 +80,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), textValue);
retMap.put(uiAttributes.get(InputUIElement.ID), textValue);
return retMap;
}
@ -96,7 +91,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
* @param valueMap
*/
public void setValues(Map<String, String> valueMap) {
String val = valueMap.get(uiAttribute.get(InputUIElement.ID));
String val = valueMap.get(uiAttributes.get(InputUIElement.ID));
String key = null;
String subString = null;
if (val != null) {
@ -126,22 +121,22 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
this.uiComposite = uiComposite;
label = new Label(uiComposite, SWT.LEFT);
label.setText(uiAttribute.get(InputUIElement.WIDGETLABEL));
if ((uiAttribute.get(UIElement.TYPE)).equalsIgnoreCase(InputUIElement.MULTILINETYPE)) {
label.setText(uiAttributes.get(InputUIElement.WIDGETLABEL));
if ((uiAttributes.get(UIElement.TYPE)).equalsIgnoreCase(InputUIElement.MULTILINETYPE)) {
gd = new GridData();
gd.verticalAlignment = SWT.BEGINNING;
gd.verticalIndent = 5;
label.setLayoutData(gd);
}
if (uiAttribute.get(UIElement.DESCRIPTION) != null){
String tipText = uiAttribute.get(UIElement.DESCRIPTION);
if (uiAttributes.get(UIElement.DESCRIPTION) != null){
String tipText = uiAttributes.get(UIElement.DESCRIPTION);
tipText = tipText.replaceAll("\\\\r\\\\n", "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
label.setToolTipText(tipText);
}
text = getTextWidget(uiAttribute.get(UIElement.TYPE));
text = getTextWidget(uiAttributes.get(UIElement.TYPE));
text.addModifyListener(this);
text.setData(".uid", uiAttribute.get(UIElement.ID)); //$NON-NLS-1$
text.setData(".uid", uiAttributes.get(UIElement.ID)); //$NON-NLS-1$
text.setText(textValue);
}
@ -179,7 +174,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
uiComposite.firePatternEvent(new PatternEvent(this, message, false));
} else {
String checkproject = attribute.get(InputUIElement.CHECKPROJECT);
String checkproject = uiAttributes.get(InputUIElement.CHECKPROJECT);
if ((checkproject != null) && (checkproject.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE))
&& TemplateEngineHelper.checkDirectoryInWorkspace(userInputText)) {
@ -197,7 +192,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
* evaluatePattern.
*/
public void modifyText(ModifyEvent e) {
String patternName = uiAttribute.get(InputUIElement.INPUTPATTERN);
String patternName = uiAttributes.get(InputUIElement.INPUTPATTERN);
if (patternName == null) {
patternValue = null;
@ -220,7 +215,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
if ((patternValue == null) || (textValue == null))
return;
String mandatory = attribute.get(InputUIElement.MANDATORY);
String mandatory = uiAttributes.get(InputUIElement.MANDATORY);
if ((mandatory == null || !mandatory.equalsIgnoreCase("true")) && textValue.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$
return;
}
@ -260,7 +255,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
*/
public boolean isValid() {
boolean retVal = true;
String mandatory = uiAttribute.get(InputUIElement.MANDATORY);
String mandatory = uiAttributes.get(InputUIElement.MANDATORY);
if (((mandatory != null) && (mandatory.equalsIgnoreCase(TemplateEngineHelper.BOOLTRUE)))
&& ((textValue == null) || (textValue.equals("")) || //$NON-NLS-1$
@ -297,7 +292,7 @@ public class UITextWidget extends InputUIElement implements ModifyListener {
GridData multiTextData = new GridData(GridData.FILL_HORIZONTAL);
multiTextData.widthHint = 70;
String line = uiAttribute.get(InputUIElement.SIZE);
String line = uiAttributes.get(InputUIElement.SIZE);
int cnt = 1;
if (line != null) {
cnt = Integer.parseInt(line);

View file

@ -79,7 +79,6 @@ For a project template the <code>type</code> should be <code>ProjTempl</code>.
<li>
<p>
<code>version</code>: Use this attribute to specify the major version
number of the template.
</p>
<li>
<p>
@ -235,7 +234,7 @@ property
The syntax for the <code>property</code> elements included by the
property-group element is as follows:
</p>
<p class="CodeBlock"><code>&lt;property <br>id="propertyId"<br>label="User visible label of the property"<br>description="A brief description of the property"<br>type="type of the property"<br>pattern="Regular expression of the expected property"<br>default="Default value of the property"<br>size="size"<br>mandatory="true|false"<br>hidden="true|false"<br>persist="true|false"&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name="name of the item"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label="User visible label of the item"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;selected="true|false"&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/item&gt;<br>&lt;/property&gt;</code></p>
<p class="CodeBlock"><code>&lt;property <br>id="propertyId"<br>label="User visible label of the property"<br>description="A brief description of the property"<br>type="type of the property"<br>pattern="Regular expression of the expected property"<br>default="Default value of the property"<br>size="size"<br>mandatory="true|false"<br>hidden="true|false"<br>persist="true|false"&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value="value of the item"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label="User visible label of the item"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/item&gt;<br>&lt;/property&gt;</code></p>
<p>
Here is a list of attributes of the <code>property</code> element:
</p>
@ -339,27 +338,20 @@ If the property <code>type</code> is <code>select</code> or
specify the items to be listed. There is no limitation on the number of items
that can be listed. Here is the syntax for the <code>item</code> element:
</p>
<p class="CodeBlock"><code>&lt;item <br>name="name of the item"<br>label="User visible label of the item"<br>selected="true|false"&gt;<br>&lt;/item&gt;</code></p>
<p class="CodeBlock"><code>&lt;item <br>value="value of the item"<br>label="User visible label of the item"<br>&lt;/item&gt;</code></p>
<p>
Here is a list of attributes of the <code>item</code> element:
</p>
<ul>
<li>
<p>
<code>name</code>: Used to specify a unique name for the list item.
</p>
<li>
<p>
<code>label</code>: Used to specify a label that is displayed to the
user.
</p>
<li>
<p>
<code>selected</code>: Used to specify whether the list item is
selected by default. The value for this attribute can either be
<code>true</code> or <code>false</code>.
<code>value</code>: Used to specify a unique value for the list item. This will be the value used in macro expansions.
</p>
</li>
</ul>
<h4 class="subheading">
process

View file

@ -94,14 +94,15 @@ The following is an example template to create a simple Symbian OS
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label="Target Type"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description="Select the target type"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;type="select"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default="app"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hidden="false"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mandatory="true"<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;persist="true"&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="APP" selected="true" name="app"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="LIB" selected="false" name="lib"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="DLL" selected="false" name="dll"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="EXE" selected="false" name="exe"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="EXEDLL" selected="false" name="exedll"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="APP" value="app"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="LIB" value="lib"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="DLL" value="dll"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="EXE" value="exe"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item label="EXEDLL" value="exedll"/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/property&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/property-group&gt;<br>
<br>