JBoss Tools SVN: r14070 - branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-03-06 02:47:33 -0500 (Fri, 06 Mar 2009)
New Revision: 14070
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3934
Modified: branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java
===================================================================
--- branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2009-03-06 07:42:49 UTC (rev 14069)
+++ branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2009-03-06 07:47:33 UTC (rev 14070)
@@ -625,7 +625,7 @@
PagesDiagramEditPart diagram = (PagesDiagramEditPart) getScrollingGraphicalViewer()
.getRootEditPart().getChildren().get(0);
FreeformViewport vp = diagram.getFreeformViewport();
- if (vp != null && part instanceof PagesEditPart) {
+ if (vp != null && part instanceof PagesEditPart && part != diagram) {
PagesEditPart pagesPart = (PagesEditPart) part;
NodeFigure fig = (NodeFigure)pagesPart.getFigure();
if (fig.getLocation().x == 0 && fig.getLocation().y == 0) {
15 years, 8 months
JBoss Tools SVN: r14069 - trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2009-03-06 02:42:49 -0500 (Fri, 06 Mar 2009)
New Revision: 14069
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3934
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2009-03-06 06:42:12 UTC (rev 14068)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/PagesEditor.java 2009-03-06 07:42:49 UTC (rev 14069)
@@ -625,7 +625,7 @@
PagesDiagramEditPart diagram = (PagesDiagramEditPart) getScrollingGraphicalViewer()
.getRootEditPart().getChildren().get(0);
FreeformViewport vp = diagram.getFreeformViewport();
- if (vp != null && part instanceof PagesEditPart) {
+ if (vp != null && part instanceof PagesEditPart && part != diagram) {
PagesEditPart pagesPart = (PagesEditPart) part;
NodeFigure fig = (NodeFigure)pagesPart.getFigure();
if (fig.getLocation().x == 0 && fig.getLocation().y == 0) {
15 years, 8 months
JBoss Tools SVN: r14068 - trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-03-06 01:42:12 -0500 (Fri, 06 Mar 2009)
New Revision: 14068
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java
Log:
JBIDE-3945
Fix it
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java 2009-03-06 06:18:02 UTC (rev 14067)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelConstants.java 2009-03-06 06:42:12 UTC (rev 14068)
@@ -19,7 +19,6 @@
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[] DECODER_CLASSES = new String[] {
@@ -34,11 +33,11 @@
public static final String BEAN_ID = "beanId";
- public static final String FORMATE = "formate";
+ public static final String FORMATE = "format";
public static final String LOCALE_LANGUAGE = "Locale-Language";
- public static final String LOCALE_CONTRY = "Locale-Contry";
+ public static final String LOCALE_CONTRY = "Locale-Country";
public static final String BEAN_CLASS = "beanClass";
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java 2009-03-06 06:18:02 UTC (rev 14067)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/model/util/SmooksModelUtils.java 2009-03-06 06:42:12 UTC (rev 14068)
@@ -31,11 +31,11 @@
*/
public class SmooksModelUtils {
-
+
public static final String TYPE_XSL = "xsl";
-
- public static final String[] TEMPLATE_TYPES = new String[] { "xsl","ftl" };
-
+
+ public static final String[] TEMPLATE_TYPES = new String[] { "xsl", "ftl" };
+
public static final String BEAN_CLASS = "beanClass";
public static final String BEAN_ID = "beanId";
@@ -78,44 +78,52 @@
}
return Collections.EMPTY_LIST;
}
-
+
public static boolean isBeanPopulatorResource(ResourceConfigType type) {
ResourceType resource = type.getResource();
if (resource == null)
return false;
String value = resource.getStringValue();
- if(value != null) value = value.trim();
+ if (value != null)
+ value = value.trim();
if (SmooksModelConstants.BEAN_POPULATOR.equals(value)) {
return true;
}
return false;
}
-
- public static void setPropertyValueToAnyType(Object value,EStructuralFeature attribute,AnyType anyType){
+
+ public static void setPropertyValueToAnyType(Object value,
+ EStructuralFeature attribute, AnyType anyType) {
anyType.getAnyAttribute().set(attribute, value);
}
-
- public static AnyType getBindingViaProperty(ResourceConfigType resourceConfig , String property){
+
+ public static AnyType getBindingViaProperty(
+ ResourceConfigType resourceConfig, String property) {
List bindingList = getBindingListFromResourceConfigType(resourceConfig);
for (Iterator iterator = bindingList.iterator(); iterator.hasNext();) {
AnyType binding = (AnyType) iterator.next();
- String pro = getAttributeValueFromAnyType(binding, ATTRIBUTE_PROPERTY);
- if(pro != null) pro = pro.trim();
- if(property.equals(pro)){
+ String pro = getAttributeValueFromAnyType(binding,
+ ATTRIBUTE_PROPERTY);
+ if (pro != null)
+ pro = pro.trim();
+ if (property.equals(pro)) {
return binding;
}
}
return null;
}
-
- public static boolean isInnerFileContents(ResourceConfigType resourceConfig){
+
+ public static boolean isInnerFileContents(ResourceConfigType resourceConfig) {
ResourceType resource = resourceConfig.getResource();
- if(resource == null) return false;
+ if (resource == null)
+ return false;
String type = resource.getType();
- if(type != null) type = type.trim();
+ if (type != null)
+ type = type.trim();
for (int i = 0; i < TEMPLATE_TYPES.length; i++) {
String type1 = TEMPLATE_TYPES[i];
- if(type1.equalsIgnoreCase(type)) return true;
+ if (type1.equalsIgnoreCase(type))
+ return true;
}
return false;
}
@@ -125,10 +133,11 @@
if (resource == null)
return false;
String value = resource.getStringValue();
- if(value != null) value = value.trim();
+ if (value != null)
+ value = value.trim();
for (int i = 0; i < SmooksModelConstants.DECODER_CLASSES.length; i++) {
String decoderClass = SmooksModelConstants.DECODER_CLASSES[i];
- if(decoderClass.equals(value)){
+ if (decoderClass.equals(value)) {
return true;
}
}
@@ -224,16 +233,20 @@
ParamType param = null;
for (Iterator<ParamType> iterator = list.iterator(); iterator.hasNext();) {
ParamType paramType = (ParamType) iterator.next();
- if (paramType.getName().equalsIgnoreCase(paramName)) {
+ String n = paramType.getName();
+ if (n == null)
+ continue;
+ n = n.trim();
+ if (n.equalsIgnoreCase(paramName)) {
param = paramType;
break;
}
}
if (param == null) {
param = SmooksFactory.eINSTANCE.createParamType();
+ param.setName(paramName);
resourceConfigType.getParam().add(param);
}
- param.setName(paramName);
setTextToAnyType(param, value);
}
@@ -242,7 +255,11 @@
List plist = resourceConfigType.getParam();
for (Iterator iterator = plist.iterator(); iterator.hasNext();) {
ParamType p = (ParamType) iterator.next();
- if (paramName.equalsIgnoreCase(p.getName())) {
+ String n = p.getName();
+ if (n == null)
+ continue;
+ n = n.trim();
+ if (paramName.equalsIgnoreCase(n)) {
return getAnyTypeText(p);
}
}
15 years, 8 months
JBoss Tools SVN: r14067 - trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-03-06 01:18:02 -0500 (Fri, 06 Mar 2009)
New Revision: 14067
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java
Log:
JBIDE-3949
Remove the "SAX/DOM" button
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 2009-03-06 06:05:55 UTC (rev 14066)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java 2009-03-06 06:18:02 UTC (rev 14067)
@@ -85,8 +85,6 @@
private Button domButton;
- private Button saxdomButton;
-
private EditingDomain domain;
private List hidenResourceConfigs;
@@ -198,8 +196,6 @@
saxButton.setSelection(false);
if (domButton != null)
domButton.setSelection(false);
- if (saxdomButton != null)
- saxdomButton.setSelection(false);
if (this.getModelPackage() != null) {
List list = modelPackage.getSmooksResourceList()
.getAbstractResourceConfig();
@@ -229,10 +225,6 @@
if (domButton != null)
domButton.setSelection(true);
}
- if ("SAX/DOM".equals(type)) { //$NON-NLS-1$
- if (saxdomButton != null)
- saxdomButton.setSelection(true);
- }
}
}
}
@@ -270,9 +262,6 @@
SmooksModelConstants.SAX);
domButton = createTypeSelectRadioButton(buttonComposite, tool,
SmooksModelConstants.DOM);
- saxdomButton = createTypeSelectRadioButton(buttonComposite, tool,
- SmooksModelConstants.SAX_DOM);
-
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
// tool.createSeparator(otherConfigurationComposite, SWT.HORIZONTAL)
@@ -419,14 +408,6 @@
}
});
- saxdomButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent e) {
- setTransformType(SmooksModelConstants.SAX_DOM);
- }
-
- });
-
addFileButton.addSelectionListener(new SelectionAdapter() {
@Override
15 years, 8 months
JBoss Tools SVN: r14066 - trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-03-06 01:05:55 -0500 (Fri, 06 Mar 2009)
New Revision: 14066
Modified:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java
Log:
JBIDE-3928 - NPE
Modified: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java 2009-03-06 06:05:36 UTC (rev 14065)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java 2009-03-06 06:05:55 UTC (rev 14066)
@@ -59,10 +59,12 @@
public IStatus validate(String propertyName) {
if (PROJECT_NAME.equals(propertyName)) {
String projectName = (String) model.getProperty(PROJECT_NAME);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if( project != null ) {
- if(JBossESBProjectUtil.isESBProject(project))
- return Status.OK_STATUS;
+ if( projectName != null ) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if( project != null ) {
+ if(JBossESBProjectUtil.isESBProject(project))
+ return Status.OK_STATUS;
+ }
}
return new Status(IStatus.ERROR, ESBProjectPlugin.PLUGIN_ID,
NLS.bind(JBossESBUIMessages.ESBExportWizard_NotValidProject, projectName));
15 years, 8 months
JBoss Tools SVN: r14065 - branches/jbosstools-3.0.x/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2009-03-06 01:05:36 -0500 (Fri, 06 Mar 2009)
New Revision: 14065
Modified:
branches/jbosstools-3.0.x/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java
Log:
JBIDE-3928 - NPE
Modified: branches/jbosstools-3.0.x/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java
===================================================================
--- branches/jbosstools-3.0.x/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java 2009-03-06 03:25:26 UTC (rev 14064)
+++ branches/jbosstools-3.0.x/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/export/ESBComponentExportDataModelProvider.java 2009-03-06 06:05:36 UTC (rev 14065)
@@ -59,10 +59,12 @@
public IStatus validate(String propertyName) {
if (PROJECT_NAME.equals(propertyName)) {
String projectName = (String) model.getProperty(PROJECT_NAME);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if( project != null ) {
- if(JBossESBProjectUtil.isESBProject(project))
- return Status.OK_STATUS;
+ if( projectName != null ) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if( project != null ) {
+ if(JBossESBProjectUtil.isESBProject(project))
+ return Status.OK_STATUS;
+ }
}
return new Status(IStatus.ERROR, ESBProjectPlugin.PLUGIN_ID,
NLS.bind(JBossESBUIMessages.ESBExportWizard_NotValidProject, projectName));
15 years, 8 months
JBoss Tools SVN: r14064 - in trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks: javabean/commandprocessor and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2009-03-05 22:25:26 -0500 (Thu, 05 Mar 2009)
New Revision: 14064
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/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/AbstractJavaBeanBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/JavaBeanModelAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.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/modelparser/SmooksConfigurationFileGenerateContext.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/popup/SmooksAction.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java
Log:
JBIDE-3855
Add new feature to load Array Pojo,Collection Pojo from .graph file
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 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -14,6 +14,8 @@
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
import java.util.Properties;
import org.eclipse.core.resources.IContainer;
@@ -131,8 +133,12 @@
}
if (graph != null) {
initMappingTypes(graph, sourceid, targetid);
- Params params = GraphicalFactory.eINSTANCE.createParams();
- graph.setParams(params);
+
+ Params params = graph.getParams();
+ if(params == null){
+ params = GraphicalFactory.eINSTANCE.createParams();
+ graph.setParams(params);
+ }
initParams(params, properties);
}
graphicalFileResource.save(Collections.EMPTY_MAP);
@@ -156,10 +162,22 @@
Enumeration<Object> keys = properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
- Param param = GraphicalFactory.eINSTANCE.createParam();
- param.setName(key);
+ List list = params.getParam();
+ Param param = null;
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ Param para = (Param) iterator.next();
+ if(para.getName().equals(key)){
+ param = para;
+ break;
+ }
+ }
+ if(param == null){
+ param = GraphicalFactory.eINSTANCE.createParam();
+ params.getParam().add(param);
+ param.setName(key);
+ }
param.setValue(properties.getProperty(key));
- params.getParam().add(param);
+
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/commandprocessor/JavaBeanModelCommandProcessor.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -15,7 +15,6 @@
import java.util.List;
import org.eclipse.emf.common.command.Command;
-import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.EditDomain;
import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.commands.CompoundCommand;
@@ -117,14 +116,25 @@
return false;
}
}
-
- if(source instanceof IXMLStructuredObject && t instanceof JavaBeanModel && !(source instanceof JavaBeanModel)){
- boolean isattribute = ((IXMLStructuredObject)source).isAttribute();
+
+ if (source instanceof IXMLStructuredObject
+ && t instanceof JavaBeanModel
+ && !(source instanceof JavaBeanModel)) {
+ boolean isattribute = ((IXMLStructuredObject) source).isAttribute();
JavaBeanModel targetModel = (JavaBeanModel) t;
boolean isprimitive = targetModel.isPrimitive();
- if(isattribute && !isprimitive) return false;
+ if (isattribute && !isprimitive)
+ return false;
+ boolean canlink = hasBeanCreationParentLink(targetGraphModel,
+ context);
+ if (isprimitive) {
+ if (!canlink){
+ linkBeanCreateionParentLink(sourceGraphModel,
+ targetGraphModel, context);
+ }
+ }
}
-
+
if (source instanceof JavaBeanModel && t instanceof JavaBeanModel
&& sourceGraphModel instanceof SourceModel) {
@@ -136,6 +146,16 @@
return false;
}
+ boolean canlink = hasBeanCreationParentLink(targetGraphModel,
+ context);
+
+ if (tis) {
+ if (!canlink) {
+ linkBeanCreateionParentLink(sourceGraphModel,
+ targetGraphModel, context);
+ }
+ }
+
Class sourceClass = sourceModel.getBeanClass();
Class targetClass = targetModel.getBeanClass();
boolean isCompositeSource = sourceClass.isArray()
@@ -148,6 +168,74 @@
return true;
}
+ private void linkBeanCreateionParentLink(
+ AbstractStructuredDataModel sourceGraphModel,
+ AbstractStructuredDataModel targetGraphModel,
+ SmooksConfigurationFileGenerateContext context) {
+ Object obj = sourceGraphModel.getReferenceEntityModel();
+ AbstractStructuredDataModel sourceParentGraph = null;
+ AbstractStructuredDataModel targetParentGraph = null;
+ if (obj instanceof IXMLStructuredObject) {
+ IXMLStructuredObject sourceParent = ((IXMLStructuredObject) obj)
+ .getParent();
+ sourceParentGraph = UIUtils.findGraphModel(context
+ .getGraphicalRootModel(), sourceParent);
+ }
+ Object obj1 = targetGraphModel.getReferenceEntityModel();
+ if (obj1 instanceof IXMLStructuredObject) {
+ IXMLStructuredObject targetParent = ((IXMLStructuredObject) obj1)
+ .getParent();
+ targetParentGraph = UIUtils.findGraphModel(context
+ .getGraphicalRootModel(), targetParent);
+ }
+ if (sourceParentGraph != null && targetParentGraph != null) {
+ PropertyModel propertyModel = new PropertyModel();
+ propertyModel.setName(BeanPopulatorMappingAnalyzer.PRO_BINDING_TYPE);
+ propertyModel.setValue(BeanPopulatorMappingAnalyzer.BEAN_CREATION);
+ CreateConnectionCommand command = new CreateConnectionCommand();
+ command.addPropertyModel(propertyModel);
+ command.setSource((IConnectableModel) sourceParentGraph);
+ command.setTarget((IConnectableModel) targetParentGraph);
+ context.getGefDomain().getCommandStack().execute(command);
+ }
+
+ }
+
+ private boolean hasBeanCreationParentLink(
+ AbstractStructuredDataModel sourceGraphModel,
+ SmooksConfigurationFileGenerateContext context) {
+ Object sourceNode = sourceGraphModel.getReferenceEntityModel();
+ if (!(sourceNode instanceof JavaBeanModel)) {
+ return false;
+ }
+ JavaBeanModel sourceParent = ((JavaBeanModel) sourceNode).getParent();
+ if (sourceParent == null) {
+ return false;
+ }
+ if (sourceParent instanceof JavaBeanList) {
+ return false;
+ }
+ IConnectableModel sourceParentGraph = (IConnectableModel) UIUtils
+ .findGraphModel(context.getGraphicalRootModel(), sourceParent);
+ // If the source's parent node haven't any associated resource-config ,
+ // refuse the connect request.
+ List parentConnections = sourceParentGraph.getModelTargetConnections();
+ if (parentConnections.size() == 0)
+ return false;
+ for (Iterator iterator = parentConnections.iterator(); iterator
+ .hasNext();) {
+ LineConnectionModel object = (LineConnectionModel) iterator.next();
+ if (Java2JavaAnalyzer.BEAN_CREATION.equals(object
+ .getProperty(Java2JavaAnalyzer.PRO_BINDING_TYPE))) {
+ if (object
+ .getProperty(Java2JavaAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG) != null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
private boolean checkTargetToTarget(
AbstractStructuredDataModel sourceGraphModel,
AbstractStructuredDataModel targetGraphModel,
@@ -156,14 +244,14 @@
return true;
}
Object sourceParent = sourceGraphModel.getReferenceEntityModel();
- if(!(sourceParent instanceof JavaBeanModel)){
+ if (!(sourceParent instanceof JavaBeanModel)) {
return false;
}
- sourceParent = ((JavaBeanModel)sourceParent).getParent();
- if(sourceParent == null){
+ sourceParent = ((JavaBeanModel) sourceParent).getParent();
+ if (sourceParent == null) {
return false;
}
- if(sourceParent instanceof JavaBeanList){
+ if (sourceParent instanceof JavaBeanList) {
return false;
}
IConnectableModel sourceParentGraph = (IConnectableModel) UIUtils
@@ -180,7 +268,8 @@
for (Iterator iterator = parentConnections.iterator(); iterator
.hasNext();) {
LineConnectionModel object = (LineConnectionModel) iterator.next();
- if (object.getProperty(Java2JavaAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG) == null) {
+ if (object
+ .getProperty(Java2JavaAnalyzer.PRO_REFERENCE_RESOURCE_CONFIG) == null) {
return false;
}
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/model/JavaBeanModel.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -34,8 +34,8 @@
*
*/
public class JavaBeanModel implements IValidatable, IXMLStructuredObject,
- Cloneable , ITransformTreeNode{
-
+ Cloneable, ITransformTreeNode {
+
private Properties extendProperties = new Properties();
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
@@ -94,7 +94,8 @@
public void addNodePropetyChangeListener(PropertyChangeListener listener) {
PropertyChangeListener[] array = support.getPropertyChangeListeners();
for (int i = 0; i < array.length; i++) {
- if(listener == array[i]) return;
+ if (listener == array[i])
+ return;
}
support.addPropertyChangeListener(listener);
}
@@ -103,6 +104,14 @@
support.removePropertyChangeListener(listener);
}
+ public void cleanAllNodePropertyChangeListeners() {
+ PropertyChangeListener[] ps = support.getPropertyChangeListeners();
+ for (int i = 0; i < ps.length; i++) {
+ PropertyChangeListener p = ps[i];
+ support.removePropertyChangeListener(p);
+ }
+ }
+
// /**
// * @return the isRoot
// */
@@ -126,6 +135,16 @@
return clazz.getName();
}
+ public String getBeanClassStringWithList() {
+ String s = getBeanClassString();
+ if (this.isList()) {
+ Class genericType = getGenericType();
+ if (genericType != null)
+ s += "<" + genericType.getName() + ">";
+ }
+ return s;
+ }
+
/**
* @param isRoot
* the isRoot to set
@@ -168,7 +187,6 @@
public PropertyDescriptor getPropertyDescriptor() {
return propertyDescriptor;
}
-
public void setPropertyDescriptor(PropertyDescriptor propertyDescriptor) {
this.propertyDescriptor = propertyDescriptor;
@@ -308,6 +326,22 @@
}
}
+ protected void createArrayChildren(Class<Object> clazz, String name,
+ PropertyDescriptor pd, Class<? extends Object> parentClass,
+ boolean lazyLoad) {
+ JavaBeanModel proxyModel = newChildJavaBean(clazz, name, pd,
+ parentClass, lazyLoad);
+ addProperty(proxyModel);
+ }
+
+ protected void createListChildren(Class<Object> clazz, String name,
+ PropertyDescriptor pd, Class<? extends Object> parentClass,
+ boolean lazyLoad) {
+ JavaBeanModel proxyModel = newChildJavaBean(clazz, name, pd,
+ parentClass, lazyLoad);
+ addProperty(proxyModel);
+ }
+
private List properties;
public List getProperties() {
@@ -320,17 +354,14 @@
Class beanType = beanClass;
if (isArray() || isList()) {
if (componentClass != null) {
- JavaBeanModel proxyModel = new JavaBeanModel(
- componentClass, componentClass.getSimpleName(),
- null, beanClass, this.lazyLoadProperties);
+ createArrayChildren(componentClass, componentClass
+ .getSimpleName(), null, beanClass,
+ this.lazyLoadProperties);
beanType = componentClass;
- addProperty(proxyModel);
-
} else {
- JavaBeanModel proxyModel = new JavaBeanModel(Object.class,
- "object", null, beanClass, this.lazyLoadProperties);
+ createListChildren(Object.class, "object", null, beanClass,
+ this.lazyLoadProperties);
beanType = componentClass;
- addProperty(proxyModel);
}
return properties;
}
@@ -342,7 +373,8 @@
PropertyDescriptor pd = pds[i];
if ("class".equals(pd.getName())) //$NON-NLS-1$
continue;
- if(pd.getPropertyType() == null) continue;
+ if (pd.getPropertyType() == null)
+ continue;
if (Collection.class.isAssignableFrom(pd.getPropertyType())) {
Method rmethod = pd.getReadMethod();
if (rmethod != null) {
@@ -358,7 +390,7 @@
}
}
}
- JavaBeanModel jbm = new JavaBeanModel(pd.getPropertyType(), pd
+ JavaBeanModel jbm = newChildJavaBean(pd.getPropertyType(), pd
.getName(), pd, beanClass, this.lazyLoadProperties);
addProperty(jbm);
}
@@ -366,6 +398,12 @@
return properties;
}
+ protected JavaBeanModel newChildJavaBean(Class clazz, String name,
+ PropertyDescriptor pd, Class parentClass, boolean lazyLoading) {
+ return new JavaBeanModel(clazz, name, pd, parentClass,
+ lazyLoading);
+ }
+
public void setProperties(List properties) {
this.properties = properties;
}
@@ -441,7 +479,7 @@
}
public String getSelectorString() {
- if(parent == null) {
+ if (parent == null) {
return getBeanClassString();
}
if (parent.getClass() == JavaBeanList.class) {
@@ -487,26 +525,27 @@
// TODO Auto-generated method stub
return false;
}
-
- public void setComponentClass(Class clazz){
+
+ public void setComponentClass(Class clazz) {
componentClass = clazz;
}
public Class getComponentClass() {
return componentClass;
}
-
- public void addExtendProperty(String name,String value){
+
+ public void addExtendProperty(String name, String value) {
extendProperties.setProperty(name, value);
}
-
- public String getExtendProperty(String name){
+
+ public String getExtendProperty(String name) {
return extendProperties.getProperty(name);
}
public Object clone() {
- if(isList()){
- JavaBeanModel model = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(ArrayList.class);
+ if (isList()) {
+ JavaBeanModel model = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(ArrayList.class);
model.setComponentClass(componentClass);
return model;
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/AbstractJavaBeanBuilder.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/AbstractJavaBeanBuilder.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/AbstractJavaBeanBuilder.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -3,11 +3,13 @@
*/
package org.jboss.tools.smooks.javabean.ui;
+import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.jboss.tools.smooks.graphical.GraphicalFactory;
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.graphical.Params;
import org.jboss.tools.smooks.javabean.model.JavaBeanList;
@@ -19,9 +21,11 @@
*
*/
public class AbstractJavaBeanBuilder {
+
+ private ClassLoader classLoader = null;
+
public static final int SOURCE_DATA = 0;
public static final int TARGET_DATA = 1;
- private ClassLoader classLoader = null;
public ClassLoader getClassLoader() {
return classLoader;
@@ -46,12 +50,129 @@
public void mergeJavaBeans(JavaBeanList beanList, List javabeans) {
for (Iterator iterator = javabeans.iterator(); iterator.hasNext();) {
JavaBeanModel javaBean = (JavaBeanModel) iterator.next();
- if (!hasSameNameBean(beanList, javaBean)) {
- beanList.addJavaBean(javaBean);
+ // if (!hasSameNameBean(beanList, javaBean)) {
+ beanList.addJavaBean(javaBean);
+ // }
+ }
+ }
+
+ public static String getDataSourceClassArray(GraphInformations info,
+ int dataMode) {
+ String key = "sourceDataPath"; //$NON-NLS-1$
+ if (dataMode == SOURCE_DATA) {
+ key = "sourceDataPath"; //$NON-NLS-1$
+ }
+ if (dataMode == TARGET_DATA) {
+ key = "targetDataPath"; //$NON-NLS-1$
+ }
+ if (info != null) {
+ Params params = info.getParams();
+ if (params != null) {
+ List paramList = params.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator
+ .hasNext();) {
+ Param param = (Param) iterator.next();
+ if (key.equals(param.getName())) {
+ return param.getValue();
+ }
+ }
}
}
+ return null;
}
+ public static void appendClassToGraph(JavaBeanModel clazz,
+ GraphInformations info, int dataMode) {
+ String classArray = getDataSourceClassArray(info, dataMode);
+ if (classArray == null) {
+ classArray = "";
+ }
+ if (!classArray.endsWith(";") && classArray.length() != 0) {
+ classArray += ";";
+ }
+ String newClassString = clazz.getBeanClassStringWithList();
+ if (newClassString != null) {
+ classArray += newClassString;
+ }
+ classArray = classArray.replace("<", "[");
+ classArray = classArray.replace(">", "]");
+ if (info != null) {
+ Params params = info.getParams();
+ if (params == null) {
+ params = GraphicalFactory.eINSTANCE.createParams();
+ info.setParams(params);
+ }
+ String key = "sourceDataPath"; //$NON-NLS-1$
+ if (dataMode == SOURCE_DATA) {
+ key = "sourceDataPath"; //$NON-NLS-1$
+ }
+ if (dataMode == TARGET_DATA) {
+ key = "targetDataPath"; //$NON-NLS-1$
+ }
+ Param targetParam = null;
+ ;
+ List paramList = params.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ Param param = (Param) iterator.next();
+ if (key.equals(param.getName())) {
+ targetParam = param;
+ break;
+ }
+ }
+ if (targetParam == null) {
+ targetParam = GraphicalFactory.eINSTANCE.createParam();
+ params.getParam().add(targetParam);
+ targetParam.setName(key);
+ }
+ targetParam.setValue(classArray);
+ }
+ }
+
+ public static void removeClassFromGraph(JavaBeanModel model,
+ GraphInformations info, int dataMode) {
+ String classArray = getDataSourceClassArray(info, dataMode);
+ String removeClass = model.getBeanClassStringWithList();
+ if (removeClass == null)
+ return;
+ removeClass = removeClass.replace("<", "[");
+ removeClass = removeClass.replace(">", "]");
+ int startIndex1 = classArray.indexOf(removeClass);
+ if (startIndex1 == -1)
+ return;
+ int endIndex = startIndex1 + removeClass.length();
+ endIndex++;
+ if (classArray.length() <= endIndex) {
+ endIndex --;
+ if (classArray.charAt(endIndex - 1) != ';') {
+ endIndex = startIndex1 + removeClass.length();
+ }
+ }
+ classArray = classArray.substring(0, startIndex1)
+ + classArray.substring(endIndex, classArray.length());
+ if (info != null && classArray != null) {
+ Params params = info.getParams();
+ if (params == null) {
+ params = GraphicalFactory.eINSTANCE.createParams();
+ info.setParams(params);
+ }
+ String key = "sourceDataPath"; //$NON-NLS-1$
+ if (dataMode == SOURCE_DATA) {
+ key = "sourceDataPath"; //$NON-NLS-1$
+ }
+ if (dataMode == TARGET_DATA) {
+ key = "targetDataPath"; //$NON-NLS-1$
+ }
+ List paramList = params.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ Param param = (Param) iterator.next();
+ if (key.equals(param.getName())) {
+ param.setValue(classArray);
+ break;
+ }
+ }
+ }
+ }
+
public List getTheJavaBeanFromGraphFile(ClassLoader classLoader,
GraphInformations graphInfo, int dataMode) {
String array = getDataSourceClassArray(graphInfo, dataMode);
@@ -66,9 +187,37 @@
if (className.length() == 0)
continue;
try {
- Class clazz = classLoader.loadClass(className);
- JavaBeanModel javaBean = JavaBeanModelFactory
- .getJavaBeanModelWithLazyLoad(clazz);
+ JavaBeanModel javaBean = null;
+ if (className.indexOf("[") != -1) {
+ int start = className.indexOf("[");
+ int end = className.indexOf("]");
+ String genericType = className.substring(start + 1, end);
+ if (genericType != null) {
+ genericType = genericType.trim();
+ }
+ String newClassName = className.substring(0, start);
+ Class realClass = classLoader.loadClass(newClassName);
+ if (genericType.length() == 0) {
+ javaBean = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(Array
+ .newInstance(realClass, 0).getClass());
+ } else {
+ Class genericClass = null;
+ try {
+ genericClass = classLoader.loadClass(genericType);
+ } catch (Throwable t1) {
+
+ }
+ javaBean = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(realClass);
+ if (genericClass != null)
+ javaBean.setComponentClass(genericClass);
+ }
+ } else {
+ Class clazz = classLoader.loadClass(className);
+ javaBean = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(clazz);
+ }
if (javaBean != null) {
list.add(javaBean);
}
@@ -78,29 +227,4 @@
}
return list;
}
-
- private String getDataSourceClassArray(GraphInformations info, int dataMode) {
- String key = "sourceDataPath"; //$NON-NLS-1$
- if (dataMode == SOURCE_DATA) {
- key = "sourceDataPath"; //$NON-NLS-1$
- }
- if (dataMode == TARGET_DATA) {
- key = "targetDataPath"; //$NON-NLS-1$
- }
- if (info != null) {
- Params params = info.getParams();
- if (params != null) {
- List paramList = params.getParam();
- for (Iterator iterator = paramList.iterator(); iterator
- .hasNext();) {
- Param param = (Param) iterator.next();
- if (key.equals(param.getName())) {
- return param.getValue();
- }
- }
- }
- }
- return null;
- }
-
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanSourceBuilder.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -112,7 +112,9 @@
selector = selector.substring(0, selector.length() - 2);
Class arrayClass = loader.loadClass(selector);
Object arrayInstance = Array.newInstance(arrayClass, 0);
- return arrayInstance.getClass();
+ Class arrayClasss = arrayInstance.getClass();
+ arrayInstance = null;
+ return arrayClass;
}
return loader.loadClass(selector);
} catch (ClassNotFoundException e) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/JavaBeanTargetBuilder.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -3,6 +3,7 @@
*/
package org.jboss.tools.smooks.javabean.ui;
+import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
@@ -24,6 +25,8 @@
import org.jboss.tools.smooks.model.SmooksResourceListType;
import org.jboss.tools.smooks.model.util.SmooksModelConstants;
import org.jboss.tools.smooks.model.util.SmooksModelUtils;
+import org.jboss.tools.smooks.ui.editors.SmooksGraphicalFormPage;
+import org.jboss.tools.smooks.ui.editors.TransformDataTreeViewer;
import org.jboss.tools.smooks.utils.ProjectClassLoader;
/**
@@ -31,11 +34,13 @@
*
*/
public class JavaBeanTargetBuilder extends AbstractJavaBeanBuilder implements
- ITargetModelAnalyzer {
+ ITargetModelAnalyzer, PropertyChangeListener {
+ private GraphInformations graphInfo;
public Object buildTargetInputObjects(GraphInformations graphInfo,
SmooksResourceListType listType, IFile sourceFile, Object viewer)
throws InvocationTargetException {
+ this.graphInfo = graphInfo;
ClassLoader classLoader = getClassLoader();
if (classLoader == null) {
IProject project = sourceFile.getProject();
@@ -45,9 +50,18 @@
throw new InvocationTargetException(e);
}
}
- JavaBeanList beanList = (JavaBeanList) buildTargetInputObjects(graphInfo, listType, sourceFile, viewer,
- getClassLoader());
- mergeJavaBeans(beanList, getTheJavaBeanFromGraphFile(classLoader, graphInfo, TARGET_DATA));
+ JavaBeanList beanList = (JavaBeanList) buildTargetInputObjects(
+ graphInfo, listType, sourceFile, viewer, getClassLoader());
+ mergeJavaBeans(beanList, getTheJavaBeanFromGraphFile(classLoader,
+ graphInfo, TARGET_DATA));
+ if (viewer instanceof PropertyChangeListener) {
+ registeListener((PropertyChangeListener) viewer, beanList);
+ List list = beanList.getChildren();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ JavaBeanModel beanModel = (JavaBeanModel) iterator.next();
+ registeListener((PropertyChangeListener) viewer, beanModel);
+ }
+ }
return beanList;
}
@@ -93,12 +107,12 @@
continue;
JavaBeanModel javaBean = JavaBeanModelFactory
.getJavaBeanModelWithLazyLoad(clazz);
- registeListener(viewer, javaBean);
+ // registeListener(viewer, javaBean);
beanList.addJavaBean(javaBean);
}
}
}
- registeListener(viewer, beanList);
+ // registeListener(viewer, beanList);
return beanList;
}
@@ -106,6 +120,7 @@
if (listener instanceof PropertyChangeListener) {
javaBean
.addNodePropetyChangeListener((PropertyChangeListener) listener);
+ javaBean.addNodePropetyChangeListener(this);
}
}
@@ -129,4 +144,31 @@
return null;
}
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (graphInfo != null) {
+ String type = evt.getPropertyName();
+ Object node = evt.getNewValue();
+ if(TransformDataTreeViewer.REMOVE_CHILDREN_EVENT
+ .equals(type)){
+ node = evt.getOldValue();
+ }
+ if (node instanceof JavaBeanModel) {
+ if (!((JavaBeanModel) node).isPrimitive()) {
+ if (TransformDataTreeViewer.NODE_PROPERTY_EVENT
+ .equals(type)
+ || TransformDataTreeViewer.ADD_CHILDREN_EVENT
+ .equals(type)) {
+ appendClassToGraph((JavaBeanModel) node, graphInfo,
+ TARGET_DATA);
+ }
+ if (TransformDataTreeViewer.REMOVE_CHILDREN_EVENT
+ .equals(type)) {
+ removeClassFromGraph((JavaBeanModel) node, graphInfo,
+ TARGET_DATA);
+ }
+ }
+ }
+ }
+ }
+
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/AddJavaBeanModelAction.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -80,6 +80,8 @@
}
}
}
+
+ super.run();
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/JavaBeanModelAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/JavaBeanModelAction.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/JavaBeanModelAction.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -7,6 +7,7 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
+import org.jboss.tools.smooks.ui.editors.SmooksFormEditor;
import org.jboss.tools.smooks.ui.popup.SmooksAction;
/**
@@ -25,4 +26,16 @@
}
return null;
}
+
+ protected void fireEditorIsDirty(){
+ ((SmooksFormEditor)context.getSmooksGraphcalPage().getEditor()).fireEditorDirty(true);
+ }
+
+ @Override
+ public void run() {
+ super.run();
+ fireEditorIsDirty();
+ }
+
+
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/action/RemoveJavaBeanAction.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -43,10 +43,11 @@
// disConnectAllConnections(graphModel);
}
if(viewer instanceof PropertyChangeListener){
- model.removeNodePropetyChangeListener((PropertyChangeListener)viewer);
+ model.cleanAllNodePropertyChangeListeners();
}
beanList.removeJavaBean(model);
}
+ super.run();
}
protected void disConnectAllConnections(IConnectableModel model){
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 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -60,7 +60,6 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -119,6 +118,7 @@
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.GraphicalFactory;
import org.jboss.tools.smooks.graphical.MappingDataType;
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.graphical.Params;
@@ -190,6 +190,7 @@
protected Hyperlink sourceLink = null;
protected Hyperlink targetLink = null;
protected String sourceDataTypeID = null;
+ protected GraphInformations graphinformations = null;
public String getSourceDataTypeID() {
return sourceDataTypeID;
@@ -470,9 +471,16 @@
targetViewer));
}
}
+
+
+
toolkit.paintBordersFor(rootMainControl);
form.pack();
+ /*
+ * below is init GUIs
+ */
+
Throwable throwable = null;
try {
this.initTransformViewerModel((IEditorSite) getSite(),
@@ -633,11 +641,12 @@
protected void initTargetTreeViewer() {
if (this.targetTreeViewerInputModel != null) {
-// if (targetTreeViewerInputModel instanceof ITransformTreeNode
-// && targetViewer instanceof PropertyChangeListener) {
-// ((ITransformTreeNode) targetTreeViewerInputModel)
-// .addNodePropetyChangeListener((PropertyChangeListener) targetViewer);
-// }
+ // if (targetTreeViewerInputModel instanceof ITransformTreeNode
+ // && targetViewer instanceof PropertyChangeListener) {
+ // ((ITransformTreeNode) targetTreeViewerInputModel)
+ // .addNodePropetyChangeListener((PropertyChangeListener)
+ // targetViewer);
+ // }
targetViewer.setInput(targetTreeViewerInputModel);
}
}
@@ -1001,8 +1010,10 @@
// save graphical informations
if (this.graphicalInformationSaver != null) {
- graphicalInformationSaver.doSave(monitor,
- getSmooksConfigurationFileGenerateContext());
+ SmooksConfigurationFileGenerateContext context = new SmooksConfigurationFileGenerateContext();
+ initSmooksConfigurationFileGenerateContext(context);
+ context.getProperties().clear();
+ graphicalInformationSaver.doSave(monitor, context);
}
} catch (CoreException e) {
exp = e;
@@ -1043,6 +1054,7 @@
context.setSourceDataTypeID(this.sourceDataTypeID);
context.setTargetDataTypeID(this.targetDataTypeID);
context.setSmooksType(SmooksModelConstants.SAX);
+ context.setGraphInformations(graphinformations);
context.setDataMappingRootModel(this.rootModel);
context.setSmooksConfigFile(((IFileEditorInput) getEditorInput())
.getFile());
@@ -1277,11 +1289,12 @@
throws Throwable {
graphicalInformationSaver = new GraphicalInformationSaver(input);
- GraphInformations graph = null;
try {
- graph = graphicalInformationSaver.doLoad();
- initFormEditorWithGraphInfo(graph);
- initSmooksContext(graph, this
+ if (graphinformations == null) {
+ graphinformations = graphicalInformationSaver.doLoad();
+ }
+ initFormEditorWithGraphInfo(graphinformations);
+ initSmooksContext(graphinformations, this
.getSmooksConfigurationFileGenerateContext());
} catch (Throwable t) {
// ignore
@@ -1315,7 +1328,7 @@
return;
SmooksResourceListType listType = ((DocumentRoot) smooksResource
.getContents().get(0)).getSmooksResourceList();
- this.analyzeGraphicalModel(listType, graph, file);
+ this.analyzeGraphicalModel(listType, graphinformations, file);
}
}
@@ -1330,10 +1343,10 @@
smooksResource.getContents().clear();
smooksResource.getContents().add(listType.eContainer());
}
- GraphInformations graph = null;
- if (graphicalInformationSaver != null)
- graph = graphicalInformationSaver.doLoad();
- this.analyzeGraphicalModel(listType, graph,
+ // GraphInformations graph = null;
+ // if (graphicalInformationSaver != null)
+ // graph = graphicalInformationSaver.doLoad();
+ this.analyzeGraphicalModel(listType, graphinformations,
((IFileEditorInput) getEditorInput()).getFile());
}
@@ -1450,6 +1463,30 @@
}
}
+ public void replaceInputDataPathData(String pathName, String value) {
+ if (graphinformations != null) {
+ Params params = graphinformations.getParams();
+ if (params == null) {
+ return;
+ }
+ Param param = null;
+ List list = params.getParam();
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ Param p = (Param) iterator.next();
+ if (pathName.equals(p.getName())) {
+ param = p;
+ break;
+ }
+ }
+ if (param == null) {
+ param = GraphicalFactory.eINSTANCE.createParam();
+ params.getParam().add(param);
+ param.setName(pathName);
+ }
+ param.setValue(value);
+ }
+ }
+
/**
* It's a very important method
* <p>
@@ -1490,23 +1527,17 @@
try {
if (viewer == this.sourceViewer) {
this.createSourceGraphModels();
- this
- .getSmooksConfigurationFileGenerateContext()
- .getProperties()
- .setProperty(
- SmooksConfigFileNewWizard.PRO_SOURCE_DATA_PATH,
- cw.getStructuredDataSourcePath());
+ replaceInputDataPathData(
+ SmooksConfigFileNewWizard.PRO_SOURCE_DATA_PATH,
+ cw.getStructuredDataSourcePath());
sourceDataTypeID = typeID;
}
if (viewer == this.targetViewer) {
this.createTargetGraphModels();
targetDataTypeID = typeID;
- this
- .getSmooksConfigurationFileGenerateContext()
- .getProperties()
- .setProperty(
- SmooksConfigFileNewWizard.PRO_TARGET_DATA_PATH,
- cw.getStructuredDataSourcePath());
+ replaceInputDataPathData(
+ SmooksConfigFileNewWizard.PRO_TARGET_DATA_PATH,
+ cw.getStructuredDataSourcePath());
}
commandStackChanged = true;
firePropertyChange(PROP_DIRTY);
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 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -1,643 +1,644 @@
-/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.smooks.ui.editors;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.MoveCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-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.ui.IFileEditorInput;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.ide.IDE;
-import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
-import org.jboss.tools.smooks.analyzer.NormalSmooksModelPackage;
-import org.jboss.tools.smooks.model.ImportType;
-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.util.SmooksModelConstants;
-import org.jboss.tools.smooks.model.util.SmooksModelUtils;
-import org.jboss.tools.smooks.ui.AnalyzeResult;
-import org.jboss.tools.smooks.ui.IAnalyzeListener;
-import org.jboss.tools.smooks.ui.SmooksUIActivator;
-import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
-import org.jboss.tools.smooks.utils.SmooksGraphConstants;
-import org.jboss.tools.smooks.utils.UIUtils;
-
-/**
- * @author Dart Peng Date : 2008-9-9
- */
-public class SmooksNormalContentEditFormPage extends FormPage implements
- IAnalyzeListener {
-
- protected NormalSmooksModelPackage modelPackage = null;
-
- protected SmooksResourceConfigFormBlock resourceBlock = null;
-
- protected ResourceConfigType transformType = null;
-
- private Button saxButton;
-
- private Button domButton;
-
- private Button saxdomButton;
-
- private EditingDomain domain;
-
- private List hidenResourceConfigs;
-
- private boolean disableGUI = false;
-
- public boolean isDisableGUI() {
- return disableGUI;
- }
-
- public void setDisableGUI(boolean disableGUI) {
- this.disableGUI = disableGUI;
- setGUIStates();
- }
-
- private Section parseTypeSection;
-
- private Button addFileButton;
-
- private Button removeFileButton;
-
- private Button editFileButton;
-
- private TableViewer fileViewer;
-
- public SmooksNormalContentEditFormPage(FormEditor editor, String id,
- String title, NormalSmooksModelPackage modelPacakge) {
- super(editor, id, title);
- domain = ((SmooksFormEditor) editor).getEditingDomain();
- this.createResourceConfigFormBlock();
- this.setModelPackage(modelPacakge);
- }
-
- public SmooksNormalContentEditFormPage(String id, String title,
- NormalSmooksModelPackage modelPacakge) {
- super(id, title);
- this.createResourceConfigFormBlock();
- this.setModelPackage(modelPacakge);
- }
-
- protected void createResourceConfigFormBlock() {
- resourceBlock = new SmooksResourceConfigFormBlock();
- resourceBlock.setDomain(getEditingDomain());
- resourceBlock.setParentEditor((SmooksFormEditor) this.getEditor());
- }
-
- protected EditingDomain getEditingDomain() {
- return ((SmooksFormEditor) getEditor()).getEditingDomain();
- }
-
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- final ScrolledForm form = managedForm.getForm();
- FormToolkit tool = managedForm.getToolkit();
- tool.decorateFormHeading(form.getForm());
- GridLayout gridLayout = UIUtils.createGeneralFormEditorLayout(1);
- resourceBlock.createContent(managedForm);
- Composite rootMainControl = form.getBody();
- form
- .setText(Messages
- .getString("SmooksNormalContentEditFormPage.ConfigurationPageText")); //$NON-NLS-1$
- createSmooksTypeGUI(rootMainControl, tool);
- form.getBody().setLayout(gridLayout);
- form.pack();
- this.initOtherConfigurationsGUI();
- resourceBlock.initViewers(transformType);
-
- setGUIStates();
- }
-
- @Override
- public boolean isDirty() {
- return false;
- }
-
- public void setGUIStates() {
- if (resourceBlock != null) {
- resourceBlock.setSectionStates(!disableGUI);
- }
-
- if (this.parseTypeSection != null && !parseTypeSection.isDisposed()) {
- parseTypeSection.setEnabled(!disableGUI);
- }
- }
-
- 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);
-
- return transformType;
- }
-
- protected void initOtherConfigurationsGUI() {
- if (saxButton != null)
- saxButton.setSelection(false);
- if (domButton != null)
- domButton.setSelection(false);
- if (saxdomButton != null)
- saxdomButton.setSelection(false);
- if (this.getModelPackage() != null) {
- List list = modelPackage.getSmooksResourceList()
- .getAbstractResourceConfig();
- if (fileViewer != null) {
- fileViewer.setInput(list);
- }
- for (Iterator iterator = list.iterator(); iterator.hasNext();) {
- Object sr = iterator.next();
- if (sr instanceof ResourceConfigType) {
- if (SmooksModelUtils
- .isTransformTypeResourceConfig((ResourceConfigType) sr)) {
- this.transformType = (ResourceConfigType) sr;
- break;
- }
- }
- }
- if (transformType == null) {
- transformType = createTransformType();
- }
- if (transformType != null) {
- String type = SmooksModelUtils.getTransformType(transformType);
- if (SmooksModelConstants.SAX.equals(type)) {
- if (saxButton != null)
- saxButton.setSelection(true);
- }
- if (SmooksModelConstants.DOM.equals(type)) {
- if (domButton != null)
- domButton.setSelection(true);
- }
- if ("SAX/DOM".equals(type)) { //$NON-NLS-1$
- if (saxdomButton != null)
- saxdomButton.setSelection(true);
- }
- }
- }
- }
-
- protected void createSmooksTypeGUI(Composite mainComposite, FormToolkit tool) {
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- parseTypeSection = tool.createSection(mainComposite, Section.TITLE_BAR
- | Section.TWISTIE);
- parseTypeSection.setLayoutData(gd);
- Composite otherConfigurationComposite = tool
- .createComposite(parseTypeSection);
- parseTypeSection.setClient(otherConfigurationComposite);
- parseTypeSection.setText(Messages
- .getString("SmooksNormalContentEditFormPage.SmooksParseType")); //$NON-NLS-1$
- GridLayout layout1 = new GridLayout();
- otherConfigurationComposite.setLayout(layout1);
-
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- otherConfigurationComposite.setLayoutData(gd);
- GridLayout layout = new GridLayout();
- otherConfigurationComposite.setLayout(layout);
-
- Composite buttonComposite = tool
- .createComposite(otherConfigurationComposite);
- GridLayout buttonAreaLayout = new GridLayout();
- buttonAreaLayout.numColumns = 4;
- buttonComposite.setLayout(buttonAreaLayout);
-
- gd = new GridData(GridData.FILL_HORIZONTAL);
- buttonComposite.setLayoutData(gd);
-
- tool.createLabel(buttonComposite, "Parse Type : ");
- saxButton = createTypeSelectRadioButton(buttonComposite, tool,
- SmooksModelConstants.SAX);
- domButton = createTypeSelectRadioButton(buttonComposite, tool,
- SmooksModelConstants.DOM);
- saxdomButton = createTypeSelectRadioButton(buttonComposite, tool,
- SmooksModelConstants.SAX_DOM);
-
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- tool.createSeparator(otherConfigurationComposite, SWT.HORIZONTAL)
- .setLayoutData(gd);
-
- Composite importFileComposite = tool
- .createComposite(otherConfigurationComposite);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- GridLayout fileLayout = new GridLayout();
- fileLayout.numColumns = 2;
- importFileComposite.setLayoutData(gd);
- importFileComposite.setLayout(fileLayout);
- // importFileComposite.setBackground(ColorConstants.black);
-
- Label fileListLabel = tool.createLabel(importFileComposite,
- "Import Files :");
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- fileListLabel.setLayoutData(gd);
-
- Composite viewerComposite = tool.createComposite(importFileComposite);
- FillLayout viewerLayout = new FillLayout();
- viewerLayout.marginHeight = 1;
- viewerLayout.marginWidth = 1;
- viewerComposite.setLayout(viewerLayout);
- fileViewer = new TableViewer(viewerComposite, SWT.NONE);
- fileViewer.setContentProvider(new FileImportContentProvider());
- fileViewer.setLabelProvider(new FileImportLabelProvider());
- if (getModelPackage() != null) {
- SmooksResourceListType listType = getModelPackage()
- .getSmooksResourceList();
- if (listType != null && listType.getAbstractResourceConfig() != null) {
- fileViewer.setInput(listType.getAbstractResourceConfig());
- }
- }
- fileViewer.addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- openFile(fileViewer.getSelection());
- }
- });
- fileViewer.addFilter(new ViewerFilter() {
-
- @Override
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
- if (element instanceof ImportType)
- return true;
- return false;
- }
-
- });
- gd = new GridData(GridData.FILL_BOTH);
- viewerComposite.setLayoutData(gd);
- viewerComposite.setBackground(GraphicsConstants.groupBorderColor);
- tool.paintBordersFor(viewerComposite);
-
- Composite fileActionComposite = tool
- .createComposite(importFileComposite);
- gd = new GridData(GridData.FILL_VERTICAL);
- fileActionComposite.setLayoutData(gd);
-
- GridLayout fileActionLayout = new GridLayout();
- fileActionComposite.setLayout(fileActionLayout);
-
- addFileButton = createFileActionButton(fileActionComposite, tool, "Add");
- removeFileButton = createFileActionButton(fileActionComposite, tool,
- "Remove");
- editFileButton = createFileActionButton(fileActionComposite, tool,
- "Edit");
-
- tool.paintBordersFor(fileActionComposite);
-
- hookButtons();
- }
-
- protected void openFile(ISelection selection) {
- Object obj = ((IStructuredSelection) selection).getFirstElement();
- if (obj != null && obj instanceof ImportType) {
- String filePath = ((ImportType) obj).getFile();
- IFile input = createEditorInput(filePath);
- if (input != null) {
- try {
- IDE.openEditor(SmooksUIActivator.getDefault()
- .getWorkbench().getActiveWorkbenchWindow()
- .getActivePage(), input);
- } catch (PartInitException e) {
- UIUtils.showErrorDialog(getSite().getShell(), UIUtils
- .createErrorStatus(e));
- }
- }
- }
- }
-
- private IProject getCurrentProject() {
- IFile file = ((IFileEditorInput) getEditor().getEditorInput())
- .getFile();
- if (file != null) {
- IProject project = file.getProject();
- return project;
- }
- return null;
- }
-
- protected IFile createEditorInput(String filePath) {
- String workspacePath = this.getWorkspaceFilePath(filePath);
- IProject project = getCurrentProject();
- if (project != null) {
- IResource resource = project.findMember(new Path(workspacePath));
- if (resource instanceof IFile) {
- return (IFile) resource;
- }
- }
- return null;
- }
-
- private Button createFileActionButton(Composite parent, FormToolkit tool,
- String text) {
- Button button = tool.createButton(parent, text, SWT.NONE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- button.setLayoutData(gd);
- return button;
- }
-
- 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);
- }
-
- });
-
- addFileButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- addFileImport();
- }
-
- });
-
- removeFileButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- removeFileImport();
- }
-
- });
-
- editFileButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- editFileImport();
- }
-
- });
- }
-
- protected void editFileImport() {
- IStructuredSelection selection = (IStructuredSelection) fileViewer
- .getSelection();
- Object obj = selection.getFirstElement();
- if (obj instanceof ImportType) {
- String filePath = getWorkspaceFilePath(((ImportType) obj).getFile());
- IProject project = getCurrentProject();
- if (project != null) {
- IResource resource = project.findMember(new Path(filePath));
- IFile[] files = WorkspaceResourceDialog.openFileSelection(
- getSite().getShell(), "Select Files", "", false,
- new Object[] { resource }, Collections.EMPTY_LIST);
- if (files != null) {
- IPath path1 = files[0].getFullPath().removeFirstSegments(1);
- String s = path1.toString();
- if (s.startsWith("/") || s.startsWith("\\")) {
-
- } else {
- s = "/" + s;
- }
- ((ImportType) obj).setFile("classpath:" + s);
- fileViewer.refresh();
- ((SmooksFormEditor) getEditor()).fireEditorDirty(true);
- }
- }
-
- }
- }
-
- protected void removeFileImport() {
- IStructuredSelection selection = (IStructuredSelection) fileViewer
- .getSelection();
- NormalSmooksModelPackage modelPackage = getModelPackage();
- if (modelPackage != null) {
- modelPackage.getSmooksResourceList().getAbstractResourceConfig()
- .removeAll(selection.toList());
- fileViewer.refresh();
- ((SmooksFormEditor) getEditor()).fireEditorDirty(true);
- }
- }
-
- protected void addFileImport() {
- IFile[] files = WorkspaceResourceDialog.openFileSelection(getSite()
- .getShell(), "Select Files", "", false, null,
- Collections.EMPTY_LIST);
- if (files != null && files.length > 0) {
- ImportType fileImport = SmooksFactory.eINSTANCE.createImportType();
- IPath path1 = files[0].getFullPath().removeFirstSegments(1);
- String s = path1.toString();
- if (s.startsWith("/") || s.startsWith("\\")) {
-
- } else {
- s = "/" + s;
- }
- fileImport.setFile("classpath:" + s);
- NormalSmooksModelPackage modelPackage = getModelPackage();
- if (modelPackage != null) {
- Command command = AddCommand
- .create(
- ((SmooksFormEditor) getEditor())
- .getEditingDomain(),
- modelPackage.getSmooksResourceList(),
- SmooksPackage.eINSTANCE
- .getSmooksResourceListType_AbstractResourceConfig(),
- fileImport);
- ((SmooksFormEditor) getEditor()).getEditingDomain()
- .getCommandStack().execute(command);
- fileViewer.refresh();
- ((SmooksFormEditor) getEditor()).fireEditorDirty(true);
- }
- }
- }
-
- private Button createTypeSelectRadioButton(Composite parent,
- FormToolkit tool, String labelName) {
- Button button = tool.createButton(parent, labelName, SWT.RADIO);
- return button;
- }
-
- private String getWorkspaceFilePath(String filePath) {
- if (filePath == null)
- return "";
- if (filePath.indexOf(":") != -1) {
- int index = filePath.indexOf(":");
- return filePath.substring(index + 1, filePath.length());
- }
- return filePath;
- }
-
- /**
- * @return the modelPackage
- */
- public NormalSmooksModelPackage getModelPackage() {
- return modelPackage;
- }
-
- /**
- * @param modelPackage
- * the modelPackage to set
- */
- public void setModelPackage(NormalSmooksModelPackage modelPackage) {
- if (modelPackage == this.modelPackage)
- return;
- this.modelPackage = modelPackage;
- if (resourceBlock != null)
- this.resourceBlock.setModelPackage(this.modelPackage);
- }
-
- public void endAnalyze(AnalyzeResult result) {
- if (result.getError() == null) {
- disableGUI = false;
- SmooksFormEditor parentEditor = (SmooksFormEditor) getEditor();
- NormalSmooksModelPackage pa = parentEditor
- .createNewSmooksModelPackage();
- SmooksGraphicalFormPage graphicalEditor = (SmooksGraphicalFormPage) result
- .getSourceEdtior();
- MappingResourceConfigList rclist = graphicalEditor
- .getMappingResourceConfigList();
- // for make sure that the SmooksResourceConfig model was the same :
- if (rclist != null) {
- List<ResourceConfigType> renderList = rclist
- .getGraphRenderResourceConfigList();
- if (renderList != null && renderList.size() > 0) {
- ResourceConfigType resourceConfig = renderList.get(0);
- SmooksResourceListType rootList = (SmooksResourceListType) resourceConfig
- .eContainer();
- if (!(rootList == pa.getSmooksResourceList())) {
- pa.setSmooksResourceList(rootList);
- }
- }
- pa.setHidenSmooksElements(renderList);
- }
- setModelPackage(pa);
- } else {
- setModelPackage(null);
- disableGUI = true;
- }
- initOtherConfigurationsGUI();
- if (resourceBlock != null)
- this.resourceBlock.initViewers(transformType);
- setGUIStates();
- }
-
- private class FileImportContentProvider implements
- IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof List) {
- return ((List) inputElement).toArray();
- }
- return new Object[] {};
- }
-
- public void dispose() {
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- }
-
- private class FileImportLabelProvider extends LabelProvider {
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof ImportType) {
- String path = getWorkspaceFilePath(((ImportType) element)
- .getFile());
- IProject project = getCurrentProject();
- IResource resource = project.findMember(new Path(path));
- if (resource == null || !resource.exists())
- return SmooksUIActivator.getDefault().getImageRegistry()
- .get(SmooksGraphConstants.IMAGE_ERROR);
- }
- return super.getImage(element);
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof ImportType) {
- return getWorkspaceFilePath(((ImportType) element).getFile());
- }
- return super.getText(element);
- }
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.ui.editors;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.ui.dialogs.WorkspaceResourceDialog;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.MoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+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.ui.IFileEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
+import org.jboss.tools.smooks.analyzer.NormalSmooksModelPackage;
+import org.jboss.tools.smooks.model.ImportType;
+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.util.SmooksModelConstants;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
+import org.jboss.tools.smooks.ui.AnalyzeResult;
+import org.jboss.tools.smooks.ui.IAnalyzeListener;
+import org.jboss.tools.smooks.ui.SmooksUIActivator;
+import org.jboss.tools.smooks.ui.gef.util.GraphicsConstants;
+import org.jboss.tools.smooks.utils.SmooksGraphConstants;
+import org.jboss.tools.smooks.utils.UIUtils;
+
+/**
+ * @author Dart Peng Date : 2008-9-9
+ */
+public class SmooksNormalContentEditFormPage extends FormPage implements
+ IAnalyzeListener {
+
+ protected NormalSmooksModelPackage modelPackage = null;
+
+ protected SmooksResourceConfigFormBlock resourceBlock = null;
+
+ protected ResourceConfigType transformType = null;
+
+ private Button saxButton;
+
+ private Button domButton;
+
+ private Button saxdomButton;
+
+ private EditingDomain domain;
+
+ private List hidenResourceConfigs;
+
+ private boolean disableGUI = false;
+
+ public boolean isDisableGUI() {
+ return disableGUI;
+ }
+
+ public void setDisableGUI(boolean disableGUI) {
+ this.disableGUI = disableGUI;
+ setGUIStates();
+ }
+
+ private Section parseTypeSection;
+
+ private Button addFileButton;
+
+ private Button removeFileButton;
+
+ private Button editFileButton;
+
+ private TableViewer fileViewer;
+
+ public SmooksNormalContentEditFormPage(FormEditor editor, String id,
+ String title, NormalSmooksModelPackage modelPacakge) {
+ super(editor, id, title);
+ domain = ((SmooksFormEditor) editor).getEditingDomain();
+ this.createResourceConfigFormBlock();
+ this.setModelPackage(modelPacakge);
+ }
+
+ public SmooksNormalContentEditFormPage(String id, String title,
+ NormalSmooksModelPackage modelPacakge) {
+ super(id, title);
+ this.createResourceConfigFormBlock();
+ this.setModelPackage(modelPacakge);
+ }
+
+ protected void createResourceConfigFormBlock() {
+ resourceBlock = new SmooksResourceConfigFormBlock();
+ resourceBlock.setDomain(getEditingDomain());
+ resourceBlock.setParentEditor((SmooksFormEditor) this.getEditor());
+ }
+
+ protected EditingDomain getEditingDomain() {
+ return ((SmooksFormEditor) getEditor()).getEditingDomain();
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ final ScrolledForm form = managedForm.getForm();
+ FormToolkit tool = managedForm.getToolkit();
+ tool.decorateFormHeading(form.getForm());
+ GridLayout gridLayout = UIUtils.createGeneralFormEditorLayout(1);
+ resourceBlock.createContent(managedForm);
+ Composite rootMainControl = form.getBody();
+ form
+ .setText(Messages
+ .getString("SmooksNormalContentEditFormPage.ConfigurationPageText")); //$NON-NLS-1$
+ createSmooksTypeGUI(rootMainControl, tool);
+ form.getBody().setLayout(gridLayout);
+ form.pack();
+ this.initOtherConfigurationsGUI();
+ resourceBlock.initViewers(transformType);
+
+ setGUIStates();
+ }
+
+ @Override
+ public boolean isDirty() {
+ return false;
+ }
+
+ public void setGUIStates() {
+ if (resourceBlock != null) {
+ resourceBlock.setSectionStates(!disableGUI);
+ }
+
+ if (this.parseTypeSection != null && !parseTypeSection.isDisposed()) {
+ parseTypeSection.setEnabled(!disableGUI);
+ }
+ }
+
+ 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);
+
+ return transformType;
+ }
+
+ protected void initOtherConfigurationsGUI() {
+ if (saxButton != null)
+ saxButton.setSelection(false);
+ if (domButton != null)
+ domButton.setSelection(false);
+ if (saxdomButton != null)
+ saxdomButton.setSelection(false);
+ if (this.getModelPackage() != null) {
+ List list = modelPackage.getSmooksResourceList()
+ .getAbstractResourceConfig();
+ if (fileViewer != null) {
+ fileViewer.setInput(list);
+ }
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ Object sr = iterator.next();
+ if (sr instanceof ResourceConfigType) {
+ if (SmooksModelUtils
+ .isTransformTypeResourceConfig((ResourceConfigType) sr)) {
+ this.transformType = (ResourceConfigType) sr;
+ break;
+ }
+ }
+ }
+ if (transformType == null) {
+ transformType = createTransformType();
+ }
+ if (transformType != null) {
+ String type = SmooksModelUtils.getTransformType(transformType);
+ if (SmooksModelConstants.SAX.equals(type)) {
+ if (saxButton != null)
+ saxButton.setSelection(true);
+ }
+ if (SmooksModelConstants.DOM.equals(type)) {
+ if (domButton != null)
+ domButton.setSelection(true);
+ }
+ if ("SAX/DOM".equals(type)) { //$NON-NLS-1$
+ if (saxdomButton != null)
+ saxdomButton.setSelection(true);
+ }
+ }
+ }
+ }
+
+ protected void createSmooksTypeGUI(Composite mainComposite, FormToolkit tool) {
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ parseTypeSection = tool.createSection(mainComposite, Section.TITLE_BAR
+ | Section.TWISTIE);
+ parseTypeSection.setLayoutData(gd);
+ Composite otherConfigurationComposite = tool
+ .createComposite(parseTypeSection);
+ parseTypeSection.setClient(otherConfigurationComposite);
+ parseTypeSection.setText(Messages
+ .getString("SmooksNormalContentEditFormPage.SmooksParseType")); //$NON-NLS-1$
+ GridLayout layout1 = new GridLayout();
+ otherConfigurationComposite.setLayout(layout1);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ otherConfigurationComposite.setLayoutData(gd);
+ GridLayout layout = new GridLayout();
+ otherConfigurationComposite.setLayout(layout);
+
+ Composite buttonComposite = tool
+ .createComposite(otherConfigurationComposite);
+ GridLayout buttonAreaLayout = new GridLayout();
+ buttonAreaLayout.numColumns = 4;
+ buttonComposite.setLayout(buttonAreaLayout);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ buttonComposite.setLayoutData(gd);
+
+ tool.createLabel(buttonComposite, "Parse Type : ");
+ saxButton = createTypeSelectRadioButton(buttonComposite, tool,
+ SmooksModelConstants.SAX);
+ domButton = createTypeSelectRadioButton(buttonComposite, tool,
+ SmooksModelConstants.DOM);
+ saxdomButton = createTypeSelectRadioButton(buttonComposite, tool,
+ SmooksModelConstants.SAX_DOM);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+// tool.createSeparator(otherConfigurationComposite, SWT.HORIZONTAL)
+// .setLayoutData(gd);
+
+ // below is for creating import files GUI.
+ Composite importFileComposite = tool
+ .createComposite(otherConfigurationComposite);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ GridLayout fileLayout = new GridLayout();
+ fileLayout.numColumns = 2;
+ importFileComposite.setLayoutData(gd);
+ importFileComposite.setLayout(fileLayout);
+ // importFileComposite.setBackground(ColorConstants.black);
+
+ Label fileListLabel = tool.createLabel(importFileComposite,
+ "Import Files :");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ fileListLabel.setLayoutData(gd);
+
+ Composite viewerComposite = tool.createComposite(importFileComposite);
+ FillLayout viewerLayout = new FillLayout();
+ viewerLayout.marginHeight = 1;
+ viewerLayout.marginWidth = 1;
+ viewerComposite.setLayout(viewerLayout);
+ fileViewer = new TableViewer(viewerComposite, SWT.NONE);
+ fileViewer.setContentProvider(new FileImportContentProvider());
+ fileViewer.setLabelProvider(new FileImportLabelProvider());
+ if (getModelPackage() != null) {
+ SmooksResourceListType listType = getModelPackage()
+ .getSmooksResourceList();
+ if (listType != null && listType.getAbstractResourceConfig() != null) {
+ fileViewer.setInput(listType.getAbstractResourceConfig());
+ }
+ }
+ fileViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ openFile(fileViewer.getSelection());
+ }
+ });
+ fileViewer.addFilter(new ViewerFilter() {
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ if (element instanceof ImportType)
+ return true;
+ return false;
+ }
+
+ });
+ gd = new GridData(GridData.FILL_BOTH);
+ viewerComposite.setLayoutData(gd);
+ viewerComposite.setBackground(GraphicsConstants.groupBorderColor);
+ tool.paintBordersFor(viewerComposite);
+
+ Composite fileActionComposite = tool
+ .createComposite(importFileComposite);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ fileActionComposite.setLayoutData(gd);
+
+ GridLayout fileActionLayout = new GridLayout();
+ fileActionComposite.setLayout(fileActionLayout);
+
+ addFileButton = createFileActionButton(fileActionComposite, tool, "Add");
+ removeFileButton = createFileActionButton(fileActionComposite, tool,
+ "Remove");
+ editFileButton = createFileActionButton(fileActionComposite, tool,
+ "Edit");
+
+ tool.paintBordersFor(fileActionComposite);
+
+ hookButtons();
+ }
+
+ protected void openFile(ISelection selection) {
+ Object obj = ((IStructuredSelection) selection).getFirstElement();
+ if (obj != null && obj instanceof ImportType) {
+ String filePath = ((ImportType) obj).getFile();
+ IFile input = createEditorInput(filePath);
+ if (input != null) {
+ try {
+ IDE.openEditor(SmooksUIActivator.getDefault()
+ .getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage(), input);
+ } catch (PartInitException e) {
+ UIUtils.showErrorDialog(getSite().getShell(), UIUtils
+ .createErrorStatus(e));
+ }
+ }
+ }
+ }
+
+ private IProject getCurrentProject() {
+ IFile file = ((IFileEditorInput) getEditor().getEditorInput())
+ .getFile();
+ if (file != null) {
+ IProject project = file.getProject();
+ return project;
+ }
+ return null;
+ }
+
+ protected IFile createEditorInput(String filePath) {
+ String workspacePath = this.getWorkspaceFilePath(filePath);
+ IProject project = getCurrentProject();
+ if (project != null) {
+ IResource resource = project.findMember(new Path(workspacePath));
+ if (resource instanceof IFile) {
+ return (IFile) resource;
+ }
+ }
+ return null;
+ }
+
+ private Button createFileActionButton(Composite parent, FormToolkit tool,
+ String text) {
+ Button button = tool.createButton(parent, text, SWT.NONE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ button.setLayoutData(gd);
+ return button;
+ }
+
+ 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);
+ }
+
+ });
+
+ addFileButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ addFileImport();
+ }
+
+ });
+
+ removeFileButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ removeFileImport();
+ }
+
+ });
+
+ editFileButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ editFileImport();
+ }
+
+ });
+ }
+
+ protected void editFileImport() {
+ IStructuredSelection selection = (IStructuredSelection) fileViewer
+ .getSelection();
+ Object obj = selection.getFirstElement();
+ if (obj instanceof ImportType) {
+ String filePath = getWorkspaceFilePath(((ImportType) obj).getFile());
+ IProject project = getCurrentProject();
+ if (project != null) {
+ IResource resource = project.findMember(new Path(filePath));
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(
+ getSite().getShell(), "Select Files", "", false,
+ new Object[] { resource }, Collections.EMPTY_LIST);
+ if (files != null) {
+ IPath path1 = files[0].getFullPath().removeFirstSegments(1);
+ String s = path1.toString();
+ if (s.startsWith("/") || s.startsWith("\\")) {
+
+ } else {
+ s = "/" + s;
+ }
+ ((ImportType) obj).setFile("classpath:" + s);
+ fileViewer.refresh();
+ ((SmooksFormEditor) getEditor()).fireEditorDirty(true);
+ }
+ }
+
+ }
+ }
+
+ protected void removeFileImport() {
+ IStructuredSelection selection = (IStructuredSelection) fileViewer
+ .getSelection();
+ NormalSmooksModelPackage modelPackage = getModelPackage();
+ if (modelPackage != null) {
+ modelPackage.getSmooksResourceList().getAbstractResourceConfig()
+ .removeAll(selection.toList());
+ fileViewer.refresh();
+ ((SmooksFormEditor) getEditor()).fireEditorDirty(true);
+ }
+ }
+
+ protected void addFileImport() {
+ IFile[] files = WorkspaceResourceDialog.openFileSelection(getSite()
+ .getShell(), "Select Files", "", false, null,
+ Collections.EMPTY_LIST);
+ if (files != null && files.length > 0) {
+ ImportType fileImport = SmooksFactory.eINSTANCE.createImportType();
+ IPath path1 = files[0].getFullPath().removeFirstSegments(1);
+ String s = path1.toString();
+ if (s.startsWith("/") || s.startsWith("\\")) {
+
+ } else {
+ s = "/" + s;
+ }
+ fileImport.setFile("classpath:" + s);
+ NormalSmooksModelPackage modelPackage = getModelPackage();
+ if (modelPackage != null) {
+ Command command = AddCommand
+ .create(
+ ((SmooksFormEditor) getEditor())
+ .getEditingDomain(),
+ modelPackage.getSmooksResourceList(),
+ SmooksPackage.eINSTANCE
+ .getSmooksResourceListType_AbstractResourceConfig(),
+ fileImport);
+ ((SmooksFormEditor) getEditor()).getEditingDomain()
+ .getCommandStack().execute(command);
+ fileViewer.refresh();
+ ((SmooksFormEditor) getEditor()).fireEditorDirty(true);
+ }
+ }
+ }
+
+ private Button createTypeSelectRadioButton(Composite parent,
+ FormToolkit tool, String labelName) {
+ Button button = tool.createButton(parent, labelName, SWT.RADIO);
+ return button;
+ }
+
+ private String getWorkspaceFilePath(String filePath) {
+ if (filePath == null)
+ return "";
+ if (filePath.indexOf(":") != -1) {
+ int index = filePath.indexOf(":");
+ return filePath.substring(index + 1, filePath.length());
+ }
+ return filePath;
+ }
+
+ /**
+ * @return the modelPackage
+ */
+ public NormalSmooksModelPackage getModelPackage() {
+ return modelPackage;
+ }
+
+ /**
+ * @param modelPackage
+ * the modelPackage to set
+ */
+ public void setModelPackage(NormalSmooksModelPackage modelPackage) {
+ if (modelPackage == this.modelPackage)
+ return;
+ this.modelPackage = modelPackage;
+ if (resourceBlock != null)
+ this.resourceBlock.setModelPackage(this.modelPackage);
+ }
+
+ public void endAnalyze(AnalyzeResult result) {
+ if (result.getError() == null) {
+ disableGUI = false;
+ SmooksFormEditor parentEditor = (SmooksFormEditor) getEditor();
+ NormalSmooksModelPackage pa = parentEditor
+ .createNewSmooksModelPackage();
+ SmooksGraphicalFormPage graphicalEditor = (SmooksGraphicalFormPage) result
+ .getSourceEdtior();
+ MappingResourceConfigList rclist = graphicalEditor
+ .getMappingResourceConfigList();
+ // for make sure that the SmooksResourceConfig model was the same :
+ if (rclist != null) {
+ List<ResourceConfigType> renderList = rclist
+ .getGraphRenderResourceConfigList();
+ if (renderList != null && renderList.size() > 0) {
+ ResourceConfigType resourceConfig = renderList.get(0);
+ SmooksResourceListType rootList = (SmooksResourceListType) resourceConfig
+ .eContainer();
+ if (!(rootList == pa.getSmooksResourceList())) {
+ pa.setSmooksResourceList(rootList);
+ }
+ }
+ pa.setHidenSmooksElements(renderList);
+ }
+ setModelPackage(pa);
+ } else {
+ setModelPackage(null);
+ disableGUI = true;
+ }
+ initOtherConfigurationsGUI();
+ if (resourceBlock != null)
+ this.resourceBlock.initViewers(transformType);
+ setGUIStates();
+ }
+
+ private class FileImportContentProvider implements
+ IStructuredContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List) inputElement).toArray();
+ }
+ return new Object[] {};
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ }
+
+ private class FileImportLabelProvider extends LabelProvider {
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof ImportType) {
+ String path = getWorkspaceFilePath(((ImportType) element)
+ .getFile());
+ IProject project = getCurrentProject();
+ IResource resource = project.findMember(new Path(path));
+ if (resource == null || !resource.exists())
+ return SmooksUIActivator.getDefault().getImageRegistry()
+ .get(SmooksGraphConstants.IMAGE_ERROR);
+ }
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof ImportType) {
+ return getWorkspaceFilePath(((ImportType) element).getFile());
+ }
+ return super.getText(element);
+ }
+
+ }
+}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/modelparser/SmooksConfigurationFileGenerateContext.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -22,6 +22,7 @@
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.graphical.GraphInformations;
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.model.SmooksResourceListType;
import org.jboss.tools.smooks.ui.editors.SmooksGraphicalFormPage;
@@ -43,7 +44,16 @@
protected EditingDomain domain;
protected SmooksGraphicalFormPage smooksGraphcalPage = null;
protected EditDomain gefDomain;
+ protected GraphInformations graphInformations = null;
+ public GraphInformations getGraphInformations() {
+ return graphInformations;
+ }
+
+ public void setGraphInformations(GraphInformations graphInformations) {
+ this.graphInformations = graphInformations;
+ }
+
public SmooksGraphicalFormPage getSmooksGraphcalPage() {
return smooksGraphcalPage;
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/popup/SmooksAction.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/popup/SmooksAction.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/popup/SmooksAction.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -56,7 +56,6 @@
}
public void run(){
-
}
public void selectionChanged(ISelection selection) {
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/AbstractXMLObject.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -16,6 +16,7 @@
import java.util.List;
import org.dom4j.Element;
+import org.dom4j.QName;
import org.jboss.tools.smooks.ui.IXMLStructuredObject;
import org.jboss.tools.smooks.ui.editors.TransformDataTreeViewer;
@@ -72,7 +73,7 @@
this.name = name;
Element element = this.getReferenceElement();
if(element != null){
- element.setName(name);
+ element.setQName(new QName(name,element.getNamespace()));
}
support.firePropertyChange(TransformDataTreeViewer.NODE_PROPERTY_EVENT, oldName, this.name);
}
@@ -115,6 +116,14 @@
support.removePropertyChangeListener(listener);
}
+ public void cleanAllNodePropertyChangeListeners() {
+ PropertyChangeListener[] ps = support.getPropertyChangeListeners();
+ for (int i = 0; i < ps.length; i++) {
+ PropertyChangeListener p = ps[i];
+ support.removePropertyChangeListener(p);
+ }
+ }
+
public List<IXMLStructuredObject> getChildren() {
List children = getXMLNodeChildren();
return children;
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/ITransformTreeNode.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -14,4 +14,6 @@
public void addNodePropetyChangeListener(PropertyChangeListener listener);
public void removeNodePropetyChangeListener(PropertyChangeListener listener);
+
+ public void cleanAllNodePropertyChangeListeners();
}
Modified: trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java
===================================================================
--- trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java 2009-03-06 01:15:19 UTC (rev 14063)
+++ trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/model/XMLObjectAnalyzer.java 2009-03-06 03:25:26 UTC (rev 14064)
@@ -81,6 +81,7 @@
}
protected TagObject parseElement(Element element, TagObject parentTag , String[] ignoreNodeNames) {
+
if(isIgnoreNode(element, ignoreNodeNames))
return null;
boolean canAdd = false;
15 years, 8 months
JBoss Tools SVN: r14063 - branches/jbosstools-3.0.x/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-03-05 20:15:19 -0500 (Thu, 05 Mar 2009)
New Revision: 14063
Modified:
branches/jbosstools-3.0.x/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java
Log:
fix error in JUnit Test
SeamCoreAllTests.testEarProject
Failing for the past 7 builds (Since Unstable#4 )
Took 39 sec.
Error Message: War project must see component 'authenticator' declared in ejb project
Modified: branches/jbosstools-3.0.x/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java
===================================================================
--- branches/jbosstools-3.0.x/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java 2009-03-05 23:49:40 UTC (rev 14062)
+++ branches/jbosstools-3.0.x/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/ProjectImportTestSetup.java 2009-03-06 01:15:19 UTC (rev 14063)
@@ -1,92 +1,96 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.test.util;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-import org.eclipse.core.internal.resources.ResourceException;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * @author eskimo
- *
- */
-public class ProjectImportTestSetup extends TestSetup {
-
- private String bundleName;
- private String[] projectPaths;
- private String[] projectNames;
-
- /**
- * @param test
- */
- public ProjectImportTestSetup(Test test, String bundleName, String projectPath, String projectName) {
- super(test);
- this.bundleName = bundleName;
- this.projectPaths = new String[]{projectPath};
- this.projectNames = new String[]{projectName};
- }
-
- public ProjectImportTestSetup(Test test, String bundleName, String[] projectPaths, String[] projectNames) {
- super(test);
- this.bundleName = bundleName;
- this.projectPaths = projectPaths;
- this.projectNames = projectNames;
- }
-
- public IProject importProject() throws Exception {
- return importProjects()[0];
- }
-
- public IProject[] importProjects() throws Exception {
- IProject[] projects = new IProject[projectPaths.length];
- JobUtils.waitForIdle();
- for (int i = 0; i < projectPaths.length; i++) {
- projects[i] = (IProject)ResourcesUtils.importProject(bundleName, projectPaths[i]);
- JobUtils.waitForIdle();
- }
- return projects;
- }
-
- public static IProject loadProject(String projectName) throws CoreException {
- IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(projectName);
- assertNotNull("Can't load " + projectName, project);
- IProject result = project.getProject();
- try {
- result.build(IncrementalProjectBuilder.FULL_BUILD, null);
- } catch (ResourceException e) {
- JUnitUtils.fail(e.getMessage(), e);
- }
- JobUtils.waitForIdle();
- return result;
- }
-
- @Override
- protected void setUp() throws Exception {
- importProjects();
- }
-
- @Override
- protected void tearDown() throws Exception {
- boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
- JobUtils.waitForIdle();
- for (int i = 0; i < projectNames.length; i++) {
- ResourcesUtils.deleteProject(projectNames[i]);
- JobUtils.waitForIdle();
- }
- ResourcesUtils.setBuildAutomatically(saveAutoBuild);
- }
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.test.util;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.core.internal.resources.ResourceException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * @author eskimo
+ *
+ */
+public class ProjectImportTestSetup extends TestSetup {
+
+ private String bundleName;
+ private String[] projectPaths;
+ private String[] projectNames;
+
+ /**
+ * @param test
+ */
+ public ProjectImportTestSetup(Test test, String bundleName, String projectPath, String projectName) {
+ super(test);
+ this.bundleName = bundleName;
+ this.projectPaths = new String[]{projectPath};
+ this.projectNames = new String[]{projectName};
+ }
+
+ public ProjectImportTestSetup(Test test, String bundleName, String[] projectPaths, String[] projectNames) {
+ super(test);
+ this.bundleName = bundleName;
+ this.projectPaths = projectPaths;
+ this.projectNames = projectNames;
+ }
+
+ public IProject importProject() throws Exception {
+ return importProjects()[0];
+ }
+
+ public IProject[] importProjects() throws Exception {
+ IProject[] projects = new IProject[projectPaths.length];
+ JobUtils.waitForIdle();
+ for (int i = 0; i < projectPaths.length; i++) {
+ projects[i] = (IProject)ResourcesUtils.importProject(bundleName, projectPaths[i]);
+ JobUtils.waitForIdle();
+ }
+ return projects;
+ }
+
+ public static IProject loadProject(String projectName) throws CoreException {
+ IResource project = ResourcesPlugin.getWorkspace().getRoot().findMember(projectName);
+ assertNotNull("Can't load " + projectName, project);
+ IProject result = project.getProject();
+ try {
+ result.build(IncrementalProjectBuilder.FULL_BUILD, null);
+ } catch (ResourceException e) {
+ JUnitUtils.fail(e.getMessage(), e);
+ }
+ JobUtils.waitForIdle();
+ return result;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ importProjects();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
+ JobUtils.waitForIdle();
+ for (int i = 0; i < projectNames.length; i++) {
+ ResourcesUtils.deleteProject(projectNames[i]);
+ JobUtils.waitForIdle();
+ }
+ ResourcesUtils.setBuildAutomatically(saveAutoBuild);
+ }
+
+ public void deleteProjects() throws Exception {
+ tearDown();
+ }
}
\ No newline at end of file
15 years, 8 months
JBoss Tools SVN: r14062 - trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-03-05 18:49:40 -0500 (Thu, 05 Mar 2009)
New Revision: 14062
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
Log:
EL tests were extended to increase coverage
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2009-03-05 22:21:03 UTC (rev 14061)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2009-03-05 23:49:40 UTC (rev 14062)
@@ -139,6 +139,7 @@
checkCorrectEL(t, "\\#{exprA}");
checkCorrectEL(t, "#{\"\\\"exprA\\\"\"}");
checkCorrectEL(t, "#{\"\\\"#\\\"\"}");
+ checkCorrectEL(t,"#{'+'}");
// Ask google :)
// http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#indexterm-357
checkCorrectEL(t,"#{’#{’}exprB}"); //Why this is correct?
@@ -148,6 +149,8 @@
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "#{customer.address[\"street\"]}");
checkCorrectEL(t, "#{customer.address['street']}");
+ checkCorrectEL(t, "#{customer.address[1]}");
+ checkCorrectEL(t, "#{customer.address[customer.address[customer.address[0]]]}");
checkCorrectEL(t, "#{planets[object.counter].mass}");
}
@@ -163,10 +166,95 @@
checkCorrectEL(t, "#{false}");
}
+ public void testReservedWordAnd() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"and");
+ }
+
+ public void testReservedWordOr() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"or");
+ }
+
+ public void testReservedWordNot() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"not");
+ }
+
+ public void testReservedWordEq() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"eq");
+ }
+
+ public void testReservedWordNe() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"ne");
+ }
+ public void testReservedWordLt() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"lt");
+ }
+
+ public void testReservedWordQt() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"qt");
+ }
+
+ public void testReservedWordLe() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"le");
+ }
+
+ public void testReservedWordGe() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"ge");
+ }
+
+ public void testReservedWordTrue() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkIncorrectEL(t, "#{true.method1}", 3);
+ }
+
+ public void testReservedWordFlase() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkIncorrectEL(t, "#{false.method1}", 3);
+ }
+
+ public void testReservedWordNull() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkIncorrectEL(t, "#{null.method1}", 3);
+ }
+
+ public void testReservedWordInstanceof() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"instanceof");
+ }
+
+ public void testReservedWordEmpty() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkIncorrectEL(t, "#{empty.method1}", 3);
+ }
+
+ public void testReservedWordDiv() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"div");
+ }
+
+ public void testReservedWordMod() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ doReservedWordTest(t,"mod");
+ }
+
+ private void doReservedWordTest(Tokenizer t, String keyword) {
+ checkIncorrectEL(t, "#{"+keyword+"}",3);
+ checkIncorrectEL(t, "#{"+keyword+".method1}", 3);
+ checkIncorrectEL(t, "#{"+keyword+"+"+keyword+"}", 3);
+ }
+
public void testComplexMath() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t,
- "#{(7 * (13 + 7.9)) * (a + b.c / d) / (1.E5) - (1/a.b+8./c.d)}");
+ "#{(7 * (13 + 7.9)) * (a + b.c / d) / (1.3E5) - (1/a.b+8./c.d)}");
}
public void testComplexInvocation() {
@@ -197,13 +285,42 @@
checkIncorrectEL(t, "#{a.b + -c.d + g)}", 16);
// 2. Incorrect use of '.' in second EL instance
checkIncorrectEL(t, "#{a.b + -c.d + g}#{hh.vv..m()}", 25);
+ // incorrect operation
+ checkIncorrectEL(t, "#{c.a[1.5E7]}",7);
+ checkIncorrectEL(t, "#{!}", 3);
+ checkIncorrectEL(t, "#{+}", 3);
+ checkIncorrectEL(t, "#{-}", 3);
+ checkIncorrectEL(t, "#{()}", 4);
+ checkIncorrectEL(t, "#{[1]}", 3);
+ checkIncorrectEL(t, "#{%}", 3);
+ checkIncorrectEL(t, "#{:}", 3);
+ checkIncorrectEL(t, "#{/}", 3);
+ checkIncorrectEL(t, "#{*}", 3);
+ checkIncorrectEL(t, "#{&&}", 3);
+ checkIncorrectEL(t, "#{||}", 3);
+ checkIncorrectEL(t, "#{<}", 3);
+ checkIncorrectEL(t, "#{>}", 3);
+ checkIncorrectEL(t, "#{<=}", 3);
+ checkIncorrectEL(t, "#{>=}", 3);
+ checkIncorrectEL(t, "#{==}", 3);
+ checkIncorrectEL(t, "#{!=}", 3);
+ checkIncorrectEL(t, "#{?}", 3);
+ checkIncorrectEL(t, "#{=}", 3);
}
+ public void testLexemas() {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ checkIncorrectEL(t, "#{#identifier}", 3);
+ checkIncorrectEL(t, "#{2identifier}", 3);
+ checkIncorrectEL(t, "#{$identifier}", 3);
+ checkIncorrectEL(t, "#{i1.2methodorproperty}", 6);
+ }
+
private void checkIncorrectEL(Tokenizer t, String test,
int expectedErrorPosition) {
LexicalToken token = t.parse(test);
List<SyntaxError> errors = t.getErrors();
- assertTrue("EL '" + test + "' has syntax problems. ", errors.size() > 0);
+ assertTrue("EL '" + test + "' has no syntax problems. ", errors.size() > 0);
assertEquals(expectedErrorPosition, errors.get(0).getPosition());
String correctPart = test.substring(0, expectedErrorPosition);
String parsed = restore(token);
15 years, 8 months
JBoss Tools SVN: r14061 - trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2009-03-05 17:21:03 -0500 (Thu, 05 Mar 2009)
New Revision: 14061
Modified:
trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
Log:
enable back test for EL expression
#{?\226?\128?\153#{?\226?\128?\153}exprB}
Modified: trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2009-03-05 20:32:23 UTC (rev 14060)
+++ trunk/common/tests/org.jboss.tools.common.el.core.test/src/org/jboss/tools/common/el/core/test/ELParserTest.java 2009-03-05 22:21:03 UTC (rev 14061)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.common.el.core.test;
import java.util.List;
@@ -26,42 +26,44 @@
import junit.framework.TestCase;
public class ELParserTest extends TestCase {
-
- public ELParserTest() {}
-
+
+ public ELParserTest() {
+ }
+
protected void setUp() throws Exception {
}
-
+
public void testTokenizerOnCorrectEL() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- //1. One variable
+ // 1. One variable
checkCorrectEL(t, "#{a}");
- //2. Two EL instances
+ // 2. Two EL instances
checkCorrectEL(t, "#{a}#{b}");
- //3. Property invocation
+ // 3. Property invocation
checkCorrectEL(t, "#{a.b}");
- //4. Argument invocation
+ // 4. Argument invocation
checkCorrectEL(t, "#{a.b['xxx']}");
- //5a. Method invocation
+ // 5a. Method invocation
checkCorrectEL(t, "#{a.b()}");
- //5b. Method invocation with one parameter
+ // 5b. Method invocation with one parameter
checkCorrectEL(t, "#{a.b(c)}");
- //5b. Method invocation with two parameters
+ // 5b. Method invocation with two parameters
checkCorrectEL(t, "#{a.b(c.d , e['u'])}");
- //6. Numeric
+ // 6. Numeric
checkCorrectEL(t, "#{a.b(16.900)}");
- //7. Boolean
+ // 7. Boolean
checkCorrectEL(t, "#{a.b(false)}");
- //8. Operators
+ // 8. Operators
checkCorrectEL(t, "#{a.b(7 + 8) * 4 / 2 - 1}");
- //9. Complex expressions
+ // 9. Complex expressions
checkCorrectEL(t, "#{a.b(7 + 8) * (4 / 2 - 1)/c.d}");
- //10. Complex expressions
- checkCorrectEL(t, "#{a.b(7 + 8) * (4 / 2 - 1)/c.d}");
+ // 10. Complex expressions
+ checkCorrectEL(t, "#{a.b(7 + 8) * (4 / 2 - 1)/c.d}");
}
/**
- * JBIDE-3132 An OutOfMemory exception is thrown by Code assist for "#{messages[ "
+ * JBIDE-3132 An OutOfMemory exception is thrown by Code assist for
+ * "#{messages[ "
*/
public void testJBIDE3132() {
ELParser parser = ELParserUtil.getJbossFactory().createParser();
@@ -74,32 +76,32 @@
public void testElEmptyOperator() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- checkCorrectEL(t, "#{empty a}");
+ checkCorrectEL(t, "#{empty a}");
}
-
+
public void testElLogicalNotOperators() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "#{not a == null}");
checkCorrectEL(t, "#{!a eq null}");
}
-
+
public void testElLogicalAndOperators() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "#{a!=null and a!=1}");
checkCorrectEL(t, "#{a!=null && a!=1}");
}
-
+
public void testElLogicalOrOperators() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "#{a!=null or a!=1}");
checkCorrectEL(t, "#{a!=null || a!=1}");
}
-
+
public void testElConditionalOperator() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "#{a?1:2}");
}
-
+
public void testElRelationalOperator() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "#{a == b}");
@@ -115,9 +117,9 @@
checkCorrectEL(t, "#{a >= b}");
checkCorrectEL(t, "#{a le b}");
checkCorrectEL(t, "#{'a' < 'b'}");
-
+
}
-
+
public void testElArithmeticOperators() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "#{a*b}");
@@ -129,83 +131,91 @@
checkCorrectEL(t, "#{a+b}");
checkCorrectEL(t, "#{-b+1}");
checkCorrectEL(t, "#{-b}");
- }
-
+ }
+
public void testElLiteralExpressions() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- checkCorrectEL(t,"#{\"#{\"}");
- checkCorrectEL(t,"\\#{exprA}");
- checkCorrectEL(t,"#{\"\\\"exprA\\\"\"}");
- checkCorrectEL(t,"#{\"\\\"#\\\"\"}");
- //checkCorrectEL(t,"#{’#’}"); //Why this is correct?
+ checkCorrectEL(t, "#{\"#{\"}");
+ checkCorrectEL(t, "\\#{exprA}");
+ checkCorrectEL(t, "#{\"\\\"exprA\\\"\"}");
+ checkCorrectEL(t, "#{\"\\\"#\\\"\"}");
+ // Ask google :)
+ // http://java.sun.com/javaee/5/docs/tutorial/doc/bnahq.html#indexterm-357
+ checkCorrectEL(t,"#{’#{’}exprB}"); //Why this is correct?
}
-
+
public void testElReferencesObjectProperties() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- checkCorrectEL(t,"#{customer.address[\"street\"]}");
- checkCorrectEL(t,"#{customer.address['street']}");
- checkCorrectEL(t,"#{planets[object.counter].mass}");
+ checkCorrectEL(t, "#{customer.address[\"street\"]}");
+ checkCorrectEL(t, "#{customer.address['street']}");
+ checkCorrectEL(t, "#{planets[object.counter].mass}");
}
-
+
public void testElSimpleTypes() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- checkCorrectEL(t,"#{\"string\"}");
- checkCorrectEL(t,"#{'string'}");
- checkCorrectEL(t,"#{11.0}");
- checkCorrectEL(t,"#{1.2E4}");
- checkCorrectEL(t,"#{null}");
- checkCorrectEL(t,"#{1}");
- checkCorrectEL(t,"#{true}");
- checkCorrectEL(t,"#{false}");
+ checkCorrectEL(t, "#{\"string\"}");
+ checkCorrectEL(t, "#{'string'}");
+ checkCorrectEL(t, "#{11.0}");
+ checkCorrectEL(t, "#{1.2E4}");
+ checkCorrectEL(t, "#{null}");
+ checkCorrectEL(t, "#{1}");
+ checkCorrectEL(t, "#{true}");
+ checkCorrectEL(t, "#{false}");
}
public void testComplexMath() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- checkCorrectEL(t, "#{(7 * (13 + 7.9)) * (a + b.c / d) / (1.E5) - (1/a.b+8./c.d)}");
+ checkCorrectEL(t,
+ "#{(7 * (13 + 7.9)) * (a + b.c / d) / (1.E5) - (1/a.b+8./c.d)}");
}
public void testComplexInvocation() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- checkCorrectEL(t, "#{a.b[a1.b1(a2.b2,a3.b3(x))][y].c(a4.b4,a5.b5[a6(b6)])}");
+ checkCorrectEL(t,
+ "#{a.b[a1.b1(a2.b2,a3.b3(x))][y].c(a4.b4,a5.b5[a6(b6)])}");
}
public void testSeveralELInstances() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
checkCorrectEL(t, "aaa#{a}bbb#{1}#{c()}");
}
-
+
private void checkCorrectEL(Tokenizer t, String test) {
LexicalToken token = t.parse(test);
assertEquals(test, restore(token));
List<SyntaxError> errors = t.getErrors();
- assertEquals("EL '" + test + "' has no syntax problems.", 0, errors.size());
+ assertEquals("EL '" + test + "' has no syntax problems.", 0, errors
+ .size());
System.out.println("Passed correct EL '" + test + "'");
}
public void testTokenizerOnIncorrectEL() {
Tokenizer t = TokenizerFactory.createJbossTokenizer();
- //1. Dot unfollowed by name
+ // 1. Dot unfollowed by name
checkIncorrectEL(t, "#{a.}", 4);
- //2. Incorrect use of ')'
+ // 2. Incorrect use of ')'
checkIncorrectEL(t, "#{a.b + -c.d + g)}", 16);
- //2. Incorrect use of '.' in second EL instance
+ // 2. Incorrect use of '.' in second EL instance
checkIncorrectEL(t, "#{a.b + -c.d + g}#{hh.vv..m()}", 25);
}
- private void checkIncorrectEL(Tokenizer t, String test, int expectedErrorPosition) {
+ private void checkIncorrectEL(Tokenizer t, String test,
+ int expectedErrorPosition) {
LexicalToken token = t.parse(test);
List<SyntaxError> errors = t.getErrors();
assertTrue("EL '" + test + "' has syntax problems. ", errors.size() > 0);
assertEquals(expectedErrorPosition, errors.get(0).getPosition());
String correctPart = test.substring(0, expectedErrorPosition);
String parsed = restore(token);
- assertTrue("Parsed value should be identical to source at least until first problem.", parsed.startsWith(correctPart));
+ assertTrue(
+ "Parsed value should be identical to source at least until first problem.",
+ parsed.startsWith(correctPart));
System.out.println("Passed incorrect EL '" + test + "'");
}
private String restore(LexicalToken token) {
StringBuffer sb = new StringBuffer();
- while(token != null) {
+ while (token != null) {
sb.append(token.getText());
token = token.getNextToken();
}
@@ -216,7 +226,7 @@
static int CALL_NUMBER = 1000;
public void testMultiThreadAccess() {
-
+
final ELParserFactory factory = ELParserUtil.getJbossFactory();
final Random random = new Random();
class Z {
@@ -224,12 +234,15 @@
int parserErrors = 0;
int syntaxErrors = 0;
int expectedSyntaxErrors = 0;
+
synchronized void addParserError() {
parserErrors++;
}
+
synchronized void addSyntaxError() {
syntaxErrors++;
}
+
synchronized void addExpectedSyntaxError() {
expectedSyntaxErrors++;
}
@@ -243,15 +256,19 @@
try {
for (int j = 0; j < CALL_NUMBER; j++) {
boolean addError = random.nextInt(100) < 50;
- if(addError) z.addExpectedSyntaxError();
+ if (addError)
+ z.addExpectedSyntaxError();
ELParser parser = factory.createParser();
- String el = "#{(a + b(c.d" + random.nextInt(1000) + ") + c().k" + (addError ? "." : "") + ") + 9.7}";
+ String el = "#{(a + b(c.d" + random.nextInt(1000)
+ + ") + c().k" + (addError ? "." : "")
+ + ") + 9.7}";
ELModel model = parser.parse(el);
LexicalToken t = model.getFirstToken();
- if(!el.equals(restore(t))) {
+ if (!el.equals(restore(t))) {
z.addParserError();
}
- if(model.getSyntaxErrors() != null && model.getSyntaxErrors().size() > 0) {
+ if (model.getSyntaxErrors() != null
+ && model.getSyntaxErrors().size() > 0) {
z.addSyntaxError();
}
}
@@ -263,21 +280,21 @@
new Thread(r).start();
}
- while(z.counter > 0) {
+ while (z.counter > 0) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
-
+
}
}
- System.out.println("testMultiThreadAccess: Expected syntax errors=" + z.expectedSyntaxErrors);
+ System.out.println("testMultiThreadAccess: Expected syntax errors="
+ + z.expectedSyntaxErrors);
assertEquals(0, z.parserErrors);
assertEquals(z.expectedSyntaxErrors, z.syntaxErrors);
-
-
+
}
}
15 years, 8 months