Skip to content

Commit

Permalink
Merge branch 'dev_eclipseplugin'
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeec committed May 20, 2020
2 parents ab8e9c3 + b17ec42 commit e11b871
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 161 deletions.
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse-feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="com.devonfw.cobigen.eclipse.feature"
label="CobiGen Eclipse Plug-in"
version="5.2.0"
version="5.2.1"
provider-name="devonfw Team">

<description>
Expand Down
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse-feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>com.devonfw.cobigen.eclipse.feature</artifactId>
<name>CobiGen - Eclipse Plug-In Feature</name>
<packaging>eclipse-feature</packaging>
<version>5.2.0</version>
<version>5.2.1</version>

<parent>
<groupId>com.devonfw.cobigen</groupId>
Expand Down
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse-test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CobiGen Eclipse Plug-In Tests
Bundle-SymbolicName: com.devonfw.cobigen.eclipse.test;singleton:=true
Bundle-Version: 5.2.0
Bundle-Version: 5.2.1
Bundle-Vendor: Capgemini
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Expand Down
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>com.devonfw.cobigen.eclipse.test</artifactId>
<name>CobiGen - Eclipse Plug-In Tests</name>
<packaging>eclipse-test-plugin</packaging>
<version>5.2.0</version>
<version>5.2.1</version>

<parent>
<groupId>com.devonfw.cobigen</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants;
import com.devonfw.cobigen.eclipse.test.common.SystemTest;
import com.devonfw.cobigen.eclipse.test.common.swtbot.AllJobsAreFinished;
import com.devonfw.cobigen.eclipse.test.common.swtbot.HasBeenBuilt;
import com.devonfw.cobigen.eclipse.test.common.utils.EclipseCobiGenUtils;
import com.devonfw.cobigen.eclipse.test.common.utils.EclipseUtils;

