Author: DartPeng
Date: 2009-03-11 03:57:31 -0400 (Wed, 11 Mar 2009)
New Revision: 14163
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/ui/editors/SmooksGraphicalFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
Log:
JBIDE-3981
If the .graph file didn't record the source data path , when user open the editor , it
will ask user to select the source.
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-11
07:38:46 UTC (rev 14162)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/AbstractJavaBeanBuilder.java 2009-03-11
07:57:31 UTC (rev 14163)
@@ -50,9 +50,9 @@
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);
+ }
}
}
@@ -142,7 +142,7 @@
int endIndex = startIndex1 + removeClass.length();
endIndex++;
if (classArray.length() <= endIndex) {
- endIndex --;
+ endIndex--;
if (classArray.charAt(endIndex - 1) != ';') {
endIndex = startIndex1 + removeClass.length();
}
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-11
07:38:46 UTC (rev 14162)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-03-11
07:57:31 UTC (rev 14163)
@@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
@@ -32,6 +33,7 @@
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.gef.DefaultEditDomain;
import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.KeyHandler;
import org.eclipse.gef.KeyStroke;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.commands.CommandStack;
@@ -125,7 +127,6 @@
import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
import org.jboss.tools.smooks.model.AbstractResourceConfig;
import org.jboss.tools.smooks.model.DocumentRoot;
-import org.jboss.tools.smooks.model.ParamType;
import org.jboss.tools.smooks.model.ResourceConfigType;
import org.jboss.tools.smooks.model.SmooksFactory;
import org.jboss.tools.smooks.model.SmooksResourceListType;
@@ -174,8 +175,14 @@
private CompositeSelectionProvider compositeSelectionProvider = new
CompositeSelectionProvider();
- private final String[] REQUIRED_SOURCE_SELECT_TYPE = new String[] {
"org.jboss.tools.smooks.xml.viewerInitor.xml" };
+ private final String[] REQUIRED_SOURCE_SELECT_TYPE = new String[] {
+ "org.jboss.tools.smooks.ui.viewerInitor.javabean",
+ "org.jboss.tools.smooks.xml.viewerInitor.xml" };
+ private Map requiredSourceCheckMap = new HashMap();
+
+ private Map requiredTargetCheckMap = new HashMap();
+
private List<IAnalyzeListener> analyzeListenerList = new
ArrayList<IAnalyzeListener>();
protected boolean disableMappingGUI = false;
@@ -1336,21 +1343,25 @@
context);
}
}
- if (sourceTreeViewerInputModel == null && sourceDataTypeID != null) {
+ if (!checkDataInput("sourceDataPath") && sourceDataTypeID != null
+ && needCheckSourceDataPath(sourceDataTypeID, targetDataTypeID)) {
SmooksConfigurationFileGenerateContext context =
getSmooksConfigurationFileGenerateContext();
context.setSourceDataTypeID(sourceDataTypeID);
context.setTargetDataTypeID(targetDataTypeID);
sourceTreeViewerInputModel = selectSourceDataSource(
sourceDataTypeID, context);
- if(sourceTreeViewerInputModel != null) setDirty(true);
+ if (sourceTreeViewerInputModel != null)
+ setDirty(true);
}
- if (targetTreeViewerInputModel == null && targetDataTypeID != null) {
+ if (!checkDataInput("targetDataPath") && targetDataTypeID != null
+ && needCheckTargetDataPath(sourceDataTypeID, targetDataTypeID)) {
SmooksConfigurationFileGenerateContext context =
getSmooksConfigurationFileGenerateContext();
context.setSourceDataTypeID(sourceDataTypeID);
context.setTargetDataTypeID(targetDataTypeID);
targetTreeViewerInputModel = selectSourceDataSource(
targetDataTypeID, context);
- if(targetTreeViewerInputModel != null) setDirty(true);
+ if (targetTreeViewerInputModel != null)
+ setDirty(true);
}
smooksResource = this.getSmooksResource();
if (smooksResource != null) {
@@ -1364,6 +1375,40 @@
}
}
+ private boolean needCheckSourceDataPath(String sourceId, String targetId) {
+ String key = sourceId + ":" + targetId;
+ List needList = (List) requiredSourceCheckMap.get(key);
+ if (needList != null) {
+ for (Iterator iterator = needList.iterator(); iterator.hasNext();) {
+ Object k = (Object) iterator.next();
+ if (k.equals(sourceId)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean needCheckTargetDataPath(String sourceId, String targetId) {
+ String key = sourceId + ":" + targetId;
+ List needList = (List) requiredTargetCheckMap.get(key);
+ if (needList != null) {
+ for (Iterator iterator = needList.iterator(); iterator.hasNext();) {
+ Object k = (Object) iterator.next();
+ if (k.equals(targetId)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean checkDataInput(String paramName) {
+ String path = UIUtils
+ .getParamToGraphModel(graphinformations, paramName);
+ return (path != null);
+ }
+
/**
*
* @param listType
@@ -1460,6 +1505,7 @@
if (requiredSelectDataSource(typeID)) {
IStructuredDataCreationWizard wizard1 = ViewerInitorStore
.getInstance().getStructuredDataCreationWizard(typeID);
+ wizard1.init(getEditorSite(), getEditorInput());
WizardDialog dialog1 = new WizardDialog(getSite().getShell(),
wizard1);
((Wizard) wizard1).setWindowTitle("Source Data Selection");
@@ -1489,6 +1535,52 @@
}
}
+ private void initRequiredSourceDataCheckMap() {
+ List l1 = new ArrayList();
+ l1.add("org.jboss.tools.smooks.ui.viewerInitor.javabean");
+ l1.add("org.jboss.tools.smooks.xml.viewerInitor.xml");
+ requiredSourceCheckMap
+ .put(
+ "org.jboss.tools.smooks.ui.viewerInitor.javabean:org.jboss.tools.smooks.xml.viewerInitor.xml",
+ l1);
+ List l2 = new ArrayList();
+ l2.add("org.jboss.tools.smooks.ui.viewerInitor.javabean");
+ requiredSourceCheckMap
+ .put(
+ "org.jboss.tools.smooks.ui.viewerInitor.javabean:org.jboss.tools.smooks.ui.viewerInitor.javabean",
+ l2);
+
+ List l3 = new ArrayList();
+ l3.add("org.jboss.tools.smooks.xml.viewerInitor.xml");
+ requiredSourceCheckMap
+ .put(
+ "org.jboss.tools.smooks.xml.viewerInitor.xml:org.jboss.tools.smooks.xml.viewerInitor.xml",
+ l3);
+ }
+
+ private void initRequiredTargetDataCheckMap() {
+ // List l1 = new ArrayList();
+ // l1.add("org.jboss.tools.smooks.ui.viewerInitor.javabean");
+ // l1.add("org.jboss.tools.smooks.xml.viewerInitor.xml");
+ // requiredTargetCheckMap
+ // .put(
+ //
"org.jboss.tools.smooks.ui.viewerInitor.javabean:org.jboss.tools.smooks.xml.viewerInitor.xml",
+ // l1);
+ // List l2 = new ArrayList();
+ // l2.add("org.jboss.tools.smooks.ui.viewerInitor.javabean");
+ // requiredTargetCheckMap
+ // .put(
+ //
"org.jboss.tools.smooks.ui.viewerInitor.javabean:org.jboss.tools.smooks.ui.viewerInitor.javabean",
+ // l2);
+ //
+ // List l3 = new ArrayList();
+ // l3.add("org.jboss.tools.smooks.xml.viewerInitor.xml");
+ // requiredTargetCheckMap
+ // .put(
+ //
"org.jboss.tools.smooks.xml.viewerInitor.xml:org.jboss.tools.smooks.xml.viewerInitor.xml",
+ // l3);
+ }
+
/*
* (non-Javadoc)
*
@@ -1498,6 +1590,8 @@
*/
public void init(IEditorSite site, IEditorInput input) {
super.init(site, input);
+ initRequiredSourceDataCheckMap();
+ initRequiredTargetDataCheckMap();
FormEditor parentEditor = this.getEditor();
if (parentEditor instanceof SmooksFormEditor) {
editingDomain = ((SmooksFormEditor) parentEditor)
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2009-03-11
07:38:46 UTC (rev 14162)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/utils/UIUtils.java 2009-03-11
07:57:31 UTC (rev 14163)
@@ -775,6 +775,26 @@
}
params.getParam().remove(p);
}
+
+ public static String getParamToGraphModel(GraphInformations graph,String paramName){
+ Params params = graph.getParams();
+ if(params == null){
+ return null;
+ }
+ List<Param> paramList = params.getParam();
+ Param p = null;
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ Param param = (Param) iterator.next();
+ if(paramName.equalsIgnoreCase(param.getName())){
+ p = param;
+ break;
+ }
+ }
+ if(p == null){
+ return null;
+ }
+ return p.getValue();
+ }
public static void addParamToGraphModel(GraphInformations graph,String paramName,String
paramValue){
Params params = graph.getParams();
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2009-03-11
07:38:46 UTC (rev 14162)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2009-03-11
07:57:31 UTC (rev 14163)
@@ -125,7 +125,9 @@
}
return document;
} catch (FileNotFoundException e) {
- throw new InvocationTargetException(e);
+ throw new InvocationTargetException(
+ new Exception(
+ "Can't find the file from .graph file , please make sure the
source/target data xml exists"));
} catch (DocumentException e) {
throw new InvocationTargetException(e);
}
@@ -177,8 +179,9 @@
}
}
} else {
- throw new InvocationTargetException(new Exception(
- "can't load xml file"));
+ throw new InvocationTargetException(
+ new Exception(
+ "Can't load xml file from .graph file , please make sure that the .graph
file records any source/target xml file path"));
}
}
return document;
@@ -188,14 +191,15 @@
// cdata = cdata.replaceAll(":", "-");
int start_index = cdata.indexOf("<");
int end_index = cdata.indexOf(">");
- if(start_index == -1 || end_index == -1) return cdata;
- String contents = cdata.substring(start_index,end_index);
-
if(contents.indexOf("\"http://www.w3.org/1999/XSL/Transform\&qu... !=
-1){
+ if (start_index == -1 || end_index == -1)
return cdata;
+ String contents = cdata.substring(start_index, end_index);
+ if (
contents.indexOf("\"http://www.w3.org/1999/XSL/Transform\"... !=
-1) {
+ return cdata;
}
-
- String second_frg = cdata.substring(end_index,cdata.length());
-
+
+ String second_frg = cdata.substring(end_index, cdata.length());
+
cdata = contents + XSL_NAMESPACE + second_frg;
return cdata;
}