Author: DartPeng
Date: 2008-10-22 06:05:13 -0400 (Wed, 22 Oct 2008)
New Revision: 11070
Added:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLTargetModelAnalyzer.java
Removed:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStructuredDataCreationWizard.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java
Log:
JBIDE-2945
1.Change the data path keys' value of graphical information file .
The old keys' value is "xmlFile".
The new keys' value is "sourceDataPath" or "targetDataPath".
2.Add a extension to make the tools can parse the target xml data type.
3.Modify the creation wizard , if user don't select the source and target both , the
wizard can't finish.
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/plugin.xml 2008-10-22
10:05:13 UTC (rev 11070)
@@ -154,8 +154,13 @@
</mappingAnalyzer>
<sourceModelAnalyzer
class="org.jboss.tools.smooks.xml2java.analyzer.XMLSourceModelAnalyzer"
- name="XML"
+ name="XML Source"
typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
</sourceModelAnalyzer>
+ <targetModelAnalyzer
+
class="org.jboss.tools.smooks.xml2java.analyzer.XMLTargetModelAnalyzer"
+ name="XML Target"
+ typeID="org.jboss.tools.smooks.xml.viewerInitor.xml">
+ </targetModelAnalyzer>
</extension>
</plugin>
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/util/GraphicalInformationSaver.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -42,7 +42,7 @@
private IEditorInput input;
protected Resource graphicalFileResource;
-
+
private IFile file = null;
/**
@@ -114,6 +114,12 @@
public void doSave(IProgressMonitor monitor, String sourceid,
String targetid) throws IOException, CoreException {
+ this.doSave(monitor, sourceid,targetid,null);
+ }
+
+ public void doSave(IProgressMonitor monitor, String sourceid,
+ String targetid, Properties properties) throws IOException,
+ CoreException {
GraphInformations graph = null;
if (graphicalFileResource != null) {
if (graphicalFileResource.getContents().isEmpty()) {
@@ -125,10 +131,15 @@
}
if (graph != null) {
initMappingTypes(graph, sourceid, targetid);
+ Params params = GraphicalFactory.eINSTANCE.createParams();
+ graph.setParams(params);
+ initParams(params, properties);
}
graphicalFileResource.save(Collections.EMPTY_MAP);
- if(this.file != null) file.refreshLocal(IResource.DEPTH_ONE, monitor);
+ if (this.file != null)
+ file.refreshLocal(IResource.DEPTH_ONE, monitor);
}
+
}
public void doSave(IProgressMonitor monitor,
@@ -136,36 +147,18 @@
CoreException {
String sourceID = context.getSourceDataTypeID();
String targetID = context.getTargetDataTypeID();
- GraphInformations graph = null;
- if (graphicalFileResource != null) {
- if (graphicalFileResource.getContents().isEmpty()) {
- graph = GraphicalFactory.eINSTANCE.createGraphInformations();
- graphicalFileResource.getContents().add(graph);
- } else {
- graph = (GraphInformations) graphicalFileResource.getContents()
- .get(0);
- }
- if (graph != null) {
- initMappingTypes(graph, sourceID, targetID);
- Params params = GraphicalFactory.eINSTANCE.createParams();
- graph.setParams(params);
- initParams(params, context);
- }
- graphicalFileResource.save(Collections.EMPTY_MAP);
- if(this.file != null) file.refreshLocal(IResource.DEPTH_ONE, monitor);
- }
-
+ Properties properties = context.getProperties();
+ this.doSave(monitor, sourceID,targetID,properties);
}
- private void initParams(Params params,
- SmooksConfigurationFileGenerateContext context) {
- Properties pros = context.getProperties();
- Enumeration<Object> keys = pros.keys();
+ private void initParams(Params params, Properties properties) {
+ if(properties == null) return;
+ Enumeration<Object> keys = properties.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
Param param = GraphicalFactory.eINSTANCE.createParam();
param.setName(key);
- param.setValue(pros.getProperty(key));
+ param.setValue(properties.getProperty(key));
params.getParam().add(param);
}
}
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -41,6 +41,8 @@
import org.jboss.tools.smooks.analyzer.MappingResourceConfigList;
import org.jboss.tools.smooks.analyzer.SmooksAnalyzerException;
import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.jboss.tools.smooks.graphical.Param;
+import org.jboss.tools.smooks.graphical.Params;
import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
import org.jboss.tools.smooks.javabean.model.JavaBeanModelFactory;
import org.jboss.tools.smooks.model.AbstractResourceConfig;
@@ -76,6 +78,10 @@
public static final String SPACE_STRING = " ";
+ private static final int TARGET_DATA = 1;
+
+ private static final int SOURCE_DATA = 0;
+
private List usedConnectionList = new ArrayList();
private ComposedAdapterFactory adapterFactory;
@@ -350,7 +356,7 @@
AbstractStructuredDataModel sourceModel) {
JavaBeanModel source = (JavaBeanModel) sourceModel
.getReferenceEntityModel();
- if(source.getBeanClass().isArray()){
+ if (source.getBeanClass().isArray()) {
return source.getName();
}
if (Collection.class.isAssignableFrom(source.getBeanClass())) {
@@ -491,7 +497,11 @@
/*
* (non-Javadoc)
*
- * @see
org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel(org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext)
+ * @see
+ * org.jboss.tools.smooks.analyzer.IMappingAnalyzer#analyzeMappingGraphModel
+ * (
+ * org.jboss.tools.smooks.ui.modelparser.SmooksConfigurationFileGenerateContext
+ * )
*/
public void analyzeMappingGraphModel(
SmooksConfigurationFileGenerateContext context)
@@ -541,7 +551,8 @@
}
String beanClass = SmooksModelUtils.getParmaText(
"beanClass", rc);
- if (targetName!=null && targetName.trim().equals(beanClass)) {
+ if (targetName != null
+ && targetName.trim().equals(beanClass)) {
setSelectorIsUsed(sourceName);
// create the first connection
mappingModelList.add(new MappingModel(source, target));
@@ -649,6 +660,27 @@
return null;
}
+ private String getDataSourceClass(GraphInformations info, int dataMode) {
+ String key = "sourceDataPath";
+ if (dataMode == SOURCE_DATA) {
+ key = "sourceDataPath";
+ }
+ if (dataMode == TARGET_DATA) {
+ key = "targetDataPath";
+ }
+
+ Params params = info.getParams();
+ 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 Object buildSourceInputObjects(GraphInformations graphInfo,
SmooksResourceListType listType, IFile sourceFile,
ClassLoader classLoader) throws InvocationTargetException {
@@ -673,9 +705,12 @@
}
}
}
-
- if (rootClassName == null)
+ if (rootClassName == null) {
+ rootClassName = this.getDataSourceClass(graphInfo, SOURCE_DATA);
+ }
+ if (rootClassName == null) {
return null;
+ }
boolean isWarning = false;
boolean isError = false;
@@ -756,10 +791,16 @@
}
}
}
- if (current == null)
+ if (current == null) {
+ rootClassName = this.getDataSourceClass(graphInfo, TARGET_DATA);
+ }
+ // if can't load the source from GraphicalInformation , return NULL
+ if (current == null && rootClassName == null)
return null;
Class rootClass = null;
- rootClassName = SmooksModelUtils.getParmaText("beanClass", current);
+ if (rootClassName == null) {
+ rootClassName = SmooksModelUtils.getParmaText("beanClass", current);
+ }
if (rootClassName != null && loader != null) {
try {
rootClass = loader.loadClass(rootClassName);
@@ -801,9 +842,6 @@
String selector = SmooksModelUtils
.getAttributeValueFromAnyType(binding,
SmooksModelUtils.ATTRIBUTE_SELECTOR);
- // if(property == null){
- // continue;
- // }
processBindingPropertyFromTargetModel(listType, property,
selector, beanModel, classLoader);
}
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/javabean/ui/NewJavaBeanStrucutredDataWizard.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -27,6 +27,7 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
import org.jboss.tools.smooks.ui.IStructuredDataCreationWizard;
import org.jboss.tools.smooks.ui.SmooksUIActivator;
@@ -34,24 +35,30 @@
* @author Dart Peng
* @Date Aug 5, 2008
*/
-public class NewJavaBeanStrucutredDataWizard extends Wizard implements
IStructuredDataCreationWizard,INewWizard{
+public class NewJavaBeanStrucutredDataWizard extends Wizard implements
+ IStructuredDataCreationWizard, INewWizard {
JavaBeanConfigWizardPage page = null;
IJavaProject project = null;
Object result = null;
Properties properties = new Properties();
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
@Override
public void addPages() {
super.addPages();
- if(page == null){
+ if (page == null) {
page = new JavaBeanConfigWizardPage(project);
this.addPage(page);
}
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
@@ -67,12 +74,12 @@
}
public void init(IEditorSite site, IEditorInput input) {
- if(input != null && input instanceof IFileEditorInput){
- IFileEditorInput fi = (IFileEditorInput)input;
+ if (input != null && input instanceof IFileEditorInput) {
+ IFileEditorInput fi = (IFileEditorInput) input;
IProject project = fi.getFile().getProject();
- if(project instanceof IJavaProject){
- this.project = (IJavaProject)project;
- }else{
+ if (project instanceof IJavaProject) {
+ this.project = (IJavaProject) project;
+ } else {
this.project = JavaCore.create(project);
}
}
@@ -87,23 +94,34 @@
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
- if(selection != null){
+ if (selection != null) {
Object obj = selection.getFirstElement();
- if(obj instanceof JavaProject){
- this.project = (JavaProject)obj;
+ if (obj instanceof JavaProject) {
+ this.project = (JavaProject) obj;
}
- if(obj instanceof IResource){
- IProject project = ((IResource)obj).getProject();
+ if (obj instanceof IResource) {
+ IProject project = ((IResource) obj).getProject();
this.project = JavaCore.create(project);
}
-
- if(project == null){
- if(obj instanceof IAdaptable){
- IResource relateResource =(IResource)
((IAdaptable)obj).getAdapter(IResource.class);
+
+ if (project == null) {
+ if (obj instanceof IAdaptable) {
+ IResource relateResource = (IResource) ((IAdaptable) obj)
+ .getAdapter(IResource.class);
IProject project = relateResource.getProject();
this.project = JavaCore.create(project);
}
}
}
}
+
+ public String getStructuredDataSourcePath() {
+ JavaBeanModel model = page.getJavaBeanModel();
+ if (model != null) {
+ Class clazz = model.getBeanClass();
+ if (clazz != null)
+ return clazz.getName();
+ }
+ return null;
+ }
}
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStructuredDataCreationWizard.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStructuredDataCreationWizard.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/IStructuredDataCreationWizard.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -31,4 +31,6 @@
public Properties getProperties();
+ public String getStructuredDataSourcePath();
+
}
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -913,7 +913,7 @@
protected void initTransformViewerModel(IEditorSite site, IEditorInput input)
throws Throwable {
graphicalInformationSaver = new GraphicalInformationSaver(input);
-
+
GraphInformations graph = null;
try {
graph = graphicalInformationSaver.doLoad();
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/TypeIDSelectionWizardPage.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -116,8 +116,18 @@
}
return false;
}
+
+
@Override
+ public boolean isPageComplete() {
+ if (this.getSourceID() != null && getTargetID() != null) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
public IWizardPage getNextPage() {
String sourceID = this.getSourceID();
String targetID = this.getTargetID();
@@ -280,7 +290,6 @@
protected void openTargetWizard() {
targetTreeViewerInputContents = getReturnObjectFromWizard(getTargetID());
- resetLinkText();
}
protected IWizard getWizardViaDataID(String dataID) {
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -6,6 +6,7 @@
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
@@ -42,6 +43,10 @@
public class SmooksConfigFileNewWizard extends Wizard implements INewWizard,
ISmooksDataCreationAddtionWizard {
+ public static final String PRO_SOURCE_DATA_PATH = "sourceDataPath";
+
+ public static final String PRO_TARGET_DATA_PATH = "targetDataPath";
+
private SmooksConfigFileNewWizardPage page;
private TypeIDSelectionWizardPage typeIDPage;
@@ -60,7 +65,8 @@
super();
setNeedsProgressMonitor(true);
super.setWindowTitle("New Smooks Configuration File");
- setDefaultPageImageDescriptor(ModelUIImages.getImageDescriptor(ModelUIImages.WIZARD_NEW_PROJECT));
+ setDefaultPageImageDescriptor(ModelUIImages
+ .getImageDescriptor(ModelUIImages.WIZARD_NEW_PROJECT));
}
/**
@@ -118,9 +124,10 @@
private void doFinish(final IFile file, IProgressMonitor monitor)
throws CoreException {
// create a sample file
- String sourceTypeID = typeIDPage.getSourceID();
- String targetTypeID = typeIDPage.getTargetID();
-
+ final String sourceTypeID = typeIDPage.getSourceID();
+ final String targetTypeID = typeIDPage.getTargetID();
+ final String[] sourceDataPath = new String[] { null };
+ final String[] targetDataPath = new String[] { null };
try {
InputStream stream = openContentStream();
if (file.exists()) {
@@ -129,11 +136,12 @@
file.create(stream, true, monitor);
}
stream.close();
- GraphicalInformationSaver ginforSave = new GraphicalInformationSaver(
- file);
- ginforSave.doSave(monitor, sourceTypeID, targetTypeID);
} catch (IOException e) {
+ // ignore
}
+ final GraphicalInformationSaver ginforSave = new GraphicalInformationSaver(
+ file);
+
monitor.worked(1);
monitor.setTaskName("Opening file for editing...");
getShell().getDisplay().asyncExec(new Runnable() {
@@ -156,32 +164,41 @@
if (sourceWizard instanceof IStructuredDataCreationWizard) {
Object sourceObj = ((IStructuredDataCreationWizard) sourceWizard)
.getTreeViewerInputContents();
-// if (sourceObj instanceof List) {
-// if (!((List) sourceObj).isEmpty()) {
-// sourceObj = ((List) sourceObj).get(0);
-// }
-// }
+ sourceDataPath[0] = ((IStructuredDataCreationWizard) sourceWizard)
+ .getStructuredDataSourcePath();
input.setSourceTreeViewerInputContents(sourceObj);
}
if (targetWizard instanceof IStructuredDataCreationWizard) {
Object targetObj = ((IStructuredDataCreationWizard) targetWizard)
.getTreeViewerInputContents();
-// if (targetObj instanceof List) {
-// if (!((List) targetObj).isEmpty()) {
-// targetObj = ((List) targetObj).get(0);
-// }
-// }
+ targetDataPath[0] = ((IStructuredDataCreationWizard) targetWizard)
+ .getStructuredDataSourcePath();
input.setTargetTreeViewerInputContents(targetObj);
}
-
+ Properties properties = null;
+ if (sourceDataPath[0] != null || targetDataPath[0] != null) {
+ properties = new Properties();
+ if (sourceDataPath[0] != null) {
+ properties.setProperty(PRO_SOURCE_DATA_PATH, sourceDataPath[0]);
+ }
+ if (targetDataPath[0] != null) {
+ properties.setProperty(PRO_TARGET_DATA_PATH, targetDataPath[0]);
+ }
+ }
+ try {
+ ginforSave.doSave(null, sourceTypeID, targetTypeID, properties);
+ } catch (IOException e) {
+ } catch (CoreException e) {
+ }
IDE.openEditor(page, input, SmooksFormEditor.EDITOR_ID,
true);// openEditor(page, file, true);
} catch (PartInitException e) {
}
}
});
+
monitor.worked(1);
}
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizardPage.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -16,11 +16,13 @@
super.setTitle("Smooks Configuration");
super.setDescription("Create a new Smooks configuration file");
this.setFileName("newConfig.smooks");
+ this.setAllowExistingResources(false);
}
@Override
protected boolean validatePage() {
boolean flag = super.validatePage();
+ if(!flag) return flag;
String name = this.getFileName();
if (name.indexOf(".") == -1)
return flag;
Deleted:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -1,233 +0,0 @@
-package org.jboss.tools.smooks.ui.wizards;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.IDialogPage;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ContainerSelectionDialog;
-
-/**
- * The "New" wizard page allows setting the container for the new file as well
- * as the file name. The page will only accept file name without the extension
- * OR with the extension that matches the expected one (smooks).
- */
-
-public class SmooksNewWizardPage extends WizardPage {
- private Text containerText;
-
- private Text fileText;
-
- private ISelection selection;
-
- private Combo typeSelectCombo;
-
- /**
- * Constructor for SampleNewWizardPage.
- *
- * @param pageName
- */
- public SmooksNewWizardPage(ISelection selection) {
- super("wizardPage");
- setTitle("Multi-page Editor File");
- setDescription("This wizard creates a new file with *.smooks extension that can be
opened by a multi-page editor.");
- this.selection = selection;
- }
-
- /**
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
-// if(true){
-// Button bu = new Button(parent,SWT.BORDER);
-// bu.setText("BUTTON");
-// this.setControl(bu);
-// return;
-// }
-// parent.setLayout(new FillLayout());
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 3;
- layout.verticalSpacing = 9;
- Label label = new Label(container, SWT.NULL);
- label.setText("&Container:");
-
- containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- containerText.setLayoutData(gd);
- containerText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- dialogChanged();
- }
- });
-
- Button button = new Button(container, SWT.PUSH);
- button.setText("Browse...");
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleBrowse();
- }
- });
- {
- Label l = new Label(container, SWT.NULL);
- l.setText("Trasform Type:");
-
- typeSelectCombo = new Combo(container, SWT.BORDER | SWT.READ_ONLY);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- typeSelectCombo.setLayoutData(gd);
- typeSelectCombo.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent evt) {
-
- }
-
- public void widgetSelected(SelectionEvent evt) {
- dialogChanged();
- }
-
- });
- }
- {
- label = new Label(container, SWT.NULL);
- label.setText("&File name:");
-
- fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- fileText.setLayoutData(gd);
- fileText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- dialogChanged();
- }
- });
- }
-
-
- initTypeSelectCombo();
- initialize();
- dialogChanged();
- setControl(container);
- }
-
- protected void initTypeSelectCombo() {
- typeSelectCombo.add("Java2Java");
- }
-
- /**
- * Tests if the current workbench selection is a suitable container to use.
- */
-
- private void initialize() {
- if (selection != null && selection.isEmpty() == false
- && selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) selection;
- if (ssel.size() > 1)
- return;
- Object obj = ssel.getFirstElement();
- if (obj instanceof IResource) {
- IContainer container;
- if (obj instanceof IContainer)
- container = (IContainer) obj;
- else
- container = ((IResource) obj).getParent();
- containerText.setText(container.getFullPath().toString());
- }
- }
- fileText.setText("smooks-config.smooks");
- }
-
- /**
- * Uses the standard container selection dialog to choose the new value for
- * the container field.
- */
-
- private void handleBrowse() {
- ContainerSelectionDialog dialog = new ContainerSelectionDialog(
- getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
- "Select new file container");
- if (dialog.open() == ContainerSelectionDialog.OK) {
- Object[] result = dialog.getResult();
- if (result.length == 1) {
- containerText.setText(((Path) result[0]).toString());
- }
- }
- }
-
- /**
- * Ensures that both text fields are set.
- */
-
- private void dialogChanged() {
- IResource container = ResourcesPlugin.getWorkspace().getRoot()
- .findMember(new Path(getContainerName()));
- String fileName = getFileName();
-
- int index = typeSelectCombo.getSelectionIndex();
-
- if (index == -1) {
- updateStatus("Please select transform type");
- return;
- }
-
- if (getContainerName().length() == 0) {
- updateStatus("File container must be specified");
- return;
- }
- if (container == null
- || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
- updateStatus("File container must exist");
- return;
- }
- if (!container.isAccessible()) {
- updateStatus("Project must be writable");
- return;
- }
- if (fileName.length() == 0) {
- updateStatus("File name must be specified");
- return;
- }
- if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
- updateStatus("File name must be valid");
- return;
- }
- int dotLoc = fileName.lastIndexOf('.');
- if (dotLoc != -1) {
- String ext = fileName.substring(dotLoc + 1);
- if (ext.equalsIgnoreCase("smooks") == false) {
- updateStatus("File extension must be \"smooks\"");
- return;
- }
- }
- updateStatus(null);
- }
-
- private void updateStatus(String message) {
- setErrorMessage(message);
- setPageComplete(message == null);
- }
-
- public String getContainerName() {
- return containerText.getText();
- }
-
- public String getFileName() {
- return fileText.getText();
- }
-}
\ No newline at end of file
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractFileSelectionWizardPage.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -62,6 +62,7 @@
public String getFilePath(){
return fileText.getText();
}
+
/*
* (non-Javadoc)
*
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/AbstractStructuredDdataWizard.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -17,31 +17,29 @@
*
*/
public abstract class AbstractStructuredDdataWizard extends Wizard implements
- IStructuredDataCreationWizard ,INewWizard{
+ IStructuredDataCreationWizard, INewWizard {
protected IWorkbench workbench;
-
+
protected IStructuredSelection selection;
-
+
protected AbstractFileSelectionWizardPage page = null;
- protected Object xsdElement = null;
+ protected Object xsdElement = null;
protected IWizardNode strucutredDataCreationWizardNode;
- /**
- *
- */
+
public AbstractStructuredDdataWizard() {
// TODO Auto-generated constructor stub
}
@Override
public void addPages() {
- if(page == null){
+ if (page == null) {
page = createAbstractFileSelectionWizardPage();
page.setSelection(this.selection);
}
this.addPage(page);
}
- abstract protected AbstractFileSelectionWizardPage
createAbstractFileSelectionWizardPage() ;
+ abstract protected AbstractFileSelectionWizardPage
createAbstractFileSelectionWizardPage();
/*
* (non-Javadoc)
@@ -53,18 +51,28 @@
xsdElement = this.page.getReturnValue();
return true;
}
+
public Object getTreeViewerInputContents() {
return xsdElement;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.ui.IStructuredDataCreationWizard#
+ * getStructuredDataSourcePath()
+ */
+ public String getStructuredDataSourcePath() {
+ return page.getFilePath();
+ }
+
public void init(IEditorSite site, IEditorInput input) {
-
+
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
this.workbench = workbench;
this.selection = selection;
}
-
-
+
}
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml/ui/XMLStructuredDataWizard.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -35,7 +35,7 @@
public boolean performFinish() {
filePath = page.getFilePath();
- properties.put(XML_FILE, filePath);
+// properties.put(XML_FILE, filePath);
return super.performFinish();
}
Added:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
(rev 0)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * 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.xml2java.analyzer;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.dom4j.DocumentException;
+import org.eclipse.core.resources.IFile;
+import org.jboss.tools.smooks.analyzer.ISourceModelAnalyzer;
+import org.jboss.tools.smooks.analyzer.ITargetModelAnalyzer;
+import org.jboss.tools.smooks.graphical.GraphInformations;
+import org.jboss.tools.smooks.graphical.Param;
+import org.jboss.tools.smooks.graphical.Params;
+import org.jboss.tools.smooks.model.SmooksResourceListType;
+import org.jboss.tools.smooks.xml.model.DocumentObject;
+import org.jboss.tools.smooks.xml.model.XMLObjectAnalyzer;
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 23, 2008
+ */
+public class AbstractXMLModelAnalyzer implements ISourceModelAnalyzer ,
ITargetModelAnalyzer {
+
+ private String parmaKey = "";
+
+ public AbstractXMLModelAnalyzer(String paramKey){
+ this.parmaKey = paramKey;
+ }
+
+ public Object buildSourceInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException {
+ Params params = graphInfo.getParams();
+ String path = null;
+ if (params != null) {
+ List<Param> paramList = graphInfo.getParams().getParam();
+ for (Iterator<Param> iterator = paramList.iterator(); iterator
+ .hasNext();) {
+ Param param = (Param) iterator.next();
+ if (param.getName().equals(parmaKey)) {
+ path = param.getValue();
+ break;
+ }
+ }
+ }
+ if (path == null) {
+ // TODO tell user the filepath can't find or not ?
+ return null;
+// throw new InvocationTargetException(new Exception(
+// "xml file path can't find in the graphInfo file"));
+ }
+ XMLObjectAnalyzer objectBuilder = new XMLObjectAnalyzer();
+ try {
+ FileInputStream stream = new FileInputStream(path);
+ DocumentObject document = objectBuilder.analyze(stream);
+ return document;
+ } catch (FileNotFoundException e) {
+ throw new InvocationTargetException(e);
+ } catch (DocumentException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+
+ public Object buildTargetInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException {
+ return buildSourceInputObjects(graphInfo,listType,sourceFile);
+ }
+}
Property changes on:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/AbstractXMLModelAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XML2JavaAnalyzer.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -218,6 +218,8 @@
JavaBeanModel sourceTarget = (JavaBeanModel) targetObject;
ResourceConfigType rootResourceConfig = findFirstMappingResourceConfig(listType);
+ // if can't find the root , return null
+ if(rootResourceConfig ==null) return null;
String xmlName = rootResourceConfig.getSelector();
AbstractXMLObject source = findXMLObjectByName(xmlName, sourceRoot);
if (source == null)
Modified:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java 2008-10-22
09:32:41 UTC (rev 11069)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLSourceModelAnalyzer.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -10,63 +10,15 @@
******************************************************************************/
package org.jboss.tools.smooks.xml2java.analyzer;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.dom4j.DocumentException;
-import org.eclipse.core.resources.IFile;
-import org.jboss.tools.smooks.analyzer.ISourceModelAnalyzer;
-import org.jboss.tools.smooks.graphical.GraphInformations;
-import org.jboss.tools.smooks.graphical.Param;
-import org.jboss.tools.smooks.graphical.Params;
-import org.jboss.tools.smooks.model.SmooksResourceListType;
-import org.jboss.tools.smooks.xml.model.AbstractXMLObject;
-import org.jboss.tools.smooks.xml.model.DocumentObject;
-import org.jboss.tools.smooks.xml.model.XMLObjectAnalyzer;
-
/**
* @author Dart Peng<br>
* Date : Sep 23, 2008
*/
-public class XMLSourceModelAnalyzer implements ISourceModelAnalyzer {
+public class XMLSourceModelAnalyzer extends AbstractXMLModelAnalyzer{
- public static final String XML_FILE = "xmlFile";
-
- public Object buildSourceInputObjects(GraphInformations graphInfo,
- SmooksResourceListType listType, IFile sourceFile)
- throws InvocationTargetException {
- Params params = graphInfo.getParams();
- String path = null;
- if (params != null) {
- List<Param> paramList = graphInfo.getParams().getParam();
- for (Iterator<Param> iterator = paramList.iterator(); iterator
- .hasNext();) {
- Param param = (Param) iterator.next();
- if (param.getName().equals(XML_FILE)) {
- path = param.getValue();
- break;
- }
- }
- }
- if (path == null) {
- // TODO tell user the filepath can't find or not ?
- return null;
-// throw new InvocationTargetException(new Exception(
-// "xml file path can't find in the graphInfo file"));
- }
- XMLObjectAnalyzer objectBuilder = new XMLObjectAnalyzer();
- try {
- FileInputStream stream = new FileInputStream(path);
- DocumentObject document = objectBuilder.analyze(stream);
- return document;
- } catch (FileNotFoundException e) {
- throw new InvocationTargetException(e);
- } catch (DocumentException e) {
- throw new InvocationTargetException(e);
- }
+ public XMLSourceModelAnalyzer() {
+ super("sourceDataPath");
}
+
}
Added:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLTargetModelAnalyzer.java
===================================================================
---
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLTargetModelAnalyzer.java
(rev 0)
+++
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLTargetModelAnalyzer.java 2008-10-22
10:05:13 UTC (rev 11070)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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.xml2java.analyzer;
+
+
+/**
+ * @author Dart Peng<br>
+ * Date : Sep 23, 2008
+ */
+public class XMLTargetModelAnalyzer extends AbstractXMLModelAnalyzer{
+
+ public XMLTargetModelAnalyzer() {
+ super("targetDataPath");
+ }
+
+}
Property changes on:
branches/jbosstools-3.0.0.Beta1/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/xml2java/analyzer/XMLTargetModelAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain