Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2019-09-02 11:00:32 -0400
committerJan Belle2019-10-12 06:09:53 -0400
commit1537b53a166a6a7f16a37df9ca6686049dceb608 (patch)
treeb7deb3e0f635426d82529c7e9bda92ecc6c7eb84
parentad0bc76a408854724e435312d0660d6ba6d9f7e1 (diff)
downloadorg.eclipse.etrice-v_2.1.0.tar.gz
org.eclipse.etrice-v_2.1.0.tar.xz
org.eclipse.etrice-v_2.1.0.zip
[ui] Fix new set of eTrice models wizardv_2.1.0
-rw-r--r--plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/CProjectConfigurator.java64
-rw-r--r--plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java8
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java6
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java1
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java19
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend10
8 files changed, 45 insertions, 71 deletions
diff --git a/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/CProjectConfigurator.java b/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/CProjectConfigurator.java
index 13abc4cf2..80c79fb54 100644
--- a/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/CProjectConfigurator.java
+++ b/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/CProjectConfigurator.java
@@ -18,6 +18,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
@@ -29,17 +30,17 @@ import org.eclipse.cdt.core.settings.model.CIncludePathEntry;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.etrice.generator.ui.wizard.ProjectCreator;
import org.eclipse.etrice.generator.ui.wizard.WizardHelpers;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.dialogs.IOverwriteQuery;
@@ -52,8 +53,8 @@ import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
*/
public class CProjectConfigurator extends ProjectConfigurator {
- private static final String C_MODELLIB_NAME = "etrice_c_modellib";
- private static final String C_RUNTIME_FOLDER_NAME = "etrice_c_runtime";
+ private static final String C_MODELLIB_FOLDER_NAME = "etrice_modellib";
+ private static final String C_RUNTIME_FOLDER_NAME = "etrice_runtime";
/* (non-Javadoc)
* @see org.eclipse.etrice.generator.ui.cdt.ProjectConfigurator#isApplicable(org.eclipse.core.resources.IProject)
@@ -133,6 +134,22 @@ public class CProjectConfigurator extends ProjectConfigurator {
return IOverwriteQuery.ALL;
}
};
+
+ @Override
+ protected void configureModelpath(IProject project, IPath path) {
+ if(!project.getFile("modelpath").exists()) {
+ List<String> srcDirs = new ArrayList<>();
+ IPath dir = path.removeFirstSegments(1);
+ if(!dir.isEmpty()) {
+ srcDirs.add(dir.toPortableString());
+ }
+ if(isCopyRuntime()) {
+ srcDirs.add(C_MODELLIB_FOLDER_NAME + "/model");
+ }
+ URI modelpathURI = URI.createPlatformResourceURI(project.getFullPath().append("modelpath").toPortableString(), false);
+ ProjectCreator.createModelpathDescription(modelpathURI, srcDirs, Collections.emptyList());
+ }
+ }
/*
* (non-Javadoc)
@@ -262,42 +279,17 @@ public class CProjectConfigurator extends ProjectConfigurator {
}
if (current!=null) {
children = structureProvider.getChildren(current);
- IPath modelFolderPath = getPath();
for (Object child : children) {
if (child instanceof ZipEntry) {
- if (! ((ZipEntry) child).isDirectory()) {
- ImportOperation importOperation = new ImportOperation(
- modelFolderPath,
- child,
- structureProvider,
- OVERWRITE_ALL_QUERY);
- importOperation.setContext(null);
- importOperation.run(SubMonitor.convert(progressMonitor, 1));
- }
+ ImportOperation importOperation = new ImportOperation(
+ project.getFullPath().append(C_MODELLIB_FOLDER_NAME),
+ child,
+ structureProvider,
+ OVERWRITE_ALL_QUERY);
+ importOperation.setContext(null);
+ importOperation.run(SubMonitor.convert(progressMonitor, 1));
}
}
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- final IContainer modelFolder = root.getFolder(modelFolderPath.append("model"));
- final IPath newPath = modelFolder.getFullPath().removeLastSegments(1).append(C_MODELLIB_NAME);
-
- ISchedulingRule rule = ResourcesPlugin.getWorkspace().getRuleFactory().createRule(modelFolder);
- WorkspaceModifyOperation operation = new WorkspaceModifyOperation(rule) {
-
- @Override
- protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
-
- modelFolder.move(newPath, true, monitor);
- }
-
- };
-
- try {
- operation.run(progressMonitor);
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
}
}
}
diff --git a/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java b/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java
index e5d1174c4..de7cb2417 100644
--- a/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java
+++ b/plugins/org.eclipse.etrice.generator.ui.cdt/src/org/eclipse/etrice/generator/ui/cdt/ProjectConfigurator.java
@@ -59,6 +59,7 @@ public abstract class ProjectConfigurator implements IProjectConfigurator {
protected abstract Map<String, String> getProjectRefInfo(ICConfigurationDescription configDescription, String toolChain);
protected abstract void copyRuntime(IProject project, IProgressMonitor progressMonitor, String platform);
protected abstract void customizeBuildConfig(IProject project, IConfiguration buildConfig);
+ protected abstract void configureModelpath(IProject project, IPath path);
@Override
public void configure(IProject project, IPath path, boolean copyRuntime, String platform, IProgressMonitor progressMonitor) {
@@ -71,7 +72,7 @@ public abstract class ProjectConfigurator implements IProjectConfigurator {
if (copyRuntime) {
copyRuntime(project, progressMonitor, platform);
}
-
+ configureModelpath(project, path);
configureIncludesAndLibraries(project, progressMonitor);
}
}
@@ -186,5 +187,5 @@ public abstract class ProjectConfigurator implements IProjectConfigurator {
setting.setSettingEntries(kind, allEntries);
}
-
+
}
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java
index a8f356e3f..0f21d2e6d 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/GeneratorPreferencePage.java
@@ -26,14 +26,6 @@ public class GeneratorPreferencePage
addLabel("");
addField(
- new RadioGroupFieldEditor(
- PreferenceConstants.BUILD_KIND,
- "Choose the build kind that is used for eTrice Java applications:",
- 1,
- new String[][] { { "&Maven", PreferenceConstants.MAVEN }, {
- "&JDT", PreferenceConstants.JDT }
- }, getFieldEditorParent()));
- addField(
new BooleanFieldEditor(
PreferenceConstants.GEN_USE_TRANSLATION,
"Let wizard create new launchers with detail code translation on initially",
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java
index cfce11f2d..1216078a3 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceConstants.java
@@ -10,10 +10,4 @@ public class PreferenceConstants {
public static final String GEN_USE_TRANSLATION = "GenerateUsingTranslation";
public static final String GEN_OLD_STYLE_TRANSITION_DATA = "GenerateOldStyleTransitionData";
- /**
- * The kind of build with the two possibilities {@link #MAVEN} and {@link #JDT}
- */
- public static final String BUILD_KIND = "BuildKind";
- public static final String MAVEN = "Maven";
- public static final String JDT = "JDT";
}
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java
index 6d1243bfc..7ed09c1ba 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/preferences/PreferenceInitializer.java
@@ -16,7 +16,6 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
*/
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getInstance().getPreferenceStore();
- store.setDefault(PreferenceConstants.BUILD_KIND, PreferenceConstants.JDT);
store.setDefault(PreferenceConstants.GEN_DIR, "src-gen");
store.setDefault(PreferenceConstants.GEN_DOC_DIR, "doc-gen");
store.setDefault(PreferenceConstants.GEN_USE_TRANSLATION, true);
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java
index ab9ba4f9e..15a136e1c 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java
@@ -137,10 +137,7 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
String projectName = project.getName();
URI projectURI = URI.createPlatformResourceURI(projectName, true);
- String modelName = MODEL_NAME;
- ProjectCreator.createBuildProperties(projectURI.appendSegment("build.properties"), modelName);
-
ProjectCreator.createLaunchGeneratorConfig(projectURI.appendSegment("generate_Template.launch"),
"java", "/" + projectName + "/model", "Mapping", AbstractGeneratorOptions.MAIN_NAME.getDefaultValue(), additionalLaunchConfigLines);
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java
index 90b943750..3568f0e46 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectCreator.java
@@ -346,21 +346,6 @@ public class ProjectCreator {
writeFile(uri, ProjectFileFragments.getBasicMappingModel(baseName));
}
- public static void createBuildProperties(URI uri, String baseName) {
- try {
- PrintStream prop = new PrintStream(
- URIConverter.INSTANCE.createOutputStream(uri, null), false,
- "UTF-8");
- prop.println("source.. = src/,\\");
- prop.println("src-gen/");
- prop.close();
- } catch (UnsupportedEncodingException e) {
- Logger.getLogger(ProjectCreator.class).error(e.getMessage(), e);
- } catch (IOException e) {
- Logger.getLogger(ProjectCreator.class).error(e.getMessage(), e);
- }
- }
-
public static void createLaunchGeneratorConfig(URI uri, String targetLanguage, String modelPath, String mappingName,
String mainMethodName, String[] addLines) {
writeFile(uri, ProjectFileFragments.getGeneratorLaunchConfig(targetLanguage, modelPath, mappingName, mainMethodName, addLines));
@@ -401,6 +386,10 @@ public class ProjectCreator {
project.getName());
}
}
+
+ public static void createModelpathDescription(URI uri, Iterable<String> srcDirs, Iterable<String> projects) {
+ writeFile(uri, ProjectFileFragments.getModelpathDescription(srcDirs, projects));
+ }
/**
* @param project
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend
index f1ce3fdd7..ae7f9c318 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ProjectFileFragments.xtend
@@ -146,4 +146,14 @@ class ProjectFileFragments {
</launchConfiguration>
'''
}
+
+ def static String getModelpathDescription(Iterable<String> srcDirs, Iterable<String> projects) '''
+ «FOR s : srcDirs»
+ srcDir «s»
+ «ENDFOR»
+
+ «FOR p : projects»
+ project «p»
+ «ENDFOR»
+ '''
} \ No newline at end of file

Back to the top