[jbosstools-commits] JBoss Tools SVN: r23869 - in trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse: launch and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Mon Aug 2 12:29:11 EDT 2010
Author: vyemialyanchyk
Date: 2010-08-02 12:29:10 -0400 (Mon, 02 Aug 2010)
New Revision: 23869
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizard.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationStrings.java
Log:
https://jira.jboss.org/browse/JBIDE-6518 - adjust after code review - simplify factories methods use
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizard.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizard.java 2010-08-02 16:28:53 UTC (rev 23868)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizard.java 2010-08-02 16:29:10 UTC (rev 23869)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Copyright (c) 2010 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,
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java 2010-08-02 16:28:53 UTC (rev 23868)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java 2010-08-02 16:29:10 UTC (rev 23869)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Copyright (c) 2010 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,
@@ -11,11 +11,8 @@
package org.hibernate.eclipse.codegen;
import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import org.dom4j.Element;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField;
@@ -29,9 +26,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-import org.hibernate.console.ConfigurationXMLFactory;
import org.hibernate.eclipse.console.HibernateConsoleMessages;
-import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.utils.LaunchHelper;
import org.hibernate.eclipse.launch.CodeGenXMLFactory;
@@ -144,19 +139,7 @@
return null;
}
final CodeGenXMLFactory codeGenXMLFactory = new CodeGenXMLFactory(lc);
- Element rootBuildXml = codeGenXMLFactory.createRoot();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ConfigurationXMLFactory.dump(baos, rootBuildXml);
- String baosResult = baos.toString().replace(
- codeGenXMLFactory.getPropFileContentStubUID(), codeGenXMLFactory.getPropFileContentPreSave());
- ByteArrayInputStream bais = null;
- try {
- bais = new ByteArrayInputStream(baosResult.getBytes("UTF-8")); //$NON-NLS-1$
- } catch (UnsupportedEncodingException uec) {
- HibernateConsolePlugin.getDefault()
- .logErrorMessage("Problems converting to UTF-8", uec); //$NON-NLS-1$
- bais = new ByteArrayInputStream(baos.toString().getBytes());
- }
- return bais;
+ String buildXml = codeGenXMLFactory.createCodeGenXML();
+ return new ByteArrayInputStream(buildXml.getBytes());
}
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-08-02 16:28:53 UTC (rev 23868)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-08-02 16:29:10 UTC (rev 23869)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Copyright (c) 2010 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,
@@ -10,6 +10,7 @@
******************************************************************************/
package org.hibernate.eclipse.launch;
+import java.io.ByteArrayOutputStream;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Iterator;
@@ -51,7 +52,11 @@
public static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
public static final long versionUID4PropFile = 1841714864553304000L;
- protected String propFileContentPreSave = null;
+ /**
+ * presave generated Hibernate Properties file content,
+ * this is necessary to proper content formating
+ */
+ protected String propFileContentPreSave = ""; //$NON-NLS-1$
protected ILaunchConfiguration lc = null;
@@ -60,7 +65,7 @@
}
@SuppressWarnings("unchecked")
- public Element createRoot() {
+ protected Element createRoot() {
ExporterAttributes attributes = null;
try {
attributes = new ExporterAttributes(lc);
@@ -304,6 +309,15 @@
}
public String getPropFileContentPreSave() {
- return propFileContentPreSave;
+ return propFileContentPreSave == null ? "" : propFileContentPreSave; //$NON-NLS-1$
}
+
+ public String createCodeGenXML() {
+ Element rootBuildXml = createRoot();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ConfigurationXMLFactory.dump(baos, rootBuildXml);
+ String res = baos.toString().replace(
+ getPropFileContentStubUID(), getPropFileContentPreSave()).trim();
+ return res;
+ }
}
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationStrings.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationStrings.java 2010-08-02 16:28:53 UTC (rev 23868)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationStrings.java 2010-08-02 16:29:10 UTC (rev 23869)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007-2010 Red Hat, Inc.
+ * Copyright (c) 2010 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,
More information about the jbosstools-commits
mailing list