Merge "Bug 565699 - Add support for bulk migration" into develop
diff --git a/plugins/org.eclipse.app4mc.amalthea.converters.ui/src/org/eclipse/app4mc/amalthea/converters/ui/dialog/ModelMigrationDialog.java b/plugins/org.eclipse.app4mc.amalthea.converters.ui/src/org/eclipse/app4mc/amalthea/converters/ui/dialog/ModelMigrationDialog.java
index 96b2a04..271d2c2 100644
--- a/plugins/org.eclipse.app4mc.amalthea.converters.ui/src/org/eclipse/app4mc/amalthea/converters/ui/dialog/ModelMigrationDialog.java
+++ b/plugins/org.eclipse.app4mc.amalthea.converters.ui/src/org/eclipse/app4mc/amalthea/converters/ui/dialog/ModelMigrationDialog.java
@@ -83,6 +83,7 @@
 	private MigrationSettings migrationSettings;
 	private MigrationSettings recursiveMigrationSettings;
 	private ArrayList<MigrationInputFile> selectedFiles = new ArrayList<>();
+	private ArrayList<String> warningFolders = new ArrayList<>();
 
 	public ModelMigrationDialog(Shell parentShell, MigrationProcessor migrationProcessor, MigrationSettings settings, IProject iProject) {
 		super(parentShell);
@@ -254,16 +255,18 @@
 	}
 
 	private void updateWarningMessage() {
-		Map<String, Map<String, List<MigrationInputFile>>> collect = this.currentSettings.getMigModelFiles().stream()
+		Map<String, Map<String, List<MigrationInputFile>>> collect = this.selectedFiles.stream()
 				.collect(Collectors.groupingBy(
 						mig -> mig.getOriginalFile().getParent(), 
 						Collectors.groupingBy(MigrationInputFile::getModelVersion)));
 		
+		this.warningFolders.clear();
 		StringBuilder builder = new StringBuilder();
 		for (Map.Entry<String, Map<String, List<MigrationInputFile>>> folderMapping : collect.entrySet()) {
 			if (folderMapping.getValue().size() > 1) {
-				String ident = currentSettings.getProject().toURI().relativize(new File(folderMapping.getKey()).toURI()).getPath();
+				String ident = this.currentSettings.getProject().toURI().relativize(new File(folderMapping.getKey()).toURI()).getPath();
 				builder.append("The folder ").append(ident).append(" contains multiple files with different model versions!\n");
+				this.warningFolders.add(ident);
 			}
 		}
 
@@ -271,6 +274,8 @@
 		this.messageLabel.setVisible(this.messageLabel.getText() != null && !this.messageLabel.getText().isEmpty());
 		
 		this.messageLabel.getParent().layout();
+		
+		this.tableViewer.refresh(true);
 	}
 	
 	private void populateMigrationVersionCombo() {
@@ -354,7 +359,18 @@
 						                new StyleRange(0, path.length(),
 						                        Display.getCurrent().getSystemColor(SWT.COLOR_BLUE), null);
 								StyleRange[] range = { styledRange };
-						        cell.setStyleRanges(range);							}
+						        cell.setStyleRanges(range);
+						    }
+							
+							if (warningFolders.stream().anyMatch(folder -> path.startsWith(folder))) {
+								StyleRange styledRange =
+						                new StyleRange(0, path.length(),
+						                        Display.getCurrent().getSystemColor(SWT.COLOR_RED), null);
+								StyleRange[] range = { styledRange };
+						        cell.setStyleRanges(range);
+							} else {
+								cell.setStyleRanges(null);
+							}
 						}
 						catch (final Exception e) {
 
@@ -387,6 +403,17 @@
 						StyleRange[] range = { styledRange };
 				        cell.setStyleRanges(range);
 				    }
+					
+					String path = migModelFile.getProjectRelativePath();
+					if (warningFolders.stream().anyMatch(folder -> path.startsWith(folder))) {
+						StyleRange styledRange =
+				                new StyleRange(0, path.length(),
+				                        Display.getCurrent().getSystemColor(SWT.COLOR_RED), null);
+						StyleRange[] range = { styledRange };
+				        cell.setStyleRanges(range);
+					} else {
+						cell.setStyleRanges(null);
+					}
 				}
 				
 				super.update(cell);
@@ -406,6 +433,7 @@
 			} else {
 				selectedFiles.remove(event.getElement());
 			}
+			updateWarningMessage();
 		});
 
 		this.selectedFiles = new ArrayList<>(this.currentSettings.getMigModelFiles());