diff --git a/bundles/org.eclipse.vorto.codegen.ui/src/org/eclipse/vorto/codegen/ui/handler/ModelGenerationTask.java b/bundles/org.eclipse.vorto.codegen.ui/src/org/eclipse/vorto/codegen/ui/handler/ModelGenerationTask.java index e6ef557b3a..81b35b9fdb 100644 --- a/bundles/org.eclipse.vorto.codegen.ui/src/org/eclipse/vorto/codegen/ui/handler/ModelGenerationTask.java +++ b/bundles/org.eclipse.vorto.codegen.ui/src/org/eclipse/vorto/codegen/ui/handler/ModelGenerationTask.java @@ -21,15 +21,16 @@ public class ModelGenerationTask extends AbstractTemplateGeneratorTask { - public static final String SRC_MODELS = "src/models/"; private final String suffix; private final ITemplate fileTemplate; + private final String modelFolder; public ModelGenerationTask(String fileSuffix, - ITemplate template) { + ITemplate template, String modelFolder) { suffix = fileSuffix.startsWith(".") ? fileSuffix : "." .concat(fileSuffix); fileTemplate = template; + this.modelFolder = modelFolder; } @Override @@ -39,7 +40,7 @@ public String getFileName(IModelProjectContext ctx) { @Override public String getPath(IModelProjectContext ctx) { - return SRC_MODELS; + return modelFolder; } @Override diff --git a/bundles/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/InformationModelProject.java b/bundles/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/InformationModelProject.java index bbe776ccb3..964d1d9b46 100644 --- a/bundles/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/InformationModelProject.java +++ b/bundles/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/InformationModelProject.java @@ -29,6 +29,7 @@ import org.eclipse.vorto.core.api.model.model.ModelReference; import org.eclipse.vorto.core.api.model.model.ModelType; import org.eclipse.vorto.core.model.nature.InformationModelProjectNature; +import org.eclipse.vorto.core.model.nature.VortoProjectNature; import org.eclipse.vorto.core.parser.IModelParser; public class InformationModelProject extends AbstractModelProject { @@ -45,7 +46,7 @@ public IFile getModelFile() { public static boolean isInformationModelProject(IProject project) { try { - return project.getNature(InformationModelProjectNature.NATURE_ID) != null; + return (project.getNature(InformationModelProjectNature.NATURE_ID) != null || project.getNature(VortoProjectNature.VORTO_NATURE) != null); } catch (CoreException e) { return false; } diff --git a/bundles/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/nature/VortoProjectNature.java b/bundles/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/nature/VortoProjectNature.java new file mode 100644 index 0000000000..d549b7b98f --- /dev/null +++ b/bundles/org.eclipse.vorto.core.ui/src/org/eclipse/vorto/core/model/nature/VortoProjectNature.java @@ -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; + } + +} diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractModelWizardPage.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractModelWizardPage.java new file mode 100644 index 0000000000..1fef0c1fb3 --- /dev/null +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractModelWizardPage.java @@ -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 .."); + 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; + } + +} diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java index 7abba8bb49..707e63c4b6 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/AbstractWizardPage.java @@ -21,13 +21,12 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.vorto.codegen.ui.context.IModelProjectContext; import com.google.common.base.Strings; -public abstract class AbstractWizardPage extends WizardPage implements - IModelProjectContext { +public abstract class AbstractWizardPage extends WizardPage { public static final String PROJECTNAME_REGEX = "[^a-zA-Z0-9 \\._]"; public static final String FUNCTIONBLOCK_REGEX = "[A-Z][a-zA-Z0-9_]*$"; @@ -36,6 +35,14 @@ public abstract class AbstractWizardPage extends WizardPage implements protected AbstractWizardPage(String pageName) { super(pageName); } + + protected AbstractWizardPage(String pageName, String title, ImageDescriptor descriptor) { + super(pageName, title, descriptor); + } + + protected String getWindowTitle() { + return ""; + } protected boolean checkProjectName(String projectName) { if (checkForRegexPattern(projectName, true, PROJECTNAME_REGEX)) { @@ -104,4 +111,6 @@ protected boolean validateExistingSameProjectName(String projectName) { return true; } + protected abstract String getProjectName(); + } diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/ModelBaseWizardPage.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/ModelBaseWizardPage.java index a98a38adf8..da38ee1859 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/ModelBaseWizardPage.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/ModelBaseWizardPage.java @@ -15,24 +15,25 @@ package org.eclipse.vorto.wizard; -import org.apache.commons.lang3.StringUtils; +import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; -public abstract class ModelBaseWizardPage extends AbstractWizardPage { +public abstract class ModelBaseWizardPage extends AbstractModelWizardPage { protected ModelBaseWizardPage(String pageName) { super(pageName); @@ -41,13 +42,12 @@ protected ModelBaseWizardPage(String pageName) { private Text txtModelName; private Text txtVersion; - private Text txtProjectName; - private Text txtWorkspaceLocation; private Text txtDescription; private String workspaceLocation; + protected Composite topContainer; public void createControl(Composite parent) { - Composite topContainer = new Composite(parent, SWT.NULL); + topContainer = new Composite(parent, SWT.NULL); setControl(topContainer); topContainer.setLayout(new GridLayout(1, false)); @@ -108,57 +108,6 @@ public void modifyText(ModifyEvent e) { gridTxtDescription.heightHint = 53; txtDescription.setLayoutData(gridTxtDescription); - Group grpProjectDetails = new Group(topContainer, SWT.NONE); - grpProjectDetails.setLayout(new GridLayout(3, false)); - GridData gridGrpProjectDetails = new GridData(SWT.CENTER, SWT.CENTER, - false, false, 1, 1); - gridGrpProjectDetails.heightHint = 97; - gridGrpProjectDetails.widthHint = 575; - grpProjectDetails.setLayoutData(gridGrpProjectDetails); - grpProjectDetails.setText("Project Details"); - - Label lblProjectName = new Label(grpProjectDetails, SWT.NONE); - GridData gridLblProjectName = new GridData(SWT.RIGHT, SWT.CENTER, - false, false, 1, 1); - gridLblProjectName.widthHint = 78; - lblProjectName.setLayoutData(gridLblProjectName); - lblProjectName.setText("Project Name:"); - - txtProjectName = new Text(grpProjectDetails, SWT.BORDER); - GridData gridTxtProjectName = new GridData(SWT.FILL, SWT.CENTER, false, - false, 1, 1); - gridTxtProjectName.widthHint = 370; - txtProjectName.setLayoutData(gridTxtProjectName); - txtProjectName.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - projectNameChanged(); - dialogChanged(); - } - }); - new Label(grpProjectDetails, SWT.NONE); - - Label lblLocation = new Label(grpProjectDetails, SWT.NONE); - GridData gridLblLocation = new GridData(SWT.RIGHT, SWT.CENTER, false, - false, 1, 1); - gridLblLocation.widthHint = 48; - lblLocation.setLayoutData(gridLblLocation); - lblLocation.setText("Location:"); - - txtWorkspaceLocation = new Text(grpProjectDetails, SWT.BORDER); - txtWorkspaceLocation.setEditable(false); - GridData gridTxtLocation = new GridData(SWT.LEFT, SWT.CENTER, false, - false, 1, 1); - gridTxtLocation.widthHint = 385; - txtWorkspaceLocation.setLayoutData(gridTxtLocation); - - Button btnBrowse = new Button(grpProjectDetails, SWT.NONE); - btnBrowse.setText("Browse..."); - btnBrowse.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleBrowse(e); - } - - }); initialize(); dialogChanged(); setControl(topContainer); @@ -167,33 +116,14 @@ public void widgetSelected(SelectionEvent e) { private void initialize() { txtModelName.setText(getDefaultModelName()); txtVersion.setText(getDefaultVersion()); - txtProjectName.setText(getDefaultModelName()); + /*txtProjectName.setText(getDefaultModelName()); txtWorkspaceLocation.setText(getWorkspaceLocation() + "/" - + getDefaultModelName()); + + getDefaultModelName());*/ txtDescription.setText(getDefaultDescription() + getDefaultModelName()); } - protected void handleBrowse(SelectionEvent e) { - DirectoryDialog directoryDialog = new DirectoryDialog(getShell()); - directoryDialog.setFilterPath(workspaceLocation); - directoryDialog.setText("Workspace folder selection"); - directoryDialog.setMessage("Select a directory for this project"); - - String selectedDirectory = directoryDialog.open(); - selectedDirectory = StringUtils.replace(selectedDirectory, "\\", "/"); - - if (selectedDirectory != null) { - workspaceLocation = selectedDirectory; - updateWorkspaceLocationField(workspaceLocation); - dialogChanged(); - } - } - - private void projectNameChanged() { - txtWorkspaceLocation.setText(getWorkspaceLocation() + "/" - + getProjectName()); - } + public void dialogChanged() { if (this.validateProject()) { @@ -205,34 +135,24 @@ public void dialogChanged() { } + public Composite getTopContainer() { + return topContainer; + } + protected boolean validateProject() { boolean result = true; - String projectName = getProjectName(); String modelName = getModelName(); String fbVersion = getModelVersion(); - - result &= validateStrExist(projectName, - "Project name must be specified"); result &= validateStrExist(modelName, "Functionblock name must be specified"); - result &= validateExistingSameProjectName(projectName); - - result &= checkProjectName(projectName); - result &= checkModelName(modelName); result &= checkFBVersion(fbVersion); return result; } - public void updateWorkspaceLocationField(String directory) { - txtWorkspaceLocation.setText(directory + "/" + getProjectName()); - } - private void modelNameChanged() { String modelName = getModelName(); - txtProjectName.setText(modelName); - txtWorkspaceLocation.setText(getWorkspaceLocation() + "/" + modelName); txtDescription.setText(getDefaultDescription() + modelName); } @@ -247,7 +167,26 @@ public String getWorkspaceLocation() { @Override public String getProjectName() { - return txtProjectName.getText(); + IProject project = getProject(); + + return (project != null) ? project.getName() : null; + } + + public IProject getProject() { + IProject project = null; + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection(); + Object firstElement = selection.getFirstElement(); + if (firstElement instanceof IAdaptable) + { + project = (IProject)((IAdaptable)firstElement).getAdapter(IProject.class); + IPath path = project.getFullPath(); + System.out.println(path); + } + } + return project; + } @Override diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/VortoProjectCreationTask.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/VortoProjectCreationTask.java new file mode 100644 index 0000000000..38d4011aa0 --- /dev/null +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/VortoProjectCreationTask.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.vorto.codegen.api.DefaultMappingContext; +import org.eclipse.vorto.codegen.ui.context.IProjectContext; +import org.eclipse.vorto.codegen.ui.progresstask.IProgressTask; +import org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator; +import org.eclipse.vorto.codegen.ui.tasks.LocationWrapper; +import org.eclipse.vorto.core.model.nature.VortoProjectNature; + +public class VortoProjectCreationTask implements IProgressTask { + + + private static final String ERROR_MESSAGE = "Problem when creating project, error: "; + + private String errorMessage = ""; + + private String projectName; + private String workspaceLocation; + + public static final String XTEXT_NATURE = "org.eclipse.xtext.ui.shared.xtextNature"; + public static final String[] ALL_MODEL_FOLDERS = {"datatypes", "functionblocks", "informationmodels","mappings"}; + + private IProjectContext context = null; + + public VortoProjectCreationTask(IProjectContext context) { + this.projectName = context.getProjectName(); + workspaceLocation = context.getWorkspaceLocation(); + this.context = context; + } + + @Override + public void run(IProgressMonitor monitor) throws InvocationTargetException, + InterruptedException { + try { + EclipseProjectGenerator generator = new EclipseProjectGenerator( + new LocationWrapper(workspaceLocation, projectName)); + generator.addNature(XTEXT_NATURE); + generator.addNature(VortoProjectNature.VORTO_NATURE); + for (String folder : ALL_MODEL_FOLDERS) { + generator.addFolder(folder); + } + generator.generate(context, new DefaultMappingContext(), monitor); + + IProject iProject = generator.getProject(); + iProject.refreshLocal(IResource.DEPTH_ONE, monitor); + + } catch (CoreException e) { + errorMessage = e.getMessage(); + throw new RuntimeException(ERROR_MESSAGE + e.getMessage(), e); + } finally { + monitor.done(); + } + } + + @Override + public String getErrorMessage() { + return this.errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + +} diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/WizardCreateProjectHandler.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/WizardCreateProjectHandler.java index 22af410385..840209d2ca 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/WizardCreateProjectHandler.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/WizardCreateProjectHandler.java @@ -17,8 +17,13 @@ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; public abstract class WizardCreateProjectHandler extends AbstractHandler { @@ -31,6 +36,23 @@ public Object execute(ExecutionEvent arg0) throws ExecutionException { dialog.open(); return null; } + + public IProject getCurrentProject() { + IProject project = null; + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) + { + IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection(); + Object firstElement = selection.getFirstElement(); + if (firstElement instanceof IAdaptable) + { + project = (IProject)((IAdaptable)firstElement).getAdapter(IProject.class); + IPath path = project.getFullPath(); + System.out.println(path); + } + } + return project; + } public abstract Wizard getWizard(); } diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/datatype/AbstractDatatypeWizard.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/datatype/AbstractDatatypeWizard.java index 6a4863b5bd..5d3ab9c161 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/datatype/AbstractDatatypeWizard.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/datatype/AbstractDatatypeWizard.java @@ -14,27 +14,32 @@ *******************************************************************************/ package org.eclipse.vorto.wizard.datatype; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Display; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; -import org.eclipse.vorto.codegen.api.ICodeGeneratorTask; -import org.eclipse.vorto.codegen.ui.context.IModelProjectContext; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; +import org.eclipse.vorto.codegen.api.DefaultMappingContext; import org.eclipse.vorto.codegen.ui.handler.ModelGenerationTask; -import org.eclipse.vorto.codegen.ui.progresstask.ProgressTaskExecutionService; -import org.eclipse.vorto.core.model.IModelProject; -import org.eclipse.vorto.core.model.nature.FbDatatypeProjectNature; -import org.eclipse.vorto.core.service.ModelProjectServiceFactory; +import org.eclipse.vorto.codegen.ui.tasks.ProjectFileOutputter; import org.eclipse.vorto.wizard.AbstractVortoWizard; -import org.eclipse.vorto.wizard.ProjectCreationTask; public abstract class AbstractDatatypeWizard extends AbstractVortoWizard implements INewWizard { private DatatypeWizardPage iotWizardPage; - private final String fileExt = ".type"; + private final String SUFFIX = ".type"; + + private String modelFolder = "datatypes/"; private Datatype datatype; @@ -47,32 +52,39 @@ public void addPages() { } public boolean performFinish() { - ProgressTaskExecutionService progressTaskExecutionService = ProgressTaskExecutionService - .getProgressTaskExecutionService(); + new ModelGenerationTask(SUFFIX, new DataTypeFileTemplate(datatype.name().toLowerCase()), modelFolder).generate(iotWizardPage, + new DefaultMappingContext(), new ProjectFileOutputter(iotWizardPage.getProject())); + openDatatypeWithDefaultEditor(); + return true; + } - progressTaskExecutionService.syncRun(new ProjectCreationTask( - iotWizardPage) { - @Override - public IModelProject getIotproject(IProject project) { - return ModelProjectServiceFactory.getDefault() - .getProjectFromEclipseProject(project); - } + private void openDatatypeWithDefaultEditor() { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IProject project = workspace.getRoot().getProject( + iotWizardPage.getProjectName()); - @Override - protected ICodeGeneratorTask getCodeGeneratorTask() { - return new ModelGenerationTask(fileExt, - new DataTypeFileTemplate(datatype.name().toLowerCase())); - } + String fbName = iotWizardPage.getModelName(); + final IFile fbfile = project.getFile(modelFolder + + fbName + SUFFIX); + Display.getDefault().asyncExec(new Runnable() { @Override - protected String[] getProjectNature() { - return new String[] { FbDatatypeProjectNature.NATURE_ID }; + public void run() { + IWorkbenchWindow activeWindow = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + if (activeWindow != null) { + IWorkbenchPage page = activeWindow.getActivePage(); + if (page != null) { + try { + IDE.openEditor(page, fbfile); + } catch (PartInitException e) { + throw new RuntimeException(e); + } + } + } } }); - - BasicNewProjectResourceWizard - .updatePerspective(getConfigurationElement()); - return true; + } @Override diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/functionblock/FunctionBlockWizard.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/functionblock/FunctionBlockWizard.java index 53acdac973..2d8476c19a 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/functionblock/FunctionBlockWizard.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/functionblock/FunctionBlockWizard.java @@ -25,21 +25,17 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; -import org.eclipse.vorto.codegen.api.ICodeGeneratorTask; -import org.eclipse.vorto.codegen.ui.context.IModelProjectContext; +import org.eclipse.vorto.codegen.api.DefaultMappingContext; import org.eclipse.vorto.codegen.ui.handler.ModelGenerationTask; -import org.eclipse.vorto.codegen.ui.progresstask.ProgressTaskExecutionService; -import org.eclipse.vorto.core.model.IModelProject; -import org.eclipse.vorto.core.model.nature.IoTProjectNature; -import org.eclipse.vorto.core.service.ModelProjectServiceFactory; +import org.eclipse.vorto.codegen.ui.tasks.ProjectFileOutputter; import org.eclipse.vorto.wizard.AbstractVortoWizard; -import org.eclipse.vorto.wizard.ProjectCreationTask; public class FunctionBlockWizard extends AbstractVortoWizard implements INewWizard { private static final String SUFFIX = ".fbmodel"; private FunctionBlockWizardPage iotWizardPage; + + private String modelFolder = "functionblocks/"; @Override public void addPages() { @@ -52,34 +48,9 @@ public void addPages() { @Override public boolean performFinish() { - ProgressTaskExecutionService progressTaskExecutionService = ProgressTaskExecutionService - .getProgressTaskExecutionService(); - progressTaskExecutionService.syncRun(new ProjectCreationTask( - iotWizardPage) { - @Override - protected IModelProject getIotproject(IProject project) { - return ModelProjectServiceFactory.getDefault() - .getProjectFromEclipseProject(project); - } - - @Override - protected ICodeGeneratorTask getCodeGeneratorTask() { - return new ModelGenerationTask(SUFFIX, - new FbmodelTemplateFileContent()); - } - - @Override - protected String[] getProjectNature() { - return new String[] { IoTProjectNature.NATURE_ID }; - } - - }); - + new ModelGenerationTask(SUFFIX, new FbmodelTemplateFileContent(), modelFolder).generate(iotWizardPage, + new DefaultMappingContext(), new ProjectFileOutputter(iotWizardPage.getProject())); openFBModelWithDefaultEditor(); - - BasicNewProjectResourceWizard - .updatePerspective(getConfigurationElement()); - return true; } @@ -89,7 +60,7 @@ private void openFBModelWithDefaultEditor() { iotWizardPage.getProjectName()); String fbName = iotWizardPage.getModelName(); - final IFile fbfile = project.getFile(ModelGenerationTask.SRC_MODELS + final IFile fbfile = project.getFile(modelFolder + fbName + SUFFIX); Display.getDefault().asyncExec(new Runnable() { diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/infomodel/InfomodelWizard.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/infomodel/InfomodelWizard.java index 3184ecd0ce..790c5c16af 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/infomodel/InfomodelWizard.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/infomodel/InfomodelWizard.java @@ -27,22 +27,18 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard; -import org.eclipse.vorto.codegen.api.ICodeGeneratorTask; -import org.eclipse.vorto.codegen.ui.context.IModelProjectContext; +import org.eclipse.vorto.codegen.api.DefaultMappingContext; import org.eclipse.vorto.codegen.ui.handler.ModelGenerationTask; -import org.eclipse.vorto.codegen.ui.progresstask.ProgressTaskExecutionService; -import org.eclipse.vorto.core.model.IModelProject; -import org.eclipse.vorto.core.model.nature.InformationModelProjectNature; -import org.eclipse.vorto.core.service.ModelProjectServiceFactory; +import org.eclipse.vorto.codegen.ui.tasks.ProjectFileOutputter; import org.eclipse.vorto.wizard.AbstractVortoWizard; -import org.eclipse.vorto.wizard.ProjectCreationTask; public class InfomodelWizard extends AbstractVortoWizard implements INewWizard { private static final String SUFFIX = ".infomodel"; private InfomodelWizardPage iotWizardPage; + private String modelFolder = "informationmodels/"; + public InfomodelWizard() { super(); setNeedsProgressMonitor(true); @@ -57,33 +53,11 @@ public void addPages() { } public boolean performFinish() { - ProgressTaskExecutionService progressTaskExecutionService = ProgressTaskExecutionService - .getProgressTaskExecutionService(); - - progressTaskExecutionService.syncRun(new ProjectCreationTask( - iotWizardPage) { - @Override - public IModelProject getIotproject(IProject project) { - return ModelProjectServiceFactory.getDefault() - .getProjectFromEclipseProject(project); - } - - @Override - protected ICodeGeneratorTask getCodeGeneratorTask() { - return new ModelGenerationTask(SUFFIX, - new InfomodelTemplateFileContent()); - } - - @Override - protected String[] getProjectNature() { - return new String[] { InformationModelProjectNature.NATURE_ID }; - } - }); + + new ModelGenerationTask(SUFFIX, new InfomodelTemplateFileContent(), modelFolder).generate(iotWizardPage, + new DefaultMappingContext(), new ProjectFileOutputter(iotWizardPage.getProject())); openFBModelWithDefaultEditor(); - - BasicNewProjectResourceWizard - .updatePerspective(getConfigurationElement()); return true; } @@ -93,7 +67,7 @@ private void openFBModelWithDefaultEditor() { iotWizardPage.getProjectName()); String modelName = iotWizardPage.getModelName(); - final IFile modelfile = project.getFile(ModelGenerationTask.SRC_MODELS + final IFile modelfile = project.getFile(modelFolder + modelName + SUFFIX); Display.getDefault().asyncExec(new Runnable() { @@ -116,6 +90,14 @@ public void run() { } + public InfomodelWizardPage getIotWizardPage() { + return iotWizardPage; + } + + public void setIotWizardPage(InfomodelWizardPage iotWizardPage) { + this.iotWizardPage = iotWizardPage; + } + @Override public void init(IWorkbench arg0, IStructuredSelection arg1) { } diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModelWizard.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModelWizard.java index c8d89f89f7..20f1852855 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModelWizard.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModelWizard.java @@ -31,14 +31,14 @@ import org.eclipse.vorto.codegen.ui.context.IModelProjectContext; import org.eclipse.vorto.codegen.ui.handler.ModelGenerationTask; import org.eclipse.vorto.codegen.ui.progresstask.ProgressTaskExecutionService; +import org.eclipse.vorto.wizard.ProjectCreationTask; import org.eclipse.vorto.core.model.IModelProject; import org.eclipse.vorto.core.service.ModelProjectServiceFactory; import org.eclipse.vorto.wizard.AbstractVortoWizard; -import org.eclipse.vorto.wizard.ProjectCreationTask; public class MappingModelWizard extends AbstractVortoWizard implements INewWizard { private static final String SUFFIX = ".mapping"; - private static final String MAPPING_PATH = "src/mappings/"; + private String modelFolder = "mappings/"; private MappingModellWizardPage iotWizardPage; @@ -56,6 +56,7 @@ public void addPages() { } public boolean performFinish() { + ProgressTaskExecutionService progressTaskExecutionService = ProgressTaskExecutionService .getProgressTaskExecutionService(); @@ -69,13 +70,7 @@ public IModelProject getIotproject(IProject project) { @Override protected ICodeGeneratorTask getCodeGeneratorTask() { - return new ModelGenerationTask(SUFFIX, - new MappingModelTemplateFileContent()) { - @Override - public String getPath(IModelProjectContext ctx) { - return MAPPING_PATH; - } - }; + return new ModelGenerationTask(SUFFIX, new MappingModelTemplateFileContent(), modelFolder); } @Override @@ -95,7 +90,7 @@ private void openModelWithDefaultEditor() { iotWizardPage.getProjectName()); String modelName = iotWizardPage.getModelName(); - final IFile modelfile = project.getFile(MAPPING_PATH + final IFile modelfile = project.getFile(modelFolder + modelName + SUFFIX); Display.getDefault().asyncExec(new Runnable() { diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModellWizardPage.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModellWizardPage.java index de75d205e5..9ff60000c1 100644 --- a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModellWizardPage.java +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/mapping/MappingModellWizardPage.java @@ -14,6 +14,7 @@ *******************************************************************************/ package org.eclipse.vorto.wizard.mapping; +import org.eclipse.core.resources.IProject; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; @@ -23,14 +24,14 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; +import org.eclipse.vorto.codegen.ui.context.IModelProjectContext; import org.eclipse.vorto.core.model.IModelProject; import org.eclipse.vorto.core.service.ModelProjectServiceFactory; import org.eclipse.vorto.wizard.AbstractWizardPage; -public class MappingModellWizardPage extends AbstractWizardPage { +public class MappingModellWizardPage extends AbstractWizardPage implements IModelProjectContext { public static final String TARGETPLATFORM_REGEX = "[^a-zA-Z0-9\\._]"; - private static final String DEFAULT_VERSION = "1.0.0"; private IModelProject selectedModelProject = null; protected MappingModellWizardPage(String pageName) { @@ -194,12 +195,10 @@ public IModelProject getSelectedModelProject(){ return this.selectedModelProject; } - @Override public String getModelVersion() { return txtVersion.getText(); } - @Override public String getModelName() { return txtModelName.getText(); } @@ -208,7 +207,6 @@ public String getTargetPlatform() { return this.txtTargetPlatform.getText(); } - @Override public String getModelDescription() { return txtDescription.getText(); } @@ -232,6 +230,10 @@ protected String getGroupTitle() { protected String getModelLabel() { return "Mapping Name:"; } + + public IProject getProject() { + return null; + } } diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/NewVortoProjectHandler.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/NewVortoProjectHandler.java new file mode 100644 index 0000000000..7e29ed0699 --- /dev/null +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/NewVortoProjectHandler.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * 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.vorto; + +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.vorto.codegen.ui.handler.WizardCreateProjectHandler; + +public class NewVortoProjectHandler extends WizardCreateProjectHandler { + + @Override + public Wizard getWizard() { + VortoProjectWizard vortoWizard = new VortoProjectWizard(); + return vortoWizard; + } + +} diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/VortoProjectWizard.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/VortoProjectWizard.java new file mode 100644 index 0000000000..a4f519627c --- /dev/null +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/VortoProjectWizard.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * 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.vorto; + +import org.eclipse.ui.INewWizard; +import org.eclipse.vorto.codegen.ui.progresstask.ProgressTaskExecutionService; +import org.eclipse.vorto.wizard.AbstractVortoWizard; +import org.eclipse.vorto.wizard.VortoProjectCreationTask; + +public class VortoProjectWizard extends AbstractVortoWizard implements INewWizard { + + + protected static final String VORTO_WIZARD_TITLE = "New Vorto Project"; + + private VortoProjectWizardPage vortoWizardPage; + + public VortoProjectWizard() { + super(); + setWindowTitle(VORTO_WIZARD_TITLE); + setNeedsProgressMonitor(true); + } + + public void addPages() { + vortoWizardPage = new VortoProjectWizardPage("Vorto Model Project Wizard"); + vortoWizardPage.setTitle("Create new Vorto Project"); + vortoWizardPage + .setDescription("Please enter the details for creating new Vorto project."); + addPage(vortoWizardPage); + } + + @Override + public boolean performFinish() { + ProgressTaskExecutionService progressTaskExecutionService = ProgressTaskExecutionService + .getProgressTaskExecutionService(); + progressTaskExecutionService.syncRun(new VortoProjectCreationTask(vortoWizardPage)); + return true; + } +} \ No newline at end of file diff --git a/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/VortoProjectWizardPage.java b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/VortoProjectWizardPage.java new file mode 100644 index 0000000000..c6e26580bb --- /dev/null +++ b/bundles/org.eclipse.vorto.wizard/src/org/eclipse/vorto/wizard/vorto/VortoProjectWizardPage.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * 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.vorto; + +import org.apache.commons.lang3.StringUtils; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.vorto.codegen.ui.context.IProjectContext; +import org.eclipse.vorto.wizard.AbstractWizardPage; + +public class VortoProjectWizardPage extends AbstractWizardPage implements IProjectContext { + + + private Text txtProjectName; + private Text txtWorkspaceLocation; + private String workspaceLocation; + + public static final String PROJECTNAME_REGEX = "[^a-zA-Z0-9 \\._]"; + private static final String DEFAULT_PROJECT_NAME = "NewVortoProject"; + + protected VortoProjectWizardPage(String pageName) { + super(pageName); + } + + @Override + public void createControl(Composite parent) { + Composite topContainer = new Composite(parent, SWT.NULL); + + setControl(topContainer); + topContainer.setLayout(new GridLayout(1, false)); + Group grpProjectDetails = new Group(topContainer, SWT.NONE); + grpProjectDetails.setLayout(new GridLayout(3, false)); + GridData gridGrpProjectDetails = new GridData(SWT.CENTER, SWT.CENTER, + false, false, 1, 1); + gridGrpProjectDetails.heightHint = 60; + gridGrpProjectDetails.widthHint = 575; + grpProjectDetails.setLayoutData(gridGrpProjectDetails); + grpProjectDetails.setText("Project Details"); + + Label lblProjectName = new Label(grpProjectDetails, SWT.NONE); + GridData gridLblProjectName = new GridData(SWT.RIGHT, SWT.CENTER, + false, false, 1, 1); + gridLblProjectName.widthHint = 78; + lblProjectName.setLayoutData(gridLblProjectName); + lblProjectName.setText("Project Name:"); + + txtProjectName = new Text(grpProjectDetails, SWT.BORDER); + GridData gridTxtProjectName = new GridData(SWT.FILL, SWT.CENTER, false, + false, 1, 1); + gridTxtProjectName.widthHint = 370; + txtProjectName.setLayoutData(gridTxtProjectName); + txtProjectName.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + projectNameChanged(); + dialogChanged(); + } + }); + new Label(grpProjectDetails, SWT.NONE); + + Label lblLocation = new Label(grpProjectDetails, SWT.NONE); + GridData gridLblLocation = new GridData(SWT.RIGHT, SWT.CENTER, false, + false, 1, 1); + gridLblLocation.widthHint = 48; + lblLocation.setLayoutData(gridLblLocation); + lblLocation.setText("Location:"); + + txtWorkspaceLocation = new Text(grpProjectDetails, SWT.BORDER); + txtWorkspaceLocation.setEditable(false); + GridData gridTxtLocation = new GridData(SWT.LEFT, SWT.CENTER, false, + false, 1, 1); + gridTxtLocation.widthHint = 385; + txtWorkspaceLocation.setLayoutData(gridTxtLocation); + + Button btnBrowse = new Button(grpProjectDetails, SWT.NONE); + btnBrowse.setText("Browse..."); + btnBrowse.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + handleBrowse(e); + } + + }); + initialize(); + setControl(topContainer); + + } + + private void initialize() { + txtProjectName.setText(DEFAULT_PROJECT_NAME); + txtWorkspaceLocation.setText(getWorkspaceLocation() + "/" + DEFAULT_PROJECT_NAME); + + } + + + protected void handleBrowse(SelectionEvent e) { + DirectoryDialog directoryDialog = new DirectoryDialog(getShell()); + directoryDialog.setFilterPath(workspaceLocation); + directoryDialog.setText("Workspace folder selection"); + directoryDialog.setMessage("Select a directory for this project"); + + String selectedDirectory = directoryDialog.open(); + selectedDirectory = StringUtils.replace(selectedDirectory, "\\", "/"); + + if (selectedDirectory != null) { + workspaceLocation = selectedDirectory; + updateWorkspaceLocationField(workspaceLocation); + dialogChanged(); + } + } + + + private void projectNameChanged() { + txtWorkspaceLocation.setText(getWorkspaceLocation() + "/" + + getProjectName()); + } + public void dialogChanged() { + if (this.validateProject()) { + this.setErrorMessage(null); + setPageComplete(true); + } else { + setPageComplete(false); + } + + } + + protected boolean validateProject() { + boolean result = true; + String projectName = getProjectName(); + result &= validateStrExist(projectName, + "Project name must be specified"); + result &= validateStrExist(txtProjectName.getText(), + "Project name must be specified"); + result &= validateExistingSameProjectName(projectName); + result &= checkProjectName(projectName); + return result; + } + + public void updateWorkspaceLocationField(String directory) { + txtWorkspaceLocation.setText(directory + "/" + getProjectName()); + } + + @Override + public String getProjectName() { + return txtProjectName.getText(); + } + + @Override + public String getWorkspaceLocation() { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + if (workspaceLocation == null) { + workspaceLocation = workspace.getRoot().getLocation().toString(); + } + return workspaceLocation; + } +}