diff --git a/client/package.json b/client/package.json index 11b314f..fe2d7fb 100755 --- a/client/package.json +++ b/client/package.json @@ -3,12 +3,19 @@ "displayName": "Hyperledger Composer", "description": "Hyperledger Composer syntax highlighting, autocomplete, snippets & error checking", "author": "Hyperledger Composer", + "keywords": [ + "Hyperledger Composer", + "distributed ledger technology", + "blockchain", + "DLT" + ], + "homepage": "https://hyperledger.github.io/composer/", "license": "Apache-2.0", - "version": "0.11.3", + "version": "0.13.1", "publisher": "HyperledgerComposer", "icon": "icon.png", "engines": { - "vscode": "^1.12.2" + "vscode": "^1.15.1" }, "repository": { "type": "git", @@ -55,17 +62,17 @@ "type": "object", "title": "Composer configuration", "properties": { - "composer.pUML.keepSourceFileOpen": { + "composer.UML.keepSourceFileOpen": { "type": "boolean", "default": true, "description": "Keeps open the 'composer.puml' source file after generating the diagram." }, - "composer.pUML.autoShowDiagam": { + "composer.UML.autoShowDiagam": { "type": "boolean", "default": true, - "description": "If true, the pUML diagram will automatically be shown. If false, a 'composer.puml' files will be created without showing the diagram." + "description": "If true, the PlantUML diagram will automatically be shown. If false, a 'composer.puml' files will be created without showing the diagram." }, - "composer.pUML.includeSystemNamespace": { + "composer.UML.includeSystemNamespace": { "type": "string", "enum": [ "none", @@ -73,9 +80,9 @@ "simple" ], "default": "simple", - "description": "Options to control System Namespace inlusion in pUML diagrams. 'all' will include all System Namespace artifacts. 'none' will remove all System Namespace artifacts. 'simple' keeps the bare minimum of System Namesapce artifacts. The more artifacts kept, the more cluttered the diagram will be." + "description": "Options to control System Namespace inlusion in PlantUML diagrams. 'all' will include all System Namespace artifacts. 'none' will remove all System Namespace artifacts. 'simple' keeps the bare minimum of System Namesapce artifacts. The more artifacts kept, the more cluttered the diagram will be." }, - "composer.pUML.diagramStyle": { + "composer.UML.diagramStyle": { "type": "string", "enum": [ "normal", @@ -86,6 +93,15 @@ "default": "normal", "description": "Style of diagram to draw." }, + "composer.UML.diagramTheme": { + "type": "string", + "enum": [ + "yellow", + "blue" + ], + "default": "yellow", + "description": "Diagram PlantUML theme. 'yellow' gives the default yellow diagram theme, where as 'blue' uses the newer blue theme" + }, "composer.contributor": { "type": "boolean", "default": false, @@ -242,7 +258,7 @@ "@types/mocha": "^2.2.33", "@types/node": "^6.0.52", "typescript": "^2.1.5", - "vscode": "^1.1.4", + "vscode": "^1.1.5", "vsce": "^1.30.0" }, "dependencies": { diff --git a/client/src/extension.ts b/client/src/extension.ts index 86795dd..e062a2a 100755 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -89,7 +89,7 @@ export function activate(context: ExtensionContext) { /** * Client handler for 'composer.generateUML' Command - * @param {string} docContent - info passed from server - pUML text as a string + * @param {string} docContent - info passed from server - UML text as a string * @param {string} originatingFileName - name of the cto file command was activated on as passed to server * note that this can be undefined if the command was activated by a keyboard shortcut! */ @@ -115,8 +115,9 @@ async function handleGenerateUml(docContent: string, originatingFileName: string //get config info we need to set flags let allConfig = workspace.getConfiguration(); - let keepSrcFileOpen = allConfig.get('composer.pUML.keepSourceFileOpen'); - let autoShowDiagam = allConfig.get('composer.pUML.autoShowDiagam'); + let keepSrcFileOpen = allConfig.get('composer.UML.keepSourceFileOpen'); + let autoShowDiagam = allConfig.get('composer.UML.autoShowDiagam'); + let diagramTheme = allConfig.get('composer.UML.diagramTheme'); //if we are to try and show the diagram, we need the plantUML extention installed. if (autoShowDiagam) { @@ -144,20 +145,23 @@ async function handleGenerateUml(docContent: string, originatingFileName: string let configPlantUml = allConfig['plantuml']; configPlantUml.previewAutoUpdate = false; configPlantUml.previewFileType = 'svg'; + if (diagramTheme === 'blue') { + configPlantUml.includes = ['styles/blue']; + } } //Note: This looks like it should work but does not. TODO: Raise vscode issue //allConfig.update('plantuml.previewAutoUpdate',false,false); } } - + //construct temp file name var fileName = os.tmpdir() + path.sep + "composer.puml"; var umlDocUri = Uri.file(fileName) //make sure file exists - needed as a workaround to vscode issue #29156 - if( ! fs.existsSync(fileName)) { - fs.writeFileSync(fileName,""); + if (!fs.existsSync(fileName)) { + fs.writeFileSync(fileName, ""); } //open file - contents will always be replaced later on. @@ -171,7 +175,7 @@ async function handleGenerateUml(docContent: string, originatingFileName: string } let textEditor = await window.showTextDocument(document, options); return await textEditor.edit(async (editBuilder) => { - //edit doc to replace all doc content with new puml syntax + //edit doc to replace all doc content with new PlantUML syntax var lastLineLength = document.lineAt(document.lineCount - 1).text.length; editBuilder.replace(new Range(new Position(0, 0), new Position(textEditor.document.lineCount - 1, lastLineLength)), docContent); }).then(async editApplied => { @@ -183,7 +187,7 @@ async function handleGenerateUml(docContent: string, originatingFileName: string //save the file whilst it's the active one var saved = await document.save(); - if(!saved) { + if (!saved) { console.log("Client could not save doc: " + umlDocUri.toString()); } @@ -199,8 +203,8 @@ async function handleGenerateUml(docContent: string, originatingFileName: string if (result !== undefined) { //console.log("Client preview returned: " + result); //debug } - - //check for option to close .puml file + + //check for option to close the composer.puml file if (!keepSrcFileOpen) { //make sure we are closing the correct window, just in case if (window.activeTextEditor) { @@ -222,7 +226,7 @@ async function handleGenerateUml(docContent: string, originatingFileName: string } //reset the correct cto editor as active if we are showing the diagram - //otherwise let the omposer.puml file have focus + //otherwise let the composer.puml file have focus if (autoShowDiagam) { //Note that the visibleTextEditors list is the nost accurate as it contains //the correct view column. However, we're not always present in this list diff --git a/server/src/server.ts b/server/src/server.ts index bda107f..69e1a1d 100755 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -83,11 +83,12 @@ interface Settings { interface ComposerSettings { contributor: boolean maxNumberOfProblems: number - pUML: { + UML: { keepSourceFileOpen: boolean autoShowDiagam: boolean includeSystemNamespace: string diagramStyle: string + diagramTheme: string } } @@ -144,7 +145,7 @@ connection.onExecuteCommand((params) => { /** * Server processor for 'composer.generateUML' Command - * @param {string} diagramTitle - pUML diagram title + * @param {string} diagramTitle - UML diagram title * @param {string} originatingFileName - name of the cto file command was activated on as passed to server * note that this can be undefined if the command was activated by a keyboard shortcut! */ @@ -162,7 +163,7 @@ function handleGenerateUml(diagramTitle: string, originatingFileName: string) { for (let n = 0; n < modelFiles.length; n++) { const modelFile: ModelFile = modelFiles[n]; //we exclude models from the system namespace by default - if (options.pUML.includeSystemNamespace === "all") { + if (options.UML.includeSystemNamespace === "all") { result = result.concat(modelFile.getAllDeclarations()); } else if (modelFile.getNamespace() != ModelUtil.getSystemNamespace()) { result = result.concat(modelFile.getAllDeclarations()); @@ -170,17 +171,25 @@ function handleGenerateUml(diagramTitle: string, originatingFileName: string) { } //begin UML definition and global defines - parameters.fileWriter.writeLine(0, "@startuml"); + parameters.fileWriter.writeLine(0, "@startuml composer"); parameters.fileWriter.writeLine(0, "'** Auto generated content, any changes may be lost **'"); parameters.fileWriter.writeLine(0, "!define DATE %date[EEE, MMM d, ''yy 'at' HH:mm]%"); + if (options.UML.diagramTheme === 'yellow') { + parameters.fileWriter.writeLine(0, "skinparam titleBackgroundColor LightYellow"); + } else { + parameters.fileWriter.writeLine(0, "'AutoInclude") //include the blue style + parameters.fileWriter.writeLine(0, "skinparam titleBackgroundColor AliceBlue"); + } parameters.fileWriter.writeLine(0, "skinparam titleBorderThickness 0.5"); parameters.fileWriter.writeLine(0, "skinparam titleBorderRoundCorner 6"); - parameters.fileWriter.writeLine(0, "skinparam titleBackgroundColor LightYellow"); - if (options.pUML.diagramStyle === 'handwritten') { + parameters.fileWriter.writeLine(0, "skinparam titleFontColor Black"); + parameters.fileWriter.writeLine(0, "skinparam titleFontSize 18"); + + if (options.UML.diagramStyle === 'handwritten') { parameters.fileWriter.writeLine(0, "skinparam handwritten true") - } else if (options.pUML.diagramStyle === 'monochrome') { + } else if (options.UML.diagramStyle === 'monochrome') { parameters.fileWriter.writeLine(0, "skinparam monochrome true"); - } else if (options.pUML.diagramStyle === 'monochrome-reverse') { + } else if (options.UML.diagramStyle === 'monochrome-reverse') { parameters.fileWriter.writeLine(0, "skinparam monochrome reverse"); } @@ -194,7 +203,7 @@ function handleGenerateUml(diagramTitle: string, originatingFileName: string) { decl.accept(visitor, parameters); }); - if (options.pUML.includeSystemNamespace === "none") { + if (options.UML.includeSystemNamespace === "none") { //skip system namespace artifacts. Note that we can only hide classes that already exist, //so for now simply search for the relevant string to check for existance. This is //not a failsafe solution but should work well enough for now.