Author: DartPeng
Date: 2009-01-09 03:06:35 -0500 (Fri, 09 Jan 2009)
New Revision: 12956
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.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/xml2java/analyzer/XML2JavaAnalyzer.java
Log:
JBIDE-3429
synchronize the model for configuration page and graphical page
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2009-01-09
07:32:58 UTC (rev 12955)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2009-01-09
08:06:35 UTC (rev 12956)
@@ -998,8 +998,9 @@
return list;
int startIndex = resourceConfigList.indexOf(current);
for (int i = startIndex; i < resourceConfigList.size(); i++) {
- ResourceConfigType resourceConfig = (ResourceConfigType) resourceConfigList
- .get(i);
+ AbstractResourceConfig abstractRC = (AbstractResourceConfig)
resourceConfigList.get(i);
+ if(!(abstractRC instanceof ResourceConfigType)) continue;
+ ResourceConfigType resourceConfig = (ResourceConfigType) abstractRC;
ResourceType resourceType = resourceConfig.getResource();
String selector = resourceConfig.getSelector();
if (selector != null)
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-01-09
07:32:58 UTC (rev 12955)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-01-09
08:06:35 UTC (rev 12956)
@@ -512,17 +512,14 @@
try {
this.initTransformViewerModel((IEditorSite) getSite(),
getEditorInput());
- } catch (IOWrappedException ex) {
- MessageDialog.openWarning(getSite().getShell(), "Waring", //$NON-NLS-1$
- "Exceptions occurd during parsing Smooks file, no worries");
//$NON-NLS-1$
} catch (Throwable e) {
throwable = e;
}
if (throwable != null) {
this.disableMappingGUI = true;
((SmooksFormEditor) getEditor()).setParseException(true, throwable);
- this.notifyAnalyzeListeners(throwable);
}
+ this.notifyAnalyzeListeners(throwable);
if (initSourceTreeViewerProviders()) {
initSourceTreeViewer();
@@ -558,8 +555,8 @@
problemSection.setLayoutData(gd);
problemSection.setVisible(false);
}
-
- public void refreshAllGUI(InputStream stream){
+
+ public void refreshAllGUI(InputStream stream) {
sourceTreeViewerInputModel = null;
targetTreeViewerInputModel = null;
Throwable throwable = null;
@@ -892,8 +889,8 @@
control.setBackground(ColorConstants.white);
return viewer;
}
-
- public void setDirty(boolean dirty){
+
+ public void setDirty(boolean dirty) {
commandStackChanged = dirty;
}
@@ -913,7 +910,6 @@
builder.setSmooksResource(this.smooksResource);
SmooksConfigurationFileGenerateContext context = this
.getSmooksConfigurationFileGenerateContext();
- Exception exp = null;
this.cleanMappingResourceConfig();
return builder.generateSmooksFile(context, monitor);
}
@@ -1249,12 +1245,17 @@
}
}
- public void analyzeGraphicalModel(InputStream stream) throws IOException, CoreException,
InvocationTargetException {
+ public void analyzeGraphicalModel(InputStream stream) throws IOException,
+ CoreException, InvocationTargetException {
Resource resource = new SmooksResourceFactoryImpl()
.createResource(null);
resource.load(stream, Collections.EMPTY_MAP);
SmooksResourceListType listType = ((DocumentRoot) resource
.getContents().get(0)).getSmooksResourceList();
+ if (smooksResource != null) {
+ smooksResource.getContents().clear();
+ smooksResource.getContents().add(listType.eContainer());
+ }
GraphInformations graph = null;
if (graphicalInformationSaver != null)
graph = graphicalInformationSaver.doLoad();
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-01-09
07:32:58 UTC (rev 12955)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksNormalContentEditFormPage.java 2009-01-09
08:06:35 UTC (rev 12956)
@@ -59,6 +59,7 @@
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;
@@ -563,9 +564,17 @@
.getSourceEdtior();
MappingResourceConfigList rclist = graphicalEditor
.getMappingResourceConfigList();
+ // for make sure that the SmooksResourceConfig model was the same :
if (rclist != null) {
- pa.setHidenSmooksElements(rclist
- .getGraphRenderResourceConfigList());
+ 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 {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2009-01-09
07:32:58 UTC (rev 12955)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2009-01-09
08:06:35 UTC (rev 12956)
@@ -138,7 +138,7 @@
}
// if the resource config was created , return
if (beanID != null) {
- if(isResourceConfigCreated(beanID)){
+ if (isResourceConfigCreated(beanID)) {
return;
}
}
@@ -146,7 +146,7 @@
ResourceConfigType resourceConfigType = SmooksFactory.eINSTANCE
.createResourceConfigType();
context.getGeneratorResourceList().add(resourceConfigType);
- // registe it
+ // registe it
registeCreatedResourceConfig(beanID, resourceConfigType);
// addResourceConfigType(listType, resourceConfigType);
// set the selector string value
@@ -246,8 +246,9 @@
name = "@" + name;
}
AbstractXMLObject parent = sourceModel.getParent();
- while (parent != null && parent.getName() != null && !(parent
instanceof TagList)) {
- if (parent == currentRoot){
+ while (parent != null && parent.getName() != null
+ && !(parent instanceof TagList)) {
+ if (parent == currentRoot) {
isChild = true;
break;
}
@@ -258,19 +259,20 @@
name = resourceConfigSelector + SPACE_SPLITER + name;
}
// if the node is not the child of current root node , reload the name
- if(!isChild){
+ if (!isChild) {
name = sourceModel.getName();
if (sourceModel instanceof TagPropertyObject) {
name = "@" + name;
}
parent = sourceModel.getParent();
- if(parent == null) return name;
- while(!(parent instanceof TagList)){
+ if (parent == null)
+ return name;
+ while (!(parent instanceof TagList)) {
name = name + SPACE_SPLITER + parent.getName();
parent = parent.getParent();
}
}
-
+
return name;
}
@@ -319,8 +321,10 @@
List rlist = listType.getAbstractResourceConfig();
int startIndex = rlist.indexOf(rootResourceConfig);
for (int i = startIndex; i < rlist.size(); i++) {
- ResourceConfigType resourceConfig = (ResourceConfigType) rlist
+ AbstractResourceConfig abstractRC = (AbstractResourceConfig) rlist
.get(i);
+ if(!(abstractRC instanceof ResourceConfigType)) continue;
+ ResourceConfigType resourceConfig = (ResourceConfigType) abstractRC;
ResourceType resource = resourceConfig.getResource();
if (resource == null)
continue;
@@ -487,16 +491,17 @@
// Load the bindings of parameter element:
List<Object> bindings = SmooksModelUtils
.getBindingListFromResourceConfigType(processingConfig);
- // If the resourceConfig was be used , don't to generate binding for it and
return.
- if(isResourceConfigUsed(processingConfig)){
+ // If the resourceConfig was be used , don't to generate binding for it
+ // and return.
+ if (isResourceConfigUsed(processingConfig)) {
return;
- }else{
+ } else {
// when starting to process the ResourceConfig , mark it be used
setResourceConfigUsed(processingConfig);
}
// If the bindings isn't NULL to visit the "property" and
"selector" of
// binding to render the graphical
- if (bindings != null ) {
+ if (bindings != null) {
for (Iterator<Object> iterator = bindings.iterator(); iterator
.hasNext();) {
Object anyType = iterator.next();
@@ -623,7 +628,9 @@
SmooksResourceListType listType) {
List list = listType.getAbstractResourceConfig();
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
- ResourceConfigType resource = (ResourceConfigType) iterator.next();
+ AbstractResourceConfig abstractRC = (AbstractResourceConfig) iterator.next();
+ if(!(abstractRC instanceof ResourceConfigType)) continue;
+ ResourceConfigType resource = (ResourceConfigType) abstractRC;
ResourceType rt = resource.getResource();
if (rt == null)
continue;
@@ -739,19 +746,22 @@
public void registeCreatedResourceConfig(String beanId,
ResourceConfigType resourceConfig) {
- if(beanId == null) return;
+ if (beanId == null)
+ return;
beanId = beanId.trim().toLowerCase();
createdResourceConfigMap.put(beanId, resourceConfig);
}
public ResourceConfigType getCreatedResourceConfig(String beanId) {
- if(beanId == null) return null;
+ if (beanId == null)
+ return null;
beanId = beanId.trim().toLowerCase();
return createdResourceConfigMap.get(beanId);
}
public boolean isResourceConfigCreated(String beanId) {
- if(beanId == null) return false;
+ if (beanId == null)
+ return false;
beanId = beanId.trim().toLowerCase();
return getCreatedResourceConfig(beanId) != null;
}