Expand Down Expand Up @@ -72,8 +71,7 @@ public void testBasicOpenAPIGeneration() throws Exception {
FileUtils.copyFile(new File(resourcesRootPath + "input/devonfw.yml"),
project.getUnderlyingResource().getLocation().append("devonfw.yml").toFile());
project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
EclipseUtils.updateMavenProject(bot, testProjName);
bot.waitUntil(new HasBeenBuilt(project), 2000, 100);
tmpMavenProjectRule.updateProject();

EclipseCobiGenUtils.runAndCaptureHealthCheck(bot);
EclipseUtils.openErrorsTreeInProblemsView(bot);
Expand Down Expand Up @@ -154,8 +152,7 @@ public void testServiceBasedOpenAPIGeneration() throws Exception {
FileUtils.copyFile(new File(resourcesRootPath + "input/devonfw.yml"),
project.getUnderlyingResource().getLocation().append("devonfw.yml").toFile());
project.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
EclipseUtils.updateMavenProject(bot, testProjName);
bot.waitUntil(new HasBeenBuilt(project), 2000, 100);
tmpMavenProjectRule.updateProject();

EclipseCobiGenUtils.runAndCaptureHealthCheck(bot);
EclipseUtils.openErrorsTreeInProblemsView(bot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static void importExistingGeneralProject(SWTWorkbenchBot bot, String proj
SWTBotCombo comboBox = bot.comboBox();
comboBox.setText(projectPath);

bot.waitUntil(new AllJobsAreFinished(), EclipseCobiGenUtils.DEFAULT_TIMEOUT);
SWTBotCheckBox cbCopyProjects = bot.checkBox("Copy projects into workspace");
SWTBotButton selectAll = bot.button("Select All");
selectAll.setFocus();
Expand Down
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse-updatesite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>eclipse</artifactId>
<name>CobiGen - Eclipse Plug-In UpdateSite</name>
<packaging>eclipse-repository</packaging>
<version>5.2.0</version>
<version>5.2.1</version>

<parent>
<groupId>com.devonfw.cobigen</groupId>
Expand Down
4 changes: 2 additions & 2 deletions cobigen-eclipse/cobigen-eclipse/.classpath
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="lib/core-6.1.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/core-api-6.1.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
Expand Down Expand Up @@ -28,7 +30,5 @@
<classpathentry exported="true" kind="lib" path="lib/logback-core-1.1.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mmm-util-core-7.4.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.7.21.jar"/>
<classpathentry exported="true" kind="lib" path="lib/core-6.1.0.jar" sourcepath="/core"/>
<classpathentry exported="true" kind="lib" path="lib/core-api-6.1.0.jar" sourcepath="/core-api"/>
<classpathentry kind="output" path="eclipse-target/classes"/>
</classpath>
6 changes: 3 additions & 3 deletions cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CobiGen Eclipse Plug-in
Bundle-SymbolicName: com.devonfw.cobigen.eclipse;singleton:=true
Bundle-Version: 5.2.0
Bundle-Version: 5.2.1
Bundle-Activator: com.devonfw.cobigen.eclipse.Activator
Bundle-Vendor: devonfw Team
Require-Bundle: org.eclipse.ui;bundle-version="3.104.0",
Expand Down Expand Up @@ -45,6 +45,6 @@ Bundle-ClassPath: .,
lib/logback-core-1.1.2.jar,
lib/mmm-util-core-7.4.0.jar,
lib/slf4j-api-1.7.21.jar,
lib/core-6.1.0.jar,
lib/core-api-6.1.0.jar
lib/core-6.1.1.jar,
lib/core-api-6.1.1.jar
Export-Package: com.devonfw.cobigen.eclipse.common.constants.external
4 changes: 2 additions & 2 deletions cobigen-eclipse/cobigen-eclipse/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ bin.includes = .,\
lib/logback-core-1.1.2.jar,\
lib/mmm-util-core-7.4.0.jar,\
lib/slf4j-api-1.7.21.jar,\
lib/core-6.1.0.jar,\
lib/core-api-6.1.0.jar
lib/core-6.1.1.jar,\
lib/core-api-6.1.1.jar
4 changes: 2 additions & 2 deletions cobigen-eclipse/cobigen-eclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<artifactId>com.devonfw.cobigen.eclipse</artifactId>
<name>CobiGen - Eclipse Plug-In</name>
<packaging>eclipse-plugin</packaging>
<version>5.2.0</version>
<version>5.2.1</version>

<parent>
<groupId>com.devonfw.cobigen</groupId>
Expand All @@ -15,7 +15,7 @@
<dependency>
<groupId>com.devonfw.cobigen</groupId>
<artifactId>core</artifactId>
<version>6.1.0</version>
<version>6.1.1</version>
</dependency>
<dependency>
<groupId>com.devonfw.cobigen</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package com.devonfw.cobigen.eclipse.common.tools;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.devonfw.cobigen.api.exception.CobiGenRuntimeException;
import com.devonfw.cobigen.api.exception.InvalidConfigurationException;
import com.devonfw.cobigen.eclipse.common.constants.external.ResourceConstants;
import com.devonfw.cobigen.eclipse.common.exceptions.GeneratorCreationException;
import com.devonfw.cobigen.eclipse.common.exceptions.GeneratorProjectNotExistentException;
import com.devonfw.cobigen.eclipse.common.exceptions.InvalidInputException;
import com.devonfw.cobigen.eclipse.healthcheck.HealthCheckDialog;

/**
* Util class to handle exceptions
*/
public class ExceptionHandler {

/** Logger instance. */
private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);

/**
* @param e
* the exception to be handled
* @param activeShell
* the shell a potential message dialog should be bound to or null if a default should be
* created
*/
public static void handle(Throwable e, Shell activeShell) {

if (CoreException.class.isAssignableFrom(e.getClass())) {
LOG.error("Eclipse internal Exception", e);
PlatformUIUtil.openErrorDialog("An eclipse internal exception occurred during processing:\n"
+ e.getMessage() + "\n If this problem persists please report it to the CobiGen developers.", e);
} else if (InvalidConfigurationException.class.isAssignableFrom(e.getClass())) {
LOG.warn("Invalid configuration.", e);
openInvalidConfigurationErrorDialog((InvalidConfigurationException) e);
} else if (GeneratorProjectNotExistentException.class.isAssignableFrom(e.getClass())) {
LOG.error(
"The project '{}' containing the configuration and templates is currently not existent. Please create one or check it out from SVN as stated in the user documentation.",
ResourceConstants.CONFIG_PROJECT_NAME, e);
MessageDialog.openError(getShell(activeShell), "Generator configuration project not found!", "The project '"
+ ResourceConstants.CONFIG_PROJECT_NAME
+ "' containing the configuration and templates is currently not existent. Please create one or check it out from SVN as stated in the user documentation.");
} else if (GeneratorCreationException.class.isAssignableFrom(e.getClass())) {
LOG.error("Could not create an instance of the generator.", e);
PlatformUIUtil.openErrorDialog("Could not initialize CobiGen for the given selection: " + e.getMessage(),
e);
} else if (InvalidInputException.class.isAssignableFrom(e.getClass())) {
LOG.info("Invalid input selected for generation: {}", e.getMessage());
MessageDialog.openInformation(getShell(activeShell), "Invalid selection", e.getMessage());
} else if (CobiGenRuntimeException.class.isAssignableFrom(e.getClass())) {
LOG.error("CobiGen Exception:\n{}", e.getMessage(), e);
PlatformUIUtil.openErrorDialog(e.getMessage(), e);
} else {
LOG.error("An unexpected exception occurred!", e);
PlatformUIUtil.openErrorDialog("An unexpected exception occurred!", e);
}
}

/**
* @param activeShell
* active shell or null if not passed
* @return the shell to be used
*/
private static Shell getShell(Shell activeShell) {
return activeShell != null ? activeShell : Display.getDefault().getActiveShell();
}

/**
* Opens up a message dialog for displaying further guidance on context configuration issues.
* @param e
* {@link InvalidConfigurationException} occurred
*/
private static void openInvalidConfigurationErrorDialog(InvalidConfigurationException e) {
MessageDialog dialog =
new MessageDialog(Display.getDefault().getActiveShell(), "Invalid context configuration!", null,
"Any context/templates configuration has been changed into an invalid state "
+ "OR is simply outdated, if you recently updated CobiGen. "
+ "For further investigation and automatic upgrade options start CobiGen's Health Check."
+ "\n\nOriginal error message: " + e.getMessage(),
MessageDialog.ERROR, new String[] { "Health Check", "OK" }, 1);
dialog.setBlockOnOpen(true);

int result = dialog.open();
if (result == 0) {
new HealthCheckDialog().execute();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -471,28 +471,6 @@ private boolean isOverridableFile(Set<TemplateTo> templates) {
return false;
}

/**
* Resolves all target files for the given templates. Only resources which are located in the workspace
* will be returned.
* @param generatedTemplates
* templates for which the target files should be resolved
* @return workspace dependent paths of all possible generated resources.
*/
public Set<String> getAllTargetPathsInWorkspace(List<TemplateTo> generatedTemplates) {
Set<String> paths = new HashSet<>();

List<Object> inputs = cobiGen.resolveContainers(this.inputs.get(0));
for (TemplateTo template : generatedTemplates) {
for (Object input : inputs) {
String path = resolveWorkspaceDependentTemplateDestinationPath(template, input);
if (path != null) {
paths.add(path);
}
}
}
return paths;
}

/**
* Returns the set of all workspace relative destination paths for the templates of the given
* {@link ComparableIncrement} mapped to the correlated {@link TemplateTo}. This is done for the
Expand Down Expand Up @@ -750,21 +728,6 @@ public boolean isValidInput() throws InvalidInputException {
return firstTriggers != null && !firstTriggers.isEmpty();
}

/**
* Resolves the template's destination paths by while using the {@link #getCurrentRepresentingInput()} as
* input
* @param template
* the destination path should be resolved for
* @return the destination {@link Path}
*/
public Path resolveTemplateDestinationPath(TemplateTo template) {
Path resolvedPath = resolvedDestPathsCache.get(template);
if (resolvedPath != null) {
return resolvedPath;
}
return resolveTemplateDestinationPath(template, getCurrentRepresentingInput());
}

/**
* Resolves the template's destination paths by while using the given input
* @param template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.devonfw.cobigen.api.to.IncrementTo;
import com.devonfw.cobigen.api.to.TemplateTo;
import com.devonfw.cobigen.eclipse.common.constants.InfrastructureConstants;
import com.devonfw.cobigen.eclipse.common.tools.ExceptionHandler;
import com.devonfw.cobigen.eclipse.common.tools.MapUtils;
import com.devonfw.cobigen.eclipse.generator.CobiGenWrapper;
import com.devonfw.cobigen.eclipse.generator.entity.ComparableIncrement;
Expand Down Expand Up @@ -86,44 +87,50 @@ public void checkStateChanged(CheckStateChangedEvent event) {
MDC.put(InfrastructureConstants.CORRELATION_ID, UUID.randomUUID().toString());
LOG.info("Increment selection changed. Calculating generation preview file tree...");

CheckboxTreeViewer resourcesTree = page.getResourcesTree();
CheckboxTreeViewer incrementSelector = page.getPackageSelector();

if (event.getSource().equals(resourcesTree)) {
resourcesTree.setSubtreeChecked(event.getElement(), event.getChecked());
((SelectFileLabelProvider) resourcesTree.getLabelProvider())
.setSelectedResources(resourcesTree.getCheckedElements());
refreshNodes(event);
} else if (event.getSource().equals(incrementSelector)) {
performCheckLogic(event, incrementSelector);
Set<Object> checkedElements = new HashSet<>(Arrays.asList(incrementSelector.getCheckedElements()));
performCheckLogicForALLIncrement(incrementSelector, checkedElements);

Map<String, Set<TemplateTo>> paths = cobigenWrapper.getTemplateDestinationPaths(selectedIncrements);
Set<String> workspaceExternalPaths = Sets.newHashSet();
for (String path : paths.keySet()) {
if (cobigenWrapper.isWorkspaceExternalPath(path)) {
workspaceExternalPaths.add(path);
try {
CheckboxTreeViewer resourcesTree = page.getResourcesTree();
CheckboxTreeViewer incrementSelector = page.getPackageSelector();

if (event.getSource().equals(resourcesTree)) {
resourcesTree.setSubtreeChecked(event.getElement(), event.getChecked());
((SelectFileLabelProvider) resourcesTree.getLabelProvider())
.setSelectedResources(resourcesTree.getCheckedElements());
refreshNodes(event);
} else if (event.getSource().equals(incrementSelector)) {
performCheckLogic(event, incrementSelector);
Set<Object> checkedElements = new HashSet<>(Arrays.asList(incrementSelector.getCheckedElements()));
performCheckLogicForALLIncrement(incrementSelector, checkedElements);

Map<String, Set<TemplateTo>> paths = cobigenWrapper.getTemplateDestinationPaths(selectedIncrements);
Set<String> workspaceExternalPaths = Sets.newHashSet();
for (String path : paths.keySet()) {
if (cobigenWrapper.isWorkspaceExternalPath(path)) {
workspaceExternalPaths.add(path);
}
}
List<OffWorkspaceResourceTreeNode> offScopeResourceTree =
buildOffScopeResourceTree(workspaceExternalPaths);
((SelectFileContentProvider) resourcesTree.getContentProvider()).filter(paths.keySet(),
offScopeResourceTree);
page.setDisplayedfilePathToTemplateMapping(paths);

resourcesTree.setCheckedElements(new Object[0]);
resourcesTree.refresh();
resourcesTree.expandAll();
if (!batch) {
selectNewResources();
selectMergeableResources();
selectOverridingResources();
} else {
selectAllResources(paths.keySet());
}
}
List<OffWorkspaceResourceTreeNode> offScopeResourceTree = buildOffScopeResourceTree(workspaceExternalPaths);
((SelectFileContentProvider) resourcesTree.getContentProvider()).filter(paths.keySet(),
offScopeResourceTree);
page.setDisplayedfilePathToTemplateMapping(paths);

resourcesTree.setCheckedElements(new Object[0]);
resourcesTree.refresh();
resourcesTree.expandAll();
if (!batch) {
selectNewResources();
selectMergeableResources();
selectOverridingResources();
} else {
selectAllResources(paths.keySet());
}
}

checkPageComplete();
checkPageComplete();

} catch (Throwable e) {
ExceptionHandler.handle(e, null);
}

LOG.info("Calculating of changed preview file tree finished.");
MDC.remove(InfrastructureConstants.CORRELATION_ID);
Expand Down
Loading

0 comments on commit e11b871

Please sign in to comment.