esteinberg / plantuml4idea

Intellij IDEA plugin for PlantUML
Apache License 2.0
633 stars 113 forks source link

Add a PUML context for Live Templates #338

Open JinoBetti opened 2 years ago

JinoBetti commented 2 years ago

I like using live template to create diagrams more efficiently, and when you create live templates in intellij, you have to select the context in which the templates will appear. It would be great to be able to select the "Puml" context, for the live template to appear only in the PUML files (currently, I've selected the template "other" so that it will only appear in non java, non xml, non [...] files

Documentation about live templates if needed

dvdvdmt commented 2 years ago

It would be even greater if the plugin will come with a predefined set of default templates for basic blocks like if, switch, note, etc. By the way, thank you so much guys for this plugin!

krasa commented 2 years ago

Feel free to copypaste yours. Like this:

<template name="Alice -&gt; Bob" value="Alice -&gt; Bob: Authentication Request&#10;Bob --&gt; Alice: Authentication Response" description="A" toReformat="true" toShortenFQNames="true">
  <context>
    <option name="PUML" value="true" />
  </context>
</template>

https://plugins.jetbrains.com/docs/intellij/template-support.html#export-the-live-template

dvdvdmt commented 2 years ago

@krasa Thank you very much for the context addition! 👍 Here are 4 of my live templates for PantUML Activity diagrams

<template name="action" value=":$SELECTION$;" description="Activity diagram. Action" toReformat="false" toShortenFQNames="true">
  <context>
    <option name="PUML" value="true" />
  </context>
</template>
<template name="if" value="if (condition?) is (yes) then&#10;  :true;&#10;else (no)&#10;  :false;&#10;endif" description="Activity diagram. If statement" toReformat="false" toShortenFQNames="true">
  <context>
    <option name="PUML" value="true" />
  </context>
</template>
<template name="note" value="note&#10;$START$&#10;end note" description="Activity diagram. Note" toReformat="false" toShortenFQNames="true">
  <variable name="START" expression="" defaultValue="" alwaysStopAt="true" />
  <context>
    <option name="PUML" value="true" />
  </context>
</template>
<template name="while" value="while (data available?)&#10;  :read data;&#10;endwhile" description="Activity diagram. While loop" toReformat="false" toShortenFQNames="true">
  <context>
    <option name="PUML" value="true" />
  </context>
</template>
image