Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit bc7cfe4

Browse files
m-g-kSimon Stone
authored andcommitted
Update Plant UML theme choices and options (#45)
* Update to 0.13.1 to support decorators * update engine version to prevent packaging failure * Update Plant UML theme choices and options
1 parent 399dd00 commit bc7cfe4

File tree

3 files changed

+47
-25
lines changed

3 files changed

+47
-25
lines changed

client/package.json

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,27 @@
6262
"type": "object",
6363
"title": "Composer configuration",
6464
"properties": {
65-
"composer.pUML.keepSourceFileOpen": {
65+
"composer.UML.keepSourceFileOpen": {
6666
"type": "boolean",
6767
"default": true,
6868
"description": "Keeps open the 'composer.puml' source file after generating the diagram."
6969
},
70-
"composer.pUML.autoShowDiagam": {
70+
"composer.UML.autoShowDiagam": {
7171
"type": "boolean",
7272
"default": true,
73-
"description": "If true, the pUML diagram will automatically be shown. If false, a 'composer.puml' files will be created without showing the diagram."
73+
"description": "If true, the PlantUML diagram will automatically be shown. If false, a 'composer.puml' files will be created without showing the diagram."
7474
},
75-
"composer.pUML.includeSystemNamespace": {
75+
"composer.UML.includeSystemNamespace": {
7676
"type": "string",
7777
"enum": [
7878
"none",
7979
"all",
8080
"simple"
8181
],
8282
"default": "simple",
83-
"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."
83+
"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."
8484
},
85-
"composer.pUML.diagramStyle": {
85+
"composer.UML.diagramStyle": {
8686
"type": "string",
8787
"enum": [
8888
"normal",
@@ -93,6 +93,15 @@
9393
"default": "normal",
9494
"description": "Style of diagram to draw."
9595
},
96+
"composer.UML.diagramTheme": {
97+
"type": "string",
98+
"enum": [
99+
"yellow",
100+
"blue"
101+
],
102+
"default": "yellow",
103+
"description": "Diagram PlantUML theme. 'yellow' gives the default yellow diagram theme, where as 'blue' uses the newer blue theme"
104+
},
96105
"composer.contributor": {
97106
"type": "boolean",
98107
"default": false,

client/src/extension.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function activate(context: ExtensionContext) {
8989

9090
/**
9191
* Client handler for 'composer.generateUML' Command
92-
* @param {string} docContent - info passed from server - pUML text as a string
92+
* @param {string} docContent - info passed from server - UML text as a string
9393
* @param {string} originatingFileName - name of the cto file command was activated on as passed to server
9494
* note that this can be undefined if the command was activated by a keyboard shortcut!
9595
*/
@@ -115,8 +115,9 @@ async function handleGenerateUml(docContent: string, originatingFileName: string
115115

116116
//get config info we need to set flags
117117
let allConfig = workspace.getConfiguration();
118-
let keepSrcFileOpen = allConfig.get('composer.pUML.keepSourceFileOpen');
119-
let autoShowDiagam = allConfig.get('composer.pUML.autoShowDiagam');
118+
let keepSrcFileOpen = allConfig.get('composer.UML.keepSourceFileOpen');
119+
let autoShowDiagam = allConfig.get('composer.UML.autoShowDiagam');
120+
let diagramTheme = allConfig.get('composer.UML.diagramTheme');
120121

121122
//if we are to try and show the diagram, we need the plantUML extention installed.
122123
if (autoShowDiagam) {
@@ -144,20 +145,23 @@ async function handleGenerateUml(docContent: string, originatingFileName: string
144145
let configPlantUml = allConfig['plantuml'];
145146
configPlantUml.previewAutoUpdate = false;
146147
configPlantUml.previewFileType = 'svg';
148+
if (diagramTheme === 'blue') {
149+
configPlantUml.includes = ['styles/blue'];
150+
}
147151
}
148152

149153
//Note: This looks like it should work but does not. TODO: Raise vscode issue
150154
//allConfig.update('plantuml.previewAutoUpdate',false,false);
151155
}
152156
}
153-
157+
154158
//construct temp file name
155159
var fileName = os.tmpdir() + path.sep + "composer.puml";
156160
var umlDocUri = Uri.file(fileName)
157161

158162
//make sure file exists - needed as a workaround to vscode issue #29156
159-
if( ! fs.existsSync(fileName)) {
160-
fs.writeFileSync(fileName,"");
163+
if (!fs.existsSync(fileName)) {
164+
fs.writeFileSync(fileName, "");
161165
}
162166

163167
//open file - contents will always be replaced later on.
@@ -171,7 +175,7 @@ async function handleGenerateUml(docContent: string, originatingFileName: string
171175
}
172176
let textEditor = await window.showTextDocument(document, options);
173177
return await textEditor.edit(async (editBuilder) => {
174-
//edit doc to replace all doc content with new puml syntax
178+
//edit doc to replace all doc content with new PlantUML syntax
175179
var lastLineLength = document.lineAt(document.lineCount - 1).text.length;
176180
editBuilder.replace(new Range(new Position(0, 0), new Position(textEditor.document.lineCount - 1, lastLineLength)), docContent);
177181
}).then(async editApplied => {
@@ -183,7 +187,7 @@ async function handleGenerateUml(docContent: string, originatingFileName: string
183187

184188
//save the file whilst it's the active one
185189
var saved = await document.save();
186-
if(!saved) {
190+
if (!saved) {
187191
console.log("Client could not save doc: " + umlDocUri.toString());
188192
}
189193

@@ -199,8 +203,8 @@ async function handleGenerateUml(docContent: string, originatingFileName: string
199203
if (result !== undefined) {
200204
//console.log("Client preview returned: " + result); //debug
201205
}
202-
203-
//check for option to close .puml file
206+
207+
//check for option to close the composer.puml file
204208
if (!keepSrcFileOpen) {
205209
//make sure we are closing the correct window, just in case
206210
if (window.activeTextEditor) {
@@ -222,7 +226,7 @@ async function handleGenerateUml(docContent: string, originatingFileName: string
222226
}
223227

224228
//reset the correct cto editor as active if we are showing the diagram
225-
//otherwise let the omposer.puml file have focus
229+
//otherwise let the composer.puml file have focus
226230
if (autoShowDiagam) {
227231
//Note that the visibleTextEditors list is the nost accurate as it contains
228232
//the correct view column. However, we're not always present in this list

server/src/server.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ interface Settings {
8383
interface ComposerSettings {
8484
contributor: boolean
8585
maxNumberOfProblems: number
86-
pUML: {
86+
UML: {
8787
keepSourceFileOpen: boolean
8888
autoShowDiagam: boolean
8989
includeSystemNamespace: string
9090
diagramStyle: string
91+
diagramTheme: string
9192
}
9293
}
9394

@@ -144,7 +145,7 @@ connection.onExecuteCommand((params) => {
144145

145146
/**
146147
* Server processor for 'composer.generateUML' Command
147-
* @param {string} diagramTitle - pUML diagram title
148+
* @param {string} diagramTitle - UML diagram title
148149
* @param {string} originatingFileName - name of the cto file command was activated on as passed to server
149150
* note that this can be undefined if the command was activated by a keyboard shortcut!
150151
*/
@@ -162,7 +163,7 @@ function handleGenerateUml(diagramTitle: string, originatingFileName: string) {
162163
for (let n = 0; n < modelFiles.length; n++) {
163164
const modelFile: ModelFile = modelFiles[n];
164165
//we exclude models from the system namespace by default
165-
if (options.pUML.includeSystemNamespace === "all") {
166+
if (options.UML.includeSystemNamespace === "all") {
166167
result = result.concat(modelFile.getAllDeclarations());
167168
} else if (modelFile.getNamespace() != ModelUtil.getSystemNamespace()) {
168169
result = result.concat(modelFile.getAllDeclarations());
@@ -173,14 +174,22 @@ function handleGenerateUml(diagramTitle: string, originatingFileName: string) {
173174
parameters.fileWriter.writeLine(0, "@startuml composer");
174175
parameters.fileWriter.writeLine(0, "'** Auto generated content, any changes may be lost **'");
175176
parameters.fileWriter.writeLine(0, "!define DATE %date[EEE, MMM d, ''yy 'at' HH:mm]%");
177+
if (options.UML.diagramTheme === 'yellow') {
178+
parameters.fileWriter.writeLine(0, "skinparam titleBackgroundColor LightYellow");
179+
} else {
180+
parameters.fileWriter.writeLine(0, "'AutoInclude") //include the blue style
181+
parameters.fileWriter.writeLine(0, "skinparam titleBackgroundColor AliceBlue");
182+
}
176183
parameters.fileWriter.writeLine(0, "skinparam titleBorderThickness 0.5");
177184
parameters.fileWriter.writeLine(0, "skinparam titleBorderRoundCorner 6");
178-
parameters.fileWriter.writeLine(0, "skinparam titleBackgroundColor LightYellow");
179-
if (options.pUML.diagramStyle === 'handwritten') {
185+
parameters.fileWriter.writeLine(0, "skinparam titleFontColor Black");
186+
parameters.fileWriter.writeLine(0, "skinparam titleFontSize 18");
187+
188+
if (options.UML.diagramStyle === 'handwritten') {
180189
parameters.fileWriter.writeLine(0, "skinparam handwritten true")
181-
} else if (options.pUML.diagramStyle === 'monochrome') {
190+
} else if (options.UML.diagramStyle === 'monochrome') {
182191
parameters.fileWriter.writeLine(0, "skinparam monochrome true");
183-
} else if (options.pUML.diagramStyle === 'monochrome-reverse') {
192+
} else if (options.UML.diagramStyle === 'monochrome-reverse') {
184193
parameters.fileWriter.writeLine(0, "skinparam monochrome reverse");
185194
}
186195

@@ -194,7 +203,7 @@ function handleGenerateUml(diagramTitle: string, originatingFileName: string) {
194203
decl.accept(visitor, parameters);
195204
});
196205

197-
if (options.pUML.includeSystemNamespace === "none") {
206+
if (options.UML.includeSystemNamespace === "none") {
198207
//skip system namespace artifacts. Note that we can only hide classes that already exist,
199208
//so for now simply search for the relevant string to check for existance. This is
200209
//not a failsafe solution but should work well enough for now.

0 commit comments

Comments
 (0)