Skip to content

Commit 6eecaef

Browse files
committed
#186: Merge branch 'dev_eclipseplugin'
2 parents 3681303 + 970928c commit 6eecaef

File tree

13 files changed

+132
-105
lines changed

13 files changed

+132
-105
lines changed

cobigen-eclipse/cobigen-eclipse-feature/feature.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<feature
33
id="cobigen-eclipse-feature"
44
label="CobiGen Eclipse Plug-in"
5-
version="1.4.2"
5+
version="1.4.3"
66
provider-name="Capgemini">
77

88
<description>

cobigen-eclipse/cobigen-eclipse-feature/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<artifactId>cobigen-eclipse-feature</artifactId>
77
<name>CobiGen - Eclipse Plug-In Feature</name>
88
<packaging>eclipse-feature</packaging>
9-
<version>1.4.2</version>
9+
<version>1.4.3</version>
1010

1111
<parent>
1212
<groupId>com.capgemini</groupId>

cobigen-eclipse/cobigen-eclipse-updatesite/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>com.capgemini</groupId>
66
<artifactId>cobigen-eclipse-updatesite</artifactId>
77
<name>CobiGen - Eclipse Plug-In UpdateSite</name>
8-
<version>1.4.2</version>
8+
<version>1.4.3</version>
99
<packaging>eclipse-repository</packaging>
1010

1111
<parent>

cobigen-eclipse/cobigen-eclipse/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: CobiGen Eclipse Plug-In
44
Bundle-SymbolicName: cobigen-eclipse;singleton:=true
5-
Bundle-Version: 1.4.2
5+
Bundle-Version: 1.4.3
66
Bundle-Activator: com.capgemini.cobigen.eclipse.Activator
77
Bundle-Vendor: Capgemini
88
Require-Bundle: org.eclipse.ui;bundle-version="3.104.0",

cobigen-eclipse/cobigen-eclipse/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<artifactId>cobigen-eclipse</artifactId>
77
<name>CobiGen - Eclipse Plug-In</name>
88
<packaging>eclipse-plugin</packaging>
9-
<version>1.4.2</version>
9+
<version>1.4.3</version>
1010

1111
<parent>
1212
<groupId>com.capgemini</groupId>

