Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Struckmann2014-11-04 11:46:57 +0000
committerSebastian Struckmann2014-11-04 11:47:13 +0000
commitf76d9322cb6514ab1c4d0aa10174c99c3674a9d1 (patch)
tree6b03869c16e9e01afa10bb28e5436d2e261232a3 /org.eclipse.jubula.client.api.converter.ui
parentab500b36bc13cd06d9fbb7faab56467d2abd6b71 (diff)
downloadorg.eclipse.jubula.core-f76d9322cb6514ab1c4d0aa10174c99c3674a9d1.tar.gz
org.eclipse.jubula.core-f76d9322cb6514ab1c4d0aa10174c99c3674a9d1.tar.xz
org.eclipse.jubula.core-f76d9322cb6514ab1c4d0aa10174c99c3674a9d1.zip
Sprint task - Java API - Extended converter to generate CAPs (without parameters)
Diffstat (limited to 'org.eclipse.jubula.client.api.converter.ui')
-rw-r--r--org.eclipse.jubula.client.api.converter.ui/META-INF/MANIFEST.MF7
-rw-r--r--org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java49
-rw-r--r--org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/Messages.java1
-rw-r--r--org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/messages.properties1
4 files changed, 54 insertions, 4 deletions
diff --git a/org.eclipse.jubula.client.api.converter.ui/META-INF/MANIFEST.MF b/org.eclipse.jubula.client.api.converter.ui/META-INF/MANIFEST.MF
index d9cdfd3ff..9e4c644c3 100644
--- a/org.eclipse.jubula.client.api.converter.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.jubula.client.api.converter.ui/META-INF/MANIFEST.MF
@@ -6,14 +6,17 @@ Bundle-Version: 2.4.0.qualifier
Bundle-Vendor: Eclipse Jubula
Require-Bundle: org.eclipse.jubula.tools;bundle-version="[2.4.0,2.5.0)",
org.apache.commons.io;bundle-version="[2.0.0,3.0.0)",
+ org.apache.commons.lang;bundle-version="[2.4.0,3.0.0)",
+ org.slf4j.api;bundle-version="[1.7.2,2.0.0)",
org.eclipse.jface;bundle-version="[3.6.1,4.0.0)",
org.eclipse.ui.workbench;bundle-version="[3.6.1,4.0.0)",
+ org.eclipse.jubula.toolkit.common;bundle-version="[2.4.0,2.5.0)",
org.eclipse.jubula.client.ui;bundle-version="[2.4.0,2.5.0)",
org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
org.eclipse.core.commands;bundle-version="[3.6.0,4.0.0)",
org.eclipse.jubula.client.core;bundle-version="[2.4.0,2.5.0)",
org.eclipse.jubula.client.api.converter;bundle-version="[2.4.0,2.5.0)",
- org.eclipse.jubula.rc.rcp.common,
- org.eclipse.jubula.client.ui.rcp
+ org.eclipse.jubula.client.ui.rcp;bundle-version="[2.4.0,2.5.0)",
+ org.eclipse.jubula.toolkit.api.gen;bundle-version="[2.4.0,2.5.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java
index 3c322c532..e199b8abb 100644
--- a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java
+++ b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/handlers/ConvertProjectHandler.java
@@ -18,6 +18,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
+import java.util.NoSuchElementException;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
@@ -34,6 +35,7 @@ import org.eclipse.jubula.client.api.converter.exceptions.InvalidNodeNameExcepti
import org.eclipse.jubula.client.api.converter.ui.i18n.Messages;
import org.eclipse.jubula.client.api.converter.utils.Utils;
import org.eclipse.jubula.client.core.errorhandling.ErrorMessagePresenter;
+import org.eclipse.jubula.client.core.model.IAUTMainPO;
import org.eclipse.jubula.client.core.model.ICategoryPO;
import org.eclipse.jubula.client.core.model.INodePO;
import org.eclipse.jubula.client.core.model.IProjectPO;
@@ -43,10 +45,14 @@ import org.eclipse.jubula.client.core.persistence.IExecPersistable;
import org.eclipse.jubula.client.core.persistence.ISpecPersistable;
import org.eclipse.jubula.client.core.persistence.ProjectPM;
import org.eclipse.jubula.client.ui.handlers.AbstractHandler;
+import org.eclipse.jubula.client.ui.rcp.Plugin;
import org.eclipse.jubula.client.ui.utils.ErrorHandlingUtil;
+import org.eclipse.jubula.toolkit.api.gen.internal.genmodel.CommonGenInfo;
+import org.eclipse.jubula.toolkit.common.xml.businessprocess.ComponentBuilder;
import org.eclipse.jubula.tools.internal.constants.StringConstants;
import org.eclipse.jubula.tools.internal.exception.JBException;
import org.eclipse.jubula.tools.internal.messagehandling.MessageIDs;
+import org.eclipse.jubula.tools.internal.xml.businessmodell.ToolkitDescriptor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DirectoryDialog;
@@ -125,6 +131,8 @@ public class ConvertProjectHandler extends AbstractHandler {
/** the project */
private static IProgressMonitor progressMonitor;
+ /** the default factory */
+ private static String defaultFactory;
/** {@inheritDoc} */
public void run(IProgressMonitor monitor) {
@@ -137,6 +145,8 @@ public class ConvertProjectHandler extends AbstractHandler {
StringConstants.SLASH);
if (project != null) {
+ defaultFactory = determineDefaultFactory(project);
+
// Handle the reused projects
Iterator iterator = project.getUsedProjects().iterator();
while (iterator.hasNext()) {
@@ -144,7 +154,8 @@ public class ConvertProjectHandler extends AbstractHandler {
(IReusedProjectPO) iterator.next();
IProjectPO usedProject;
try {
- usedProject = ProjectPM.loadProject(reusedProject);
+ usedProject = ProjectPM
+ .loadReusedProjectInMasterSession(reusedProject);
handleProject(usedProject, basePath);
} catch (JBException e) {
ErrorHandlingUtil.createMessageDialog(
@@ -159,6 +170,37 @@ public class ConvertProjectHandler extends AbstractHandler {
}
/**
+ * Returns the default factory name for a project
+ * by inspecting its first AUT
+ * @param project the project
+ * @return the name of the default factory
+ */
+ private String determineDefaultFactory(IProjectPO project) {
+ String name = null;
+ IAUTMainPO firstAUT = null;
+ try {
+ firstAUT = project.getAutCont()
+ .getAutMainList().iterator().next();
+ } catch (NoSuchElementException e) {
+ ErrorMessagePresenter.getPresenter().showErrorMessage(
+ new JBException(
+ Messages.NoAutInProject,
+ MessageIDs.E_NO_AUT_IN_PROJECT),
+ null, null);
+ progressMonitor.setCanceled(true);
+ }
+ if (firstAUT != null) {
+ ToolkitDescriptor toolkitDescriptor =
+ ComponentBuilder.getInstance().getCompSystem()
+ .getToolkitDescriptor(firstAUT.getToolkit());
+ CommonGenInfo defaultFactoryInfo =
+ new CommonGenInfo(toolkitDescriptor, false);
+ name = defaultFactoryInfo.getFqClassName();
+ }
+ return name;
+ }
+
+ /**
* Traverses a project and creates files and directories for its content.
* @param project the project
* @param basePath the base path
@@ -237,7 +279,7 @@ public class ConvertProjectHandler extends AbstractHandler {
file.createNewFile();
NodeGenerator gen = new NodeGenerator();
NodeInfo info = new NodeInfo(file.getName(), node,
- genPackage);
+ genPackage, defaultFactory);
String content = gen.generate(info);
writeContentToFile(file, content);
} catch (IOException e) {
@@ -318,6 +360,9 @@ public class ConvertProjectHandler extends AbstractHandler {
file.getAbsolutePath(), extension);
file = new File(oldName + StringConstants.UNDERSCORE
+ extension);
+
+ Plugin.getDefault().writeErrorLineToConsole(
+ "Duplicate filename error:" + fileName, true); //$NON-NLS-1$
}
return file;
}
diff --git a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/Messages.java b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/Messages.java
index 5742fdfd6..9824b3542 100644
--- a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/Messages.java
+++ b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/Messages.java
@@ -26,6 +26,7 @@ public class Messages extends NLS {
public static String InputDialogMessage;
public static String InvalidNodeName;
public static String InvalidPackageName;
+ public static String NoAutInProject;
public static String NoPackageNameSpecified;
static {
diff --git a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/messages.properties b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/messages.properties
index 01556e1e1..e2d7036ab 100644
--- a/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/messages.properties
+++ b/org.eclipse.jubula.client.api.converter.ui/src/org/eclipse/jubula/client/api/converter/ui/i18n/messages.properties
@@ -12,4 +12,5 @@ InputDialogName=Choose package name
InputDialogMessage=Please type the name of the package which should be the target of the project conversion.
InvalidNodeName=The node "{0}" could not be translated to a valid Java class name. Please fix it manually and retry.
InvalidPackageName=The given string is no valid package name.
+NoAutInProject=No AUT was specified in the project.
NoPackageNameSpecified=The given string must not be empty.

Back to the top