/******************************************************************************* * @license * Copyright (c) 2012 Abstratt Technologies. * All rights reserved. This program and the accompanying materials are made * available under the terms of the Eclipse Public License v1.0 * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html). * * Contributors: * Rafael Chaves - initial API and implementation *******************************************************************************/ window.onload = function() { var checkSyntax = function(title, contents) { return dojo.xhrGet({ handleAs: 'json', url: "../mdd/builder" + title, load: function(result) { return result } }); }; var getOutline = function(text, title) { return dojo.xhrPost({ postData: text, handleAs: 'json', url: "../mdd/analyzer/?fileName=" + title, load: function(result) { return result; } }); }; var autoFormat = function(selectedText, text, selection, resource) { return dojo.xhrPost({ postData: text, handleAs: 'text', url: "../mdd/formatter/?fileName=" + resource, load: function(result) { return { text: result, selection: null }; } }); }; var computeProposals = function(prefix, buffer, selection) { return [ { proposal: "package package_name;\n\n/* add classes here */\n\nend.", description: 'New package' }, { proposal: "class class_name\n/* add attributes and operations here */\nend;", description: 'New class' }, { proposal: "attribute attribute_name : String;", description: 'New attribute' }, { proposal: "operation operation_name(param1 : String, param2 : Integer) : Boolean;\nbegin\n /* IMPLEMENT ME */\n return false;\nend;", description: 'New operation' } ]; }; var deploy = function(selection) { return dojo.xhrPost({ postData: '', handleAs: 'json', url: "../mdd/deployer/?path=" + selection[0].Location }); }; var provider = new eclipse.PluginProvider(); provider.registerServiceProvider("orion.core.contenttype", {}, { contentTypes: [{ id: "text/uml", name: "TextUML", extension: ["tuml"], extends: "text/plain" }] }); provider.registerServiceProvider("orion.core.contenttype", {}, { contentTypes: [{ id: "application/vnd-json-data", name: "JSON-encoded dataset", filename: ["data.json"], extends: "application/javascript" }] }); provider.registerServiceProvider("orion.core.contenttype", {}, { contentTypes: [{ id: "application/vnd-mdd-properties", name: "Cloudfier properties file", filename: ["mdd.properties"], extends: "text/plain" }] }); provider.registerServiceProvider("orion.navigate.content", null, { id: "orion.cloudfier.content.examples", name: "Get Cloudfier examples", description: "Get the Cloudfier example applications into your workspace by cloning a git repository. Once the repository is cloned, a 'cloudfier-examples' folder will appear in the Navigator.", uriTemplate: "{OrionHome}/git/git-repository.html#,cloneGitRepository=https://bitbucket.org/abstratt/cloudfier-examples.git" }); provider.registerServiceProvider("orion.edit.validator", { checkSyntax: checkSyntax }, { contentType: ["text/uml", "application/vnd-json-data"] }); provider.registerServiceProvider("orion.edit.outliner", { getOutline: getOutline }, { contentType: ["text/uml"], id: "com.abstratt.textuml.outliner", name: "TextUML outliner" }); provider.registerServiceProvider("orion.edit.command", { run : autoFormat }, { name : "Format (^M)", key : [ "m", true ], contentType: ["text/uml"] }); provider.registerServiceProvider("orion.navigate.command", { run: deploy }, { name: "Deploy Application", id: "orion.cloudfier.commands.deploy", forceSingleItem: true, tooltip: "Deploys the selected project to Cloudfier", contentType: ["application/vnd-mdd-properties"] }); provider.registerServiceProvider("orion.navigate.command", { }, { name: "Start Application", id: "orion.cloudfier.commands.launchApp", forceSingleItem: true, tooltip: "Start the application in Cloudfier (you must deploy first)", uriTemplate: "http://localhost:8090/mdd/ui/session/?location={Location}", contentType: ["application/vnd-mdd-properties"] }); provider.registerServiceProvider("orion.navigate.command", { }, { name: "Browse REST API", id: "orion.cloudfier.commands.browseAPI", forceSingleItem: true, tooltip: "Browse the REST API for the selected project in Cloudfier", uriTemplate: "http://localhost:8090/mdd/api/session/?location={Location}", contentType: ["application/vnd-mdd-properties"] }); /* Registers a highlighter service. */ provider.registerServiceProvider("orion.edit.highlighter", { // "grammar" provider is purely declarative. No service methods. }, { type : "grammar", contentType: ["text/uml"], grammar: { patterns: [ { end: '"', begin: '"', name: 'string.quoted.double.textuml', }, { begin: "\\(\\*", end: "\\*\\)", name: "comment.model.textuml" }, { begin: "/\\*", end: "\\*/", name: "comment.ignored.textuml" }, { name: 'keyword.control.untitled', match: '\\b(abstract|access|aggregation|alias|and|any|association|as|attribute|begin|by|class|datatype|derived|composition|constant|dependency|end|enumeration|extends|function|implements|interface|in|initial|inout|invariant|is|model|navigable|nonunique|not|on|operation|or|ordered|out|package|postcondition|precondition|private|primitive|profile|property|protected|public|raises|readonly|reference|required|return|role|self|specializes|state|statemachine|static|stereotype|subsets|terminate|to|transition|type|unique|unordered|var|when)\\b' }, { "match": "([a-zA-Z_][a-zA-Z0-9_]*)", "name": "variable.other.textuml" }, { "match": "<|>|<=|>=|=|==|\\*|/|-|\\+", "name": "keyword.other.textuml" }, { "match": ";", "name": "punctuation.textuml" } ] } }); provider.registerServiceProvider("orion.edit.contentAssist", { computeProposals: computeProposals }, { name: "TextUML content assist", contentType: ["text/uml"] } ); provider.connect(); };