cobigen-eclipse/cobigen-eclipse/src/com/capgemini/cobigen/eclipse/common/tools/PlatformUIUtil.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,18 @@ public void run() {
9595
public static MultiStatus createMultiStatus(Throwable t) {
9696

9797
List<Status> childStatus = Lists.newArrayList();
98-
99-
StackTraceElement[] stackTraces = t.getStackTrace();
100-
101-
for (StackTraceElement stackTrace : stackTraces) {
102-
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, stackTrace.toString());
98+
StackTraceElement[] stackTraceElements = t.getStackTrace();
99+
for (int i = 0; i < stackTraceElements.length; i++) {
100+
StackTraceElement element = stackTraceElements[i];
101+
Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, element.toString());
103102
childStatus.add(status);
104103
}
105104

105+
if (t.getCause() != null) {
106+
childStatus.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Caused by"));
107+
childStatus.add(createMultiStatus(t.getCause()));
108+
}
109+
106110
MultiStatus ms =
107111
new MultiStatus(Activator.PLUGIN_ID, IStatus.ERROR, childStatus.toArray(new Status[0]),
108112
t.toString(), t);

cobigen-eclipse/cobigen-eclipse/src/com/capgemini/cobigen/eclipse/generator/AbstractCobiGenWrapper.java

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public AbstractCobiGenWrapper() throws GeneratorProjectNotExistentException, Cor
6262
private CobiGen initializeGenerator() throws GeneratorProjectNotExistentException, CoreException,
6363
InvalidConfigurationException, IOException {
6464

65+
ResourcesPluginUtil.refreshConfigurationProject();
6566
IProject generatorProj = ResourcesPluginUtil.getGeneratorConfigurationProject();
6667
return new CobiGen(generatorProj.getLocationURI());
6768
}

cobigen-eclipse/cobigen-eclipse/src/com/capgemini/cobigen/eclipse/generator/GeneratorWrapperFactory.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class GeneratorWrapperFactory {
4848
*/
4949
public static CobiGenWrapper createGenerator(IStructuredSelection selection)
5050
throws GeneratorCreationException, GeneratorProjectNotExistentException, InvalidInputException {
51+
5152
List<Object> extractedInputs = extractValidEclipseInputs(selection);
5253

5354
if (extractedInputs.size() > 0) {
@@ -94,7 +95,7 @@ public static CobiGenWrapper createGenerator(IStructuredSelection selection)
9495
* combination of inputs.
9596
* @author mbrunnli (04.12.2014)
9697
*/
97-
public static List<Object> extractValidEclipseInputs(IStructuredSelection selection)
98+
private static List<Object> extractValidEclipseInputs(IStructuredSelection selection)
9899
throws InvalidInputException {
99100
LOG.info("Start extraction of valid inputs from selection...");
100101
int type = 0;

cobigen-eclipse/cobigen-eclipse/src/com/capgemini/cobigen/eclipse/healthcheck/AdvancedHealthCheck.java

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
package com.capgemini.cobigen.eclipse.healthcheck;
22

33
import java.io.File;
4-
import java.io.FileFilter;
54
import java.nio.file.Path;
65
import java.nio.file.Paths;
6+
import java.util.List;
77
import java.util.Map;
88
import java.util.Set;
99

1010
import org.eclipse.core.runtime.CoreException;
1111
import org.slf4j.Logger;
1212
import org.slf4j.LoggerFactory;
1313

14+
import com.capgemini.cobigen.config.ContextConfiguration;
1415
import com.capgemini.cobigen.config.constant.ConfigurationConstants;
1516
import com.capgemini.cobigen.config.constant.TemplatesConfigurationVersion;
17+
import com.capgemini.cobigen.config.entity.Trigger;
1618
import com.capgemini.cobigen.config.upgrade.TemplateConfigurationUpgrader;
1719
import com.capgemini.cobigen.eclipse.common.tools.PlatformUIUtil;
1820
import com.capgemini.cobigen.eclipse.common.tools.ResourcesPluginUtil;
21+
import com.google.common.collect.Lists;
1922
import com.google.common.collect.Maps;
2023
import com.google.common.collect.Sets;
2124

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

5154
// 2. Determine current state
5255
TemplateConfigurationUpgrader templateConfigurationUpgrader = new TemplateConfigurationUpgrader();
53-
Set<String> hasConfiguration = Sets.newTreeSet();
54-
Map<String, Boolean> isAccessible = Maps.newHashMap();
56+
Set<String> hasConfiguration = Sets.newHashSet();
57+
Set<String> isAccessible = Sets.newHashSet();
5558
Map<String, Path> upgradeableConfigurations = Maps.newHashMap();
5659
Set<String> upToDateConfigurations = Sets.newHashSet();
5760

58-
for (File dir : directoryChildren) {
61+
for (String expectedTemplateFolder : expectedTemplatesConfigurations) {
62+
Path templateFolder = configurationProjectPath.resolve(expectedTemplateFolder);
5963
Path templatesConfigurationPath =
60-
dir.toPath().resolve(ConfigurationConstants.TEMPLATES_CONFIG_FILENAME);
64+
templateFolder.resolve(ConfigurationConstants.TEMPLATES_CONFIG_FILENAME);
6165
File templatesConfigurationFile = templatesConfigurationPath.toFile();
62-
String key =
63-
templatesConfigurationPath.subpath(templatesConfigurationPath.getNameCount() - 2,
64-
templatesConfigurationPath.getNameCount()).toString();
6566
if (templatesConfigurationFile.exists()) {
66-
hasConfiguration.add(key);
67+
hasConfiguration.add(expectedTemplateFolder);
6768
if (templatesConfigurationFile.canWrite()) {
68-
isAccessible.put(key, true);
69+
isAccessible.add(expectedTemplateFolder);
6970

7071
TemplatesConfigurationVersion resolvedVersion =
71-
templateConfigurationUpgrader.resolveLatestCompatibleSchemaVersion(dir.toPath());
72+
templateConfigurationUpgrader
73+
.resolveLatestCompatibleSchemaVersion(templateFolder);
7274
if (resolvedVersion != null) {
7375
if (resolvedVersion != TemplatesConfigurationVersion.getLatest()) {
74-
upgradeableConfigurations.put(key, dir.toPath());
76+
upgradeableConfigurations.put(expectedTemplateFolder, templateFolder);
7577
} else {
76-
upToDateConfigurations.add(key);
78+
upToDateConfigurations.add(expectedTemplateFolder);
7779
}
7880
}
79-
} else {
80-
isAccessible.put(key, false);
8181
}
8282
}
8383
}
8484

8585
// 3. Show current status to the user
8686
AdvancedHealthCheckDialog advancedHealthCheckDialog =
87-
new AdvancedHealthCheckDialog(hasConfiguration, isAccessible, upgradeableConfigurations,
88-
upToDateConfigurations);
87+
new AdvancedHealthCheckDialog(expectedTemplatesConfigurations, hasConfiguration,
88+
isAccessible, upgradeableConfigurations, upToDateConfigurations);
8989
advancedHealthCheckDialog.setBlockOnOpen(false);
9090
advancedHealthCheckDialog.open();
9191

cobigen-eclipse/cobigen-eclipse/src/com/capgemini/cobigen/eclipse/healthcheck/AdvancedHealthCheckDialog.java

+37-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.capgemini.cobigen.eclipse.healthcheck;
22

33
import java.nio.file.Path;
4+
import java.util.List;
45
import java.util.Map;
56
import java.util.Set;
67
import java.util.UUID;
@@ -43,16 +44,21 @@ public class AdvancedHealthCheckDialog extends Dialog {
4344
private Set<String> hasConfiguration;
4445

4546
/** Accessibility of templates configuration for changes */
46-
private Map<String, Boolean> isAccessible;
47+
private Set<String> isAccessible;
4748

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

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

55+
/** Expected templates configurations liked by the context configuration */
56+
private List<String> expectedTemplatesConfigurations;
57+
5458
/**
5559
* Creates a new {@link AdvancedHealthCheckDialog} with the given parameters.
60+
* @param expectedTemplatesConfigurations
61+
* expected templates configurations liked by the context configuration
5662
* @param hasConfiguration
5763
* Availability of templates configuration in the found folders
5864
* @param isAccessible
@@ -63,13 +69,15 @@ public class AdvancedHealthCheckDialog extends Dialog {
6369
* Templates configurations, which are already up to date
6470
* @author mbrunnli (Jun 24, 2015)
6571
*/
66-
AdvancedHealthCheckDialog(Set<String> hasConfiguration, Map<String, Boolean> isAccessible,
67-
Map<String, Path> upgradeableConfigurations, Set<String> upToDateConfigurations) {
72+
AdvancedHealthCheckDialog(List<String> expectedTemplatesConfigurations, Set<String> hasConfiguration,
73+
Set<String> isAccessible, Map<String, Path> upgradeableConfigurations,
74+
Set<String> upToDateConfigurations) {
6875
super(Display.getDefault().getActiveShell());
6976
this.hasConfiguration = hasConfiguration;
7077
this.isAccessible = isAccessible;
7178
this.upgradeableConfigurations = upgradeableConfigurations;
7279
this.upToDateConfigurations = upToDateConfigurations;
80+
this.expectedTemplatesConfigurations = expectedTemplatesConfigurations;
7381
}
7482

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

101109
GridData leftGridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
110+
leftGridData.widthHint = 320;
102111
GridData rightGridData = new GridData(GridData.CENTER, GridData.CENTER, false, false);
103-
for (final String key : hasConfiguration) {
112+
rightGridData.widthHint = 80;
113+
for (final String key : expectedTemplatesConfigurations) {
104114
Label label = new Label(contentParent, SWT.NONE);
105115
label.setText(key);
106116
label.setLayoutData(leftGridData);
@@ -110,26 +120,29 @@ protected Control createDialogArea(Composite parent) {
110120
infoLabel.setText("Up-to-date");
111121
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));
112122
infoLabel.setLayoutData(rightGridData);
113-
} else if (isAccessible.get(key)) {
114-
if (upgradeableConfigurations.get(key) != null) {
115-
Button upgrade = new Button(contentParent, SWT.PUSH);
116-
upgrade.setText("Upgrade");
117-
upgrade.setLayoutData(rightGridData);
118-
upgrade.addSelectionListener(new SelectionAdapter() {
119-
@Override
120-
public void widgetSelected(SelectionEvent e) {
121-
upgradeTemplatesConfiguration(upgradeableConfigurations.get(key));
122-
}
123-
});
124-
} else {
125-
Label infoLabel = new Label(contentParent, SWT.NONE);
126-
infoLabel.setText("Invalid!");
127-
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
128-
infoLabel.setLayoutData(rightGridData);
129-
}
123+
} else if (upgradeableConfigurations.containsKey(key)) {
124+
Button upgrade = new Button(contentParent, SWT.PUSH);
125+
upgrade.setText("Upgrade");
126+
upgrade.setLayoutData(rightGridData);
127+
upgrade.addSelectionListener(new SelectionAdapter() {
128+
@Override
129+
public void widgetSelected(SelectionEvent e) {
130+
upgradeTemplatesConfiguration(upgradeableConfigurations.get(key));
131+
}
132+
});
133+
} else if (!hasConfiguration.contains(key)) {
134+
Label infoLabel = new Label(contentParent, SWT.NONE);
135+
infoLabel.setText("Not found!");
136+
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
137+
infoLabel.setLayoutData(rightGridData);
138+
} else if (!isAccessible.contains(key)) {
139+
Label infoLabel = new Label(contentParent, SWT.NONE);
140+
infoLabel.setText("Not writable!");
141+
infoLabel.setLayoutData(rightGridData);
130142
} else {
131143
Label infoLabel = new Label(contentParent, SWT.NONE);
132-
infoLabel.setText("Not accessible!");
144+
infoLabel.setText("Invalid!");
145+
infoLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
133146
infoLabel.setLayoutData(rightGridData);
134147
}
135148
}

0 commit comments

Comments
 (0)