Author: DartPeng
Date: 2009-03-06 03:21:05 -0500 (Fri, 06 Mar 2009)
New Revision: 14071
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/wizards/SmooksConfigFileNewWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
Log:
JBIDE-3948
when create a new file , the tool will generate the "stream.filter.type";
when open a file , if the file don't have the "stream.filter.type" , the
tool will add that automatically
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
07:47:33 UTC (rev 14070)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2009-03-06
08:21:05 UTC (rev 14071)
@@ -123,9 +123,14 @@
import org.jboss.tools.smooks.graphical.Param;
import org.jboss.tools.smooks.graphical.Params;
import org.jboss.tools.smooks.graphical.util.GraphicalInformationSaver;
+import org.jboss.tools.smooks.model.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;
import org.jboss.tools.smooks.model.util.SmooksModelConstants;
+import org.jboss.tools.smooks.model.util.SmooksModelUtils;
import org.jboss.tools.smooks.model.util.SmooksResourceFactoryImpl;
import org.jboss.tools.smooks.ui.AnalyzeResult;
import org.jboss.tools.smooks.ui.IAnalyzeListener;
@@ -1328,9 +1333,47 @@
return;
SmooksResourceListType listType = ((DocumentRoot) smooksResource
.getContents().get(0)).getSmooksResourceList();
+ checkSmooksConfigFileModel(listType);
this.analyzeGraphicalModel(listType, graphinformations, file);
}
}
+
+ /**
+ *
+ * @param listType
+ */
+ protected void checkSmooksConfigFileModel(SmooksResourceListType listType){
+ List<AbstractResourceConfig> list = listType.getAbstractResourceConfig();
+ ResourceConfigType globalParameterResource = null;
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ AbstractResourceConfig arc = (AbstractResourceConfig) iterator
+ .next();
+ if(arc instanceof ResourceConfigType){
+ String selector = ((ResourceConfigType)arc).getSelector();
+ if(selector == null) continue;
+ selector = selector.trim();
+ if(SmooksModelConstants.GLOBAL_PARAMETERS.equals(selector)){
+ globalParameterResource = (ResourceConfigType)arc;
+ break;
+ }
+ }
+ }
+
+ if(globalParameterResource == null){
+ globalParameterResource = SmooksFactory.eINSTANCE.createResourceConfigType();
+ globalParameterResource.setSelector(SmooksModelConstants.GLOBAL_PARAMETERS);
+ SmooksModelUtils.setParamText("stream.filter.type", "SAX",
globalParameterResource);
+ }else{
+ String value = SmooksModelUtils.getParmaText("stream.filter.type",
globalParameterResource);
+ if(value == null){
+ SmooksModelUtils.setParamText("stream.filter.type", "SAX",
globalParameterResource);
+ }else{
+ if(value.trim().length() == 0){
+ SmooksModelUtils.setParamText("stream.filter.type", "SAX",
globalParameterResource);
+ }
+ }
+ }
+ }
public void analyzeGraphicalModel(InputStream stream) throws IOException,
CoreException, InvocationTargetException {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2009-03-06
07:47:33 UTC (rev 14070)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksConfigFileNewWizard.java 2009-03-06
08:21:05 UTC (rev 14071)
@@ -35,7 +35,7 @@
/**
*
* @author Dart
- *
+ *
*/
public class SmooksConfigFileNewWizard extends Wizard implements INewWizard,
ISmooksDataCreationAddtionWizard {
@@ -60,8 +60,11 @@
public SmooksConfigFileNewWizard() {
super();
setNeedsProgressMonitor(true);
- super.setWindowTitle(Messages.getString("SmooksConfigFileNewWizard.NewConfigFileWizardTitle"));
//$NON-NLS-1$
- setDefaultPageImageDescriptor(SmooksUIActivator.getImageDescriptor("icons/smooks-wiz.gif"));
+ super
+ .setWindowTitle(Messages
+ .getString("SmooksConfigFileNewWizard.NewConfigFileWizardTitle"));
//$NON-NLS-1$
+ setDefaultPageImageDescriptor(SmooksUIActivator
+ .getImageDescriptor("icons/smooks-wiz.gif"));
}
/**
@@ -103,8 +106,12 @@
return false;
} catch (InvocationTargetException e) {
Throwable realException = e.getTargetException();
- MessageDialog.openError(getShell(),
Messages.getString("SmooksConfigFileNewWizard.ErrorTitle"), realException
//$NON-NLS-1$
- .getMessage());
+ MessageDialog
+ .openError(
+ getShell(),
+ Messages
+ .getString("SmooksConfigFileNewWizard.ErrorTitle"), realException
//$NON-NLS-1$
+ .getMessage());
return false;
}
return true;
@@ -176,14 +183,17 @@
if (sourceDataPath[0] != null || targetDataPath[0] != null) {
properties = new Properties();
if (sourceDataPath[0] != null) {
- properties.setProperty(PRO_SOURCE_DATA_PATH, sourceDataPath[0]);
+ properties.setProperty(PRO_SOURCE_DATA_PATH,
+ sourceDataPath[0]);
}
if (targetDataPath[0] != null) {
- properties.setProperty(PRO_TARGET_DATA_PATH, targetDataPath[0]);
+ properties.setProperty(PRO_TARGET_DATA_PATH,
+ targetDataPath[0]);
}
}
try {
- ginforSave.doSave(null, sourceTypeID, targetTypeID, properties);
+ ginforSave.doSave(null, sourceTypeID, targetTypeID,
+ properties);
} catch (IOException e) {
} catch (CoreException e) {
}
@@ -193,7 +203,7 @@
}
}
});
-
+
monitor.worked(1);
}
@@ -203,7 +213,11 @@
private InputStream openContentStream() {
String contents = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
- + " <smooks-resource-list
xmlns=\"http://www.milyn.org/xsd/smooks-1.0.xsd\"/>"; //$NON-NLS-1$
+ + "<smooks-resource-list
xmlns=\"http://www.milyn.org/xsd/smooks-1.0.xsd\">\n"
+ + " <resource-config selector=\"global-parameters\">\n"
+ + " <param
name=\"stream.filter.type\">SAX</param>\n"
+ + " </resource-config>\n" +
+ "</smooks-resource-list>"; //$NON-NLS-1$
return new ByteArrayInputStream(contents.getBytes());
}
@@ -228,12 +242,16 @@
public void addSourceWizardPage(IWizardPage page) {
sourceCreationPages.add(page);
- page.setTitle(Messages.getString("SmooksConfigFileNewWizard.SourceDataTypeSelectionTitle"));
//$NON-NLS-1$
+ page
+ .setTitle(Messages
+ .getString("SmooksConfigFileNewWizard.SourceDataTypeSelectionTitle"));
//$NON-NLS-1$
}
public void addTargetWizardPage(IWizardPage page) {
targetCreationPages.add(page);
- page.setTitle(Messages.getString("SmooksConfigFileNewWizard.TargetDataTypeSelectionTitle"));
//$NON-NLS-1$
+ page
+ .setTitle(Messages
+ .getString("SmooksConfigFileNewWizard.TargetDataTypeSelectionTitle"));
//$NON-NLS-1$
}
public void clearSourceWizardPages() {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2009-03-06
07:47:33 UTC (rev 14070)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/wizards/SmooksNewWizardPage.java 2009-03-06
08:21:05 UTC (rev 14071)
@@ -24,9 +24,7 @@
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).
+ * @deprecated
*/
public class SmooksNewWizardPage extends WizardPage {