From ead67f40b19fd50d3f8c86f58c0a0b50e6c688f3 Mon Sep 17 00:00:00 2001 From: shiv12095 Date: Mon, 22 Aug 2016 10:08:51 +0530 Subject: [PATCH] Squashed vorto devtool commits Signed-off-by: shiv12095 --- .../META-INF/MANIFEST.MF | 15 + .../build.properties | 5 + .../pom.xml | 25 + .../META-INF/MANIFEST.MF | 11 +- .../build.properties | 3 +- .../pom.xml | 2 +- .../FunctionblockInjectorProvider.java | 60 -- .../{ => tests}/AllEditorTests.java | 30 +- .../tests/FunctionblockParsingTest.xtend | 51 + .../FunctionblockModelFormatterTest.xtend | 4 +- .../META-INF/MANIFEST.MF | 64 +- ...odule.java => FunctionblockUiModule.xtend} | 22 +- .../.gitignore | 1 + .../pom.xml | 129 +++ .../web/FunctionblockServlet.xtend | 48 + .../web/FunctionblockWebModule.xtend | 41 + .../web/FunctionblockWebSetup.xtend | 44 + .../META-INF/MANIFEST.MF | 74 +- .../pom.xml | 55 +- .../FunctionblockRuntimeModule.java | 78 -- .../FunctionblockRuntimeModule.xtend | 69 ++ ...ava => FunctionblockStandaloneSetup.xtend} | 19 +- .../functionblock/GenerateFunctionblock.mwe2 | 212 ++--- .../generator/FunctionblockGenerator.xtend | 12 +- .../FunctionblockSemanticSequencer.xtend} | 23 +- .../FunctionblockSyntacticSequencer.xtend | 23 + .../META-INF/MANIFEST.MF | 6 +- .../pom.xml | 31 +- .../web/InformationModelServlet.xtend | 2 +- .../web/InformationModelWebModule.xtend | 18 +- bundles/org.eclipse.vorto.editor.web/pom.xml | 80 ++ .../web/resource/HashMapResourceHandler.xtend | 54 ++ .../WebEditorResourceSetProvider.xtend | 66 ++ bundles/pom.xml | 60 +- server/devtool/pom.xml | 165 +++- .../vorto/server/devtool/DevToolServer.java | 2 + .../devtool/config/SecurityConfiguration.java | 12 +- .../devtool/config/XtextConfiguration.java | 55 +- .../devtool/controller/ProjectController.java | 208 ++++ .../controller/RepositoryController.java | 38 + .../editor/FunctionBlockEditorController.java | 94 ++ .../controller/editor/IEditorController.java | 31 + .../InformationModelEditorController.java | 96 ++ .../ProjectAlreadyExistsException.java | 19 + .../exception/ProjectNotFoundException.java | 20 + ...ProjectResourceAlreadyExistsException.java | 19 + .../vorto/server/devtool/models/Project.java | 77 ++ .../devtool/models/ProjectResource.java | 67 ++ .../service/IProjectRepositoryService.java | 42 + .../service/IProjectRespositoryDAO.java | 31 + .../FunctionBlockEditorServiceImpl.java | 58 ++ .../service/editor/IEditorService.java | 50 + .../InformationModelEditorServiceImpl.java | 54 ++ .../impl/MapProjectRespositoryDAOImpl.java | 78 ++ .../impl/ProjectRepositoryServiceImpl.java | 137 +++ .../devtool/utils/DevtoolReferenceLinker.java | 171 ++++ .../devtool/utils/DevtoolRestClient.java | 107 +++ .../src/main/resources/application.properties | 2 + .../main/resources/static/css/ace-custom.css | 60 ++ .../main/resources/static/css/dashboard.css | 26 + .../src/main/resources/static/css/style.css | 900 ++++++++++++++++++ .../resources/static/dist/js/controllers.js | 620 +++++++++++- .../resources/static/dist/js/devtoolApp.js | 58 +- .../resources/static/dist/js/directives.js | 27 + .../src/main/resources/static/dist/js/main.js | 33 +- .../static/dist/js/xtext/mode-fbmodel.js | 35 + .../static/dist/js/xtext/mode-infomodel.js | 35 + .../src/main/resources/static/index.html | 20 +- .../templates/add-editor-modal-template.html | 21 + .../close-project-modal-template.html | 11 + .../create-project-modal-template.html | 32 + .../delete-editor-modal-template.html | 11 + .../describe-editor-modal-template.html | 70 ++ .../static/templates/editor-template.html | 130 ++- .../static/templates/project-template.html | 70 ++ .../service/ProjectRepositoryServiceTest.java | 59 ++ .../impl/ProjectRepositoryDAOTest.java | 56 ++ server/pom.xml | 1 + server/repo/pom.xml | 1 + server/repo/repo-core/pom.xml | 5 + .../internal/service/IModelParser.java | 2 +- .../internal/service/JcrModelRepository.java | 6 +- .../internal/service/ModelParserFactory.java | 6 +- .../service/emf/AbstractModelParser.java | 6 +- .../GenerationDelegateProxyService.java | 8 +- .../service/sequencer/ModelSequencer.java | 4 +- .../service/utils/BulkUploadHelper.java | 2 +- .../service/utils/ModelReferencesHelper.java | 2 +- .../BulkModelDuplicateIdValidation.java | 4 +- .../BulkModelReferencesValidation.java | 4 +- .../validation/DuplicateModelValidation.java | 2 +- .../validation/ModelReferencesValidation.java | 4 +- .../CouldNotResolveReferenceException.java | 4 +- .../vorto/repository/model/Comment.java | 2 + .../repository/model/ModelEMFResource.java | 3 + .../vorto/repository/model/ModelHandle.java | 2 +- .../repository/model/ModelUploadHandle.java | 3 + .../repository/model/UploadModelResult.java | 2 + .../vorto/repository/model/ZipData.java | 3 + .../notification/message/CheckinMessage.java | 6 +- .../repository/service/CommentService.java | 2 +- .../repository/service/ICommentService.java | 2 +- .../repository/service/IGeneratorService.java | 2 +- .../repository/service/IModelRepository.java | 4 +- .../ModelReferentialIntegrityException.java | 2 +- .../validation/IModelValidator.java | 2 +- .../validation/ValidationException.java | 2 +- .../service/ModelRepositoryTest.java | 8 +- .../service/NotificationServiceTest.java | 6 +- server/repo/repo-http-models/pom.xml | 19 + .../eclipse/vorto/http}/model/ModelId.java | 5 +- .../vorto/http}/model/ModelResource.java | 4 +- .../eclipse/vorto/http}/model/ModelType.java | 4 +- server/repo/repo-ui/pom.xml | 5 + .../web/ModelGenerationController.java | 2 +- .../web/ModelRepositoryController.java | 4 +- .../web/comment/CommentController.java | 4 +- 117 files changed, 4846 insertions(+), 657 deletions(-) create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.ide/META-INF/MANIFEST.MF create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.ide/build.properties create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.ide/pom.xml delete mode 100644 bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockInjectorProvider.java rename bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/{ => tests}/AllEditorTests.java (54%) create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/FunctionblockParsingTest.xtend rename bundles/org.eclipse.vorto.editor.functionblock.ui/src/org/eclipse/vorto/editor/functionblock/ui/{FunctionblockUiModule.java => FunctionblockUiModule.xtend} (61%) create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.web/.gitignore create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.web/pom.xml create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockServlet.xtend create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebModule.xtend create mode 100644 bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebSetup.xtend delete mode 100644 bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.java create mode 100644 bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.xtend rename bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/{FunctionblockStandaloneSetup.java => FunctionblockStandaloneSetup.xtend} (71%) rename bundles/{org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockUiInjectorProvider.java => org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSemanticSequencer.xtend} (50%) create mode 100644 bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSyntacticSequencer.xtend create mode 100644 bundles/org.eclipse.vorto.editor.web/pom.xml create mode 100644 bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/HashMapResourceHandler.xtend create mode 100644 bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/WebEditorResourceSetProvider.xtend create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/ProjectController.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/RepositoryController.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/FunctionBlockEditorController.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/IEditorController.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/InformationModelEditorController.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectAlreadyExistsException.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectNotFoundException.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectResourceAlreadyExistsException.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/Project.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRepositoryService.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRespositoryDAO.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/FunctionBlockEditorServiceImpl.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/InformationModelEditorServiceImpl.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/MapProjectRespositoryDAOImpl.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/ProjectRepositoryServiceImpl.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java create mode 100644 server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolRestClient.java create mode 100644 server/devtool/src/main/resources/application.properties create mode 100644 server/devtool/src/main/resources/static/css/ace-custom.css create mode 100644 server/devtool/src/main/resources/static/css/dashboard.css create mode 100644 server/devtool/src/main/resources/static/css/style.css create mode 100644 server/devtool/src/main/resources/static/dist/js/directives.js create mode 100644 server/devtool/src/main/resources/static/dist/js/xtext/mode-fbmodel.js create mode 100644 server/devtool/src/main/resources/static/dist/js/xtext/mode-infomodel.js create mode 100644 server/devtool/src/main/resources/static/templates/add-editor-modal-template.html create mode 100644 server/devtool/src/main/resources/static/templates/close-project-modal-template.html create mode 100644 server/devtool/src/main/resources/static/templates/create-project-modal-template.html create mode 100644 server/devtool/src/main/resources/static/templates/delete-editor-modal-template.html create mode 100644 server/devtool/src/main/resources/static/templates/describe-editor-modal-template.html create mode 100644 server/devtool/src/main/resources/static/templates/project-template.html create mode 100644 server/devtool/src/test/java/org/eclipse/vorto/server/devtool/service/ProjectRepositoryServiceTest.java create mode 100644 server/devtool/src/test/java/org/eclipse/vorto/server/devtool/service/impl/ProjectRepositoryDAOTest.java create mode 100644 server/repo/repo-http-models/pom.xml rename server/repo/{repo-core/src/main/java/org/eclipse/vorto/repository => repo-http-models/src/main/java/org/eclipse/vorto/http}/model/ModelId.java (99%) rename server/repo/{repo-core/src/main/java/org/eclipse/vorto/repository => repo-http-models/src/main/java/org/eclipse/vorto/http}/model/ModelResource.java (98%) rename server/repo/{repo-core/src/main/java/org/eclipse/vorto/repository => repo-http-models/src/main/java/org/eclipse/vorto/http}/model/ModelType.java (97%) diff --git a/bundles/org.eclipse.vorto.editor.functionblock.ide/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.editor.functionblock.ide/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..1167b55cec --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.ide/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +FManifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: org.eclipse.vorto.editor.functionblock.ide +Bundle-Vendor: My Company +Bundle-Version: 0.9.0.qualifier +Bundle-SymbolicName: org.eclipse.vorto.editor.functionblock.ide;singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.vorto.editor.functionblock, + org.eclipse.xtext.ide, + org.eclipse.xtext.xbase.ide +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.vorto.editor.functionblock.ide.contentassist.antlr, + org.eclipse.vorto.editor.functionblock.ide.contentassist.antlr.internal +Import-Package: org.eclipse.vorto.editor.datatype.services, + org.eclipse.vorto.editor.functionblock.services diff --git a/bundles/org.eclipse.vorto.editor.functionblock.ide/build.properties b/bundles/org.eclipse.vorto.editor.functionblock.ide/build.properties new file mode 100644 index 0000000000..47a0f6e832 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.ide/build.properties @@ -0,0 +1,5 @@ +source.. = src/,\ + src-gen/,\ + xtend-gen/ +bin.includes = .,\ + META-INF/ \ No newline at end of file diff --git a/bundles/org.eclipse.vorto.editor.functionblock.ide/pom.xml b/bundles/org.eclipse.vorto.editor.functionblock.ide/pom.xml new file mode 100644 index 0000000000..75ddbbb8c6 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.ide/pom.xml @@ -0,0 +1,25 @@ + + 4.0.0 + + + org.eclipse.vorto + bundles + 0.9.0-SNAPSHOT + + + org.eclipse.vorto.editor.functionblock.ide + eclipse-plugin + + Function Block Editor Plugin IDE + + + + + org.eclipse.xtend + xtend-maven-plugin + + + + + diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.editor.functionblock.tests/META-INF/MANIFEST.MF index a922267ef0..7c93826b45 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.tests/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.vorto.editor.functionblock.tests/META-INF/MANIFEST.MF @@ -18,10 +18,11 @@ Require-Bundle: org.eclipse.vorto.editor.functionblock.ui, org.eclipse.ui.workbench;resolution:=optional, org.eclipse.xtext.xbase.lib Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: org.eclipse.vorto.editor.functionblock -Import-Package: org.junit.runner;version="4.5.0", - org.junit.runners;version="4.5.0", +Export-Package: org.eclipse.vorto.editor.functionblock.tests +Import-Package: org.hamcrest.core, + org.junit;version="4.5.0", + org.junit.runner;version="4.5.0", org.junit.runner.manipulation;version="4.5.0", org.junit.runner.notification;version="4.5.0", - org.junit.runners.model;version="4.5.0", - org.hamcrest.core + org.junit.runners;version="4.5.0", + org.junit.runners.model;version="4.5.0" diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/build.properties b/bundles/org.eclipse.vorto.editor.functionblock.tests/build.properties index a2369e078f..d6417321d5 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.tests/build.properties +++ b/bundles/org.eclipse.vorto.editor.functionblock.tests/build.properties @@ -1,5 +1,6 @@ source.. = src/,\ - xtend-gen/ + xtend-gen/,\ + src-gen/ bin.includes = META-INF/,\ .,\ about.html diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/pom.xml b/bundles/org.eclipse.vorto.editor.functionblock.tests/pom.xml index a9fb716c46..897a607453 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.tests/pom.xml +++ b/bundles/org.eclipse.vorto.editor.functionblock.tests/pom.xml @@ -10,7 +10,7 @@ org.eclipse.vorto.editor.functionblock.tests eclipse-test-plugin - Vorto Functionblock Editor Tests + Vorto Function Block Editor Tests diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockInjectorProvider.java b/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockInjectorProvider.java deleted file mode 100644 index c468f3dc67..0000000000 --- a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockInjectorProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2015-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 - */ -/* -* generated by Xtext -*/ -package org.eclipse.vorto.editor.functionblock; - -import org.eclipse.vorto.editor.functionblock.FunctionblockStandaloneSetup; -import org.eclipse.xtext.junit4.GlobalRegistries; -import org.eclipse.xtext.junit4.GlobalRegistries.GlobalStateMemento; -import org.eclipse.xtext.junit4.IInjectorProvider; -import org.eclipse.xtext.junit4.IRegistryConfigurator; - -import com.google.inject.Injector; - -public class FunctionblockInjectorProvider implements IInjectorProvider, IRegistryConfigurator { - - protected GlobalStateMemento stateBeforeInjectorCreation; - protected GlobalStateMemento stateAfterInjectorCreation; - protected Injector injector; - - static { - GlobalRegistries.initializeDefaults(); - } - - public Injector getInjector() - { - if (injector == null) { - stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); - this.injector = internalCreateInjector(); - stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); - } - return injector; - } - - protected Injector internalCreateInjector() { - return new FunctionblockStandaloneSetup().createInjectorAndDoEMFRegistration(); - } - - public void restoreRegistry() { - stateBeforeInjectorCreation.restoreGlobalState(); - } - - public void setupRegistry() { - getInjector(); - stateAfterInjectorCreation.restoreGlobalState(); - } -} diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/AllEditorTests.java b/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/AllEditorTests.java similarity index 54% rename from bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/AllEditorTests.java rename to bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/AllEditorTests.java index 35f745e360..8153b91f2d 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/AllEditorTests.java +++ b/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/AllEditorTests.java @@ -1,18 +1,18 @@ -/** - * Copyright (c) 2015-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.editor.functionblock; +/******************************************************************************* + * Copyright (c) 2015,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.editor.functionblock.tests; import org.eclipse.vorto.editor.functionblock.tests.formatter.FunctionblockModelFormatterTest; import org.eclipse.vorto.editor.functionblock.tests.validator.FBEntityEnumCrossReferenceTest; diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/FunctionblockParsingTest.xtend b/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/FunctionblockParsingTest.xtend new file mode 100644 index 0000000000..e095445a45 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/FunctionblockParsingTest.xtend @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + *******************************************************************************/ +/* + * generated by Xtext + */ +package org.eclipse.vorto.editor.functionblock.tests + +import com.google.inject.Inject +import org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel +import org.eclipse.vorto.core.api.model.functionblock.impl.FunctionblockPackageImpl +import org.eclipse.xtext.junit4.InjectWith +import org.eclipse.xtext.junit4.XtextRunner +import org.eclipse.xtext.junit4.util.ParseHelper +import org.junit.Assert +import org.junit.BeforeClass +import org.junit.Test +import org.junit.runner.RunWith + +@RunWith(typeof(XtextRunner)) +@InjectWith(typeof(FunctionblockInjectorProvider)) +class FunctionblockParsingTest{ + + @Inject extension ParseHelper parserHelper; + + @BeforeClass + def static void initializeModel() { + FunctionblockPackageImpl.init(); + } + + @Test + def void loadModel() { + val result = parserHelper.parse(''' + Hello Xtext! + ''') + Assert.assertNotNull(result) + } + +} diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/formatter/FunctionblockModelFormatterTest.xtend b/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/formatter/FunctionblockModelFormatterTest.xtend index fd93819533..0f7d46429d 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/formatter/FunctionblockModelFormatterTest.xtend +++ b/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/tests/formatter/FunctionblockModelFormatterTest.xtend @@ -1,10 +1,10 @@ package org.eclipse.vorto.editor.functionblock.tests.formatter import com.google.inject.Inject +import org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel import org.eclipse.vorto.core.api.model.functionblock.impl.FunctionblockPackageImpl -import org.eclipse.vorto.editor.functionblock.FunctionblockInjectorProvider +import org.eclipse.vorto.editor.functionblock.tests.FunctionblockInjectorProvider import org.eclipse.xtext.formatting.INodeModelFormatter -import org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel import org.eclipse.xtext.junit4.AbstractXtextTests import org.eclipse.xtext.junit4.InjectWith import org.eclipse.xtext.junit4.XtextRunner diff --git a/bundles/org.eclipse.vorto.editor.functionblock.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.editor.functionblock.ui/META-INF/MANIFEST.MF index ab265e60b6..f4b7b0f98b 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.vorto.editor.functionblock.ui/META-INF/MANIFEST.MF @@ -1,32 +1,32 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Vorto Functionblock Editor UI (Incubation) -Bundle-Vendor: Eclipse.org/Vorto -Bundle-Version: 0.9.0.qualifier -Bundle-SymbolicName: org.eclipse.vorto.editor.functionblock.ui;singleton:=true -Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.xtext.ui, - org.eclipse.ui.editors;bundle-version="3.5.0", - org.eclipse.ui.ide;bundle-version="3.5.0", - org.eclipse.xtext.ui.shared, - org.eclipse.ui, - org.eclipse.xtext.builder, - org.antlr.runtime, - org.eclipse.xtext.common.types.ui, - org.eclipse.xtext.ui.codetemplates.ui, - org.eclipse.compare, - org.eclipse.vorto.editor.datatype, - org.eclipse.vorto.editor.datatype.ui, - org.eclipse.vorto.editor.functionblock, - org.eclipse.vorto.core, - org.eclipse.xtext.xbase.lib -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: org.eclipse.vorto.editor.functionblock.ui,org.eclipse. - vorto.editor.functionblock.ui.contentassist,org.eclipse.vorto.editor. - functionblock.ui.contentassist.antlr,org.eclipse.vorto.editor.functio - nblock.ui.contentassist.antlr.internal,org.eclipse.vorto.editor.funct - ionblock.ui.internal,org.eclipse.vorto.editor.functionblock.ui.quickf - ix -Bundle-ClassPath: templates/,.,icons/ -Import-Package: org.apache.log4j -Bundle-Activator: org.eclipse.vorto.editor.functionblock.ui.internal.FunctionblockActivator +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Vorto Functionblock Editor UI (Incubation) +Bundle-Vendor: Eclipse.org/Vorto +Bundle-Version: 0.9.0.qualifier +Bundle-SymbolicName: org.eclipse.vorto.editor.functionblock.ui;singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.xtext.ui, + org.eclipse.ui.editors;bundle-version="3.5.0", + org.eclipse.ui.ide;bundle-version="3.5.0", + org.eclipse.xtext.ui.shared, + org.eclipse.ui, + org.eclipse.xtext.builder, + org.antlr.runtime, + org.eclipse.xtext.common.types.ui, + org.eclipse.xtext.ui.codetemplates.ui, + org.eclipse.compare, + org.eclipse.vorto.editor.datatype, + org.eclipse.vorto.editor.datatype.ui, + org.eclipse.vorto.editor.functionblock, + org.eclipse.vorto.editor.functionblock.ide, + org.eclipse.vorto.core, + org.eclipse.xtext.xbase.lib, + org.eclipse.xtend.lib;resolution:=optional +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.vorto.editor.functionblock.ui, + org.eclipse.vorto.editor.functionblock.ui.contentassist, + org.eclipse.vorto.editor.functionblock.ui.internal, + org.eclipse.vorto.editor.functionblock.ui.quickfix +Bundle-ClassPath: templates/,.,icons/ +Import-Package: org.apache.log4j +Bundle-Activator: org.eclipse.vorto.editor.functionblock.ui.internal.FunctionblockActivator diff --git a/bundles/org.eclipse.vorto.editor.functionblock.ui/src/org/eclipse/vorto/editor/functionblock/ui/FunctionblockUiModule.java b/bundles/org.eclipse.vorto.editor.functionblock.ui/src/org/eclipse/vorto/editor/functionblock/ui/FunctionblockUiModule.xtend similarity index 61% rename from bundles/org.eclipse.vorto.editor.functionblock.ui/src/org/eclipse/vorto/editor/functionblock/ui/FunctionblockUiModule.java rename to bundles/org.eclipse.vorto.editor.functionblock.ui/src/org/eclipse/vorto/editor/functionblock/ui/FunctionblockUiModule.xtend index fcee2b955c..45d1f41c1c 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.ui/src/org/eclipse/vorto/editor/functionblock/ui/FunctionblockUiModule.java +++ b/bundles/org.eclipse.vorto.editor.functionblock.ui/src/org/eclipse/vorto/editor/functionblock/ui/FunctionblockUiModule.xtend @@ -1,32 +1,28 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. +/** + * Copyright (c) 2015 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 /* * generated by Xtext */ -package org.eclipse.vorto.editor.functionblock.ui; +org.eclipse.vorto.editor.functionblock.ui -import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.ui.plugin.AbstractUIPlugin -/** - * - * +/** * Use this class to register components to be used within the IDE. */ -public class FunctionblockUiModule extends - org.eclipse.vorto.editor.functionblock.ui.AbstractFunctionblockUiModule { - public FunctionblockUiModule(AbstractUIPlugin plugin) { - super(plugin); +class FunctionblockUiModule extends org.eclipse.vorto.editor.functionblock.ui.AbstractFunctionblockUiModule { + new(AbstractUIPlugin plugin) { + super(plugin) } } diff --git a/bundles/org.eclipse.vorto.editor.functionblock.web/.gitignore b/bundles/org.eclipse.vorto.editor.functionblock.web/.gitignore new file mode 100644 index 0000000000..c07a3c197b --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.web/.gitignore @@ -0,0 +1 @@ +/WebRoot/ diff --git a/bundles/org.eclipse.vorto.editor.functionblock.web/pom.xml b/bundles/org.eclipse.vorto.editor.functionblock.web/pom.xml new file mode 100644 index 0000000000..63ae8b5daf --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.web/pom.xml @@ -0,0 +1,129 @@ + + 4.0.0 + + + org.eclipse.vorto + bundles + 0.9.0-SNAPSHOT + + + org.eclipse.vorto.editor.functionblock.web + + Function Block Editor Plugin Web + + + src + + + src + + **/*.java + **/*.xtend + + + + + + org.eclipse.xtend + xtend-maven-plugin + + + maven-war-plugin + 2.6 + + WebRoot + false + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + initialize + + add-source + add-resource + + + + src-gen + + + + src-gen + + **/*.java + + + + + + + + + + + + + + org.springframework + spring-web + 4.3.0.RELEASE + + + org.eclipse.vorto + org.eclipse.vorto.core + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.web + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.datatype + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.functionblock + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.functionblock.ide + ${project.version} + + + org.eclipse.xtext + org.eclipse.xtext.xbase.web + ${xtext.version} + + + org.eclipse.xtext + org.eclipse.xtext.web.servlet + ${xtext.version} + + + org.eclipse.xtend + org.eclipse.xtend.lib + ${xtext.version} + + + org.eclipse.jetty + jetty-annotations + 9.2.11.v20150529 + provided + + + org.slf4j + slf4j-api + 1.7.1 + provided + + + diff --git a/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockServlet.xtend b/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockServlet.xtend new file mode 100644 index 0000000000..a7b425f742 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockServlet.xtend @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + *******************************************************************************/ +/* + * generated by Xtext + */ +package org.eclipse.vorto.editor.functionblock.web + +import com.google.inject.Provider +import java.util.List +import java.util.concurrent.ExecutorService +import java.util.concurrent.Executors +import javax.servlet.annotation.WebServlet +import org.eclipse.xtext.web.servlet.XtextServlet + +/** + * Deploy this class into a servlet container to enable DSL-specific services. + */ +@WebServlet(name = 'Functionblock XtextServices', urlPatterns = '/funcitonblock/xtext-service/') +class FunctionblockServlet extends XtextServlet { + + val List executorServices = newArrayList + + override init() { + super.init() + val Provider executorServiceProvider = [Executors.newCachedThreadPool => [executorServices += it]] + new FunctionblockWebSetup(executorServiceProvider).createInjectorAndDoEMFRegistration() + } + + override destroy() { + executorServices.forEach[shutdown()] + executorServices.clear() + super.destroy() + } + +} diff --git a/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebModule.xtend b/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebModule.xtend new file mode 100644 index 0000000000..75d4dee853 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebModule.xtend @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + *******************************************************************************/ +/* + * generated by Xtext + */ +package org.eclipse.vorto.editor.functionblock.web + +import org.eclipse.vorto.editor.web.resource.HashMapResourceHandler +import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider +import org.eclipse.xtext.web.server.persistence.IServerResourceHandler + +/** + * Use this class to register additional components to be used within the web application. + */ +@FinalFieldsConstructor +class FunctionblockWebModule extends AbstractFunctionblockWebModule { + + def Class bindIWebResourceSetProvider() { + return WebEditorResourceSetProvider + } + + def Class bindIServerResourceHandler() { + return HashMapResourceHandler; + } + +} diff --git a/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebSetup.xtend b/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebSetup.xtend new file mode 100644 index 0000000000..2bd21b2cce --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock.web/src/org/eclipse/vorto/editor/functionblock/web/FunctionblockWebSetup.xtend @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + *******************************************************************************/ +/* + * generated by Xtext + */ +package org.eclipse.vorto.editor.functionblock.web + +import com.google.inject.Guice +import com.google.inject.Injector +import com.google.inject.Provider +import com.google.inject.util.Modules +import java.util.concurrent.ExecutorService +import org.eclipse.vorto.editor.functionblock.FunctionblockRuntimeModule +import org.eclipse.vorto.editor.functionblock.FunctionblockStandaloneSetup +import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor + +/** + * Initialization support for running Xtext languages in web applications. + */ +@FinalFieldsConstructor +class FunctionblockWebSetup extends FunctionblockStandaloneSetup { + + val Provider executorServiceProvider; + + override Injector createInjector() { + val runtimeModule = new FunctionblockRuntimeModule() + val webModule = new FunctionblockWebModule(executorServiceProvider) + return Guice.createInjector(Modules.override(runtimeModule).with(webModule)) + } + +} diff --git a/bundles/org.eclipse.vorto.editor.functionblock/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.editor.functionblock/META-INF/MANIFEST.MF index 9175f0897c..e6845d6e5f 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.vorto.editor.functionblock/META-INF/MANIFEST.MF @@ -1,37 +1,37 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Vorto Functionblock Editor (Incubation) -Bundle-Vendor: Eclipse.org/Vorto -Bundle-Version: 0.9.0.qualifier -Bundle-SymbolicName: org.eclipse.vorto.editor.functionblock;singleton:=true -Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.xtext;visibility:=reexport, - org.eclipse.xtext.xbase;resolution:=optional;visibility:=reexport, - org.eclipse.xtext.generator;resolution:=optional, - org.apache.commons.logging;resolution:=optional, - org.eclipse.emf.codegen.ecore;resolution:=optional, - org.eclipse.emf.mwe.utils;resolution:=optional, - org.eclipse.emf.mwe2.launch;resolution:=optional, - org.eclipse.xtext.util, - org.eclipse.emf.ecore, - org.eclipse.emf.common, - org.antlr.runtime, - org.eclipse.xtext.common.types, - org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional, - org.eclipse.vorto.core, - org.eclipse.vorto.editor.datatype, - org.eclipse.vorto.editor, - org.eclipse.xtext.xbase.lib -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: org.eclipse.vorto.editor.functionblock; uses:="org.ecl - ipse.xtext, org.eclipse.xtext.service, org.eclipse.xtext.common.typ - es, com.google.inject",org.eclipse.vorto.editor.functionblock.format - ting,org.eclipse.vorto.editor.functionblock.generator;uses:="org.ecli - pse.xtext.generator",org.eclipse.vorto.editor.functionblock.parser.an - tlr,org.eclipse.vorto.editor.functionblock.parser.antlr.internal,org. - eclipse.vorto.editor.functionblock.scoping,org.eclipse.vorto.editor.f - unctionblock.serializer,org.eclipse.vorto.editor.functionblock.servic - es,org.eclipse.vorto.editor.functionblock.validation;uses:="org.eclip - se.vorto.editor.validation" -Bundle-ClassPath: . -Import-Package: org.apache.log4j +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Vorto Functionblock Editor (Incubation) +Bundle-Vendor: Eclipse.org/Vorto +Bundle-Version: 0.9.0.qualifier +Bundle-SymbolicName: org.eclipse.vorto.editor.functionblock;singleton:=true +Bundle-ActivationPolicy: lazy +Require-Bundle: org.eclipse.xtext;visibility:=reexport, + org.eclipse.xtext.xbase;resolution:=optional;visibility:=reexport, + org.eclipse.xtext.generator;resolution:=optional, + org.apache.commons.logging;resolution:=optional, + org.eclipse.emf.codegen.ecore;resolution:=optional, + org.eclipse.emf.mwe.utils;resolution:=optional, + org.eclipse.emf.mwe2.launch;resolution:=optional, + org.eclipse.xtext.util, + org.eclipse.emf.ecore, + org.eclipse.emf.common, + org.antlr.runtime, + org.eclipse.xtext.common.types, + org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional, + org.eclipse.vorto.core, + org.eclipse.vorto.editor.datatype, + org.eclipse.vorto.editor, + org.eclipse.xtext.xbase.lib, + org.eclipse.xtend.lib +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Export-Package: org.eclipse.vorto.editor.functionblock; uses:="org.eclipse.xtext, org.eclipse.xtext.service, org.eclipse.xtext.common.types, com.google.inject", + org.eclipse.vorto.editor.functionblock.formatting, + org.eclipse.vorto.editor.functionblock.generator;uses:="org.eclipse.xtext.generator", + org.eclipse.vorto.editor.functionblock.parser.antlr, + org.eclipse.vorto.editor.functionblock.parser.antlr.internal, + org.eclipse.vorto.editor.functionblock.scoping, + org.eclipse.vorto.editor.functionblock.serializer, + org.eclipse.vorto.editor.functionblock.services, + org.eclipse.vorto.editor.functionblock.validation;uses:="org.eclipse.vorto.editor.validation" +Bundle-ClassPath: . +Import-Package: org.apache.log4j diff --git a/bundles/org.eclipse.vorto.editor.functionblock/pom.xml b/bundles/org.eclipse.vorto.editor.functionblock/pom.xml index a21e12c6f8..dc56698397 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock/pom.xml +++ b/bundles/org.eclipse.vorto.editor.functionblock/pom.xml @@ -25,6 +25,7 @@ exec-maven-plugin + mwe2Launcher generate-sources java @@ -34,6 +35,7 @@ false true + false org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher file://${project.basedir}/src/org/eclipse/vorto/editor/functionblock/GenerateFunctionblock.mwe2 @@ -41,14 +43,19 @@ -p - runtimeProject=/${project.basedir} + rootPath=/${project.basedir}/.. + + org.eclipse.emf + org.eclipse.emf.mwe2.launch + 2.8.3 + org.eclipse.xtext - org.eclipse.xtext.xtext + org.eclipse.xtext.xtext.generator ${xtext.version} @@ -72,10 +79,52 @@ org.eclipse.xtend xtend-maven-plugin + + org.apache.maven.plugins + maven-clean-plugin + + + + ${basedir}/../org.eclipse.vorto.editor.functionblock/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.vorto.editor.functionblock.ide/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.vorto.editor.functionblock.ui/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.vorto.editor.functionblock.web/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.vorto.editor.functionblock.tests/src-gen/ + + **/* + + + + ${basedir}/model/generated/ + + + + - + org.eclipse.m2e lifecycle-mapping diff --git a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.java b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.java deleted file mode 100644 index 17d5f86c81..0000000000 --- a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2015-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 - */ -/* - * generated by Xtext - */ -package org.eclipse.vorto.editor.functionblock; - -import org.eclipse.vorto.editor.datatype.QualifiedNameWithVersionProvider; -import org.eclipse.vorto.editor.datatype.converter.DatatypeValueConverter; -import org.eclipse.vorto.editor.functionblock.generator.FbOutputConfigurationProvider; -import org.eclipse.vorto.editor.functionblock.scoping.FunctionblockScopeProvider; -import org.eclipse.vorto.editor.functionblock.validation.TypeFileAccessingHelper; -import org.eclipse.vorto.editor.functionblock.validation.TypeHelper; -import org.eclipse.xtext.conversion.IValueConverterService; -import org.eclipse.xtext.generator.IOutputConfigurationProvider; -import org.eclipse.xtext.naming.IQualifiedNameProvider; -import org.eclipse.xtext.scoping.IScopeProvider; - -import com.google.inject.Binder; -import com.google.inject.Provides; -import com.google.inject.Singleton; - -/** - * Use this class to register components to be used at runtime / without the - * Equinox extension registry. - */ -public class FunctionblockRuntimeModule - extends - org.eclipse.vorto.editor.functionblock.AbstractFunctionblockRuntimeModule { - - @Override - public void configure(Binder binder) { - super.configure(binder); - binder.bind(IOutputConfigurationProvider.class) - .to(FbOutputConfigurationProvider.class).in(Singleton.class); - } - - @Override - public Class bindIScopeProvider() { - return FunctionblockScopeProvider.class; - } - - @Provides - public TypeHelper getTypeHelper() { - return new TypeFileAccessingHelper(); - } - - @Override - public Class bindIQualifiedNameProvider() { - return QualifiedNameWithVersionProvider.class; - } - - @SuppressWarnings("restriction") - @Override - public void configureSerializerIScopeProvider(Binder binder) { - binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class) - .annotatedWith( - org.eclipse.xtext.serializer.tokens.SerializerScopeProviderBinding.class) - .to(FunctionblockScopeProvider.class); - } - - @Override - public Class bindIValueConverterService() { - return DatatypeValueConverter.class; - } -} diff --git a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.xtend b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.xtend new file mode 100644 index 0000000000..19a9be0223 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockRuntimeModule.xtend @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2015 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 +/* + * generated by Xtext + */ +org.eclipse.vorto.editor.functionblock + +import com.google.inject.Binder +import com.google.inject.Provides +import com.google.inject.Singleton +import org.eclipse.vorto.editor.datatype.QualifiedNameWithVersionProvider +import org.eclipse.vorto.editor.datatype.converter.DatatypeValueConverter +import org.eclipse.vorto.editor.functionblock.formatting.FunctionblockFormatter +import org.eclipse.vorto.editor.functionblock.generator.FbOutputConfigurationProvider +import org.eclipse.vorto.editor.functionblock.scoping.FunctionblockScopeProvider +import org.eclipse.vorto.editor.functionblock.validation.TypeFileAccessingHelper +import org.eclipse.vorto.editor.functionblock.validation.TypeHelper +import org.eclipse.xtext.conversion.IValueConverterService +import org.eclipse.xtext.generator.IOutputConfigurationProvider +import org.eclipse.xtext.naming.IQualifiedNameProvider +import org.eclipse.xtext.scoping.IScopeProvider +import org.eclipse.xtext.serializer.tokens.SerializerScopeProviderBinding + +/** + * Use this class to register components to be used at runtime / without the + * Equinox extension registry. + */ +class FunctionblockRuntimeModule extends AbstractFunctionblockRuntimeModule { + override void configure(Binder binder) { + super.configure(binder) + binder.bind(IOutputConfigurationProvider).to(FbOutputConfigurationProvider).in(Singleton) + } + + override Class bindIScopeProvider() { + return FunctionblockScopeProvider + } + + @Provides def TypeHelper getTypeHelper() { + return new TypeFileAccessingHelper() + } + + override Class bindIQualifiedNameProvider() { + return QualifiedNameWithVersionProvider + } + + @SuppressWarnings("restriction") override void configureSerializerIScopeProvider(Binder binder) { + binder.bind(IScopeProvider).annotatedWith( + SerializerScopeProviderBinding).to(FunctionblockScopeProvider) + } + + override Class bindIValueConverterService() { + return DatatypeValueConverter + } + + override bindIFormatter() { + FunctionblockFormatter + } +} diff --git a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockStandaloneSetup.java b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockStandaloneSetup.xtend similarity index 71% rename from bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockStandaloneSetup.java rename to bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockStandaloneSetup.xtend index 79a40a0b58..1efa3bf376 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockStandaloneSetup.java +++ b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/FunctionblockStandaloneSetup.xtend @@ -1,30 +1,27 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. +/** + * Copyright (c) 2015 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 /* * generated by Xtext */ -package org.eclipse.vorto.editor.functionblock; +org.eclipse.vorto.editor.functionblock -/** +/** * Initialization support for running Xtext languages without equinox extension * registry */ -public class FunctionblockStandaloneSetup extends - FunctionblockStandaloneSetupGenerated { - - public static void doSetup() { - new FunctionblockStandaloneSetup().createInjectorAndDoEMFRegistration(); +class FunctionblockStandaloneSetup extends FunctionblockStandaloneSetupGenerated { + def static void doSetup() { + new FunctionblockStandaloneSetup().createInjectorAndDoEMFRegistration() } } diff --git a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/GenerateFunctionblock.mwe2 b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/GenerateFunctionblock.mwe2 index 896637e213..ecbfa0e748 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/GenerateFunctionblock.mwe2 +++ b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/GenerateFunctionblock.mwe2 @@ -13,160 +13,74 @@ * Bosch Software Innovations GmbH - Please refer to git log * *******************************************************************************/ -module org.eclipse.vorto.fbeditor.GenerateFunctionblock +module org.eclipse.vorto.editor.functionblock.GenerateFunctionblock +import org.eclipse.xtext.xtext.generator.* +import org.eclipse.xtext.xtext.generator.model.project.* import org.eclipse.emf.mwe.utils.* import org.eclipse.xtext.generator.* import org.eclipse.xtext.ui.generator.* -var grammarURI = "platform:/resource/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/Functionblock.xtext" -var fileExtensions = "fbmodel" -var projectName = "org.eclipse.vorto.editor.functionblock" -var runtimeProject = "../${projectName}" -var generateXtendStub = true -var encoding = "UTF-8" +var rootPath = ".." Workflow { - bean = StandaloneSetup { - scanClassPath = true - resourceSet = org.eclipse.xtext.resource.XtextResourceSet:theResourceSet {} - platformUri = "${runtimeProject}/.." - - uriMap = { - from = "platform:/resource/org.eclipse.xtext.common.types/" - to = "classpath:/" - } - - uriMap = { - from = "platform:/plugin/org.eclipse.vorto.core/model/Datatype.ecore" - to = "platform:/plugin/org.eclipse.vorto.core/model/Datatype.ecore" - } - - uriMap = { - from = "platform:/plugin/org.eclipse.vorto.core/model/Functionblock.ecore" - to = "platform:/plugin/org.eclipse.vorto.core/model/Functionblock.ecore" - } - - projectMapping = { projectName = '${projectName}' path = '${runtimeProject}' } - - registerGeneratedEPackage = "org.eclipse.vorto.core.api.model.datatype.DatatypePackage" - registerGenModelFile = "platform:/resource/org.eclipse.vorto.core/model/Datatype.genmodel" - - registerGeneratedEPackage = "org.eclipse.vorto.core.api.model.functionblock.FunctionblockPackage" - registerGenModelFile = "platform:/resource/org.eclipse.vorto.core/model/Functionblock.genmodel" - - registerGeneratedEPackage = "org.eclipse.vorto.core.api.model.model.ModelPackage" - registerGenModelFile = "platform:/resource/org.eclipse.vorto.core/model/Model.genmodel" - } - - component = DirectoryCleaner { - directory = "${runtimeProject}/src-gen" - } - - component = DirectoryCleaner { - directory = "${runtimeProject}.ui/src-gen" - } - - component = DirectoryCleaner { - directory = "${runtimeProject}.tests/src-gen" - } - - component = Generator { - pathRtProject = runtimeProject - pathUiProject = "${runtimeProject}.ui" - pathTestProject = "${runtimeProject}.tests" - projectNameRt = projectName - projectNameUi = "${projectName}.ui" - encoding = encoding - language = auto-inject { - forcedResourceSet = theResourceSet - - uri = grammarURI - - // Java API to access grammar elements (required by several other fragments) - fragment = grammarAccess.GrammarAccessFragment auto-inject {} - - // generates Java API for the generated EPackages -// fragment = ecore.EMFGeneratorFragment auto-inject {} - - // the old serialization component - // fragment = parseTreeConstructor.ParseTreeConstructorFragment auto-inject {} - - // serializer 2.0 - fragment = serializer.SerializerFragment auto-inject { - generateStub = false - } - - // a custom ResourceFactory for use with EMF - fragment = resourceFactory.ResourceFactoryFragment auto-inject {} - - // The antlr parser generator fragment. - fragment = parser.antlr.XtextAntlrGeneratorFragment auto-inject { - // options = { - // backtrack = true - // } - } - - // Xtend-based API for validation - fragment = validation.ValidatorFragment auto-inject { - // composedCheck = "org.eclipse.xtext.validation.ImportUriValidator" - // composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator" - } - - // old scoping and exporting API - // fragment = scoping.ImportURIScopingFragment auto-inject {} - // fragment = exporting.SimpleNamesFragment auto-inject {} - - // scoping and exporting API - fragment = scoping.ImportNamespacesScopingFragment auto-inject { -// generateStub = false - } - fragment = exporting.QualifiedNamesFragment auto-inject {} - fragment = builder.BuilderIntegrationFragment auto-inject {} - - // generator API - fragment = generator.GeneratorFragment auto-inject {} - - // formatter API - fragment = formatting.FormatterFragment auto-inject {} - - // labeling API - fragment = labeling.LabelProviderFragment auto-inject {} - - // outline API - fragment = outline.OutlineTreeProviderFragment auto-inject {} - fragment = outline.QuickOutlineFragment auto-inject {} - - // quickfix API - fragment = quickfix.QuickfixProviderFragment auto-inject {} - - // content assist API - fragment = contentAssist.ContentAssistFragment auto-inject {} - - // generates a more lightweight Antlr parser and lexer tailored for content assist - fragment = parser.antlr.XtextAntlrUiGeneratorFragment auto-inject {} - - // generates junit test support classes into Generator#pathTestProject - fragment = junit.Junit4Fragment auto-inject {} - - // rename refactoring - fragment = refactoring.RefactorElementNameFragment auto-inject {} - - // provides the necessary bindings for java types integration -// fragment = types.TypesGeneratorFragment auto-inject {} - - // generates the required bindings only if the grammar inherits from Xbase -// fragment = xbase.XbaseGeneratorFragment auto-inject {} - - // generates the required bindings only if the grammar inherits from Xtype -// fragment = xbase.XtypeGeneratorFragment auto-inject {} - - // provides a preference page for template proposals - fragment = templates.CodetemplatesGeneratorFragment auto-inject {} - - // provides a compare view - fragment = compare.CompareFragment auto-inject {} - } - } -} + component = XtextGenerator { + configuration = { + project = StandardProjectConfig { + baseName = "org.eclipse.vorto.editor.functionblock" + rootPath = rootPath + eclipsePlugin = { + enabled = true + } + genericIde = { + enabled = true + } + web = { + enabled = true + } + runtimeTest = { + enabled = true + } + createEclipseMetaData = true + } + code = { + encoding = "UTF-8" + fileHeader = "/******************************************************************************* + * Copyright (c) 2014 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 + * + *******************************************************************************/ +/* + * generated by Xtext + */" + } + } + language = StandardLanguage { + name = "org.eclipse.vorto.editor.functionblock.Functionblock" + fileExtensions = "fbmodel" + + referencedResource = "platform:/resource/org.eclipse.vorto.core/model/Datatype.genmodel" + referencedResource = "platform:/resource/org.eclipse.vorto.core/model/Model.genmodel" + referencedResource = "platform:/resource/org.eclipse.vorto.core/model/Functionblock.genmodel" + + webSupport = { + framework = "Ace" + generateHtmlExample=false + generateJettyLauncher=false + generateServlet=true + generateJsHighlighting=true + } + } + } +} \ No newline at end of file diff --git a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/generator/FunctionblockGenerator.xtend b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/generator/FunctionblockGenerator.xtend index 6418c08317..1e2f92f7df 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/generator/FunctionblockGenerator.xtend +++ b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/generator/FunctionblockGenerator.xtend @@ -15,17 +15,19 @@ package org.eclipse.vorto.editor.functionblock.generator +import org.eclipse.xtext.generator.AbstractGenerator import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.xtext.generator.IFileSystemAccess -import org.eclipse.xtext.generator.IGenerator +import org.eclipse.xtext.generator.IFileSystemAccess2 +import org.eclipse.xtext.generator.IGeneratorContext /** * Generates code from your model files on save. * * see http://www.eclipse.org/Xtext/documentation.html#TutorialCodeGeneration */ -class FunctionblockGenerator implements IGenerator { - - override void doGenerate(Resource resource, IFileSystemAccess fsa) { +class FunctionblockGenerator extends AbstractGenerator { + + override doGenerate(Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) { +// throw new UnsupportedOperationException("TODO: auto-generated method stub") } } diff --git a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockUiInjectorProvider.java b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSemanticSequencer.xtend similarity index 50% rename from bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockUiInjectorProvider.java rename to bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSemanticSequencer.xtend index e8377b4a4f..0e6ec0045d 100644 --- a/bundles/org.eclipse.vorto.editor.functionblock.tests/src/org/eclipse/vorto/editor/functionblock/FunctionblockUiInjectorProvider.java +++ b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSemanticSequencer.xtend @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2015-2016 Bosch Software Innovations GmbH and others. +/******************************************************************************* + * Copyright (c) 2014 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. @@ -11,20 +11,13 @@ * * Contributors: * Bosch Software Innovations GmbH - Please refer to git log - */ + * + *******************************************************************************/ /* -* generated by Xtext -*/ -package org.eclipse.vorto.editor.functionblock; - -import org.eclipse.xtext.junit4.IInjectorProvider; + * generated by Xtext + */ +package org.eclipse.vorto.editor.functionblock.serializer -import com.google.inject.Injector; -public class FunctionblockUiInjectorProvider implements IInjectorProvider { - - public Injector getInjector() { - return org.eclipse.vorto.editor.functionblock.ui.internal.FunctionblockActivator.getInstance().getInjector("org.eclipse.vorto.fbeditor.Functionblock"); - } - +class FunctionblockSemanticSequencer extends AbstractFunctionblockSemanticSequencer { } diff --git a/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSyntacticSequencer.xtend b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSyntacticSequencer.xtend new file mode 100644 index 0000000000..6c0b7af024 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.functionblock/src/org/eclipse/vorto/editor/functionblock/serializer/FunctionblockSyntacticSequencer.xtend @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2014 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 + * + *******************************************************************************/ +/* + * generated by Xtext + */ +package org.eclipse.vorto.editor.functionblock.serializer + + +class FunctionblockSyntacticSequencer extends AbstractFunctionblockSyntacticSequencer { +} diff --git a/bundles/org.eclipse.vorto.editor.infomodel.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.vorto.editor.infomodel.ui/META-INF/MANIFEST.MF index 568eeaa3f2..9f67b7bdbc 100644 --- a/bundles/org.eclipse.vorto.editor.infomodel.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.vorto.editor.infomodel.ui/META-INF/MANIFEST.MF @@ -23,7 +23,7 @@ Require-Bundle: org.eclipse.xtext.ui, org.eclipse.vorto.editor.infomodel.ide Import-Package: org.apache.log4j Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Export-Package: org.eclipse.vorto.editor.infomodel.ui.contentassist,or - g.eclipse.vorto.editor.infomodel.ui.internal,org.eclipse.vorto.editor - .infomodel.ui.quickfix +Export-Package: org.eclipse.vorto.editor.infomodel.ui.contentassist, + org.eclipse.vorto.editor.infomodel.ui.internal, + org.eclipse.vorto.editor.infomodel.ui.quickfix Bundle-Activator: org.eclipse.vorto.editor.infomodel.ui.internal.InfomodelActivator diff --git a/bundles/org.eclipse.vorto.editor.infomodel.web/pom.xml b/bundles/org.eclipse.vorto.editor.infomodel.web/pom.xml index 9d0b4599ae..ffcffc4575 100644 --- a/bundles/org.eclipse.vorto.editor.infomodel.web/pom.xml +++ b/bundles/org.eclipse.vorto.editor.infomodel.web/pom.xml @@ -67,11 +67,27 @@ + + + org.springframework + spring-web + 4.3.0.RELEASE + org.eclipse.vorto org.eclipse.vorto.core ${project.version} + + org.eclipse.vorto + org.eclipse.vorto.editor.web + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.datatype + ${project.version} + org.eclipse.vorto org.eclipse.vorto.editor.functionblock @@ -102,21 +118,6 @@ org.eclipse.xtend.lib ${xtext.version} - - org.webjars - requirejs - 2.1.15 - - - org.webjars - jquery - 2.1.1 - - - org.webjars - ace - 1.2.0 - org.eclipse.jetty jetty-annotations diff --git a/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelServlet.xtend b/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelServlet.xtend index ba027a77af..b13a802bba 100644 --- a/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelServlet.xtend +++ b/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelServlet.xtend @@ -30,7 +30,7 @@ import org.eclipse.vorto.editor.functionblock.FunctionblockStandaloneSetup /** * Deploy this class into a servlet container to enable DSL-specific services. */ -@WebServlet(name = 'XtextServices', urlPatterns = '/xtext-service/*') +@WebServlet(name = 'InformationModel XtextServices', urlPatterns = '/infomodel/xtext-service/') class InformationModelServlet extends XtextServlet { val List executorServices = newArrayList diff --git a/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelWebModule.xtend b/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelWebModule.xtend index eaee81faaf..ac8812400a 100644 --- a/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelWebModule.xtend +++ b/bundles/org.eclipse.vorto.editor.infomodel.web/src/org/eclipse/vorto/editor/infomodel/web/InformationModelWebModule.xtend @@ -3,26 +3,38 @@ * 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 - * + * *******************************************************************************/ /* * generated by Xtext */ package org.eclipse.vorto.editor.infomodel.web +import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider import org.eclipse.xtend.lib.annotations.FinalFieldsConstructor +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider +import org.eclipse.xtext.web.server.persistence.IServerResourceHandler +import org.eclipse.vorto.editor.web.resource.HashMapResourceHandler /** * Use this class to register additional components to be used within the web application. */ @FinalFieldsConstructor class InformationModelWebModule extends AbstractInformationModelWebModule { + + def Class bindIWebResourceSetProvider() { + return WebEditorResourceSetProvider + } + + def Class bindIServerResourceHandler() { + return HashMapResourceHandler; + } } diff --git a/bundles/org.eclipse.vorto.editor.web/pom.xml b/bundles/org.eclipse.vorto.editor.web/pom.xml new file mode 100644 index 0000000000..d788c2d505 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.web/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + org.eclipse.vorto + bundles + 0.9.0-SNAPSHOT + + + org.eclipse.vorto.editor.web + + Vorto Editor Web + + + src + + + src + + **/*.java + **/*.xtend + + + + + + org.eclipse.xtend + xtend-maven-plugin + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + initialize + + add-source + add-resource + + + + src-gen + + + + src-gen + + **/*.java + + + + + + + + + + + + + org.eclipse.xtext + org.eclipse.xtext.xbase.web + ${xtext.version} + + + org.eclipse.xtext + org.eclipse.xtext.web.servlet + ${xtext.version} + + + org.eclipse.xtend + org.eclipse.xtend.lib + ${xtext.version} + + + + diff --git a/bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/HashMapResourceHandler.xtend b/bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/HashMapResourceHandler.xtend new file mode 100644 index 0000000000..65adfded83 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/HashMapResourceHandler.xtend @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.editor.web.resource + +import com.google.inject.Inject +import java.io.IOException +import org.eclipse.emf.common.util.URI +import org.eclipse.xtext.resource.XtextResource +import org.eclipse.xtext.web.server.IServiceContext +import org.eclipse.xtext.web.server.model.IWebDocumentProvider +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider +import org.eclipse.xtext.web.server.model.IXtextWebDocument +import org.eclipse.xtext.web.server.persistence.IServerResourceHandler +import org.eclipse.emf.common.util.WrappedException + +class HashMapResourceHandler implements IServerResourceHandler { + + @Inject IWebResourceSetProvider resourceSetProvider; + + @Inject IWebDocumentProvider documentProvider; + + override get(String resourceId, IServiceContext serviceContext) throws IOException { + try { + val resourceSet = resourceSetProvider.get(resourceId, serviceContext); + val uri = URI.createFileURI(resourceId); + val resource = resourceSet.getResource(uri, true) as XtextResource + return documentProvider.get(resourceId, serviceContext) => [ + setInput(resource) + ] + }catch (WrappedException exception){ + throw exception.cause + } + } + + override put(IXtextWebDocument document, IServiceContext serviceContext) throws IOException { + /* + * Since the files are being stored in memory here, this has not been implemented + */ + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + +} diff --git a/bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/WebEditorResourceSetProvider.xtend b/bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/WebEditorResourceSetProvider.xtend new file mode 100644 index 0000000000..849b488fc6 --- /dev/null +++ b/bundles/org.eclipse.vorto.editor.web/src/org/eclipse/vorto/editor/web/resource/WebEditorResourceSetProvider.xtend @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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.editor.web.resource + +import com.google.inject.Inject +import java.util.HashSet +import java.util.Set +import javax.inject.Provider +import javax.inject.Singleton +import org.eclipse.emf.ecore.resource.ResourceSet +import org.eclipse.xtext.web.server.IServiceContext +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider + +@Singleton +class WebEditorResourceSetProvider implements IWebResourceSetProvider { + + @Inject package Provider provider + + override ResourceSet get(String resourceId, IServiceContext serviceContext) { + return getResourceSetFromSession(serviceContext) + } + + def setSessionResourceSet(IServiceContext serviceContext, ResourceSet resourceSet) { + serviceContext.getSession().put("set", resourceSet) + } + + def setSessionRefencedResourceSet(IServiceContext serviceContext, HashSet referencedResourceSet) { + serviceContext.getSession().put("referenceSet", referencedResourceSet) + } + + def ResourceSet getResourceSetFromSession(IServiceContext serviceContext) { + if (serviceContext.getSession().get("set") === null) { + var ResourceSet resourceSet = provider.get() + setSessionResourceSet(serviceContext, resourceSet); + return resourceSet + } else { + return serviceContext.getSession().get("set") + } + } + + def Set getReferencedResourcesFromSession(IServiceContext serviceContext) { + if (serviceContext.getSession().get("referenceSet") === null) { + var HashSet referencedResourceSet = new HashSet() + serviceContext.getSession().put("referenceSet", referencedResourceSet) + return referencedResourceSet + } else { + return serviceContext.getSession().get("referenceSet") + } + } + + def ResourceSet getNewResourceSet() { + return provider.get(); + } +} diff --git a/bundles/pom.xml b/bundles/pom.xml index d298190f16..a53cc8da67 100644 --- a/bundles/pom.xml +++ b/bundles/pom.xml @@ -1,51 +1,53 @@ - - + + - - org.eclipse.vorto - org.eclipse.vorto.parent - 0.9.0-SNAPSHOT - + + org.eclipse.vorto + org.eclipse.vorto.parent + 0.9.0-SNAPSHOT + - 4.0.0 - bundles + 4.0.0 + bundles - Eclipse Vorto Bundles + Eclipse Vorto Bundles - pom + pom - + org.eclipse.vorto.core - org.eclipse.vorto.core.ui + org.eclipse.vorto.core.ui org.eclipse.vorto.editor - org.eclipse.vorto.editor.ui - + org.eclipse.vorto.editor.ui + org.eclipse.vorto.editor.web + org.eclipse.vorto.editor.datatype - org.eclipse.vorto.editor.datatype.ui + org.eclipse.vorto.editor.datatype.ui org.eclipse.vorto.editor.datatype.tests - + org.eclipse.vorto.editor.functionblock - org.eclipse.vorto.editor.functionblock.ui + org.eclipse.vorto.editor.functionblock.ui org.eclipse.vorto.editor.functionblock.tests + org.eclipse.vorto.editor.functionblock.ide + org.eclipse.vorto.editor.functionblock.web org.eclipse.vorto.editor.infomodel - org.eclipse.vorto.editor.infomodel.ui + org.eclipse.vorto.editor.infomodel.ui org.eclipse.vorto.editor.infomodel.tests org.eclipse.vorto.editor.infomodel.ide - org.eclipse.vorto.editor.infomodel.web + org.eclipse.vorto.editor.infomodel.web org.eclipse.vorto.editor.mapping - org.eclipse.vorto.editor.mapping.ui - org.eclipse.vorto.editor.mapping.tests - + org.eclipse.vorto.editor.mapping.ui + org.eclipse.vorto.editor.mapping.tests + org.eclipse.vorto.codegen - org.eclipse.vorto.codegen.ui + org.eclipse.vorto.codegen.ui org.eclipse.vorto.codegen.templates.java - + org.eclipse.vorto.wizard org.eclipse.vorto.repository - org.eclipse.vorto.perspective - + org.eclipse.vorto.perspective - - + + \ No newline at end of file diff --git a/server/devtool/pom.xml b/server/devtool/pom.xml index 1ce6338c87..9170ef027e 100644 --- a/server/devtool/pom.xml +++ b/server/devtool/pom.xml @@ -6,15 +6,17 @@ org.eclipse.vorto.server devtool - 0.4.0-SNAPSHOT + 0.9.0-SNAPSHOT war + Vorto Devtool + A web editor to create and edit Vorto models org.springframework.boot spring-boot-starter-parent 1.3.0.RELEASE - + 2.9.2 @@ -24,6 +26,12 @@ org.springframework.boot spring-boot-maven-plugin + + + -Xdebug + -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 + + @@ -43,6 +51,7 @@ + org.springframework.boot spring-boot-starter-web @@ -53,25 +62,52 @@ - org.springframework.boot spring-boot-starter-security + + + io.swagger + swagger-annotations + 1.5.6 + + + io.swagger + swagger-models + 1.5.6 + + + org.eclipse.vorto - org.eclipse.vorto.editor.infomodel + org.eclipse.vorto.core ${project.version} org.eclipse.vorto - org.eclipse.vorto.editor.infomodel.web + repo-http-models ${project.version} org.eclipse.vorto - org.eclipse.vorto.editor.infomodel.ide + org.eclipse.vorto.editor.web + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.functionblock + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.functionblock.web + ${project.version} + + + org.eclipse.vorto + org.eclipse.vorto.editor.functionblock.ide ${project.version} @@ -80,15 +116,20 @@ - - org.eclipse.xtext - org.eclipse.xtext - ${xtext.version} - - - com.google.guava - guava - - + org.apache.commons + commons-lang3 + 3.1 + + - org.eclipse.xtext - org.eclipse.xtext.xbase - ${xtext.version} - - - org.ow2.asm - asm - - - com.google.guava - guava - - - --> - + org.webjars + requirejs + 2.1.15 + + + org.webjars + jquery + 2.1.1 + + + org.webjars + ace + 1.2.0 + + + org.webjars + angularjs + 1.3.13 + + + org.webjars.bower + angular-route + 1.3.13 + + + org.webjars + angular-ui-bootstrap + 0.14.3 + + + org.webjars.bower + angular-animate + 1.3.13 + + + org.webjars.bower + angular-aria + 1.3.15 + + + org.webjars + font-awesome + 4.2.0 + + + org.webjars.npm + angular-smart-table + 2.1.6 + + + + + junit + junit + test + + + org.springframework + spring-test + test + + + org.springframework.boot + spring-boot-starter-test + test + + + diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/DevToolServer.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/DevToolServer.java index 64ce244b88..a9133eb9a5 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/DevToolServer.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/DevToolServer.java @@ -18,8 +18,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.context.web.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; @SpringBootApplication +@ComponentScan(basePackages = {"org.eclipse.vorto.server.devtool"}) public class DevToolServer extends SpringBootServletInitializer { public static void main(String... args) { diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/SecurityConfiguration.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/SecurityConfiguration.java index a88c0a92e1..00c1e8b79b 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/SecurityConfiguration.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/SecurityConfiguration.java @@ -26,6 +26,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; @Configuration @@ -40,7 +41,16 @@ protected void doFilterInternal(final HttpServletRequest request, HttpServletRes FilterChain filterChain) throws ServletException, IOException { filterChain.doFilter(request, response); } - }; } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/**").permitAll() + .anyRequest().authenticated() + .and() + .csrf().disable(); + } } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/XtextConfiguration.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/XtextConfiguration.java index 043fad2701..b83815cb5f 100644 --- a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/XtextConfiguration.java +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/config/XtextConfiguration.java @@ -14,16 +14,67 @@ */ package org.eclipse.vorto.server.devtool.config; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.eclipse.vorto.core.api.model.informationmodel.impl.InformationModelPackageImpl; +import org.eclipse.vorto.editor.functionblock.FunctionblockStandaloneSetup; +import org.eclipse.vorto.editor.functionblock.web.FunctionblockServlet; +import org.eclipse.vorto.editor.infomodel.InformationModelRuntimeModule; import org.eclipse.vorto.editor.infomodel.web.InformationModelServlet; +import org.eclipse.vorto.editor.infomodel.web.InformationModelWebModule; +import org.eclipse.xtext.xbase.lib.CollectionLiterals; +import org.eclipse.xtext.xbase.lib.ObjectExtensions; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; import org.springframework.boot.context.embedded.ServletRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Provider; +import com.google.inject.util.Modules; + @Configuration public class XtextConfiguration { + private final List executorServices = CollectionLiterals. newArrayList(); + + @Bean + public Injector getInjectorBean() { + final Provider _function = new Provider() { + @Override + public ExecutorService get() { + ExecutorService _newCachedThreadPool = Executors.newCachedThreadPool(); + final Procedure1 _function = new Procedure1() { + @Override + public void apply(final ExecutorService it) { + XtextConfiguration.this.executorServices.add(it); + } + }; + return ObjectExtensions. operator_doubleArrow(_newCachedThreadPool, _function); + } + }; + final Provider executorServiceProvider = _function; + + FunctionblockStandaloneSetup.doSetup(); + InformationModelPackageImpl.init(); + + + return Guice.createInjector( + Modules.override(new InformationModelRuntimeModule()) + .with(new InformationModelWebModule(executorServiceProvider))); + } + + @Bean + public ServletRegistrationBean functionBlockXtextServlet() { + return new ServletRegistrationBean(new FunctionblockServlet(), "/functionblock/xtext-service/*"); + } + @Bean - public ServletRegistrationBean xtextServlet() { - return new ServletRegistrationBean(new InformationModelServlet(), "/xtext-service/*"); + public ServletRegistrationBean informationModelXtextServlet() { + return new ServletRegistrationBean(new InformationModelServlet(), "/infomodel/xtext-service/*"); } + } diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/ProjectController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/ProjectController.java new file mode 100644 index 0000000000..e15b381218 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/ProjectController.java @@ -0,0 +1,208 @@ +/******************************************************************************* + * 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.server.devtool.controller; + +import java.util.ArrayList; +import java.util.Objects; + +import javax.servlet.http.HttpServletRequest; + +import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; +import org.eclipse.vorto.server.devtool.exception.ProjectAlreadyExistsException; +import org.eclipse.vorto.server.devtool.exception.ProjectNotFoundException; +import org.eclipse.vorto.server.devtool.exception.ProjectResourceAlreadyExistsException; +import org.eclipse.vorto.server.devtool.models.Project; +import org.eclipse.vorto.server.devtool.models.ProjectResource; +import org.eclipse.vorto.server.devtool.service.IProjectRepositoryService; +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider; +import org.eclipse.xtext.web.servlet.HttpServiceContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import com.google.inject.Injector; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +@RestController +@RequestMapping(value = "/project") +public class ProjectController { + + @Autowired + Injector injector; + + @Autowired + IProjectRepositoryService projectRepositoryService; + + @ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Project not found") + @ExceptionHandler(ProjectNotFoundException.class) + public void handleProjectNotFoundException() { + + } + + @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Project already exists") + @ExceptionHandler(ProjectAlreadyExistsException.class) + public void handleProjectAlreadyExistsException() { + + } + + @ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "Resource already exists") + @ExceptionHandler(ProjectResourceAlreadyExistsException.class) + public void handleProjectResourceAlreadyExistsException() { + + } + + @ApiOperation(value = "Checks whether a Vorto project already exists") + @RequestMapping(value = "/{projectName}/check", method = RequestMethod.GET) + public void checkProjectExists( + @ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName, + @ApiParam(value = "Request", required = true) final HttpServletRequest request) + throws ProjectAlreadyExistsException { + + Objects.requireNonNull(projectName, "projectName must not be null"); + + String sessionId = request.getSession().getId(); + + projectRepositoryService.checkProjectExists(sessionId, projectName); + } + + @ApiOperation(value = "Checks whether a resource exists within the Vorto project") + @RequestMapping(value = "/{projectName}/resources/check/{namespace}/{name}/{version:.+}", method = RequestMethod.GET) + public void checkResourceExists( + @ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName, + @ApiParam(value = "Namespace", required = true) final @PathVariable String namespace, + @ApiParam(value = "Name", required = true) final @PathVariable String name, + @ApiParam(value = "Version", required = true) final @PathVariable String version, + @ApiParam(value = "Request", required = true) final HttpServletRequest request) + throws ProjectNotFoundException, ProjectAlreadyExistsException, ProjectResourceAlreadyExistsException { + + Objects.requireNonNull(projectName, "projectName must not be null"); + Objects.requireNonNull(namespace, "namespace must not be null"); + Objects.requireNonNull(name, "namespace must not be null"); + Objects.requireNonNull(version, "namespace must not be null"); + String sessionId = request.getSession().getId(); + + ProjectResource projectResource = new ProjectResource(); + projectResource.setName(name); + projectResource.setNamespace(namespace); + projectResource.setVersion(version); + + projectRepositoryService.checkResourceExists(sessionId, projectName, projectResource); + } + + @ApiOperation(value = "Creates a new Vorto project") + @RequestMapping(method = RequestMethod.POST) + public void createProject(@RequestBody Project project, + @ApiParam(value = "Request", required = true) final HttpServletRequest request) + throws ProjectAlreadyExistsException { + + Objects.requireNonNull(project.getProjectName(), "projectName must not be null"); + HttpServiceContext httpServiceContext = new HttpServiceContext(request); + WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector + .getInstance(IWebResourceSetProvider.class); + + String sessionId = request.getSession().getId(); + + project = projectRepositoryService.createProject(sessionId, project.getProjectName()); + + webEditorResourceSetProvider.setSessionResourceSet(httpServiceContext, project.getResourceSet()); + webEditorResourceSetProvider.setSessionRefencedResourceSet(httpServiceContext, + project.getReferencedResourceSet()); + } + + @ApiOperation(value = "Opens an existing Vorto project") + @RequestMapping(value = "/{projectName}/open", method = RequestMethod.GET) + public void openProject(@ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName, + @ApiParam(value = "Request", required = true) final HttpServletRequest request) + throws ProjectNotFoundException { + + Objects.requireNonNull(projectName, "projectName must not be null"); + + HttpServiceContext httpServiceContext = new HttpServiceContext(request); + WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector + .getInstance(IWebResourceSetProvider.class); + + String sessionId = request.getSession().getId(); + Project project = projectRepositoryService.openProject(sessionId, projectName); + + webEditorResourceSetProvider.setSessionResourceSet(httpServiceContext, project.getResourceSet()); + webEditorResourceSetProvider.setSessionRefencedResourceSet(httpServiceContext, + project.getReferencedResourceSet()); + } + + @ApiOperation(value = "Returns all the project for the user") + @RequestMapping(method = RequestMethod.GET) + public ArrayList getProjects(final HttpServletRequest request) { + String sessionId = request.getSession().getId(); + return projectRepositoryService.getProjects(sessionId); + } + + @ApiOperation(value = "Deletes the resource in the Vorto project") + @RequestMapping(value = "/{projectName}/resources/delete/{namespace}/{name}/{version:.+}", method = RequestMethod.GET) + public void deleteProjectResource( + @ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName, + @ApiParam(value = "Namespace", required = true) final @PathVariable String namespace, + @ApiParam(value = "Name", required = true) final @PathVariable String name, + @ApiParam(value = "Version", required = true) final @PathVariable String version, + @ApiParam(value = "Request", required = true) final HttpServletRequest request) + throws ProjectNotFoundException { + + Objects.requireNonNull(projectName, "projectName must not be null"); + Objects.requireNonNull(namespace, "namespace must not be null"); + Objects.requireNonNull(name, "namespace must not be null"); + Objects.requireNonNull(version, "namespace must not be null"); + String sessionId = request.getSession().getId(); + + ProjectResource projectResource = new ProjectResource(); + projectResource.setName(name); + projectResource.setNamespace(namespace); + projectResource.setVersion(version); + + projectRepositoryService.deleteResource(sessionId, projectName, projectResource); + } + + @ApiOperation(value = "Creates a new resource in the Vorto project") + @RequestMapping(value = "/{projectName}/resources/create", method = RequestMethod.POST) + public void createProjectResource( + @RequestBody ProjectResource projectResoure, + @ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName, + @ApiParam(value = "Request", required = true) final HttpServletRequest request) + throws ProjectNotFoundException, ProjectResourceAlreadyExistsException { + + Objects.requireNonNull(projectName, "projectName must not be null"); + String sessionId = request.getSession().getId(); + projectRepositoryService.createResource(sessionId, projectName, projectResoure); + } + + @ApiOperation(value = "Returns a list of resources in the Vorto project") + @RequestMapping(value = "/{projectName}/resources", method = RequestMethod.GET) + public ArrayList getResources( + @ApiParam(value = "ProjectName", required = true) final @PathVariable String projectName, + @ApiParam(value = "Request", required = true) final HttpServletRequest request) + throws ProjectNotFoundException { + + Objects.requireNonNull(projectName, "projectName must not be null"); + + String sessionId = request.getSession().getId(); + return projectRepositoryService.getProjectResources(sessionId, projectName); + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/RepositoryController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/RepositoryController.java new file mode 100644 index 0000000000..38435d0c5a --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/RepositoryController.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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.server.devtool.controller; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.google.gson.JsonObject; + +@RestController +@RequestMapping(value = "/repository") +public class RepositoryController { + + @Value("${vorto.repository.base.path}") + String repositoryBasePath; + + @RequestMapping(value = "/basepath", method = RequestMethod.GET) + public String getRepoUrl() { + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty("basepath", repositoryBasePath); + String json = jsonObject.toString(); + return json; + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/FunctionBlockEditorController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/FunctionBlockEditorController.java new file mode 100644 index 0000000000..30544ac59e --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/FunctionBlockEditorController.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * 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.server.devtool.controller.editor; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; +import org.eclipse.vorto.http.model.ModelId; +import org.eclipse.vorto.http.model.ModelResource; +import org.eclipse.vorto.server.devtool.service.editor.FunctionBlockEditorServiceImpl; +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider; +import org.eclipse.xtext.web.servlet.HttpServiceContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.google.inject.Injector; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +@RestController +@RequestMapping(value = "/editor/functionblock") +public class FunctionBlockEditorController implements IEditorController { + + @Autowired + Injector injector; + + @Autowired + FunctionBlockEditorServiceImpl functionBlockEditorService; + + @ApiOperation(value = "Adds the data type to the resource set") + @RequestMapping(value = "/link/datatype/{resourceId}/{namespace}/{name}/{version:.+}", method = RequestMethod.GET) + public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @PathVariable String resourceId, + @ApiParam(value = "Namespace", required = true) final @PathVariable String namespace, + @ApiParam(value = "Name", required = true) final @PathVariable String name, + @ApiParam(value = "Version", required = true) final @PathVariable String version, + @ApiParam(value = "Request", required = true) final HttpServletRequest request, + @ApiParam(value = "Response", required = true) final HttpServletResponse response) { + + Objects.requireNonNull(resourceId, "resourceId must not be null"); + Objects.requireNonNull(namespace, "namespace must not be null"); + Objects.requireNonNull(name, "name must not be null"); + Objects.requireNonNull(version, "version must not be null"); + + ModelId modelId = new ModelId(name, namespace, version); + + HttpServiceContext httpServiceContext = new HttpServiceContext(request); + WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector.getInstance(IWebResourceSetProvider.class); + ResourceSet resourceSet = webEditorResourceSetProvider.getResourceSetFromSession(httpServiceContext); + HashSet referencedResourceSet = (HashSet) webEditorResourceSetProvider + .getReferencedResourcesFromSession(httpServiceContext); + + String content = functionBlockEditorService.linkModelToResource(resourceId, modelId, resourceSet, referencedResourceSet); + try { + IOUtils.copy(new ByteArrayInputStream(content.getBytes()), response.getOutputStream()); + response.flushBuffer(); + } catch (IOException e) { + throw new RuntimeException("Error copying file.", e); + } + } + + @ApiOperation(value = "") + @RequestMapping(value = "/search={expression:.*}", method = RequestMethod.GET) + public List searchByExpression( + @ApiParam(value = "Search expression", required = true) @PathVariable String expression) { + + Objects.requireNonNull(expression, "namespace must not be null"); + return functionBlockEditorService.searchModelByExpression(expression); + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/IEditorController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/IEditorController.java new file mode 100644 index 0000000000..e00d373658 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/IEditorController.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.server.devtool.controller.editor; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.vorto.http.model.ModelResource; + +public interface IEditorController { + + public void linkEditor(String resourceId, String namespace, String name, String version, HttpServletRequest request, + HttpServletResponse response); + + List searchByExpression(String expression); + +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/InformationModelEditorController.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/InformationModelEditorController.java new file mode 100644 index 0000000000..b51f2bd638 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/controller/editor/InformationModelEditorController.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.server.devtool.controller.editor; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; +import org.eclipse.vorto.http.model.ModelId; +import org.eclipse.vorto.http.model.ModelResource; +import org.eclipse.vorto.server.devtool.service.editor.InformationModelEditorServiceImpl; +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider; +import org.eclipse.xtext.web.servlet.HttpServiceContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.google.inject.Injector; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +@RestController +@RequestMapping(value = "/editor/infomodel") +public class InformationModelEditorController implements IEditorController { + + @Autowired + Injector injector; + + @Autowired + InformationModelEditorServiceImpl iInformationModelEditorService; + + @ApiOperation(value = "Adds the function block to the resource set") + @RequestMapping(value = "/link/functionblock/{resourceId}/{namespace}/{name}/{version:.+}", method = RequestMethod.GET) + public void linkEditor(@ApiParam(value = "ResourceId", required = true) final @PathVariable String resourceId, + @ApiParam(value = "Namespace", required = true) final @PathVariable String namespace, + @ApiParam(value = "Name", required = true) final @PathVariable String name, + @ApiParam(value = "Version", required = true) final @PathVariable String version, + @ApiParam(value = "Request", required = true) final HttpServletRequest request, + @ApiParam(value = "Response", required = true) final HttpServletResponse response) { + + Objects.requireNonNull(resourceId, "resourceId must not be null"); + Objects.requireNonNull(namespace, "namespace must not be null"); + Objects.requireNonNull(name, "name must not be null"); + Objects.requireNonNull(version, "version must not be null"); + + ModelId modelId = new ModelId(name, namespace, version); + + HttpServiceContext httpServiceContext = new HttpServiceContext(request); + WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector + .getInstance(IWebResourceSetProvider.class); + ResourceSet resourceSet = webEditorResourceSetProvider.getResourceSetFromSession(httpServiceContext); + HashSet referencedResourceSet = (HashSet) webEditorResourceSetProvider + .getReferencedResourcesFromSession(httpServiceContext); + + String content = iInformationModelEditorService.linkModelToResource(resourceId, modelId, resourceSet, + referencedResourceSet); + try { + IOUtils.copy(new ByteArrayInputStream(content.getBytes()), response.getOutputStream()); + response.flushBuffer(); + } catch (IOException e) { + throw new RuntimeException("Error copying file.", e); + } + } + + @ApiOperation(value = "") + @RequestMapping(value = "/search={expression:.*}", method = RequestMethod.GET) + public List searchByExpression( + @ApiParam(value = "Search expression", required = true) @PathVariable String expression) { + + Objects.requireNonNull(expression, "namespace must not be null"); + return iInformationModelEditorService.searchModelByExpression(expression); + } +} \ No newline at end of file diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectAlreadyExistsException.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectAlreadyExistsException.java new file mode 100644 index 0000000000..a821dbecf5 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectAlreadyExistsException.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * 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.server.devtool.exception; + +public class ProjectAlreadyExistsException extends Exception { + +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectNotFoundException.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectNotFoundException.java new file mode 100644 index 0000000000..ea17deccd6 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectNotFoundException.java @@ -0,0 +1,20 @@ +/******************************************************************************* + * 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.server.devtool.exception; + +public class ProjectNotFoundException extends Exception { + + +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectResourceAlreadyExistsException.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectResourceAlreadyExistsException.java new file mode 100644 index 0000000000..8b711288c4 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/exception/ProjectResourceAlreadyExistsException.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * 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.server.devtool.exception; + +public class ProjectResourceAlreadyExistsException extends Exception{ + +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/Project.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/Project.java new file mode 100644 index 0000000000..bf5b503b1c --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/Project.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * 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.server.devtool.models; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +public class Project { + + private String projectName; + private String sessionId; //change this later to author or login id + private ResourceSet resourceSet; + private HashSet referencedResourceSet; + private ArrayList resourceList; + + public Project(){ + + } + + public Project(String projectName){ + this.projectName = projectName; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + public ResourceSet getResourceSet() { + return resourceSet; + } + + public void setResourceSet(ResourceSet projectResourceSet) { + this.resourceSet = projectResourceSet; + } + + public HashSet getReferencedResourceSet() { + return referencedResourceSet; + } + + public void setReferencedResourceSet(HashSet referencedResourceSet) { + this.referencedResourceSet = referencedResourceSet; + } + + public ArrayList getResourceList() { + return resourceList; + } + + public void setResourceList(ArrayList resourceList) { + this.resourceList = resourceList; + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java new file mode 100644 index 0000000000..0ad9dd3862 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/models/ProjectResource.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * 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.server.devtool.models; + +public class ProjectResource { + + private String resourceId; + private String name; + private String version; + private String namespace; + + public String getResourceId() { + return resourceId; + } + + public void setResourceId(String resourceId) { + this.resourceId = resourceId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + @Override + public boolean equals(Object obj) { + if (obj.getClass().equals(this.getClass())) { + ProjectResource projectResource = (ProjectResource) obj; + if (this.name.equals(projectResource.name) && this.namespace.equals(projectResource.namespace) + && this.version.equals(projectResource.version)) { + return true; + } + } + return false; + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRepositoryService.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRepositoryService.java new file mode 100644 index 0000000000..7adbb8743a --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRepositoryService.java @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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.server.devtool.service; + +import java.util.ArrayList; + +import org.eclipse.vorto.server.devtool.exception.ProjectAlreadyExistsException; +import org.eclipse.vorto.server.devtool.exception.ProjectNotFoundException; +import org.eclipse.vorto.server.devtool.exception.ProjectResourceAlreadyExistsException; +import org.eclipse.vorto.server.devtool.models.Project; +import org.eclipse.vorto.server.devtool.models.ProjectResource; + +public interface IProjectRepositoryService { + + void checkProjectExists(String sessionId, String projectName) throws ProjectAlreadyExistsException; + + void checkResourceExists(String sessionId, String projectName, ProjectResource projectResource) throws ProjectAlreadyExistsException, ProjectResourceAlreadyExistsException, ProjectNotFoundException; + + Project createProject(String sessionId, String projectName) throws ProjectAlreadyExistsException; + + Project openProject(String sessionId, String projectName) throws ProjectNotFoundException; + + ArrayList getProjects(String sessionId); + + ArrayList getProjectResources(String sessionId, String projectName) throws ProjectNotFoundException; + + void createResource(String sessionId, String projectName, ProjectResource projectResource) throws ProjectNotFoundException, ProjectResourceAlreadyExistsException; + + void deleteResource(String sessionId, String projectName, ProjectResource projectResource) throws ProjectNotFoundException; +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRespositoryDAO.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRespositoryDAO.java new file mode 100644 index 0000000000..024efe13dd --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/IProjectRespositoryDAO.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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.server.devtool.service; + +import java.util.ArrayList; + +import org.eclipse.vorto.server.devtool.models.Project; + +public interface IProjectRespositoryDAO { + + void createProject(Project project, String sessionId); + + boolean projectExists(String projectName, String sessionId); + + Project openProject(String projectName, String sessionId); + + ArrayList getProjects(String sessionId); + +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/FunctionBlockEditorServiceImpl.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/FunctionBlockEditorServiceImpl.java new file mode 100644 index 0000000000..885ae4d045 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/FunctionBlockEditorServiceImpl.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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.server.devtool.service.editor; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.vorto.http.model.ModelId; +import org.eclipse.vorto.http.model.ModelResource; +import org.eclipse.vorto.server.devtool.utils.DevtoolReferenceLinker; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class FunctionBlockEditorServiceImpl extends IEditorService { + + @Autowired + DevtoolReferenceLinker devtoolReferenceLinker; + + public String linkModelToResource(String functionBlockResourceId, ModelId datatypeModelId, + ResourceSet resourceSet, Set referencedResourceSet) { + devtoolReferenceLinker.linkDataTypeToFunctionBlock(functionBlockResourceId, datatypeModelId, + resourceSet, referencedResourceSet); + Resource functionBlockResource = resourceSet.getResource(URI.createURI(functionBlockResourceId), true); + try { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + functionBlockResource.save(byteArrayOutputStream, null); + return byteArrayOutputStream.toString(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + + public List searchModelByExpression(String expression) { + List modelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelType.Datatype.toString() , org.eclipse.vorto.http.model.ModelType.Datatype); + List functionBlockModelList = searchModelByExpressionAndValidate(expression + " " + org.eclipse.vorto.http.model.ModelType.Functionblock.toString(), org.eclipse.vorto.http.model.ModelType.Functionblock); + modelList.addAll(functionBlockModelList); + return modelList; + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.java new file mode 100644 index 0000000000..e741f49647 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/IEditorService.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.server.devtool.service.editor; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.vorto.http.model.ModelId; +import org.eclipse.vorto.http.model.ModelResource; +import org.eclipse.vorto.server.devtool.utils.DevtoolRestClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public abstract class IEditorService { + + @Autowired + DevtoolRestClient devtoolRestClient; + + public abstract String linkModelToResource(String infoModelResourceId, ModelId modelId, ResourceSet resourceSet, + Set referencedResourceSet); + + public abstract List searchModelByExpression(String expression); + + protected final List searchModelByExpressionAndValidate(String expression, + org.eclipse.vorto.http.model.ModelType modelType) { + List resourceList = devtoolRestClient.searchByExpression(expression); + ArrayList modelResourceList = new ArrayList(); + for (ModelResource modelResource : resourceList) { + if (modelResource.getModelType().equals(modelType)) { + modelResourceList.add(modelResource); + } + } + return modelResourceList; + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/InformationModelEditorServiceImpl.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/InformationModelEditorServiceImpl.java new file mode 100644 index 0000000000..2a2a193f8f --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/editor/InformationModelEditorServiceImpl.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * 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.server.devtool.service.editor; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.vorto.http.model.ModelId; +import org.eclipse.vorto.http.model.ModelResource; +import org.eclipse.vorto.server.devtool.utils.DevtoolReferenceLinker; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class InformationModelEditorServiceImpl extends IEditorService { + + @Autowired + DevtoolReferenceLinker devtoolReferenceLinker; + + public String linkModelToResource(String infoModelResourceId, ModelId functionBlockModelId, + ResourceSet resourceSet, Set referencedResourceSet) { + devtoolReferenceLinker.linkFunctionBlockToInfoModel(infoModelResourceId, functionBlockModelId, + resourceSet, referencedResourceSet); + Resource infoModelResource = resourceSet.getResource(URI.createURI(infoModelResourceId), true); + try { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + infoModelResource.save(byteArrayOutputStream, null); + return byteArrayOutputStream.toString(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public List searchModelByExpression(String expression) { + return searchModelByExpressionAndValidate(expression + org.eclipse.vorto.http.model.ModelType.Functionblock.toString(), org.eclipse.vorto.http.model.ModelType.Functionblock); + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/MapProjectRespositoryDAOImpl.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/MapProjectRespositoryDAOImpl.java new file mode 100644 index 0000000000..cd1ec8793b --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/MapProjectRespositoryDAOImpl.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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.server.devtool.service.impl; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.eclipse.vorto.server.devtool.models.Project; +import org.eclipse.vorto.server.devtool.service.IProjectRespositoryDAO; +import org.springframework.stereotype.Service; + +@Service +public class MapProjectRespositoryDAOImpl implements IProjectRespositoryDAO { + + private HashMap> projectRepositoryHashMap = new HashMap<>(); + + @Override + public void createProject(Project project, String sessionId) { + ArrayList projectList = projectRepositoryHashMap.get(sessionId); + if(projectList == null){ + projectList = new ArrayList<>(); + } + projectRepositoryHashMap.put(sessionId, projectList); + if(!projectExists(project.getProjectName(), sessionId)){ + projectList.add(project); + projectRepositoryHashMap.put(sessionId, projectList); + } + } + + @Override + public boolean projectExists(String projectName, String sessionId) { + ArrayList projectList = projectRepositoryHashMap.get(sessionId); + if(projectList == null){ + projectList = new ArrayList<>(); + } + for(Project project : projectList){ + if(project.getProjectName().equals(projectName)){ + return true; + } + } + return false; + } + + @Override + public Project openProject(String projectName, String sessionId) { + if(projectExists(projectName, sessionId)){ + ArrayList projectList = projectRepositoryHashMap.get(sessionId); + for(Project project : projectList){ + if(project.getProjectName().equals(projectName)){ + return project; + } + } + } + return null; + } + + @Override + public ArrayList getProjects(String sessionId) { + ArrayList projectList = projectRepositoryHashMap.get(sessionId); + if(projectList == null){ + projectList = new ArrayList<>(); + } + return projectList; + } + +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/ProjectRepositoryServiceImpl.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/ProjectRepositoryServiceImpl.java new file mode 100644 index 0000000000..41fd914de0 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/service/impl/ProjectRepositoryServiceImpl.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * 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.server.devtool.service.impl; + +import java.util.ArrayList; +import java.util.HashSet; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.vorto.editor.web.resource.WebEditorResourceSetProvider; +import org.eclipse.vorto.server.devtool.exception.ProjectAlreadyExistsException; +import org.eclipse.vorto.server.devtool.exception.ProjectNotFoundException; +import org.eclipse.vorto.server.devtool.exception.ProjectResourceAlreadyExistsException; +import org.eclipse.vorto.server.devtool.models.Project; +import org.eclipse.vorto.server.devtool.models.ProjectResource; +import org.eclipse.vorto.server.devtool.service.IProjectRepositoryService; +import org.eclipse.vorto.server.devtool.service.IProjectRespositoryDAO; +import org.eclipse.xtext.web.server.model.IWebResourceSetProvider; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.google.inject.Injector; + +@Component +public class ProjectRepositoryServiceImpl implements IProjectRepositoryService{ + + @Autowired + Injector injector; + + @Autowired + IProjectRespositoryDAO projectRespositoryDAO; + + @Override + public void checkProjectExists(String sessionId, String projectName) throws ProjectAlreadyExistsException { + if(projectRespositoryDAO.projectExists(projectName, sessionId)){ + throw new ProjectAlreadyExistsException(); + } + } + + @Override + public void checkResourceExists(String sessionId, String projectName, ProjectResource projectResource) + throws ProjectAlreadyExistsException, ProjectResourceAlreadyExistsException, ProjectNotFoundException { + Project project = openProject(sessionId, projectName); + if(project.getResourceList().contains(projectResource)){ + throw new ProjectResourceAlreadyExistsException(); + } + } + + @Override + public Project createProject(String sessionId, String projectName) throws ProjectAlreadyExistsException { + WebEditorResourceSetProvider webEditorResourceSetProvider = (WebEditorResourceSetProvider) injector.getInstance(IWebResourceSetProvider.class); + Project project = new Project(projectName); + project.setResourceSet(webEditorResourceSetProvider.getNewResourceSet()); + project.setReferencedResourceSet(new HashSet()); + project.setResourceList(new ArrayList<>()); + if(!projectRespositoryDAO.projectExists(projectName, sessionId)){ + projectRespositoryDAO.createProject(project, sessionId); + return project; + }else{ + throw new ProjectAlreadyExistsException(); + } + } + + @Override + public Project openProject(String sessionId, String projectName) throws ProjectNotFoundException { + Project project = projectRespositoryDAO.openProject(projectName, sessionId); + if(project == null){ + throw new ProjectNotFoundException(); + } + return project; + } + + @Override + public ArrayList getProjectResources(String sessionId, String projectName) throws ProjectNotFoundException { + Project project = openProject(sessionId, projectName); + return project.getResourceList(); + } + + @Override + public ArrayList getProjects(String sessionId) { + ArrayList projectList = projectRespositoryDAO.getProjects(sessionId); + ArrayList projectNameList = new ArrayList<>(); + for(Project iterProject : projectList){ + Project project = new Project(iterProject.getProjectName()); + projectNameList.add(project); + } + return projectNameList; + } + + @Override + public void createResource(String sessionId, String projectName, ProjectResource projectResource) throws ProjectNotFoundException, ProjectResourceAlreadyExistsException { + Project project = openProject(sessionId, projectName); + ArrayList resourceList = project.getResourceList(); + if(resourceList.contains(projectResource)){ + throw new ProjectResourceAlreadyExistsException(); + } + resourceList.add(projectResource); + } + + @Override + public void deleteResource(String sessionId, String projectName, ProjectResource projectResource) throws ProjectNotFoundException { + Project project = openProject(sessionId, projectName) ; + ProjectResource pResource = getProjectResource(projectResource, project.getResourceList()); + if(pResource != null){ + String resourceId = pResource.getResourceId(); + URI uri = URI.createURI(resourceId); + ResourceSet resourceSet = project.getResourceSet(); + Resource resource = resourceSet.getResource(uri, true); + resourceSet.getResources().remove(resource); + projectResource.setResourceId(resourceId); + project.getResourceList().remove(projectResource); + } + } + + private ProjectResource getProjectResource(ProjectResource projectResource, ArrayList resourceList){ + for(ProjectResource pResource : resourceList){ + if(pResource.equals(projectResource)){ + return pResource; + } + } + return null; + } + +} \ No newline at end of file diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java new file mode 100644 index 0000000000..f2da69f239 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolReferenceLinker.java @@ -0,0 +1,171 @@ +/******************************************************************************* + * 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.server.devtool.utils; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel; +import org.eclipse.vorto.core.api.model.informationmodel.FunctionblockProperty; +import org.eclipse.vorto.core.api.model.informationmodel.InformationModel; +import org.eclipse.vorto.core.api.model.informationmodel.InformationModelFactory; +import org.eclipse.vorto.core.api.model.model.Model; +import org.eclipse.vorto.core.api.model.model.ModelReference; +import org.eclipse.vorto.core.api.model.model.ModelType; +import org.eclipse.vorto.http.model.ModelId; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class DevtoolReferenceLinker { + + @Autowired + DevtoolRestClient informationModelEditorRestClient; + + public void linkFunctionBlockToInfoModel(String infoModelResourceId, ModelId functionBlockModelId, + ResourceSet resourceSet, Set referencedResourceSet) { + if (!containsResource(infoModelResourceId, resourceSet)) { + throw new RuntimeException("No resource with resourceId : " + infoModelResourceId); + } + ModelType modelType = informationModelEditorRestClient.getModelType(functionBlockModelId); + if (!modelType.equals(ModelType.Functionblock)) { + throw new RuntimeException("No FunctionBlock [" + functionBlockModelId.toString() + "]"); + } + + linkReferenceToModel(infoModelResourceId, functionBlockModelId, resourceSet, referencedResourceSet); + + Resource targetResource = resourceSet.getResource(URI.createURI(infoModelResourceId), true); + InformationModel informationModel = (InformationModel) targetResource.getContents().get(0); + Resource referencedResource = resourceSet.getResource(getURI(functionBlockModelId), true); + EObject eObject = referencedResource.getContents().get(0); + FunctionblockModel funtionblockModel = (FunctionblockModel) eObject; + informationModel.getProperties().add( + createFunctionblockProperty(funtionblockModel, getVariableNames(informationModel.getProperties()))); + referencedResource.getContents().add(eObject); + } + + public void linkDataTypeToFunctionBlock(String functionBlockResourceId, ModelId datatypeModelId, + ResourceSet resourceSet, Set referencedResourceSet) { + if (!containsResource(functionBlockResourceId, resourceSet)) { + throw new RuntimeException("No resource with resourceId : " + functionBlockResourceId); + } + ModelType modelType = informationModelEditorRestClient.getModelType(datatypeModelId); + if (!modelType.equals(ModelType.Datatype)) { + throw new RuntimeException("No DataType [" + datatypeModelId.toString() + "]"); + } + + linkReferenceToModel(functionBlockResourceId, datatypeModelId, resourceSet, referencedResourceSet); + } + + private void linkReferenceToModel(String modelResourceId, ModelId referenceModelId, ResourceSet resourceSet, + Set referencedResourceSet) { + + ModelType referenceModelType = informationModelEditorRestClient.getModelType(referenceModelId); + String fileName = getFileName(referenceModelId); + URI uri = getURI(referenceModelId); + + Resource targetResource = resourceSet.getResource(URI.createURI(modelResourceId), true); + Model model = (Model) targetResource.getContents().get(0); + + ModelReference modelReference = new org.eclipse.vorto.core.api.model.model.ModelId(referenceModelType, + referenceModelId.getName(), referenceModelId.getNamespace(), referenceModelId.getVersion()) + .asModelReference(); + + if (!containsModelReference(model, modelReference)) { + Resource resource = null; + EObject eObject = null; + if (!referencedResourceSet.contains(fileName)) { + String fileContents = informationModelEditorRestClient.getModelFile(referenceModelId); + try { + resource = resourceSet.createResource(uri); + resource.load(new ByteArrayInputStream(fileContents.getBytes((StandardCharsets.UTF_8))), + resourceSet.getLoadOptions()); + referencedResourceSet.add(fileName); + System.out.println(resourceSet); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + resource = resourceSet.getResource(uri, true); + eObject = resource.getContents().get(0); + targetResource.getContents().add(eObject); + model.getReferences().add(modelReference); + resource.getContents().add(eObject); + } + } + + private boolean containsResource(String resourceId, ResourceSet resourceSet) { + URI uri = URI.createURI(resourceId); + Resource resource = resourceSet.getResource(uri, true); + if (resource == null) { + return false; + } else { + return true; + } + } + + private boolean containsModelReference(Model model, ModelReference reference) { + for (ModelReference ref : model.getReferences()) { + if (ref.getImportedNamespace().equals(reference.getImportedNamespace())) { + return true; + } + } + return false; + } + + private Set getVariableNames(EList properties) { + Set variableNames = new HashSet(); + for (FunctionblockProperty property : properties) { + variableNames.add(property.getName()); + } + return variableNames; + } + + private FunctionblockProperty createFunctionblockProperty(FunctionblockModel functionblockModel, + Set existingVariableNames) { + FunctionblockProperty functionblockProperty = InformationModelFactory.eINSTANCE.createFunctionblockProperty(); + functionblockProperty.setType(functionblockModel); + functionblockProperty.setName(generateFunctionBlockVariableName(functionblockModel, existingVariableNames)); + return functionblockProperty; + } + + private String generateFunctionBlockVariableName(FunctionblockModel fbm, Set variableNames) { + String variableName = fbm.getName().toLowerCase(); + int i = 0; + while (variableNames.contains(variableName)) { + variableName = fbm.getName().toLowerCase() + ++i; + } + return variableName; + } + + private String getFileName(ModelId modelId) { + ModelType modelType = informationModelEditorRestClient.getModelType(modelId); + return modelId.getNamespace().replace(".", "_") + "_" + modelId.getName() + "_" + + modelId.getVersion().replace(".", "_") + modelType.getExtension(); + } + + private URI getURI(ModelId modelId) { + URI uri = URI.createURI("fake:/" + getFileName(modelId)); + return uri; + } +} diff --git a/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolRestClient.java b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolRestClient.java new file mode 100644 index 0000000000..9d864b2699 --- /dev/null +++ b/server/devtool/src/main/java/org/eclipse/vorto/server/devtool/utils/DevtoolRestClient.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * 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.server.devtool.utils; + +import java.lang.reflect.Type; +import java.util.Date; +import java.util.List; + +import org.eclipse.vorto.core.api.model.model.ModelType; +import org.eclipse.vorto.http.model.ModelId; +import org.eclipse.vorto.http.model.ModelResource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.JsonParser; +import com.google.gson.reflect.TypeToken; + +@Component +public class DevtoolRestClient { + + @Value("${vorto.repository.rest.path}") + private String basePath; + + public ModelResource getModel(ModelId modelId){ + String json = getModelFile(modelId); + Gson gson = createGson(); + JsonElement jsonElement = new JsonParser().parse(json); + ModelResource modelResource = gson.fromJson(jsonElement, ModelResource.class); + return modelResource; + } + + public String getModelFile(ModelId modelId) { + try { + RestTemplate restTemplate = new RestTemplate(); + return restTemplate.getForObject(basePath + "model/file/{namespace}/{name}/{version}?output=DSL", + String.class, modelId.getNamespace(), modelId.getName(), modelId.getVersion()); + } catch (RestClientException e) { + throw new RuntimeException(e); + } + } + + public String getModelAsString(ModelId modelId) { + try { + RestTemplate restTemplate = new RestTemplate(); + return restTemplate.getForObject(basePath + "model/{namespace}/{name}/{version}", String.class, + modelId.getNamespace(), modelId.getName(), modelId.getVersion()); + } catch (RestClientException e) { + throw new RuntimeException(e); + } + } + + public ModelType getModelType(ModelId modelId) { + String modelString = getModelAsString(modelId); + String modelType = new JsonParser().parse(modelString).getAsJsonObject().get("modelType").getAsString(); + if (modelType.equalsIgnoreCase(ModelType.Datatype.toString())) { + return ModelType.Datatype; + } else if (modelType.equalsIgnoreCase(ModelType.Functionblock.toString())) { + return ModelType.Functionblock; + } else if (modelType.equalsIgnoreCase(ModelType.InformationModel.toString())) { + return ModelType.InformationModel; + } else if (modelType.equalsIgnoreCase(ModelType.Mapping.toString())) { + return ModelType.Mapping; + } else { + throw new UnsupportedOperationException("Given ModelType is unknown"); + } + } + + public List searchByExpression(String expression) { + RestTemplate restTemplate = new RestTemplate(); + String results = restTemplate.getForObject(basePath + "model/query=" + expression, String.class); + JsonElement jsonElement = new JsonParser().parse(results); + Gson gson = createGson(); + List modelResourceList = gson.fromJson(jsonElement, new TypeToken>() { + }.getType()); + return modelResourceList; + } + + private Gson createGson(){ + return new GsonBuilder().registerTypeAdapter(Date.class, new JsonDeserializer() { + @Override + public Date deserialize(JsonElement json, Type type, JsonDeserializationContext context) + throws JsonParseException { + return new Date(json.getAsJsonPrimitive().getAsLong()); + } + }).create(); + } +} diff --git a/server/devtool/src/main/resources/application.properties b/server/devtool/src/main/resources/application.properties new file mode 100644 index 0000000000..003076c517 --- /dev/null +++ b/server/devtool/src/main/resources/application.properties @@ -0,0 +1,2 @@ +vorto.repository.rest.path = http://vorto.eclipse.org//rest/ +vorto.repository.base.path = http://vorto.eclipse.org/#/ \ No newline at end of file diff --git a/server/devtool/src/main/resources/static/css/ace-custom.css b/server/devtool/src/main/resources/static/css/ace-custom.css new file mode 100644 index 0000000000..f7d034b51e --- /dev/null +++ b/server/devtool/src/main/resources/static/css/ace-custom.css @@ -0,0 +1,60 @@ + +#xtext-editor { + display: block; + position: absolute; + top: 0; + bottom: 0px; + left: 0; + right: 0; + border: 1px solid #aaa; +} + +.status-wrapper { + display: block; + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 20px; + margin-top: 10px; +} + +#status { + display: inline; +} + +.xtext-marker_error { + position: absolute; + z-index: 30; + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAABmJLR0QA/wD/AP+gvaeTAAAAHElEQVQI12NggIL/DAz/GdA5/xkY/qPKMDAwAADLZwf5rvm+LQAAAABJRU5ErkJggg=="); + background-repeat: repeat-x; + background-position: left bottom; +} + +.xtext-marker_warning { + position: absolute; + z-index: 20; + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAABmJLR0QA/wD/AP+gvaeTAAAAMklEQVQI12NkgIIvJ3QXMjAwdDN+OaEbysDA4MPAwNDNwMCwiOHLCd1zX07o6kBVGQEAKBANtobskNMAAAAASUVORK5CYII="); + background-repeat: repeat-x; + background-position: left bottom; +} + +.xtext-marker_info { + position: absolute; + z-index: 10; + background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAYAAAC09K7GAAAABmJLR0QA/wD/AP+gvaeTAAAANklEQVQI12NkgIIVRx8tZGBg6GZccfRRKAMDgw8DA0M3AwPDIiYGBoZKBgaG7ghruSsMDAwpABH5CoqwzCoTAAAAAElFTkSuQmCC"); + background-repeat: repeat-x; + background-position: left bottom; +} + +.xtext-marker_read { + position: absolute; + z-index: 5; + background-color: #ddd; +} + +.xtext-marker_write { + z-index: 5; + position: absolute; + background-color: yellow; +} \ No newline at end of file diff --git a/server/devtool/src/main/resources/static/css/dashboard.css b/server/devtool/src/main/resources/static/css/dashboard.css new file mode 100644 index 0000000000..3a0d90b791 --- /dev/null +++ b/server/devtool/src/main/resources/static/css/dashboard.css @@ -0,0 +1,26 @@ +/* + * Base structure + */ + +/* Move down content because we have a fixed navbar that is 50px tall */ +body { + padding-top: 50px; +} + + +/* + * Global add-ons + */ + +.sub-header { + padding-bottom: 10px; + border-bottom: 1px solid #eee; +} + +/* + * Top navigation + * Hide default border to remove 1px line. + */ +.navbar-fixed-top { + border: 0; +} \ No newline at end of file diff --git a/server/devtool/src/main/resources/static/css/style.css b/server/devtool/src/main/resources/static/css/style.css new file mode 100644 index 0000000000..912730630f --- /dev/null +++ b/server/devtool/src/main/resources/static/css/style.css @@ -0,0 +1,900 @@ +`/* +Global +============================= */ +body{ + line-height: 1.85em; + color: #000; + font-weight: 300; + -webkit-font-smoothing: antialiased; + font-smoothing: antialiased; + font-size: 14px; +} + +p{line-height: 24px} +a{color:#0088cc;} +a:hover{text-decoration: none;} + + +h1,h2,h3,h4,h5,h6{ font-family:'Open Sans', sans-serif} + +h1{font-size:50px; font-weight: 200; color: #555; margin-bottom: 20px;} +h2{font-size: 30px; font-weight: 300; color:#444; margin: 30px 0 20px} +h3{font-size: 20px; font-weight: 400; margin: 10px 0;} +h4{font-size:18px; font-weight: 400} + +ul.nav { + margin-top: 10px; +} + +@media (min-width: 1368px) { +ul.nav { + margin-left: 100px; +} +} + +ul.nav a { + box-shadow: none; + background: transparent; + color: #fff; + text-shadow: none; + font-weight: bold; +} + +ul.nav p { + box-shadow: none; + background: transparent; + color: #fff; + text-shadow: none; + font-weight: bold; +} + +#userWelcome, #userWelcome:FOCUS , #userWelcome:HOVER { + text-decoration: none; + color: #fff; +} + +@media (min-width: 768px) and (max-width: 1168px){ +.navbar-nav>li { + margin-left: -8px; + font-size: 12px; +} +} + +.navbar-inverse .navbar-brand { + font-weight: bold; + padding-top:10px; + color: #fff; +} + + +@media (min-width: 768px) { +.navbar-inverse .navbar-brand { + font-size: 20px; + padding-top:20px; + } +} + +@media (min-width: 970px) { +.navbar-inverse .navbar-brand { + font-size: 28px; + padding-top:20px; + } +} + +@media (min-width: 1168px) { +.navbar-inverse .navbar-brand { + font-size: 48px; + padding-top:10px; + } +} + +.navbar-inverse { + background-color: #3a5a82; + border-color: #3a5a82; + height: 65px; + padding:10px; +} + +.navbar-inverse .navbar-brand, .navbar-inverse .navbar-nav>li>a { + text-shadow: 0 -1px 0 rgba(0,0,0,0); +} + +.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.open>a { + background-image: -webkit-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0) 100%); + background-image: -o-linear-gradient(top,rgba(0,0,0,0) 0,rgba(0,0,0,0) 100%); + background-image: -webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,0)),to(rgba(0,0,0,0))); + background-image: linear-gradient(to bottom,rgba(0,0,0,0) 0,rgba(0,0,0,0) 100%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='rgba(0,0,0,0)', endColorstr='rgba(0,0,0,0)', GradientType=0); + background-repeat: repeat-x; + -webkit-box-shadow: inset 0 3px 9px rgba(0,0,0,0); + box-shadow: inset 0 3px 9px rgba(0,0,0,0); +} + +.navbar-inverse .navbar-nav>li>a { + color: #fff; +} + +.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover { + color: #2E8DE3; + background-color: rgba(0,0,0,0); +} + +.navbar-inverse .navbar-nav li a:hover { + color: #2E8DE3; + background-color: rgba(0,0,0,0); +} + +.navbar-inverse .navbar-brand:hover, +.navbar-inverse .navbar-brand:focus { + color: #2E8DE3; +} + +.navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:focus, .navbar-inverse .navbar-nav>.open>a:hover { + color: #2E8DE3; + background-color: rgba(0,0,0,0); +} + +.navbar-inverse .navbar-brand:hover { + color: #fff; +} + +.btn { + border-radius: 2px; + font-weight: bold; + border:0px; +} + +.btn-group-lg>.btn, .btn-lg { + padding: 10px 16px; + font-size: 18px; + line-height: 1.3333333; + border-radius: 3px; +} + + .btn-primary { + background-color: rgb(0, 129, 199); + background-image: -moz-linear-gradient(top, rgba(0, 129, 199, 1) 0%, rgba(0, 73, 134, 1) 100%); /* FF3.6+ */ + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(0, 129, 199, 1)), color-stop(100%, rgba(0, 73, 134, 1))); /* Chrome,Safari4+ */ + background-image: -webkit-linear-gradient(top, rgba(0, 129, 199, 1) 0%, rgba(0, 73, 134, 1) 100%); /* Chrome10+,Safari5.1+ */ + background-image: -o-linear-gradient(top, rgba(0, 129, 199, 1) 0%, rgba(0, 73, 134, 1) 100%); /* Opera 11.10+ */ + background-image: -ms-linear-gradient(top, rgba(0, 129, 199, 1) 0%, rgba(0, 73, 134, 1) 100%); /* IE10+ */ + background-image: linear-gradient(to bottom, rgba(0, 129, 199, 1) 0%, rgba(0, 73, 134, 1) 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0081c7', endColorstr='#004986', GradientType=0); /* IE6-9 */ + border-color: rgba(0,0,0,0); +} + +.btn-primary:hover, +.btn-primary:focus, +.btn-primary.focus, +.btn-primary:active, +.btn-primary.active, +.open > .dropdown-toggle.btn-primary { + color: #fff; + background-color: #286090; + border-color: rgba(0,0,0,0); + background-color: rgb(0, 73, 134); +} + +.btn-success { + background-color: #6CB674; /* Old browsers */ + background-image: -moz-linear-gradient(top, #6CB674 0%, #3AA843 50%, #348B38 100%); /* FF3.6+ */ + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #6CB674), color-stop(100%, #348B38)); /* Chrome,Safari4+ */ + background-image: -webkit-linear-gradient(top, #6CB674 0%, #3AA843 50%, #348B38 100%); /* Chrome10+,Safari5.1+ */ + background-image: -o-linear-gradient(top, #6CB674 0%, #3AA843 50%, #348B38 100%); /* Opera 11.10+ */ + background-image: -ms-linear-gradient(top, #6CB674 0%, #3AA843 50%, #348B38 100%); /* IE10+ */ + background-image: linear-gradient(to bottom, #6CB674 0%, #3AA843 50%, #208020 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6CB674', endColorstr='#348B38', GradientType=0); /* IE6-9 */ + border-color: rgba(0,0,0,0); +} + +.btn-success:hover, +.btn-success:focus, +.btn-success.focus, +.btn-success:active, +.btn-success.active, +.open > .dropdown-toggle.btn-success { + border-color: rgba(0,0,0,0); + background-color: #208020; +} + +.dropdown-menu>.active>a, .dropdown-menu>.active>a:focus, .dropdown-menu>.active>a:hover { + background-color: #208020; + background-image: -webkit-linear-gradient(top,#208020 0%, #3AA843 50%, #6CB674 100%); + background-image: -o-linear-gradient(top,#208020 0%, #3AA843 50%, #6CB674 100%); + background-image: -webkit-gradient(linear,left top,left bottom,from(#208020),to(#6CB674)); + background-image: linear-gradient(to bottom, #208020 0%, #3AA843 50%, #6CB674 100%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#208020', endColorstr='#6CB674', GradientType=0); + background-repeat: repeat-x; +} + +.dropdown-menu a:hover { + background-color: #208020; + background-image: -webkit-linear-gradient(top,#208020 0%, #3AA843 50%, #6CB674 100%); + background-image: -o-linear-gradient(top,#208020 0%, #3AA843 50%, #6CB674 100%); + background-image: -webkit-gradient(linear,left top,left bottom,from(#208020),to(#6CB674)); + background-image: linear-gradient(to bottom, #208020 0%, #3AA843 50%, #6CB674 100%); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#208020', endColorstr='#6CB674', GradientType=0); + background-repeat: repeat-x; +} + +.panel-heading { + padding: 10px 15px; + border-bottom: 1px solid transparent; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + display: inline-block; + margin: -8px 0 8px 10px; + padding: 8px 8px 4px; + border-radius: 2px; + + -webkit-transform: skewX(-8deg); + -moz-transform: skewX(-8deg); + -ms-transform: skewX(-8deg); + -o-transform: skewX(-8deg); + transform: skewX(-8deg); + -webkit-backface-visibility: hidden; + -moz-backface-visibility: hidden; + -ms-backface-visibility: hidden; + -o-backface-visibility: hidden; + backface-visibility: hidden; + + box-shadow: 3px 3px 0px 0px rgba(192, 210, 224, 1); + +} + +.panel { + margin-bottom: 20px; + background-color: rgba(255,255,255,0.35); + border: 1px solid #fff; + border-radius: 2px; + -webkit-box-shadow: 0 1px 1px rgba(0,0,0,.05); + box-shadow: 0 1px 1px rgba(0,0,0,.05); +} + +.panel-default>.panel-heading { + color: #12263A; + background: #f9fcff; /* Old browsers */ + background: -moz-linear-gradient(top, #f9fcff 0%, #d4dde8 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f9fcff), color-stop(100%, #d4dde8)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, #f9fcff 0%, #d4dde8 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, #f9fcff 0%, #d4dde8 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, #f9fcff 0%, #d4dde8 100%); /* IE10+ */ + background: linear-gradient(to bottom, #f9fcff 0%, #d4dde8 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9fcff', endColorstr='#d4dde8', GradientType=0); /* IE6-9 */ + border-color: #ddd; +} + +.panel-primary>.panel-heading { + color: #fff; + background: linear-gradient(to bottom, #179edd 0%,#117eb1 100%); + background-image: -moz-linear-gradient(to bottom, #179edd 0%,#117eb1 100%); + border-color: #337ab7; + box-shadow: 3px 3px 0px 0px rgba(30, 103, 157, 0.95); +} + +select { + font-size: 28px; +} + +.project-selection { + float:left; + margin-left:15px; + +} + +.nav>li>a { + text-decoration: none; + background-color: rgba(0,0,0,0); +} + +/* Code Styles */ +pre { + white-space: pre-wrap; + white-space: -moz-pre-wrap; + white-space: -o-pre-wrap; + word-wrap: break-word; +} + +pre.chat { + background-color: transparent; + border:0px; + font-family: 'Arial'; +} + +code { + font-family: Courier, 'New Courier', monospace; +} + +pre code { + font-size: 16px; +} + +#codeStyler { + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + margin: 1em 0; +} + +.computerGreen { + background-color: #000000; + color: green; +} + +button a, button a:hover { + color: white; + text-decoration: none; +} + +.project-selection label { + font-weight: normal; + margin:5px; + margin-right:25px; +} + +@media (max-width: 845px){ +ul.nav { + margin-left: 0px; + margin-top: 10px; +} +} + +@media (max-width: 768px){ +.navbar-inverse .navbar-brand { + font-size: 28px; + font-weight: bold; + padding-top: 10px; + color: #fff; +} +} + +.navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus { + background-color: rgba(0,0,0,0); +} + +@media (max-width: 768px){ +.navbar-inverse .in { + background-color: #3C5985; +} +} + +.navbar-inverse .navbar-toggle { + border-color: rgba(0,0,0,0); +} + +.queryFilter { + width: 240px; +} + +.main .login-box .page-header .signup-box{ + margin-top: -20px; +} + +.login-box .page-header h2, .signup-box .page-header h2 { + text-align:center; +} + +.gen-box { + border: 1px solid #cccccc; + margin-bottom: 15px; + border-radius: 5px; + background: #f5f6f7; + height: 130px; + width: 154px; + text-align: center; +} + +.gen-logo { + margin: 13px 5px 0px; +} + +.gen-name { + margin: 15px 5px 0px; + height: 30px; +} + +.gen-name span { + display: inline-block; + vertical-align: middle; + line-height: 0.9em; +} + +.rating { + unicode-bidi:bidi-override; + direction:ltr; +} +.rating span.star { + font-family:FontAwesome; + font-weight:normal; + font-style:normal; + display:inline-block; +} +@media (max-width: 1280px){ +.rating span.star { + font-size:14px; +} +} + +.rating span.star:hover { + cursor:pointer; +} +.rating span.star:before { + content:"\f006"; + padding-right:5px; + color:#999999; +} +span.star.filled:before{ + color:#ffe400; + content:"\f005"; +} + +/*downloads box*/ +@media (max-width: 768px){ +.adv { + margin-top: 50px; + position: absolute; + left: -250px; + -webkit-animation: slide 0.5s forwards; + -webkit-animation-delay: 1s; + animation: slide 0.5s forwards; + animation-delay: 2s; +} +} + +@-webkit-keyframes slide { + 100% { left: 0px; } +} + +@keyframes slide { + 100% { left: 0px; } +} + +.small-box { + border-radius: 2px; + position: relative; + display: block; + margin-bottom: 20px; + box-shadow: 0 1px 1px rgba(0,0,0,0.1); +} + +.small-box>.inner { + padding: 10px; +} + +.bg-aqua{ + background-color: #4D90C3 !important; + color: #fff !important; +} + +.small-box h3 { + font-size: 26px; + font-weight: bold; + margin: 0 0 10px 0; + white-space: nowrap; + padding: 0; +} + +.small-box p { + font-size: 15px; +} + +.small-box .icon { + -webkit-transition: all .3s linear; + -o-transition: all .3s linear; + transition: all .3s linear; + position: absolute; + top: -10px; + right: 10px; + z-index: 0; + font-size: 90px; + color: rgba(0,0,0,0.15); +} + +.small-box>.small-box-footer { + position: relative; + text-align: center; + padding: 3px 0; + color: #fff; + color: rgba(255,255,255,0.8); + display: block; + z-index: 10; + background: rgba(0,0,0,0.1); + text-decoration: none; + font-weight: bold; + font-size: 14px; +} + +/*downloads box*/ +@media (max-width: 800px){ +.adv { + display: none; +} +} + +@media (min-width: 800px){ +.adv { + margin-top: 50px; + width: 200px; + height: 200px; + position: absolute; + left: -250px; + -webkit-animation: slide 0.5s forwards; + -webkit-animation-delay: 1s; + animation: slide 0.5s forwards; + animation-delay: 1s; +} +} + +@-webkit-keyframes slide { + 100% { left: 0px; } +} + +@keyframes slide { + 100% { left: 0px; } +} + +.small-box { + border-radius: 2px; + position: relative; + display: block; + margin-bottom: 20px; + box-shadow: 0 1px 1px rgba(0,0,0,0.1); +} + +.small-box>.inner { + padding: 10px; +} + +.bg-aqua{ + background-color: #2F5B83 !important; + color: #fff !important; +} + + +.small-box h3 { + font-size: 26px; + font-weight: bold; + margin: 0 0 10px 0; + white-space: nowrap; + padding: 0; +} + +.small-box p { + font-size: 15px; +} + +.small-box .icon { + -webkit-transition: all .3s linear; + -o-transition: all .3s linear; + transition: all .3s linear; + position: absolute; + top: -10px; + right: 10px; + z-index: 0; + font-size: 90px; + color: rgba(0,0,0,0.15); +} + +.small-box>.small-box-footer { + position: relative; + text-align: center; + padding: 3px 0; + color: #fff; + color: rgba(255,255,255,0.8); + display: block; + z-index: 10; + background: rgba(0,0,0,0.1); + text-decoration: none; + font-weight: bold; + font-size: 14px; +} + +.top3 { + padding-left: 25px; +} + +.top3 label{ + font-weight: 600; +} + +@media (min-width: 1200px){ +.top3 .gen-box{ + /*width: 50%;*/ + margin: 0px auto 15px; +} +} + +@media (min-width: 769px) and (max-width: 1200px){ +.top3 .gen-box{ + width: 75%; + margin: 0px auto 15px; +} +} + + +.box-icon { + display: block; + float: left; + width: 60px; + text-align: center; + font-size: 45px; + line-height: 90px; +} + +.badge { + width: 24px; + height: 24px; + border-radius: 12px; + font-size: 14px; + line-height: 24px; + vertical-align: middle; + padding: 0px; +} + +.separator { + border-top: 1px solid #ccc; +} + +.box { + overflow: hidden; +} + +.box h4{ + font-weight: bold; + color: #325A87; +} + +.box ul { + list-style-type: none; + margin-left: -38px; + margin-top: -8px; +} + +.author { + font-weight: 600; + color: #999; +} + +.doc a{ + font-weight: 600; +} + +.infomodel { + min-height: 400px; +} + +.infomodel dt{ + font-weight: 600; + color: #1774A5; + text-align: left; + padding: 3px; +} + +.infomodel dd{ + padding: 3px; +} + +.main { + padding: 40px; +} + +th.action +, td.action { + text-align:center; +} + + + +@media (max-width: 1280px){ +.main { + padding: 20px 20px 20px 25px; +} +} + +@media (min-width: 768px) { +.dl-horizontal dt { + width: 140px; +} + +.dl-horizontal dd { + margin-left: 150px; +} +} + +@media (max-width: 1150px) { +.col-lg-3.modelGen { + width: 100%; +} +} + +@media (min-width: 1150px) and (max-width: 1280px) { +.col-sm-3.modelImg , .col-lg-3.modelGen { + width: 20%; +} + +.col-sm-6.modelDet { + width: 60%; +} +} + +@media (min-width: 1280px) and (max-width: 1680px) { +.col-sm-3.modelImg { + width: 20%; +} + +.col-lg-3.modelGen { + width: 25%; +} + +.col-sm-6.modelDet { + width: 55%; +} +} + +@media (min-width: 1150px) and (max-width: 1410px){ +.modelGen .col-lg-6 { + width: 100%; +} + +.modelGen .gen-box { + margin: 0px auto 15px; +} +} + +@media (max-width: 1150px) { +.modelGen.text-center { + text-align: left; +} +} + +@media (max-width: 768px) { +.col-sm-6.modelDet { + width: 60%; +} + +.col-sm-3.modelImg { + width: 30%; +} +} + +@media (max-width: 768px) { +#searchResult table th:nth-child(4), +#searchResult table th:nth-child(5), +#searchResult table td:nth-child(6), +#searchResult table td:nth-child(7) { + display: none; + } + } + + + /* Search - Start */ + + #onType a:hover, #onType a:active { + color: #3a5a82; + } + #onNamespace a:hover, #onNamespace a:active { + color: #3a5a82; + } + #onName a:hover, #onName a:active { + color: #3a5a82; + } + #onVersion a:hover, #onVersion a:active { + color: #3a5a82; + } + + /* Search - End */ + +/* Editor Start */ + +.custom-xtext-editor { + display: block; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + padding: 4px; + border: 1px solid #aaa; + height: 387px; + width: auto; +} + +#function-block-browser-container { + position:relative; + padding: 4px; + border: 1px solid #aaa; + height: 440px; + width: auto; +} + +#project-container { + position:relative; + padding: 4px; + height: auto; + width: auto; +} + +.center-container { + position: absolute; + top: 50%; + left: 50%; + transform: translateX(-50%) translateY(-50%); +} + +.center-col { + position: relative; + height: 440px +} + +/* Editor End */ + +.st-selected{ + background-color: #337ab7; +} + +.import-button { + text-align: center; + font-size: 50px; + background: none; + border: none; + margin-top: 180px; + margin-bottom: 180px; +} + +.search-button { + padding: 2px; + font-size: 20px; + border: none; +} + +a:hover { + cursor: pointer; + cursor: hand; +} + +.nav-tabs > li > a{ + cursor:pointer; +} + +.nav-tabs li a span:hover { + color: red; + cursor:pointer; +} + +.editor-ul.nav a { + box-shadow: none; + background: transparent; + color: #000000; + text-shadow: none; + font-weight: bold; +} + +.align-left { + float: left; +} + +.align-right { + float: right; +} + +.project-button-container { + text-align: center; + width: auto; +} + +.project-list-container { + height: 100% + transform: translateX(50%) translateY(50%); +} + +.align-center { + text-align: center; +} + +.btn-project { + width: 150px; +} + +.search-box-open-project { + width: 600px; +} \ No newline at end of file diff --git a/server/devtool/src/main/resources/static/dist/js/controllers.js b/server/devtool/src/main/resources/static/dist/js/controllers.js index c04d9cf614..9b01d620bd 100644 --- a/server/devtool/src/main/resources/static/dist/js/controllers.js +++ b/server/devtool/src/main/resources/static/dist/js/controllers.js @@ -1,27 +1,595 @@ -define(["angular"],function(angular) { -var app = angular.module('apps.controller', []); - -app.controller('InfomodelEditorController', function($rootScope, $scope, $http, $location) { - - $scope.editor = null; - $scope.error = null; - $scope.errorMessage = null; - $scope.validationError = false; - require(["webjars/ace/1.2.0/src/ace"], function() { - require(["xtext/xtext-ace"], function(xtext) { - editor = xtext.createEditor({syntaxDefinition: "mode-infomodel"}); - }); - }); - - $scope.share = function() { - if (editor.xtextServices.editorContext._annotations.length != 0) { - $scope.error = "Your information model contains errors. Please correct and try again."; - return; - } - - // do upload and checkin REST call to Vorto Information Model Repository - }; - -}); -return app; +define(["angular"], function(angular) { + var app = angular.module('apps.controller', ['smart-table', 'apps.directive']); + + app.controller('EditorController', function($rootScope, $scope, $location, $routeParams, $http, $compile, $uibModal) { + + $scope.error = null; + $scope.errorMessage = null; + $scope.validationError = false; + $scope.selectedModel = null; + $scope.selectedModelId = null; + $scope.showAddFunctionBlockButton = true; + + $scope.tabs = []; + $scope.editors = []; + $scope.counter = 0; + $scope.selectedTabIndex = 0; + $scope.selectedTabId = 0; + $scope.selectedEditor = null; + + $scope.showImportButton = true; + + $scope.showEditorBody = true; + $scope.projectName; + + $scope.editorTypes = [{ + language: 'infomodel', + display: 'Info Model' + }, { + language: 'fbmodel', + display: 'Function Block' + }]; + $scope.models = []; + $scope.queryFilter = ""; + + $scope.openProject = function() { + $scope.projectName = $routeParams.projectName; + $http.get('./project/' + $scope.projectName + '/open').success( + function(data, status, headers, config) { + $scope.showEditorBody = true; + $scope.getResources(); + }).error(function(data, status, headers, config) { + $scope.showEditorBody = false; + }); + } + + $scope.openProject(); + + $scope.getResources = function() { + $http.get('./project/' + $scope.projectName + '/resources').success( + function(data, status, headers, config) { + for (i = 0; i < data.length; i++) { + $scope.openEditor(data[i]); + } + }).error(function(data, status, headers, config) { + + }); + } + + $scope.$on("addTab", function(event, model) { + $scope.addEditor(model); + }); + + $scope.$on("describeEditor", function(event, editor) { + $scope.openDescribeEditorModal(editor); + }); + + $scope.$on("deleteEditor", function(event, tab) { + var url = './project/' + $scope.projectName + '/resources/delete/' + tab.namespace + '/' + tab.name + '/' + tab.version; + $http.get(url).success( + function(data, status, headers, config) { + $scope.deleteTab(tab.index); + }).error(function(data, status, headers, config) { + windoow.alert('Unable to delete the file'); + }); + }); + + $scope.$on("closeProject", function(event) { + $scope.closeProject(); + }); + + $scope.closeProject = function() { + $location.path('/project'); + $location.replace(); + } + + $scope.openEditor = function(resource) { + $scope.counter++; + var tabId = $scope.counter; + var editorParentDivId = "xtext-editor-parent-" + tabId; + var editorDivId = "xtext-editor-" + tabId; + var language = $scope.getResourceLanguage(resource); + var tab = { + id: tabId, + editorParentDivId: editorParentDivId, + editorDivId: editorDivId, + language: language, + name: resource.name, + version: resource.version, + namespace: resource.namespace, + resourceId: resource.resourceId + }; + $scope.tabs.push(tab); + $scope.selectedTabIndex = $scope.tabs.length - 1; + $scope.selectedTabId = $scope.tabs[$scope.selectedTabIndex]['id']; + var element = angular.element(document).find('#editors'); + element.append('
'); + $compile(element.contents())($scope); + if (language == 'infomodel') { + $scope.openInfoModelEditor(tab); + } else if (language == 'fbmodel') { + $scope.openFunctionBlockEditor(tab); + } + } + + $scope.openInfoModelEditor = function(tab) { + require(["webjars/ace/1.2.0/src/ace"], function() { + require(["xtext/xtext-ace"], function(xtext) { + editor = xtext.createEditor({ + xtextLang: "infomodel", + syntaxDefinition: "xtext/mode-infomodel", + serviceUrl: "/infomodel/xtext-service", + enableFormattingAction: "true", + showErrorDialogs: "true", + parent: tab.editorDivId, + resourceId: tab.resourceId + }); + $scope.editors.push(editor); + $scope.selectedEditor = $scope.editors[$scope.selectedTabIndex]; + $scope.search(); + }); + }); + } + + $scope.openFunctionBlockEditor = function(tab) { + require(["webjars/ace/1.2.0/src/ace"], function() { + require(["xtext/xtext-ace"], function(xtext) { + editor = xtext.createEditor({ + xtextLang: "fbmodel", + syntaxDefinition: "xtext/mode-fbmodel", + serviceUrl: "/functionblock/xtext-service", + enableFormattingAction: "true", + showErrorDialogs: "true", + parent: tab.editorDivId, + resourceId: tab.resourceId + }); + $scope.editors.push(editor); + $scope.selectedEditor = $scope.editors[$scope.selectedTabIndex]; + $scope.search(); + }); + }); + } + + $scope.addEditor = function(model) { + $http.get('./project/' + $scope.projectName + '/resources/check/' + model.namespace + '/' + model.name + '/' + model.version).success( + function(data, status, headers, config) { + $scope.counter++; + var tabId = $scope.counter; + var editorParentDivId = "xtext-editor-parent-" + tabId; + var editorDivId = "xtext-editor-" + tabId; + var tab = { + id: tabId, + editorParentDivId: editorParentDivId, + editorDivId: editorDivId, + language: model.language, + name: model.name, + }; + $scope.tabs.push(tab); + $scope.selectedTabIndex = $scope.tabs.length - 1; + $scope.selectedTabId = $scope.tabs[$scope.selectedTabIndex]['id']; + var element = angular.element(document).find('#editors'); + element.append('
'); + $compile(element.contents())($scope); + if (model.language == 'infomodel') { + $scope.addInfoModelEditor(editorDivId, model); + } else if (model.language == 'fbmodel') { + $scope.addFunctionBlockEditor(editorDivId, model); + } + }).error(function(data, status, headers, config) { + window.alert('File already exists') + }); + } + + $scope.generateInfoModelContent = function(model) { + var content = 'namespace ' + model.namespace + '\nversion ' + model.version + '\ndisplayname "' + model.displayname + '"\ndescription "' + model.description + '"\ncategory demo'; + content += "\ninfomodel " + model.displayname + " {"; + content += "\n\n}"; + return content; + } + + $scope.generateFunctionBlockContent = function(model) { + var content = 'namespace ' + model.namespace + '\nversion ' + model.version + '\ndisplayname "' + model.displayname + '"\ndescription "' + model.description + '"\ncategory demo'; + content += "\nfunctionblock " + model.displayname + " {"; + content += "\n\tconfiguration {\n\t //Please enter functionblock configuration details.\n\t}\n"; + content += "\n\tstatus {\n\t //Please enter functionblock status details.\n\t}\n"; + content += "\n\tfault {\n\t //Please enter functionblock fault configuration.\n\t}\n"; + content += "\n\toperations {\n\t //Please enter functionblock operations.\n\t}\n"; + content += "}"; + return content; + } + + $scope.addInfoModelEditor = function(parentId, model) { + var content = $scope.generateInfoModelContent(model); + require(["webjars/ace/1.2.0/src/ace"], function() { + require(["xtext/xtext-ace"], function(xtext) { + editor = xtext.createEditor({ + xtextLang: "infomodel", + syntaxDefinition: "xtext/mode-infomodel", + serviceUrl: "/infomodel/xtext-service", + enableFormattingAction: "true", + showErrorDialogs: "true", + parent: parentId + }); + editor.setValue(content); + $scope.editors.push(editor); + $scope.selectedEditor = $scope.editors[$scope.selectedTabIndex]; + $scope.search(); + var resourceId = $scope.selectedEditor.xtextServices.validationService._encodedResourceId; + var tab = $scope.tabs[$scope.selectedTabIndex]; + tab['resourceId'] = resourceId; + tab['name'] = model.name; + tab['version'] = model.version; + tab['namespace'] = model.namespace; + $http.post('./project/' + $scope.projectName + '/resources/create', { + "name": model.name, + "resourceId": resourceId, + "version": model.version, + "namespace": model.namespace + }).success( + function(data, status, headers, config) {}).error(function(data, status, headers, config) { + window.alert('File already exists') + }); + }); + }); + } + + $scope.addFunctionBlockEditor = function(parentId, model) { + var content = $scope.generateFunctionBlockContent(model); + require(["webjars/ace/1.2.0/src/ace"], function() { + require(["xtext/xtext-ace"], function(xtext) { + editor = xtext.createEditor({ + xtextLang: "fbmodel", + syntaxDefinition: "xtext/mode-fbmodel", + serviceUrl: "/functionblock/xtext-service", + enableFormattingAction: "true", + showErrorDialogs: "true", + parent: parentId + }); + editor.setValue(content); + $scope.editors.push(editor); + $scope.selectedEditor = $scope.editors[$scope.selectedTabIndex]; + $scope.search(); + var resourceId = $scope.selectedEditor.xtextServices.validationService._encodedResourceId; + var tab = $scope.tabs[$scope.selectedTabIndex]; + tab['resourceId'] = resourceId; + tab['name'] = model.name; + tab['version'] = model.version; + tab['namespace'] = model.namespace; + $http.post('./project/' + $scope.projectName + '/resources/create', { + "name": model.name, + "resourceId": resourceId, + "version": model.version, + "namespace": model.namespace + }).success( + function(data, status, headers, config) {}).error(function(data, status, headers, config) {}); + }); + }); + } + + $scope.getEditor = function(index) { + var tab = $scope.tabs[index]; + var tabEditorId = '#' + tab['editorParentDivId']; + return angular.element(document.querySelector(tabEditorId)); + } + + $scope.deleteTab = function(index) { + $scope.getEditor(index).remove(); + $scope.tabs.splice(index, 1); + $scope.editors.splice(index, 1); + } + + $scope.selectTab = function(index) { + $scope.selectedTabIndex = index; + $scope.selectedTabId = $scope.tabs[$scope.selectedTabIndex]['id'] + $scope.selectedEditor = $scope.editors[$scope.selectedTabIndex]; + $scope.search(); + } + + $scope.openAddEditorModal = function() { + var modalInstance = $uibModal.open({ + animation: true, + controller: 'AddEditorModalController', + templateUrl: 'templates/add-editor-modal-template.html', + size: 'sm', + resolve: { + editorTypes: function() { + return $scope.editorTypes; + } + } + }); + }; + + $scope.openDescribeEditorModal = function(editorType) { + var modalInstance = $uibModal.open({ + animation: true, + controller: 'DescribeEditorModalController', + templateUrl: 'templates/describe-editor-modal-template.html', + size: 'sm', + resolve: { + editorType: editorType + } + }); + }; + + $scope.openDeleteEditorModal = function(index) { + var modalInstance = $uibModal.open({ + animation: true, + controller: 'DeleteEditorModalController', + templateUrl: 'templates/delete-editor-modal-template.html', + size: 'm', + resolve: { + tab: function() { + var tab = $scope.tabs[$scope.selectedTabIndex] + tab['index'] = index; + return tab + } + } + }); + }; + + $scope.openCloseProjectModal = function() { + var modalInstance = $uibModal.open({ + animation: true, + controller: 'CloseProjectModalController', + templateUrl: 'templates/close-project-modal-template.html', + size: 'sm' + }); + }; + + $scope.openOpenResourceModal = function() { + var resources = []; + $http.get('./project/' + $scope.projectName + '/resources').success( + function(data, status, headers, config) { + var modalInstance = $uibModal.open({ + animation: true, + controller: 'OpenResourceModalController', + templateUrl: 'templates/open-resource-modal-template.html', + size: 'sm', + resolve: { + resources: function() { + return data; + } + } + }); + }).error(function(data, status, headers, config) { + window.alert('Failed to open resource'); + }); + }; + + $scope.isModelSelected = function() { + for (i = 0; i < $scope.displayedModels.length; i++) { + if ($scope.displayedModels[i]['isSelected']) { + $scope.selectedModel = $scope.displayedModels[i]; + $scope.selectedModelId = $scope.selectedModel['id']; + return true; + } + } + $scope.selectedModel = null; + $scope.selectedModelId = null; + return false; + } + + $scope.isValidEditorTab = function(index) { + return $scope.isValidModel($scope.editors[index]); + } + + $scope.isValidModel = function(editor) { + if (editor == null) { + return false; + } + if (editor.xtextServices.editorContext._annotations.length !== 0) { + return false; + } else { + return true; + } + } + + $scope.importModel = function() { + if ($scope.isValidModel($scope.selectedEditor)) { + if ($scope.isModelSelected()) { + $scope.showImportButton = false; + if ($scope.tabs[$scope.selectedTabIndex]['language'] == 'infomodel') { + $http.get('./editor/infomodel/link/functionblock/' + $scope.selectedEditor.xtextServices.validationService._encodedResourceId + '/' + $scope.selectedModelId['namespace'] + '/' + $scope.selectedModelId['name'] + '/' + $scope.selectedModelId['version']).success( + function(data, status, headers, config) { + $scope.selectedEditor.setValue(data); + }).error(function(data, status, headers, config) { + window.alert('Failed') + }).finally(function() { + $scope.showImportButton = true; + }); + } else if ($scope.tabs[$scope.selectedTabIndex]['language'] == 'fbmodel') { + $http.get('./editor/functionblock/link/datatype/' + $scope.selectedEditor.xtextServices.validationService._encodedResourceId + '/' + $scope.selectedModelId['namespace'] + '/' + $scope.selectedModelId['name'] + '/' + $scope.selectedModelId['version']).success( + function(data, status, headers, config) { + editor.setValue(data); + }).error(function(data, status, headers, config) { + window.alert('Failed') + }).finally(function() { + $scope.showImportButton = true; + }); + } + } else { + window.alert('Please select a model to import'); + } + } else { + window.alert('Your Vorto Model contains errors. Please correct and try again.'); + } + } + + $scope.searchOnEnter = function(keyEvent) { + if (keyEvent.keyCode === 13) { + $scope.search(); + } + }; + + $scope.search = function() { + var filter = null; + var modelType = null; + filter = $scope.queryFilter; + if ($scope.tabs[$scope.selectedTabIndex]['language'] == 'infomodel') { + $http.get('./editor/infomodel/search=' + filter).success( + function(data, status, headers, config) { + $scope.models = data; + }).error(function(data, status, headers, config) { + $scope.models = []; + }); + } else if ($scope.tabs[$scope.selectedTabIndex]['language'] == 'fbmodel') { + $http.get('./editor/functionblock/search=' + filter).success( + function(data, status, headers, config) { + $scope.models = data; + }).error(function(data, status, headers, config) { + $scope.models = []; + }); + } + } + + $scope.displayedModels = [].concat($scope.models); + $scope.itemsByPage = 6; + $scope.displayedPages = ($scope.models.length / 2); + + $scope.getters = { + name: function(value) { + return value.id.name.sort(); + } + } + + $scope.predicates = ['Name']; + + $scope.getResourceLanguage = function(resource) { + return resource.resourceId.split('.')[1]; + } + + }); + + app.controller('ProjectController', function($rootScope, $scope, $location, $http, $uibModal) { + $scope.selectedProject = null; + $scope.projects = []; + + $scope.$on("createProject", function(event, projectName) { + $scope.createProject(projectName); + }); + + $scope.openCreateProjectModal = function() { + var modalInstance = $uibModal.open({ + animation: true, + controller: 'CreateProjectModalController', + templateUrl: 'templates/create-project-modal-template.html', + size: 'sm' + }); + }; + + $scope.createProject = function(projectName) { + $http.post('./project', { + 'projectName': projectName + }).success( + function(data, status, headers, config) { + $location.path('editor/' + projectName); + $location.replace(); + }).error(function(data, status, headers, config) { + window.alert('Failed to create new Project ' + projectName) + }); + } + + $scope.getProjects = function() { + $http.get('./project').success( + function(data, status, headers, config) { + $scope.projects = data; + }).error(function(data, status, headers, config) { + $scope.projects = []; + }); + } + + $scope.getProjects(); + + $scope.displayedProjects = [].concat($scope.projects); + $scope.itemsByPage = 10; + $scope.displayedPages = ($scope.projects.length / 2); + + $scope.predicates = ['Name'] + + $scope.getters = { + name: function(value) { + return value.projectName.sort(); + } + } + + }); + + app.controller('AddEditorModalController', function($rootScope, $scope, $uibModalInstance, editorTypes) { + $scope.editorTypes = editorTypes; + $scope.selected = $scope.editorTypes[0]; + + $scope.ok = function() { + $uibModalInstance.close($scope.selected.editorType); + $rootScope.$broadcast("describeEditor", $scope.selected); + }; + + $scope.cancel = function() { + $uibModalInstance.dismiss('cancel'); + }; + }); + + app.controller('DescribeEditorModalController', function($rootScope, $scope, $uibModalInstance, editorType) { + + $scope.editorType = editorType; + $scope.model = { + language: editorType.language, + name: "NewModel", + displayname: "NewModel", + namespace: "com.company", + version: "1.0.0", + description: "Model description for NewModel", + category: "demo" + }; + + $scope.ok = function() { + $uibModalInstance.close($scope.model); + $scope.model.displayname = $scope.model.name; + $scope.model.name = $scope.model.name + "." + $scope.model.language; + $rootScope.$broadcast("addTab", $scope.model); + }; + + $scope.cancel = function() { + $uibModalInstance.dismiss('cancel'); + }; + }); + + app.controller('DeleteEditorModalController', function($rootScope, $scope, $uibModalInstance, tab) { + $scope.tab = tab; + + $scope.ok = function() { + $uibModalInstance.dismiss('cancel'); + $rootScope.$broadcast("deleteEditor", tab); + }; + + $scope.cancel = function() { + $uibModalInstance.dismiss('cancel'); + }; + }); + + app.controller('CreateProjectModalController', function($rootScope, $scope, $uibModalInstance) { + + $scope.projectName; + + $scope.ok = function() { + $uibModalInstance.close($scope.model); + $rootScope.$broadcast("createProject", $scope.projectName); + }; + + $scope.cancel = function() { + $uibModalInstance.dismiss('cancel'); + }; + }); + + app.controller('CloseProjectModalController', function($rootScope, $scope, $uibModalInstance) { + $scope.ok = function() { + $rootScope.$broadcast("closeProject"); + $uibModalInstance.dismiss('cancel'); + }; + + $scope.cancel = function() { + $uibModalInstance.dismiss('cancel'); + }; + }); + + return app; }); diff --git a/server/devtool/src/main/resources/static/dist/js/devtoolApp.js b/server/devtool/src/main/resources/static/dist/js/devtoolApp.js index 7eccd0b5f3..af62cbeff6 100644 --- a/server/devtool/src/main/resources/static/dist/js/devtoolApp.js +++ b/server/devtool/src/main/resources/static/dist/js/devtoolApp.js @@ -1,23 +1,39 @@ -define("devtoolApp",["angular","angular-route","controllers"],function(angular) { +define("devtoolApp", ["angular", "angular-route", "angular-animate", "angular-aria", "angular-bootstrap", "angular-bootstrap-templates", "smart-table", "controllers", "directives", "jquery"], function(angular) { - var app = angular.module('devtoolApp', ['ngRoute','apps.controller']); - - app.bootstrap = function() { - angular.bootstrap(document,['devtoolApp']); - }; - - app.config([ '$routeProvider', '$httpProvider', - function($routeProvider, $httpProvider) { - $routeProvider.when('/editor', { - templateUrl : "templates/editor-template.html", - controller : 'InfomodelEditorController' - }).otherwise({ - redirectTo : '/editor' - }); - -} ]).run(function($location, $http, $rootScope) { - // add global functions here + var app = angular.module('devtoolApp', ['ngRoute', 'apps.controller', 'apps.directive', 'ngAnimate', 'ui.bootstrap', 'ui.bootstrap.tpls']); + + app.bootstrap = function() { + angular.bootstrap(document, ['devtoolApp']); + }; + + app.config(['$routeProvider', '$httpProvider', + function($routeProvider, $httpProvider) { + $routeProvider + .when('/editor/:projectName', { + templateUrl: "templates/editor-template.html", + controller: 'EditorController' + }) + .when('/project', { + templateUrl: "templates/project-template.html", + controller: 'ProjectController' + }) + .otherwise({ + redirectTo: '/project' + }); + + } + ]).run(function($location, $http, $rootScope) { + + $rootScope.getRepositoryBasePath = function() { + $http.get('./repository/basepath').success(function(data, status, headers, config) { + $rootScope.repoBasePath = data['basepath']; + }).error(function(data, status, headers, config) { + $rootScope.repoBasePath = "http://vorto.eclipse.org/#/"; + }); + } + + $rootScope.getRepositoryBasePath(); + }); + + return app; }); - - return app; -}); \ No newline at end of file diff --git a/server/devtool/src/main/resources/static/dist/js/directives.js b/server/devtool/src/main/resources/static/dist/js/directives.js new file mode 100644 index 0000000000..0a30954a0e --- /dev/null +++ b/server/devtool/src/main/resources/static/dist/js/directives.js @@ -0,0 +1,27 @@ +define(["angular"], function(angular) { + var app = angular.module('apps.directive', []); + + app.directive('ngUniqueProjectName', ['$http', function($http) { + return { + require: 'ngModel', + link: function(scope, elem, attrs, ctrl) { + elem.on('blur', function(evt) { + scope.$apply(function() { + if (elem.val()) { + $http.get('./project/' + elem.val() + '/check').success( + function(data, status, headers, config) { + ctrl.$setValidity('unique', true); + }).error(function(data, status, headers, config) { + ctrl.$setValidity('unique', false); + }); + }else{ + ctrl.$setValidity('unique', true); + } + }); + }); + } + } + }]); + + return app; +}); diff --git a/server/devtool/src/main/resources/static/dist/js/main.js b/server/devtool/src/main/resources/static/dist/js/main.js index 28b3291285..6d826c4b32 100644 --- a/server/devtool/src/main/resources/static/dist/js/main.js +++ b/server/devtool/src/main/resources/static/dist/js/main.js @@ -1,29 +1,50 @@ require.config({ paths: { - "angular": "angular/angular.min", - "angular-route" : "angular/angular-route.min", - "jquery" : "/webjars/jquery/2.1.1/jquery.min", + "jquery" : "/webjars/jquery/2.1.1/jquery.min", + "angular": "/webjars/angularjs/1.3.13/angular.min", + "angular-route" : "/webjars/angular-route/1.3.13/angular-route.min", + "angular-animate" : "/webjars/angular-animate/1.3.13/angular-animate.min", + "angular-aria" : "/webjars/angular-aria/1.3.15/angular-aria.min", + "angular-bootstrap" : "/webjars/angular-ui-bootstrap/0.14.3/ui-bootstrap.min", + "angular-bootstrap-templates" : "/webjars/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.min", + "smart-table" : "/webjars/angular-smart-table/2.1.6/dist/smart-table.min", "mode-pwl" : "xtext-resources/generated/mode-infomodel", "ace/ext/language_tools" : "/webjars/ace/1.2.0/src/ext-language_tools", "webjars/ace/1.2.0/src/ace" : "/webjars/ace/1.2.0/src/ace", - "xtext/xtext-ace" : "/xtext/2.9.2/xtext-ace" + "xtext/xtext-ace" : "/xtext/2.9.2/xtext-ace" }, shim: { 'angular': { exports: "angular" }, 'jquery': { - exports: "jQuery" + exports: "jquery" }, 'angular-route' : { deps: ["angular"] + }, + 'angular-aria' : { + deps: ["angular"] + }, + 'angular-animate' : { + deps: ["angular"] + }, + 'angular-bootstrap' : { + deps: ["angular"] + }, + 'angular-bootstrap-templates' : { + deps: ["angular"] + }, + 'smart-table' : { + deps: ["angular"] } } }); require(['jquery'], function($) { $(document).ready(function() { + console.log('Ready'); require(['devtoolApp'],function(app) { app.bootstrap(); }) }) -}); +}); \ No newline at end of file diff --git a/server/devtool/src/main/resources/static/dist/js/xtext/mode-fbmodel.js b/server/devtool/src/main/resources/static/dist/js/xtext/mode-fbmodel.js new file mode 100644 index 0000000000..97d9e2b405 --- /dev/null +++ b/server/devtool/src/main/resources/static/dist/js/xtext/mode-fbmodel.js @@ -0,0 +1,35 @@ +define(["ace/lib/oop", "ace/mode/text", "ace/mode/text_highlight_rules"], function(oop, mText, mTextHighlightRules) { + var HighlightRules = function() { + var keywords = "Dictionary|MAX|MIMETYPE|MIN|REGEX|SCALING|STRLEN|as|base64Binary|boolean|byte|category|configuration|dateTime|description|displayname|double|entity|enum|eventable|events|extends|false|fault|float|functionblock|int|long|mandatory|measurementUnit|multiple|namespace|operations|optional|readable|returns|short|status|string|true|using|version|with|writable"; + this.$rules = { + "start": [ + {token: "comment", regex: "\\/\\/.*$"}, + {token: "comment", regex: "\\/\\*", next : "comment"}, + {token: "string", regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'}, + {token: "string", regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"}, + {token: "constant.numeric", regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, + {token: "lparen", regex: "[\\[({]"}, + {token: "rparen", regex: "[\\])}]"}, + {token: "keyword", regex: "\\b(?:" + keywords + ")\\b"} + ], + "comment": [ + {token: "comment", regex: ".*?\\*\\/", next : "start"}, + {token: "comment", regex: ".+"} + ] + }; + }; + oop.inherits(HighlightRules, mTextHighlightRules.TextHighlightRules); + + var Mode = function() { + this.HighlightRules = HighlightRules; + }; + oop.inherits(Mode, mText.Mode); + Mode.prototype.$id = "xtext/fbmodel"; + Mode.prototype.getCompletions = function(state, session, pos, prefix) { + return []; + } + + return { + Mode: Mode + }; +}); diff --git a/server/devtool/src/main/resources/static/dist/js/xtext/mode-infomodel.js b/server/devtool/src/main/resources/static/dist/js/xtext/mode-infomodel.js new file mode 100644 index 0000000000..62a2d4f1ec --- /dev/null +++ b/server/devtool/src/main/resources/static/dist/js/xtext/mode-infomodel.js @@ -0,0 +1,35 @@ +define(["ace/lib/oop", "ace/mode/text", "ace/mode/text_highlight_rules"], function(oop, mText, mTextHighlightRules) { + var HighlightRules = function() { + var keywords = "as|category|description|displayname|functionblocks|infomodel|namespace|using|version"; + this.$rules = { + "start": [ + {token: "comment", regex: "\\/\\/.*$"}, + {token: "comment", regex: "\\/\\*", next : "comment"}, + {token: "string", regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'}, + {token: "string", regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"}, + {token: "constant.numeric", regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"}, + {token: "lparen", regex: "[{]"}, + {token: "rparen", regex: "[}]"}, + {token: "keyword", regex: "\\b(?:" + keywords + ")\\b"} + ], + "comment": [ + {token: "comment", regex: ".*?\\*\\/", next : "start"}, + {token: "comment", regex: ".+"} + ] + }; + }; + oop.inherits(HighlightRules, mTextHighlightRules.TextHighlightRules); + + var Mode = function() { + this.HighlightRules = HighlightRules; + }; + oop.inherits(Mode, mText.Mode); + Mode.prototype.$id = "xtext/infomodel"; + Mode.prototype.getCompletions = function(state, session, pos, prefix) { + return []; + } + + return { + Mode: Mode + }; +}); diff --git a/server/devtool/src/main/resources/static/index.html b/server/devtool/src/main/resources/static/index.html index 76e091ae56..c116414167 100644 --- a/server/devtool/src/main/resources/static/index.html +++ b/server/devtool/src/main/resources/static/index.html @@ -7,9 +7,15 @@ - Vorto Web Editor + Vorto Developer - + + + + + + + @@ -19,19 +25,13 @@