summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2014-02-12 13:22:54 (EST)
committerJuergen Haug2014-02-14 06:26:33 (EST)
commit1e76423a6be64b0519e6f72dc0baa4d4679b0435 (patch)
tree1ebf0ef720b29c3bf19b3babd81569fab6e4a662
parent4ce072b06cd7d0d2d7aaae5b6f644a67b2a32084 (diff)
downloadorg.eclipse.etrice-1e76423a6be64b0519e6f72dc0baa4d4679b0435.zip
org.eclipse.etrice-1e76423a6be64b0519e6f72dc0baa4d4679b0435.tar.gz
org.eclipse.etrice-1e76423a6be64b0519e6f72dc0baa4d4679b0435.tar.bz2
[ui] wizard validates roomModel namerefs/changes/08/21908/5
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/EmptyProjectWizard.java9
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ModelCreationPage.java7
-rw-r--r--plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/RoomValidationHelper.java42
4 files changed, 60 insertions, 1 deletions
diff --git a/plugins/org.eclipse.etrice.generator.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.generator.ui/META-INF/MANIFEST.MF
index e571dd2..e72ab41 100644
--- a/plugins/org.eclipse.etrice.generator.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.generator.ui/META-INF/MANIFEST.MF
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.jdt.core;bundle-version="3.9.0",
org.eclipse.jdt.launching;bundle-version="3.7.0",
org.eclipse.ui.ide;bundle-version="3.9.0",
- org.eclipse.xtext.xbase.lib;bundle-version="2.4.2"
+ org.eclipse.xtext.xbase.lib;bundle-version="2.4.2",
+ org.eclipse.xtext
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.etrice.generator.ui.Activator
Export-Package: org.eclipse.etrice.generator.ui.configurator,
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 422bde5..eceb1b5 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
@@ -29,6 +29,7 @@ import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
@@ -54,6 +55,7 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
protected IProject runtimeProject;
protected String initialProjectName;
protected URI modelURI;
+ protected RoomValidationHelper roomValidator;
private EmptyProjectConfigPage config;
private static final String[] additionalLaunchConfigLines = new String[] {
@@ -67,6 +69,8 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
runtimeProject = workspace.getRoot().getProject("org.eclipse.etrice.runtime.java");
+
+ roomValidator = RoomValidationHelper.createInstance();
}
@Override
@@ -76,6 +80,11 @@ public class EmptyProjectWizard extends Wizard implements INewWizard {
@Override
protected boolean validatePage() {
if (super.validatePage()) {
+
+ String projectName = getProjectName();
+ if(!roomValidator.isValidFQN(projectName))
+ setMessage("RoomModel name will be invalid ("+roomValidator.getMessage()+")", WizardPage.WARNING);
+
IPath locationPath = getLocationPath();
projectLocation = Platform.getLocation().equals(
locationPath) ? null : locationPath;
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ModelCreationPage.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ModelCreationPage.java
index 0c97f1c..0dd1d79 100644
--- a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ModelCreationPage.java
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/ModelCreationPage.java
@@ -38,6 +38,7 @@ import org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup;
public class ModelCreationPage extends WizardPage implements Listener {
private static final int SIZING_CONTAINER_GROUP_HEIGHT = 250;
+ protected RoomValidationHelper roomValidator;
private ResourceAndContainerGroup resourceGroup;
private IStructuredSelection selection;
@@ -47,6 +48,7 @@ public class ModelCreationPage extends WizardPage implements Listener {
*/
public ModelCreationPage(String pageName, IStructuredSelection selection) {
super(pageName);
+ roomValidator = RoomValidationHelper.createInstance();
this.selection = selection;
}
@@ -146,10 +148,15 @@ public class ModelCreationPage extends WizardPage implements Listener {
setErrorMessage("file '"+file+"' already exists in the workspace");
return false;
}
+ if(!roomValidator.isValidFQN(getBaseName())){
+ setErrorMessage("Invalid roomModel name ("+roomValidator.getMessage()+")");
+ return false;
+ }
if (valid) {
setErrorMessage(null);
setMessage(null);
}
+
return valid;
}
diff --git a/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/RoomValidationHelper.java b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/RoomValidationHelper.java
new file mode 100644
index 0000000..e62f3df
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.ui/src/org/eclipse/etrice/generator/ui/wizard/RoomValidationHelper.java
@@ -0,0 +1,42 @@
+package org.eclipse.etrice.generator.ui.wizard;
+
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.eclipse.etrice.core.parser.antlr.RoomParser;
+import org.eclipse.xtext.nodemodel.INode;
+import org.eclipse.xtext.parser.IParseResult;
+import com.google.inject.Injector;
+
+public class RoomValidationHelper {
+
+ private RoomParser parser;
+ private String parserMessage;
+
+ private RoomValidationHelper(RoomParser parser){
+ this.parser = parser;
+ }
+
+ public static RoomValidationHelper createInstance(){
+ Injector injector = new org.eclipse.etrice.core.RoomStandaloneSetup().createInjector();
+ return new RoomValidationHelper(injector.getInstance(RoomParser.class));
+ }
+
+ public String getMessage(){
+ return parserMessage;
+ }
+
+ public boolean isValidFQN(String name){
+ Reader reader = new StringReader(name);
+ IParseResult result = parser.parse(parser.getGrammarAccess().getFQNRule(), reader);
+
+ parserMessage = null;
+ for(INode node : result.getSyntaxErrors())
+ if(node.getSyntaxErrorMessage() != null){
+ parserMessage = node.getSyntaxErrorMessage().getMessage();
+ break;
+ }
+
+ return !result.hasSyntaxErrors();
+ }
+}