forked from eclipse-vorto/vorto
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate multiple model projects wizards to single project wizard.
Closes eclipse-vorto#65 Signed-off-by: Nagavijay Sivakumar <[email protected]> Added new Vorto Nature for single model project. Signed-off-by: Nagavijay Sivakumar <[email protected]>
- Loading branch information
Nagavijay Sivakumar
committed
May 6, 2016
1 parent
25c8bdd
commit 0c40520
Showing
16 changed files
with
646 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/nature/VortoProjectNature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016 Bosch Software Innovations GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* The Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* Contributors: | ||
* Bosch Software Innovations GmbH - Please refer to git log | ||
*******************************************************************************/ | ||
package org.eclipse.vorto.core.model.nature; | ||
|
||
import org.eclipse.core.resources.IProject; | ||
import org.eclipse.core.resources.IProjectNature; | ||
import org.eclipse.core.runtime.CoreException; | ||
|
||
public class VortoProjectNature implements IProjectNature { | ||
|
||
public static final String VORTO_NATURE = "org.eclipse.vorto.vortonature"; | ||
|
||
private IProject project; | ||
|
||
@Override | ||
public void configure() throws CoreException { | ||
|
||
} | ||
|
||
@Override | ||
public void deconfigure() throws CoreException { | ||
|
||
} | ||
|
||
@Override | ||
public IProject getProject() { | ||
return project; | ||
} | ||
|
||
@Override | ||
public void setProject(IProject project) { | ||
this.project = project; | ||
} | ||
|
||
} |
106 changes: 106 additions & 0 deletions
106
bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractModelWizardPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016 Bosch Software Innovations GmbH and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Eclipse Distribution License v1.0 which accompany this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* The Eclipse Distribution License is available at | ||
* http://www.eclipse.org/org/documents/edl-v10.php. | ||
* | ||
* Contributors: | ||
* Bosch Software Innovations GmbH - Please refer to git log | ||
*******************************************************************************/ | ||
package org.eclipse.vorto.wizard; | ||
|
||
import java.io.IOException; | ||
import java.util.regex.Pattern; | ||
|
||
import org.eclipse.core.resources.IWorkspace; | ||
import org.eclipse.core.resources.ResourcesPlugin; | ||
import org.eclipse.core.runtime.IPath; | ||
import org.eclipse.core.runtime.Path; | ||
import org.eclipse.vorto.codegen.ui.context.IModelProjectContext; | ||
|
||
import com.google.common.base.Strings; | ||
|
||
public abstract class AbstractModelWizardPage extends AbstractWizardPage implements | ||
IModelProjectContext { | ||
|
||
public static final String PROJECTNAME_REGEX = "[^a-zA-Z0-9 \\._]"; | ||
public static final String FUNCTIONBLOCK_REGEX = "[A-Z][a-zA-Z0-9_]*$"; | ||
public static final String VERSION_REGEX = "^\\d+\\.\\d+\\.\\d+(-\\w+)*$"; | ||
|
||
protected AbstractModelWizardPage(String pageName) { | ||
super(pageName); | ||
} | ||
|
||
protected boolean checkProjectName(String projectName) { | ||
if (checkForRegexPattern(projectName, true, PROJECTNAME_REGEX)) { | ||
setErrorMessage("Project name should not contain special characters."); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
protected boolean checkModelName(String modelName) { | ||
if (checkForRegexPattern(modelName, false, FUNCTIONBLOCK_REGEX)) { | ||
setErrorMessage("Model name should start with a capital letter and must not contain any special characters."); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
protected boolean checkFBVersion(String fbVersion) { | ||
if (checkForRegexPattern(fbVersion, false, VERSION_REGEX)) { | ||
setErrorMessage("Version should follow pattern <MAJOR>.<MINOR>.<PATCH>"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
protected boolean checkForRegexPattern(String input, boolean expectedBool, | ||
String regexPattern) { | ||
return Pattern.compile(regexPattern).matcher(input).matches() == expectedBool; | ||
} | ||
|
||
protected boolean validateStrExist(String string, String errorMsgToBeShown) { | ||
if (Strings.isNullOrEmpty(string)) { | ||
this.setErrorMessage(errorMsgToBeShown); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
protected boolean validateExistingSameProjectName(String projectName) { | ||
IWorkspace workspace = ResourcesPlugin.getWorkspace(); | ||
|
||
if (workspace.getRoot().getProject(getProjectName()).exists()) { | ||
setErrorMessage("Project " + getProjectName() + " already exists."); | ||
return false; | ||
} | ||
|
||
IPath projectLocation = ResourcesPlugin.getWorkspace().getRoot() | ||
.getLocation().append(projectName); | ||
if (projectLocation.toFile().exists()) { | ||
try { | ||
String canonicalPath = projectLocation.toFile() | ||
.getCanonicalPath(); | ||
projectLocation = new Path(canonicalPath); | ||
|
||
String existingName = projectLocation.lastSegment(); | ||
if (!existingName.equals(projectName)) { | ||
setErrorMessage("Project " + getProjectName() | ||
+ " already exists."); | ||
return false; | ||
} | ||
} catch (IOException e) { | ||
} | ||
|
||
} | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.