Skip to content

Commit

Permalink
#186: Merge branch 'dev_eclipseplugin'
Browse files Browse the repository at this point in the history
  • Loading branch information
maybeec committed Jan 11, 2016
2 parents 3681303 + 970928c commit 6eecaef
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 105 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="cobigen-eclipse-feature"
label="CobiGen Eclipse Plug-in"
version="1.4.2"
version="1.4.3"
provider-name="Capgemini">

<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 @@ -6,7 +6,7 @@
<artifactId>cobigen-eclipse-feature</artifactId>
<name>CobiGen - Eclipse Plug-In Feature</name>
<packaging>eclipse-feature</packaging>
<version>1.4.2</version>
<version>1.4.3</version>

<parent>
<groupId>com.capgemini</groupId>
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 @@
<groupId>com.capgemini</groupId>
<artifactId>cobigen-eclipse-updatesite</artifactId>
<name>CobiGen - Eclipse Plug-In UpdateSite</name>
<version>1.4.2</version>
<version>1.4.3</version>
<packaging>eclipse-repository</packaging>

<parent>
Expand Down
2 changes: 1 addition & 1 deletion 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: cobigen-eclipse;singleton:=true
Bundle-Version: 1.4.2
Bundle-Version: 1.4.3
Bundle-Activator: com.capgemini.cobigen.eclipse.Activator
Bundle-Vendor: Capgemini
Require-Bundle: org.eclipse.ui;bundle-version="3.104.0",
Expand Down
2 changes: 1 addition & 1 deletion cobigen-eclipse/cobigen-eclipse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>cobigen-eclipse</artifactId>
<name>CobiGen - Eclipse Plug-In</name>
<packaging>eclipse-plugin</packaging>
<version>1.4.2</version>
<version>1.4.3</version>

