Author: DartPeng
Date: 2008-09-28 04:01:34 -0400 (Sun, 28 Sep 2008)
New Revision: 10525
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/DocumentSelectionWarrper.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DocumentResourceTypeDetailPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelPackage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResourceConfigWarrperFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksResourceConfigFormBlock.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
Log:
Add a smooks new wizard
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -600,6 +600,7 @@
}
}
}
+ if(current == null) return null;
Class rootClass = null;
rootClassName = SmooksModelUtils.getParmaText("beanClass", current);
if (rootClassName != null && loader != null) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -19,9 +19,12 @@
public static final String STREAM_FILTER_TYPE = "stream.filter.type";
public static final String SAX = "SAX";
public static final String DOM = "DOM";
+ public static final String SAX_DOM = "SAX/DOM";
public static final String BEAN_POPULATOR =
"org.milyn.javabean.BeanPopulator";
public static final String DATE_DECODER =
"org.milyn.javabean.decoders.DateDecoder";
+ public static final String AT_DOCUMENT = "@document";
+
public static final String BEAN_ID = "beanId";
public static final String FORMATE = "formate";
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.model/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -14,12 +14,14 @@
import java.util.List;
import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import org.jboss.tools.smooks.model.ParamType;
import org.jboss.tools.smooks.model.ResourceConfigType;
+import org.jboss.tools.smooks.model.ResourceType;
import org.jboss.tools.smooks.model.SmooksPackage;
/**
@@ -48,7 +50,77 @@
param.getMixed().add(ELEMENT_BINDING, binding);
return binding;
}
+
+ public static String getTransformType(ResourceConfigType resourceConfig){
+ ParamType typeParam = null;
+ if(isTransformTypeResourceConfig(resourceConfig)){
+ List paramList = resourceConfig.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType param = (ParamType) iterator.next();
+ if (SmooksModelConstants.STREAM_FILTER_TYPE.equals(param.getName())) {
+ typeParam = param;
+ break;
+ }
+ }
+ if(typeParam != null){
+ return SmooksModelUtils.getAnyTypeText(typeParam);
+ }
+ }
+ return "";
+ }
+ public static void setTransformType(ResourceConfigType resourceConfig,
+ String type) {
+ if(type == null) type = "";
+ if (isTransformTypeResourceConfig(resourceConfig)) {
+ List paramList = resourceConfig.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType param = (ParamType) iterator.next();
+ if (SmooksModelConstants.STREAM_FILTER_TYPE.equals(param.getName())) {
+ cleanTextToSmooksType(param);
+ setTextToSmooksType(param, type);
+ }
+ }
+ }
+ }
+
+ public static boolean isFilePathResourceConfig(ResourceConfigType resourceConfig){
+ ResourceType resource = resourceConfig.getResource();
+ if(resource != null){
+ String value = resource.getValue();
+ if(value != null){
+ if(value.startsWith("\\")){
+ return true;
+ }
+ if(value.startsWith("/")){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean isTransformTypeResourceConfig(
+ ResourceConfigType resourceConfig) {
+ String selector = resourceConfig.getSelector();
+ if (!SmooksModelConstants.GLOBAL_PARAMETERS.equals(selector)) {
+ return false;
+ }
+
+ if (resourceConfig.getParam().isEmpty()) {
+ return false;
+ } else {
+ List paramList = resourceConfig.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType p = (ParamType) iterator.next();
+ if (SmooksModelConstants.STREAM_FILTER_TYPE.equals(p.getName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
public static String getParmaText(String paramName,
ResourceConfigType resourceConfigType) {
List plist = resourceConfigType.getParam();
@@ -60,21 +132,21 @@
}
return null;
}
-
- public static String getAttributeValueFromAnyType(AnyType anyType,EStructuralFeature
attribute) {
+
+ public static String getAttributeValueFromAnyType(AnyType anyType,
+ EStructuralFeature attribute) {
String value = (String) anyType.getAnyAttribute().get(attribute, false);
return value;
}
-
- public static String getAnyTypeText(AnyType anyType){
+
+ public static String getAnyTypeText(AnyType anyType) {
Object value = anyType.getMixed().get(
- XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT,
- true);
+ XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, true);
if (value != null) {
- if (value instanceof List && !((List)value).isEmpty()) {
+ if (value instanceof List && !((List) value).isEmpty()) {
return ((List) value).get(0).toString().trim();
}
-// return value.toString();
+ // return value.toString();
}
return null;
}
@@ -104,17 +176,17 @@
smooksModel.getMixed().add(
XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, text);
}
-
- public static void setTextToSmooksType(AnyType smooksModel, String text){
+
+ public static void setTextToSmooksType(AnyType smooksModel, String text) {
cleanTextToSmooksType(smooksModel);
- appendTextToSmooksType(smooksModel,text);
+ appendTextToSmooksType(smooksModel, text);
}
-
+
public static void cleanTextToSmooksType(AnyType smooksModel) {
Object obj = smooksModel.getMixed().get(
- XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT,true);
- if(obj instanceof List){
- ((List)obj).clear();
+ XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, true);
+ if (obj instanceof List) {
+ ((List) obj).clear();
}
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2008-09-27
00:58:13 UTC (rev 10524)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2008-09-28
08:01:34 UTC (rev 10525)
@@ -21,7 +21,8 @@
org.eclipse.emf.edit,
org.jboss.tools.smooks.model.edit,
org.jboss.tools.smooks.graphicalInfo,
- org.eclipse.ui.views.properties.tabbed
+ org.eclipse.ui.views.properties.tabbed,
+ org.eclipse.emf.edit.ui
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-09-27 00:58:13 UTC (rev
10524)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-09-28 08:01:34 UTC (rev
10525)
@@ -48,4 +48,18 @@
</propertyTab>
</propertyTabs>
</extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <category
+ id="org.jboss.tools.smooks.ui.wizards"
+ name="Smooks">
+ </category>
+ <wizard
+ category="org.jboss.tools.smooks.ui.wizards"
+
class="org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard"
+ icon="icons/sample.gif"
+ id="org.jboss.tools.smooks.ui.wizards.SmooksConfigFileNewWizard"
+ name="Smooks Configuration File">
+ </wizard>
+ </extension>
</plugin>
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/AnalyzerFactory.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -55,11 +55,11 @@
}
public List getRegistryTargetIDList() {
- return getIDList(sourceModelAnalyzer);
+ return getIDList(targetModelAnalyzer);
}
public List getRegistrySourceIDList() {
- return getIDList(targetModelAnalyzer);
+ return getIDList(sourceModelAnalyzer);
}
protected AnalyzerFactory() {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelBuilder.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelBuilder.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -41,21 +41,24 @@
.next();
this.processResouceConfig(resourceConfig, modelPackage);
}
+ if(resourceConfigList.isEmpty()){
+
+ }
}
return modelPackage;
}
protected void processResouceConfig(ResourceConfigType config,
NormalSmooksModelPackage modelPackage) {
- if (isBeanPopulator(config)) {
- modelPackage.getBeanPopulatorResourceConfigList().add(config);
- }
- if (isDateConfig(config)) {
- modelPackage.getDateResourceConfigList().add(config);
- }
- if (isSmooksTransformType(config)) {
- modelPackage.setSmooksTransformTypeResourceConfig(config);
- }
+// if (isBeanPopulator(config)) {
+// modelPackage.getBeanPopulatorResourceConfigList().add(config);
+// }
+// if (isDateConfig(config)) {
+// modelPackage.getDateResourceConfigList().add(config);
+// }
+// if (isSmooksTransformType(config)) {
+// modelPackage.setSmooksTransformTypeResourceConfig(config);
+// }
}
public static boolean isSmooksTransformType(ResourceConfigType config) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelPackage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelPackage.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/NormalSmooksModelPackage.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.smooks.analyzer;
-import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.Assert;
@@ -22,12 +21,14 @@
* Date : Sep 11, 2008
*/
public class NormalSmooksModelPackage {
- private List<ResourceConfigType> dateResourceConfigList = new
ArrayList<ResourceConfigType>();
-
- private List<ResourceConfigType> beanPopulatorResourceConfigList = new
ArrayList<ResourceConfigType>();
-
- private ResourceConfigType smooksTransformTypeResourceConfig;
+// private List<ResourceConfigType> dateResourceConfigList = new
ArrayList<ResourceConfigType>();
+//
+// private List<ResourceConfigType> beanPopulatorResourceConfigList = new
ArrayList<ResourceConfigType>();
+//
+// private ResourceConfigType smooksTransformTypeResourceConfig;
+ private List hidenSmooksElements = null;
+
private SmooksResourceListType smooksResourceList;
public NormalSmooksModelPackage(SmooksResourceListType listType){
@@ -43,50 +44,59 @@
this.smooksResourceList = smooksResourceList;
}
- /**
- * @return the dateResourceConfigList
- */
- public List<ResourceConfigType> getDateResourceConfigList() {
- return dateResourceConfigList;
+ public List getHidenSmooksElements() {
+ return hidenSmooksElements;
}
- /**
- * @param dateResourceConfigList the dateResourceConfigList to set
- */
- public void setDateResourceConfigList(
- List<ResourceConfigType> dateResourceConfigList) {
- this.dateResourceConfigList = dateResourceConfigList;
+ public void setHidenSmooksElements(
+ List hidenSmooksElements) {
+ this.hidenSmooksElements = hidenSmooksElements;
}
- /**
- * @return the beanPopulatorResourceConfigList
- */
- public List<ResourceConfigType> getBeanPopulatorResourceConfigList() {
- return beanPopulatorResourceConfigList;
- }
-
- /**
- * @param beanPopulatorResourceConfigList the beanPopulatorResourceConfigList to set
- */
- public void setBeanPopulatorResourceConfigList(
- List<ResourceConfigType> beanPopulatorResourceConfigList) {
- this.beanPopulatorResourceConfigList = beanPopulatorResourceConfigList;
- }
-
- /**
- * @return the smooksTransformTypeResourceConfig
- */
- public ResourceConfigType getSmooksTransformTypeResourceConfig() {
- return smooksTransformTypeResourceConfig;
- }
-
- /**
- * @param smooksTransformTypeResourceConfig the smooksTransformTypeResourceConfig to
set
- */
- public void setSmooksTransformTypeResourceConfig(
- ResourceConfigType smooksTransformTypeResourceConfig) {
- this.smooksTransformTypeResourceConfig = smooksTransformTypeResourceConfig;
- }
+// /**
+// * @return the dateResourceConfigList
+// */
+// public List<ResourceConfigType> getDateResourceConfigList() {
+// return dateResourceConfigList;
+// }
+//
+// /**
+// * @param dateResourceConfigList the dateResourceConfigList to set
+// */
+// public void setDateResourceConfigList(
+// List<ResourceConfigType> dateResourceConfigList) {
+// this.dateResourceConfigList = dateResourceConfigList;
+// }
+//
+// /**
+// * @return the beanPopulatorResourceConfigList
+// */
+// public List<ResourceConfigType> getBeanPopulatorResourceConfigList() {
+// return beanPopulatorResourceConfigList;
+// }
+//
+// /**
+// * @param beanPopulatorResourceConfigList the beanPopulatorResourceConfigList to set
+// */
+// public void setBeanPopulatorResourceConfigList(
+// List<ResourceConfigType> beanPopulatorResourceConfigList) {
+// this.beanPopulatorResourceConfigList = beanPopulatorResourceConfigList;
+// }
+//
+// /**
+// * @return the smooksTransformTypeResourceConfig
+// */
+// public ResourceConfigType getSmooksTransformTypeResourceConfig() {
+// return smooksTransformTypeResourceConfig;
+// }
+//
+// /**
+// * @param smooksTransformTypeResourceConfig the smooksTransformTypeResourceConfig to
set
+// */
+// public void setSmooksTransformTypeResourceConfig(
+// ResourceConfigType smooksTransformTypeResourceConfig) {
+// this.smooksTransformTypeResourceConfig = smooksTransformTypeResourceConfig;
+// }
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/SmooksFileBuilder.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -24,10 +24,14 @@
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.jboss.tools.smooks.model.DocumentRoot;
+import org.jboss.tools.smooks.model.ParamType;
+import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.SmooksFactory;
import org.jboss.tools.smooks.model.SmooksPackage;
import org.jboss.tools.smooks.model.SmooksResourceListType;
import org.jboss.tools.smooks.model.provider.SmooksItemProviderAdapterFactory;
+import org.jboss.tools.smooks.model.util.SmooksModelConstants;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
public class SmooksFileBuilder {
@@ -84,12 +88,12 @@
context.setDomain(domain);
analyzer.analyzeMappingGraphModel(context);
-
+
insertResoureConfig(listType, context.getGeneratorResourceList());
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
smooksResource.save(outputStream, Collections.EMPTY_MAP);
- removeSavedResourceConfig(listType,context.getGeneratorResourceList());
+ removeSavedResourceConfig(listType, context.getGeneratorResourceList());
context.getGeneratorResourceList().clear();
context.setGeneratorResourceList(null);
return new ByteArrayInputStream(outputStream.toByteArray());
@@ -140,6 +144,7 @@
// EditingDomain domain = createEditingDomain();
int length = resourceConfigList.size();
List kk = list.getAbstractResourceConfig();
+ int existingLength = kk.size();
for (int i = length - 1; i >= 0; i--) {
Object obj = resourceConfigList.get(i);
Command addResourceConfigCommand = AddCommand
@@ -150,13 +155,17 @@
.getSmooksResourceListType_AbstractResourceConfig(),
obj);
addResourceConfigCommand.execute();
+ int moveIndex = 1;
+ if (existingLength < 1) {
+ moveIndex = 0;
+ }
MoveCommand
.create(
domain,
list,
SmooksPackage.eINSTANCE
.getSmooksResourceListType_AbstractResourceConfig(),
- obj, 1).execute();
+ obj, moveIndex).execute();
}
}
@@ -173,17 +182,54 @@
protected void initSmooksParseStyle(
SmooksConfigurationFileGenerateContext context,
SmooksResourceListType resourceList) {
- // String type = context.getSmooksType();
- // if(type == null) return;
- // ResourceConfigType config =
- // SmooksFactory.eINSTANCE.createResourceConfigType();
- // config.setSelector(SmooksConstants.GLOBAL_PARAMETERS);
- // ParamType param = SmooksFactory.eINSTANCE.createParamType();
- // param.setName(SmooksConstants.STREAM_FILTER_TYPE);
- // SmooksModelUtils.appendTextToSmooksType(param, SmooksConstants.SAX);
- //
- // config.getParam().add(param);
-
- // resourceList.getAbstractResourceConfig().add(0,config);
+// String type = context.getSmooksType();
+// if (type == null)
+// return;
+// ResourceConfigType config = null;
+// if (resourceList.getAbstractResourceConfig().size() < 1) {
+// } else {
+// config = (ResourceConfigType) resourceList
+// .getAbstractResourceConfig().get(0);
+// String selector = config.getSelector();
+// if (!SmooksModelConstants.GLOBAL_PARAMETERS.equals(selector)) {
+// config = null;
+// } else {
+// if (config.getParam().isEmpty()) {
+// config = null;
+// } else {
+// ParamType param = config.getParam().get(0);
+// if (!SmooksModelConstants.STREAM_FILTER_TYPE.equals(param
+// .getName())) {
+// config = null;
+// }
+// }
+// }
+// }
+// ParamType param = null;
+// if (config == null) {
+// config = SmooksFactory.eINSTANCE.createResourceConfigType();
+// AddCommand.create(domain, resourceList,
SmooksPackage.eINSTANCE.getSmooksResourceListType_AbstractResourceConfig(),
config).execute();
+// MoveCommand.create(domain, resourceList,
SmooksPackage.eINSTANCE.getSmooksResourceListType_AbstractResourceConfig(), config, 0);
+// config.setSelector(SmooksModelConstants.GLOBAL_PARAMETERS);
+// param = SmooksFactory.eINSTANCE.createParamType();
+// param.setName(SmooksModelConstants.STREAM_FILTER_TYPE);
+// config.getParam().add(param);
+// }else{
+// List paramList = config.getParam();
+// for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+// ParamType p = (ParamType) iterator.next();
+// if(SmooksModelConstants.STREAM_FILTER_TYPE.equals(p.getName())){
+// param = p;
+// break;
+// }
+// }
+// if(param == null){
+// param = SmooksFactory.eINSTANCE.createParamType();
+// param.setName(SmooksModelConstants.STREAM_FILTER_TYPE);
+// config.getParam().add(param);
+// }
+// }
+// SmooksModelUtils.cleanTextToSmooksType(param);
+// SmooksModelUtils.appendTextToSmooksType(param, context.getSmooksType());
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -57,9 +57,11 @@
String gfileName = fileName + ".graph";
if (container != null) {
IFile gfile = container.getFile(new Path(gfileName));
- if(!gfile.exists()){
+ if (!gfile.exists()) {
try {
- gfile.create(new ByteArrayInputStream("".getBytes()), true, null);
+ gfile.create(
+ new ByteArrayInputStream("".getBytes()),
+ true, null);
} catch (CoreException e) {
e.printStackTrace();
}
@@ -72,17 +74,57 @@
}
}
+ public GraphicalInformationSaver(IFile file) {
+ IContainer container = file.getParent();
+ String fileName = file.getName();
+ if (fileName.endsWith(".smooks")) {
+ String gfileName = fileName + ".graph";
+ if (container != null) {
+ IFile gfile = container.getFile(new Path(gfileName));
+ if (!gfile.exists()) {
+ try {
+ gfile.create(new ByteArrayInputStream("".getBytes()),
+ true, null);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ String osString = gfile.getLocation().toOSString();
+ graphicalFileResource = new XMLResourceFactoryImpl()
+ .createResource(URI.createFileURI(osString));
+ }
+ }
+ }
+
public GraphInformations doLoad() throws IOException {
// throw new IOException("can't find the file");
if (graphicalFileResource != null) {
graphicalFileResource.load(Collections.EMPTY_MAP);
- GraphInformations graph = (GraphInformations) graphicalFileResource
- .getContents().get(0);
- return graph;
+ GraphInformations graph = (GraphInformations) graphicalFileResource
+ .getContents().get(0);
+ return graph;
}
return null;
}
+ public void doSave(IProgressMonitor monitor, String sourceid,
+ String targetid) throws IOException {
+ GraphInformations graph = null;
+ if (graphicalFileResource != null) {
+ if (graphicalFileResource.getContents().isEmpty()) {
+ graph = GraphicalFactory.eINSTANCE.createGraphInformations();
+ graphicalFileResource.getContents().add(graph);
+ } else {
+ graph = (GraphInformations) graphicalFileResource.getContents()
+ .get(0);
+ }
+ if (graph != null) {
+ initMappingTypes(graph, sourceid, targetid);
+ }
+ graphicalFileResource.save(Collections.EMPTY_MAP);
+ }
+ }
+
public void doSave(IProgressMonitor monitor,
SmooksConfigurationFileGenerateContext context) throws IOException,
CoreException {
@@ -101,7 +143,7 @@
initMappingTypes(graph, sourceID, targetID);
Params params = GraphicalFactory.eINSTANCE.createParams();
graph.setParams(params);
- initParams(params,context);
+ initParams(params, context);
}
graphicalFileResource.save(Collections.EMPTY_MAP);
}
@@ -111,8 +153,8 @@
private void initParams(Params params,
SmooksConfigurationFileGenerateContext context) {
Properties pros = context.getProperties();
- Enumeration<Object> keys = pros.keys();
- while(keys.hasMoreElements()){
+ Enumeration<Object> keys = pros.keys();
+ while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
Param param = GraphicalFactory.eINSTANCE.createParam();
param.setName(key);
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/DocumentSelectionWarrper.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/DocumentSelectionWarrper.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/DocumentSelectionWarrper.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -0,0 +1,24 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.ui;
+
+import org.jboss.tools.smooks.model.ResourceConfigType;
+
+/**
+ * @author dart
+ *
+ */
+public class DocumentSelectionWarrper extends ResourceConfigWarrper {
+
+ public DocumentSelectionWarrper() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public DocumentSelectionWarrper(ResourceConfigType type) {
+ super(type);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/DocumentSelectionWarrper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DocumentResourceTypeDetailPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DocumentResourceTypeDetailPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DocumentResourceTypeDetailPage.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -0,0 +1,131 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.ui.editors;
+
+import java.util.Collections;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.smooks.model.ResourceType;
+import org.jboss.tools.smooks.model.SmooksPackage;
+
+/**
+ * @author dart
+ *
+ */
+public class DocumentResourceTypeDetailPage extends AbstractSmooksModelDetailPage {
+
+ private Text text;
+ private Text selectorText;
+
+ public DocumentResourceTypeDetailPage(SmooksFormEditor parentEditor,
+ EditingDomain domain) {
+ super(parentEditor, domain);
+ }
+
+ protected void createSectionContents(Composite parent) {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ parent.setLayout(layout);
+ this.formToolKit.createLabel(parent, "Selector :");
+ selectorText = formToolKit.createText(parent, "");
+ selectorText.addModifyListener(new ModifyListener(){
+
+ public void modifyText(ModifyEvent e) {
+ if(!canFireChange) return;
+ resetSelector(selectorText.getText());
+ }
+
+ });
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ selectorText.setLayoutData(gd);
+
+ this.formToolKit.createLabel(parent, "Document Path:");
+ Composite fileCom = formToolKit.createComposite(parent);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileCom.setLayoutData(gd);
+ fileCom.setLayout(layout);
+ text = formToolKit.createText(fileCom, "");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.grabExcessHorizontalSpace = true;
+ text.setLayoutData(gd);
+ text.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e) {
+ if(!canFireChange) return;
+ resetPath(text.getText());
+ }
+ });
+
+
+ Button browseButton = formToolKit.createButton(fileCom, "Browse...",
SWT.NONE);
+ browseButton.addSelectionListener(new SelectionAdapter(){
+
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ browseFileSystem();
+ }
+
+ });
+ formToolKit.paintBordersFor(parent);
+ formToolKit.paintBordersFor(fileCom);
+ }
+
+ protected void resetSelector(String selector){
+ Command command = SetCommand.create(domain, resourceConfigList,
SmooksPackage.eINSTANCE.getResourceConfigType_Selector(), selector);
+ domain.getCommandStack().execute(command);
+// resourceConfigList.getse
+ }
+
+ protected void browseFileSystem(){
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(this.parentEditor.getSite()
+ .getShell(),
+ "", "", false, null, Collections.EMPTY_LIST);
+ // dialog.setInitialSelections(selectedResources);
+ if (files.length > 0) {
+ IFile file = files[0];
+ String s = file.getFullPath().toString();
+ text.setText(s);
+ return;
+ }
+ }
+
+ protected void resetPath(String path){
+ if(this.resourceConfigList != null){
+ ResourceType resource = resourceConfigList.getResource();
+ if(resource == null){
+ return;
+ }
+ Command command = SetCommand.create(domain, resource,
SmooksPackage.eINSTANCE.getResourceType_Value(), path);
+ domain.getCommandStack().execute(command);
+ }
+ }
+
+ protected void initSectionUI() {
+ if(this.resourceConfigList != null){
+ String selector = resourceConfigList.getSelector();
+ if(selector != null) selectorText.setText(selector);
+ ResourceType resource = resourceConfigList.getResource();
+ if(resource != null){
+ String path = resource.getValue();
+ if(path == null) path = "";
+ text.setText(path);
+ }
+ }
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/DocumentResourceTypeDetailPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResourceConfigWarrperFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResourceConfigWarrperFactory.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/ResourceConfigWarrperFactory.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -13,8 +13,10 @@
import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.ResourceType;
import org.jboss.tools.smooks.model.util.SmooksModelConstants;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
import org.jboss.tools.smooks.ui.BeanPopulatorWarrper;
import org.jboss.tools.smooks.ui.DateTypeWarrper;
+import org.jboss.tools.smooks.ui.DocumentSelectionWarrper;
import org.jboss.tools.smooks.ui.ResourceConfigWarrper;
@@ -35,6 +37,10 @@
DateTypeWarrper warrper = new DateTypeWarrper(type);
return warrper;
}
+ if(SmooksModelUtils.isFilePathResourceConfig(type)){
+ DocumentSelectionWarrper warrper = new DocumentSelectionWarrper(type);
+ return warrper;
+ }
return null;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksFormEditor.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -13,9 +13,9 @@
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.CommandStack;
@@ -117,9 +117,10 @@
}
}
- public void refreshNormalPage() {
+ public void refreshNormalPage(List resourceHidenConfigs) {
NormalSmooksModelPackage modelPackage = createSmooksModelPackage();
if (this.normalPage != null) {
+ modelPackage.setHidenSmooksElements(resourceHidenConfigs);
normalPage.setModelPackage(modelPackage);
}
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -21,18 +21,15 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.ConnectionLayer;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.IOWrappedException;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.KeyStroke;
@@ -107,17 +104,14 @@
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.analyzer.SmooksFileBuilder;
import org.jboss.tools.smooks.graphical.GraphInformations;
-import org.jboss.tools.smooks.graphical.GraphicalPackage;
import org.jboss.tools.smooks.graphical.MappingDataType;
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.graphical.Params;
import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
import org.jboss.tools.smooks.model.DocumentRoot;
-import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.SmooksFactory;
import org.jboss.tools.smooks.model.SmooksResourceListType;
import org.jboss.tools.smooks.model.util.SmooksModelConstants;
-import org.jboss.tools.smooks.model.util.SmooksResourceFactoryImpl;
import org.jboss.tools.smooks.ui.IStrucutredDataCreationWizard;
import org.jboss.tools.smooks.ui.IViewerInitor;
import org.jboss.tools.smooks.ui.StructuredDataCreationWizardDailog;
@@ -226,12 +220,12 @@
list = SmooksFactory.eINSTANCE.createSmooksResourceListType();
doc.setSmooksResourceList(list);
}
- callParentRefillNormalModelInfor();
+
}
- private void callParentRefillNormalModelInfor() {
+ private void callParentRefillNormalModelInfor(List hidenResourceConfigs) {
SmooksFormEditor editor = (SmooksFormEditor) getEditor();
- editor.refreshNormalPage();
+ editor.refreshNormalPage(hidenResourceConfigs);
}
// protected void notifyParentEditorTransformNormal
@@ -242,7 +236,9 @@
try {
this.initTransformViewerModel((IEditorSite) getSite(),
getEditorInput());
- cleanMappingResourceConfig();
+ if (mappingResourceConfigList != null)
+ callParentRefillNormalModelInfor(mappingResourceConfigList
+ .getRelationgResourceConfigList());
} catch (IOWrappedException ex) {
MessageDialog.openWarning(getSite().getShell(), "Waring",
"Exceptions occurd during parsing Smooks file, no worries");
@@ -663,6 +659,7 @@
Exception exp = null;
try {
// generate smooks configuration file
+ this.cleanMappingResourceConfig();
InputStream stream = builder.generateSmooksFile(context, monitor);
IFile file = ((IFileEditorInput) this.getEditorInput()).getFile();
if (file.exists()) {
@@ -906,6 +903,12 @@
if (dialog.open() == org.eclipse.jface.dialogs.Dialog.OK) {
sourceDataTypeID = wizard.getSourceDataTypeID();
targetDataTypeID = wizard.getTargetDataTypeID();
+ this.getSmooksConfigurationFileGenerateContext()
+ .setSourceDataTypeID(sourceDataTypeID);
+ this.getSmooksConfigurationFileGenerateContext()
+ .setTargetDataTypeID(targetDataTypeID);
+ graphicalInformationSaver.doSave(new NullProgressMonitor(),
+ getSmooksConfigurationFileGenerateContext());
}
}
smooksResource = this.getSmooksResource();
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -12,9 +12,12 @@
import java.util.List;
-import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.MoveCommand;
import org.eclipse.emf.edit.domain.EditingDomain;
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;
@@ -26,8 +29,12 @@
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.jboss.tools.smooks.analyzer.NormalSmooksModelPackage;
-import org.jboss.tools.smooks.model.DocumentRoot;
-import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.model.ParamType;
+import org.jboss.tools.smooks.model.ResourceConfigType;
+import org.jboss.tools.smooks.model.SmooksFactory;
+import org.jboss.tools.smooks.model.SmooksPackage;
+import org.jboss.tools.smooks.model.util.SmooksModelConstants;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
import org.jboss.tools.smooks.utils.UIUtils;
/**
@@ -39,28 +46,41 @@
protected SmooksResourceConfigFormBlock resourceBlock = null;
+ protected ResourceConfigType transformType = null;
+
+ private Button saxButton;
+
+ private Button domButton;
+
+ private Button saxdomButton;
+
+ private EditingDomain domain;
+
+ private List hidenResourceConfigs;
+
public SmooksNormalContentEditFormPage(FormEditor editor, String id,
String title, NormalSmooksModelPackage modelPacakge) {
super(editor, id, title);
+ domain = ((SmooksFormEditor) editor).getEditingDomain();
+ this.createResourceConfigFormBlock();
this.setModelPackage(modelPacakge);
- this.createResourceConfigFormBlock();
}
public SmooksNormalContentEditFormPage(String id, String title,
NormalSmooksModelPackage modelPacakge) {
super(id, title);
- this.setModelPackage(modelPackage);
this.createResourceConfigFormBlock();
+ this.setModelPackage(modelPacakge);
}
-
- protected void createResourceConfigFormBlock(){
+
+ protected void createResourceConfigFormBlock() {
resourceBlock = new SmooksResourceConfigFormBlock();
resourceBlock.setDomain(getEditingDomain());
- resourceBlock.setParentEditor((SmooksFormEditor)this.getEditor());
+ resourceBlock.setParentEditor((SmooksFormEditor) this.getEditor());
}
-
- protected EditingDomain getEditingDomain(){
- return ((SmooksFormEditor)getEditor()).getEditingDomain();
+
+ protected EditingDomain getEditingDomain() {
+ return ((SmooksFormEditor) getEditor()).getEditingDomain();
}
@Override
@@ -75,10 +95,59 @@
createSmooksTypeGUI(rootMainControl, tool);
form.getBody().setLayout(gridLayout);
form.pack();
+ this.initTransformTypeResourceConfig();
+ resourceBlock.initViewers(transformType);
+ }
+
+ private ResourceConfigType createTransformType() {
+ ResourceConfigType transformType = SmooksFactory.eINSTANCE
+ .createResourceConfigType();
+ AddCommand.create(
+ domain,
+ modelPackage.getSmooksResourceList(),
+ SmooksPackage.eINSTANCE
+ .getSmooksResourceListType_AbstractResourceConfig(),
+ transformType).execute();
+ MoveCommand.create(domain, modelPackage.getSmooksResourceList(),
+ SmooksPackage.eINSTANCE
+ .getSmooksResourceListType_AbstractResourceConfig(),
+ transformType, 0);
+ transformType.setSelector(SmooksModelConstants.GLOBAL_PARAMETERS);
+ ParamType typeParam = SmooksFactory.eINSTANCE.createParamType();
+ typeParam.setName(SmooksModelConstants.STREAM_FILTER_TYPE);
+ transformType.getParam().add(typeParam);
- resourceBlock.initViewers();
+ return transformType;
}
+ protected void initTransformTypeResourceConfig() {
+ if (this.getModelPackage() != null) {
+ List list = modelPackage.getSmooksResourceList()
+ .getAbstractResourceConfig();
+ if (list != null && !list.isEmpty()) {
+ ResourceConfigType first = (ResourceConfigType) list.get(0);
+ if (SmooksModelUtils.isTransformTypeResourceConfig(first)) {
+ this.transformType = first;
+ }
+ }
+ if (transformType == null) {
+ transformType = createTransformType();
+ }
+ if (transformType != null) {
+ String type = SmooksModelUtils.getTransformType(transformType);
+ if (SmooksModelConstants.SAX.equals(type)) {
+ saxButton.setSelection(true);
+ }
+ if (SmooksModelConstants.DOM.equals(type)) {
+ domButton.setSelection(true);
+ }
+ if ("SAX/DOM".equals(type)) {
+ saxdomButton.setSelection(true);
+ }
+ }
+ }
+ }
+
protected void createSmooksTypeGUI(Composite mainComposite, FormToolkit tool) {
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
Section section = tool.createSection(mainComposite, Section.TITLE_BAR
@@ -97,13 +166,48 @@
layout.numColumns = 3;
typeSelectComposite.setLayout(layout);
- createTypeSelectRadioButton(typeSelectComposite, tool, "SAX")
- .setSelection(true);
- createTypeSelectRadioButton(typeSelectComposite, tool, "DOM");
- createTypeSelectRadioButton(typeSelectComposite, tool, "SAX/DOM");
+ saxButton = createTypeSelectRadioButton(typeSelectComposite, tool,
+ SmooksModelConstants.SAX);
+ domButton = createTypeSelectRadioButton(typeSelectComposite, tool,
+ SmooksModelConstants.DOM);
+ saxdomButton = createTypeSelectRadioButton(typeSelectComposite, tool,
+ SmooksModelConstants.SAX_DOM);
+ hookButtons();
+ }
+ private void setTransformType(String type) {
+ if (this.transformType != null) {
+ SmooksModelUtils.setTransformType(transformType, type);
+ ((SmooksFormEditor)getEditor()).fireEditorDirty(true);
+ }
}
+ protected void hookButtons() {
+ saxButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ setTransformType(SmooksModelConstants.SAX);
+ }
+
+ });
+
+ domButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ setTransformType(SmooksModelConstants.DOM);
+ }
+
+ });
+
+ saxdomButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ setTransformType(SmooksModelConstants.SAX_DOM);
+ }
+
+ });
+ }
+
private Button createTypeSelectRadioButton(Composite parent,
FormToolkit tool, String labelName) {
Button button = tool.createButton(parent, labelName, SWT.RADIO);
@@ -125,7 +229,7 @@
if (modelPackage == this.modelPackage)
return;
this.modelPackage = modelPackage;
- this.resourceBlock.setModelPackage(this.modelPackage);
+ if (resourceBlock != null)
+ this.resourceBlock.setModelPackage(this.modelPackage);
}
-
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksResourceConfigFormBlock.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksResourceConfigFormBlock.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksResourceConfigFormBlock.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -12,7 +12,6 @@
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
@@ -27,6 +26,8 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -46,8 +47,10 @@
import org.jboss.tools.smooks.analyzer.NormalSmooksModelPackage;
import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.SmooksPackage;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
import org.jboss.tools.smooks.ui.BeanPopulatorWarrper;
import org.jboss.tools.smooks.ui.DateTypeWarrper;
+import org.jboss.tools.smooks.ui.DocumentSelectionWarrper;
import org.jboss.tools.smooks.ui.ResourceConfigWarrper;
import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
import org.jboss.tools.smooks.ui.wizards.NewResourceConfigFactory;
@@ -61,14 +64,16 @@
public class SmooksResourceConfigFormBlock extends MasterDetailsBlock implements
ISelectionChangedListener {
- TreeViewer dateTypeViewer;
+ protected TreeViewer dateTypeViewer;
- NormalSmooksModelPackage modelPackage = null;
+ protected NormalSmooksModelPackage modelPackage = null;
- SmooksFormEditor parentEditor;
+ protected ResourceConfigType transformType = null;
- IManagedForm managedForm;
+ protected SmooksFormEditor parentEditor;
+ protected IManagedForm managedForm;
+
protected EditingDomain domain;
private SectionPart sectionPart;
@@ -136,6 +141,10 @@
new BeanPopulatorDetailPage(getParentEditor(), getDomain()));
detailsPart.registerPage(DateTypeWarrper.class, new DateTypeDetailPage(
getParentEditor(), getDomain()));
+
+ detailsPart.registerPage(DocumentSelectionWarrper.class,
+ new DocumentResourceTypeDetailPage(getParentEditor(),
+ getDomain()));
}
protected void configDateTypeViewer() {
@@ -154,30 +163,48 @@
}
if (NormalSmooksModelBuilder
.isDateConfig((ResourceConfigType) element)) {
- return "Date Type : ";
+ return "Date Type";
}
- String s =((ResourceConfigType)element).getSelector();
- if(s == null) s= "<NULL>";
+ if (SmooksModelUtils
+ .isFilePathResourceConfig((ResourceConfigType) element)) {
+ String selector = ((ResourceConfigType) element)
+ .getSelector();
+ if (selector == null)
+ selector = "<NULL>";
+ return "Template File :" + selector;
+ }
+ String s = ((ResourceConfigType) element).getSelector();
+ if (s == null)
+ s = "<NULL>";
return "UnKnown ResourceConfig - " + s;
}
return super.getText(element);
}
});
+ // don't display the first ResourceConfig element;because it will be
+ // "show" with Smooks TransformData Type GUI
+ dateTypeViewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ if (element == transformType)
+ return false;
+ if(modelPackage != null){
+ List hidenList = modelPackage.getHidenSmooksElements();
+ for (Iterator iterator = hidenList.iterator(); iterator
+ .hasNext();) {
+ Object object = (Object) iterator.next();
+ if(object == element) return false;
+ }
+ }
+ return true;
+ }
+ } });
}
- public void initViewers() {
+ public void initViewers(ResourceConfigType transformType) {
+ this.transformType = transformType;
if (this.getModelPackage() != null) {
- List all = new Vector();
- List list = modelPackage.getBeanPopulatorResourceConfigList();
- if (list != null) {
- all.addAll(list);
- }
- List dl = modelPackage.getDateResourceConfigList();
- if (dl != null) {
- all.addAll(dl);
- }
-
dateTypeViewer.setInput(modelPackage.getSmooksResourceList()
.getAbstractResourceConfig());
}
@@ -275,7 +302,8 @@
.getSelection();
Object object = selection.getFirstElement();
int index = ((List) dateTypeViewer.getInput()).indexOf(object);
- if (index >=
modelPackage.getSmooksResourceList().getAbstractResourceConfig().size()) {
+ if (index >= modelPackage.getSmooksResourceList()
+ .getAbstractResourceConfig().size()) {
return;
}
index++;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizard.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -46,8 +46,8 @@
*/
@Override
public boolean performFinish() {
- String sid = page.getSourceDataTypeID();
- String tid = page.getTargetDataTypeID();
+ String sid = page.getSourceID();
+ String tid = page.getTargetID();
if(sid == null || tid == null) return false;
this.sourceDataTypeID = sid;
this.targetDataTypeID = tid;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -13,7 +13,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.CheckStateChangedEvent;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.ICheckStateListener;
@@ -41,12 +40,29 @@
protected CheckboxTableViewer source;
protected CheckboxTableViewer target;
+ private List sourceList;
+ private String sourceID = null;
+ private String targetID = null;
+
+
+
- public TypeIDSelectionWizardPage(String pageName, String title,
- ImageDescriptor titleImage) {
- super(pageName, title, titleImage);
+ public String getSourceID() {
+ return sourceID;
}
+ public void setSourceID(String sourceID) {
+ this.sourceID = sourceID;
+ }
+
+ public String getTargetID() {
+ return targetID;
+ }
+
+ public void setTargetID(String targetID) {
+ this.targetID = targetID;
+ }
+
public TypeIDSelectionWizardPage(String pageName) {
super(pageName);
}
@@ -62,10 +78,8 @@
gl.numColumns = 2;
gl.makeColumnsEqualWidth = true;
mainComposite.setLayout(gl);
- List<DataTypeID> sourceList = AnalyzerFactory.getInstance()
+ sourceList = AnalyzerFactory.getInstance()
.getRegistrySourceIDList();
- List<DataTypeID> targetList = AnalyzerFactory.getInstance()
- .getRegistryTargetIDList();
Label sl = new Label(mainComposite, SWT.NONE);
sl.setText("Source Data Type ID List : ");
@@ -79,20 +93,12 @@
target.getTable().setLayoutData(gd);
source.setInput(sourceList);
- target.setInput(targetList);
+ target.setInput(sourceList);
initViewer();
this.setControl(mainComposite);
}
- public String getSourceDataTypeID() {
- return getDataTypeID(source);
- }
-
- public String getTargetDataTypeID() {
- return getDataTypeID(target);
- }
-
protected String getDataTypeID(CheckboxTableViewer viewer) {
Object[] objs = viewer.getCheckedElements();
if (objs == null)
@@ -146,15 +152,23 @@
viewer.setChecked(event.getElement(), true);
fireEvent = true;
}
+
+ if(viewer == source){
+ setSourceID(getDataTypeID(source));
+ }
+
+ if(viewer == target){
+ setTargetID(getDataTypeID(target));
+ }
}
});
TableColumn nameColumn = new TableColumn(viewer.getTable(), SWT.NONE);
nameColumn.setWidth(100);
nameColumn.setText("Name");
- TableColumn idColumn = new TableColumn(viewer.getTable(), SWT.NONE);
- idColumn.setWidth(100);
- idColumn.setText("ID");
+// TableColumn idColumn = new TableColumn(viewer.getTable(), SWT.NONE);
+// idColumn.setWidth(100);
+// idColumn.setText("ID");
viewer.setContentProvider(new TypeIDContentProvider());
viewer.setLabelProvider(new TypeIDLabelProvider());
return viewer;
@@ -191,8 +205,8 @@
switch (columnIndex) {
case 0:
return ((DataTypeID) element).getName();
- case 1:
- return ((DataTypeID) element).getId();
+// case 1:
+// return ((DataTypeID) element).getId();
}
}
return "";
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/NewResourceConfigFactory.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -21,15 +21,16 @@
* Date : Sep 18, 2008
*/
public class NewResourceConfigFactory implements INewResourceConfigFactory {
-
+
private static NewResourceConfigFactory instance = null;
- private NewResourceConfigFactory(){
-
+ private NewResourceConfigFactory() {
+
}
-
+
public static synchronized NewResourceConfigFactory getInstance() {
- if(instance == null) instance = new NewResourceConfigFactory();
+ if (instance == null)
+ instance = new NewResourceConfigFactory();
return instance;
}
@@ -81,6 +82,18 @@
return config;
}
+
+ if (SmooksModelConstants.AT_DOCUMENT.equals(key.getId())) {
+ ResourceConfigType config = SmooksFactory.eINSTANCE
+ .createResourceConfigType();
+// config.setSelector(SmooksModelConstants.AT_DOCUMENT);
+ ResourceType resource = SmooksFactory.eINSTANCE
+ .createResourceType();
+ resource.setValue("/");
+ config.setResource(resource);
+
+ return config;
+ }
return null;
}
@@ -92,7 +105,11 @@
NewResourceConfigKey date = new NewResourceConfigKey();
date.setId(SmooksModelConstants.DATE_DECODER);
date.setName("Date Decoder");
- return new NewResourceConfigKey[] { bean, date };
+
+ NewResourceConfigKey documentFile = new NewResourceConfigKey();
+ documentFile.setId(SmooksModelConstants.AT_DOCUMENT);
+ documentFile.setName("Document");
+ return new NewResourceConfigKey[] { bean, date ,documentFile };
}
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -0,0 +1,160 @@
+package org.jboss.tools.smooks.ui.wizards;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.core.runtime.*;
+import org.eclipse.jface.operation.*;
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import java.io.*;
+import org.eclipse.ui.*;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
+import org.jboss.tools.smooks.ui.editors.TypeIDSelectionWizardPage;
+import org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext;
+
+/**
+ * This is a sample new wizard. Its role is to create a new file resource in the
+ * provided container. If the container resource (a folder or a project) is
+ * selected in the workspace when the wizard is opened, it will accept it as the
+ * target container. The wizard creates one file with the extension "smooks".
If
+ * a sample multi-page editor (also available as a template) is registered for
+ * the same extension, it will be able to open it.
+ */
+
+public class SmooksConfigFileNewWizard extends Wizard implements INewWizard {
+ private SmooksConfigFileNewWizardPage page;
+ private ISelection selection;
+ private TypeIDSelectionWizardPage typeIDPage;
+
+ /**
+ * Constructor for SmooksConfigFileNewWizard.
+ */
+ public SmooksConfigFileNewWizard() {
+ super();
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Adding the page to the wizard.
+ */
+
+ public void addPages() {
+ page = new SmooksConfigFileNewWizardPage(selection);
+ addPage(page);
+ typeIDPage = new TypeIDSelectionWizardPage("");
+ addPage(typeIDPage);
+ }
+
+ /**
+ * This method is called when 'Finish' button is pressed in the wizard. We
+ * will create an operation and run it using wizard as execution context.
+ */
+ public boolean performFinish() {
+ final String containerName = page.getContainerName();
+ final String fileName = page.getFileName();
+ IRunnableWithProgress op = new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException {
+ try {
+ doFinish(containerName, fileName, monitor);
+ } catch (CoreException e) {
+ throw new InvocationTargetException(e);
+ } finally {
+ monitor.done();
+ }
+ }
+ };
+ try {
+ getContainer().run(true, false, op);
+ } catch (InterruptedException e) {
+ return false;
+ } catch (InvocationTargetException e) {
+ Throwable realException = e.getTargetException();
+ MessageDialog.openError(getShell(), "Error", realException
+ .getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * The worker method. It will find the container, create the file if missing
+ * or just replace its contents, and open the editor on the newly created
+ * file.
+ */
+
+ private void doFinish(String containerName, String fileName,
+ IProgressMonitor monitor) throws CoreException {
+ // create a sample file
+ monitor.beginTask("Creating " + fileName, 2);
+ String sourceTypeID = typeIDPage.getSourceID();
+ String targetTypeID = typeIDPage.getTargetID();
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource = root.findMember(new Path(containerName));
+ if (!resource.exists() || !(resource instanceof IContainer)) {
+ throwCoreException("Container \"" + containerName
+ + "\" does not exist.");
+ }
+ IContainer container = (IContainer) resource;
+ final IFile file = container.getFile(new Path(fileName));
+ try {
+ InputStream stream = openContentStream();
+ if (file.exists()) {
+ file.setContents(stream, true, true, monitor);
+ } else {
+ file.create(stream, true, monitor);
+ }
+ stream.close();
+ GraphicalInformationSaver ginforSave = new GraphicalInformationSaver(
+ file);
+ ginforSave.doSave(monitor, sourceTypeID, targetTypeID);
+ } catch (IOException e) {
+ }
+ monitor.worked(1);
+ monitor.setTaskName("Opening file for editing...");
+ getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ try {
+ IDE.openEditor(page, file, true);
+ } catch (PartInitException e) {
+ }
+ }
+ });
+ monitor.worked(1);
+ }
+
+ /**
+ * We will initialize file contents with a sample text.
+ */
+
+ private InputStream openContentStream() {
+ String contents = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"+
+ " <smooks-resource-list
xmlns=\"http://www.milyn.org/xsd/smooks-1.0.xsd\"/>";
+ return new ByteArrayInputStream(contents.getBytes());
+ }
+
+ private void throwCoreException(String message) throws CoreException {
+ IStatus status = new Status(IStatus.ERROR, "org.jboss.tools.smooks.ui",
+ IStatus.OK, message, null);
+ throw new CoreException(status);
+ }
+
+ /**
+ * We will accept the selection in the workbench to see if we can initialize
+ * from it.
+ *
+ * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.selection = selection;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -0,0 +1,186 @@
+package org.jboss.tools.smooks.ui.wizards;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+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;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.ContainerSelectionDialog;
+
+/**
+ * The "New" wizard page allows setting the container for the new file as well
+ * as the file name. The page will only accept file name without the extension
+ * OR with the extension that matches the expected one (smooks).
+ */
+
+public class SmooksConfigFileNewWizardPage extends WizardPage {
+ private Text containerText;
+
+ private Text fileText;
+
+ private ISelection selection;
+
+ /**
+ * Constructor for SampleNewWizardPage.
+ *
+ * @param pageName
+ */
+ public SmooksConfigFileNewWizardPage(ISelection selection) {
+ super("wizardPage");
+ setTitle("Smooks Configuration File");
+ setDescription("This wizard creates a new smooks configuration file with *.smooks
extension that can be opened by a Smooks editor.");
+ this.selection = selection;
+ }
+
+ /**
+ * @see IDialogPage#createControl(Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ container.setLayout(layout);
+ layout.numColumns = 3;
+ layout.verticalSpacing = 9;
+ Label label = new Label(container, SWT.NULL);
+ label.setText("&Container:");
+
+ containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ containerText.setLayoutData(gd);
+ containerText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+
+ Button button = new Button(container, SWT.PUSH);
+ button.setText("Browse...");
+ button.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ handleBrowse();
+ }
+ });
+ label = new Label(container, SWT.NULL);
+ label.setText("&File name:");
+
+ fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ fileText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ dialogChanged();
+ }
+ });
+ initialize();
+ dialogChanged();
+ setControl(container);
+ }
+
+ /**
+ * Tests if the current workbench selection is a suitable container to use.
+ */
+
+ private void initialize() {
+ if (selection != null && selection.isEmpty() == false
+ && selection instanceof IStructuredSelection) {
+ IStructuredSelection ssel = (IStructuredSelection) selection;
+ if (ssel.size() > 1)
+ return;
+ Object obj = ssel.getFirstElement();
+ if (obj instanceof IResource) {
+ IContainer container;
+ if (obj instanceof IContainer)
+ container = (IContainer) obj;
+ else
+ container = ((IResource) obj).getParent();
+ containerText.setText(container.getFullPath().toString());
+ }
+ }
+ fileText.setText("SmooksConfigurationFile.smooks");
+ }
+
+
+ /**
+ * Uses the standard container selection dialog to choose the new value for
+ * the container field.
+ */
+
+ private void handleBrowse() {
+ ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+ getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+ "Select new file container");
+ if (dialog.open() == ContainerSelectionDialog.OK) {
+ Object[] result = dialog.getResult();
+ if (result.length == 1) {
+ containerText.setText(((Path) result[0]).toString());
+ }
+ }
+ }
+
+ /**
+ * Ensures that both text fields are set.
+ */
+
+ private void dialogChanged() {
+ IResource container = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(new Path(getContainerName()));
+ String fileName = getFileName();
+
+ if (getContainerName().length() == 0) {
+ updateStatus("File container must be specified");
+ return;
+ }
+ if (container == null
+ || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
+ updateStatus("File container must exist");
+ return;
+ }
+ if (!container.isAccessible()) {
+ updateStatus("Project must be writable");
+ return;
+ }
+ if (fileName.length() == 0) {
+ updateStatus("File name must be specified");
+ return;
+ }
+ if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
+ updateStatus("File name must be valid");
+ return;
+ }
+ int dotLoc = fileName.lastIndexOf('.');
+ if (dotLoc != -1) {
+ String ext = fileName.substring(dotLoc + 1);
+ if (ext.equalsIgnoreCase("smooks") == false) {
+ updateStatus("File extension must be \"smooks\"");
+ return;
+ }
+ }
+ updateStatus(null);
+ }
+
+ private void updateStatus(String message) {
+ setErrorMessage(message);
+ setPageComplete(message == null);
+ }
+
+ public String getContainerName() {
+ return containerText.getText();
+ }
+
+ public String getFileName() {
+ return fileText.getText();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2008-09-27
00:58:13 UTC (rev 10524)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2008-09-28
08:01:34 UTC (rev 10525)
@@ -4,7 +4,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
-import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardPage;
@@ -14,7 +14,6 @@
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;