<parent>
<groupId>com.capgemini</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,18 @@ public void run() {
public static MultiStatus createMultiStatus(Throwable t) {

List<Status> childStatus = Lists.newArrayList();

StackTraceElement[] stackTraces = t.getStackTrace();

for (StackTraceElement stackTrace : stackTraces) {
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, stackTrace.toString());
StackTraceElement[] stackTraceElements = t.getStackTrace();
for (int i = 0; i < stackTraceElements.length; i++) {
StackTraceElement element = stackTraceElements[i];
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, element.toString());
childStatus.add(status);
}

if (t.getCause() != null) {
childStatus.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Caused by"));
childStatus.add(createMultiStatus(t.getCause()));
}

MultiStatus ms =
new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR, childStatus.toArray(new Status[0]),
t.toString(), t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public AbstractCobiGenWrapper() throws GeneratorProjectNotExistentException, Cor
private CobiGen initializeGenerator() throws GeneratorProjectNotExistentException, CoreException,
InvalidConfigurationException, IOException {

ResourcesPluginUtil.refreshConfigurationProject();
IProject generatorProj = ResourcesPluginUtil.getGeneratorConfigurationProject();
return new CobiGen(generatorProj.getLocationURI());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class GeneratorWrapperFactory {
*/
public static CobiGenWrapper createGenerator(IStructuredSelection selection)
throws GeneratorCreationException, GeneratorProjectNotExistentException, InvalidInputException {

List<Object> extractedInputs = extractValidEclipseInputs(selection);

if (extractedInputs.size() > 0) {
Expand Down Expand Up @@ -94,7 +95,7 @@ public static CobiGenWrapper createGenerator(IStructuredSelection selection)
* combination of inputs.
* @author mbrunnli (04.12.2014)
*/
public static List<Object> extractValidEclipseInputs(IStructuredSelection selection)
private static List<Object> extractValidEclipseInputs(IStructuredSelection selection)
throws InvalidInputException {
LOG.info("Start extraction of valid inputs from selection...");
int type = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package com.capgemini.cobigen.eclipse.healthcheck;

import java.io.File;
import java.io.FileFilter;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.capgemini.cobigen.config.ContextConfiguration;
import com.capgemini.cobigen.config.constant.ConfigurationConstants;
import com.capgemini.cobigen.config.constant.TemplatesConfigurationVersion;
import com.capgemini.cobigen.config.entity.Trigger;
import com.capgemini.cobigen.config.upgrade.TemplateConfigurationUpgrader;
import com.capgemini.cobigen.eclipse.common.tools.PlatformUIUtil;
import com.capgemini.cobigen.eclipse.common.tools.ResourcesPluginUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;

Expand All @@ -41,51 +44,48 @@ public void execute() {
// 1. Get configuration resources
Path configurationProjectPath =
Paths.get(ResourcesPluginUtil.getGeneratorConfigurationProject().getLocationURI());
File[] directoryChildren = configurationProjectPath.toFile().listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory();
}
});
// determine expected template configurations to be defined
ContextConfiguration contextConfiguration = new ContextConfiguration(configurationProjectPath);
List<String> expectedTemplatesConfigurations = Lists.newArrayList();
for (Trigger t : contextConfiguration.getTriggers()) {
expectedTemplatesConfigurations.add(t.getTemplateFolder());
}

// 2. Determine current state
TemplateConfigurationUpgrader templateConfigurationUpgrader = new TemplateConfigurationUpgrader();
Set<String> hasConfiguration = Sets.newTreeSet();
Map<String, Boolean> isAccessible = Maps.newHashMap();
Set<String> hasConfiguration = Sets.newHashSet();
Set<String> isAccessible = Sets.newHashSet();
Map<String, Path> upgradeableConfigurations = Maps.newHashMap();
Set<String> upToDateConfigurations = Sets.newHashSet();

for (File dir : directoryChildren) {
for (String expectedTemplateFolder : expectedTemplatesConfigurations) {
Path templateFolder = configurationProjectPath.resolve(expectedTemplateFolder);
Path templatesConfigurationPath =
dir.toPath().resolve(ConfigurationConstants.TEMPLATES_CONFIG_FILENAME);
templateFolder.resolve(ConfigurationConstants.TEMPLATES_CONFIG_FILENAME);
File templatesConfigurationFile = templatesConfigurationPath.toFile();
String key =
templatesConfigurationPath.subpath(templatesConfigurationPath.getNameCount() - 2,
templatesConfigurationPath.getNameCount()).toString();
if (templatesConfigurationFile.exists()) {
hasConfiguration.add(key);
hasConfiguration.add(expectedTemplateFolder);
if (templatesConfigurationFile.canWrite()) {
isAccessible.put(key, true);
isAccessible.add(expectedTemplateFolder);

TemplatesConfigurationVersion resolvedVersion =
templateConfigurationUpgrader.resolveLatestCompatibleSchemaVersion(dir.toPath());
templateConfigurationUpgrader
.resolveLatestCompatibleSchemaVersion(templateFolder);
if (resolvedVersion != null) {
if (resolvedVersion != TemplatesConfigurationVersion.getLatest()) {
upgradeableConfigurations.put(key, dir.toPath());
upgradeableConfigurations.put(expectedTemplateFolder, templateFolder);
} else {
upToDateConfigurations.add(key);
upToDateConfigurations.add(expectedTemplateFolder);
}
}
} else {
isAccessible.put(key, false);
}
}
}

// 3. Show current status to the user
AdvancedHealthCheckDialog advancedHealthCheckDialog =
new AdvancedHealthCheckDialog(hasConfiguration, isAccessible, upgradeableConfigurations,
upToDateConfigurations);
new AdvancedHealthCheckDialog(expectedTemplatesConfigurations, hasConfiguration,
isAccessible, upgradeableConfigurations, upToDateConfigurations);
advancedHealthCheckDialog.setBlockOnOpen(false);
advancedHealthCheckDialog.open();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.capgemini.cobigen.eclipse.healthcheck;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -43,16 +44,21 @@ public class AdvancedHealthCheckDialog extends Dialog {
private Set<String> hasConfiguration;

/** Accessibility of templates configuration for changes */
private Map<String, Boolean> isAccessible;
private Set<String> isAccessible;

/** Templates configurations, which can be upgraded */
private Map<String, Path> upgradeableConfigurations;

/** Templates configurations, which are already up to date */
private Set<String> upToDateConfigurations;

/** Expected templates configurations liked by the context configuration */
private List<String> expectedTemplatesConfigurations;

/**
* Creates a new {@link AdvancedHealthCheckDialog} with the given parameters.
* @param expectedTemplatesConfigurations
* expected templates configurations liked by the context configuration
* @param hasConfiguration
* Availability of templates configuration in the found folders
* @param isAccessible
Expand All @@ -63,13 +69,15 @@ public class AdvancedHealthCheckDialog extends Dialog {
* Templates configurations, which are already up to date
* @author mbrunnli (Jun 24, 2015)
*/
AdvancedHealthCheckDialog(Set<String> hasConfiguration, Map<String, Boolean> isAccessible,
Map<String, Path> upgradeableConfigurations, Set<String> upToDateConfigurations) {
AdvancedHealthCheckDialog(List<String> expectedTemplatesConfigurations, Set<String> hasConfiguration,
Set<String> isAccessible, Map<String, Path> upgradeableConfigurations,
Set<String> upToDateConfigurations) {
super(Display.getDefault().getActiveShell());
this.hasConfiguration = hasConfiguration;
this.isAccessible = isAccessible;
this.upgradeableConfigurations = upgradeableConfigurations;
this.upToDateConfigurations = upToDateConfigurations;
this.expectedTemplatesConfigurations = expectedTemplatesConfigurations;
}

/**
Expand All @@ -94,13 +102,15 @@ protected Control createDialogArea(Composite parent) {
gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
gridData.widthHint = 400;
gridData.horizontalSpan = 2;
introduction
.setText("The following template configurations have been found in the current configuration folder:");
introduction.setText("The following template folders are referenced by the context configuration. "
+ "These are the results of scanning each templates configuration.");
introduction.setLayoutData(gridData);

GridData leftGridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
leftGridData.widthHint = 320;
GridData rightGridData = new GridData(GridData.CENTER, GridData.CENTER, false, false);
for (final String key : hasConfiguration) {
rightGridData.widthHint = 80;
for (final String key : expectedTemplatesConfigurations) {
Label label = new Label(contentParent, SWT.NONE);
label.setText(key);
label.setLayoutData(leftGridData);
Expand All @@ -110,26 +120,29 @@ protected Control createDialogArea(Composite parent) {
infoLabel.setText("Up-to-date");
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));
infoLabel.setLayoutData(rightGridData);
} else if (isAccessible.get(key)) {
if (upgradeableConfigurations.get(key) != null) {
Button upgrade = new Button(contentParent, SWT.PUSH);
upgrade.setText("Upgrade");
upgrade.setLayoutData(rightGridData);
upgrade.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
upgradeTemplatesConfiguration(upgradeableConfigurations.get(key));
}
});
} else {
Label infoLabel = new Label(contentParent, SWT.NONE);
infoLabel.setText("Invalid!");
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
infoLabel.setLayoutData(rightGridData);
}
} else if (upgradeableConfigurations.containsKey(key)) {
Button upgrade = new Button(contentParent, SWT.PUSH);
upgrade.setText("Upgrade");
upgrade.setLayoutData(rightGridData);
upgrade.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
upgradeTemplatesConfiguration(upgradeableConfigurations.get(key));
}
});
} else if (!hasConfiguration.contains(key)) {
Label infoLabel = new Label(contentParent, SWT.NONE);
infoLabel.setText("Not found!");
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
infoLabel.setLayoutData(rightGridData);
} else if (!isAccessible.contains(key)) {
Label infoLabel = new Label(contentParent, SWT.NONE);
infoLabel.setText("Not writable!");
infoLabel.setLayoutData(rightGridData);
} else {
Label infoLabel = new Label(contentParent, SWT.NONE);
infoLabel.setText("Not accessible!");
infoLabel.setText("Invalid!");
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
infoLabel.setLayoutData(rightGridData);
}
}
Expand Down
Loading

0 comments on commit 6eecaef

Please sign in to comment.