Skip to content

Commit

Permalink
Grouped file templates
Browse files Browse the repository at this point in the history
  • Loading branch information
krasa committed Mar 29, 2019
1 parent e9424b3 commit 8ca95f2
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<li>Added MindMap support</li>
<li>Added Gantt support</li>
<li>Added option to use GRAPHVIZ_DOT environment variable preferentially</li>
<li>Grouped file templates</li>
<p>2.12</p>
<ul>
<li>PlantUml library upgrade to v1.2018.11</li>
Expand Down Expand Up @@ -175,6 +176,10 @@
class="org.plantuml.idea.action.AboutAction" text="About"/>
</group>

<group id="NewPlantUML" text="PlantUML">
<action id="NewPlantUMLFile" class="org.plantuml.idea.plantuml.CreatePlantUMLFileAction"/>
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFromTemplate"/>
</group>
</actions>

<extensions defaultExtensionNs="com.intellij">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions src/org/plantuml/idea/plantuml/CreatePlantUMLFileAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.plantuml.idea.plantuml;

import com.intellij.ide.actions.CreateFileFromTemplateAction;
import com.intellij.ide.actions.CreateFileFromTemplateDialog;
import com.intellij.ide.actions.CreateHtmlFileAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import org.jetbrains.annotations.NotNull;
import org.plantuml.idea.lang.PlantUmlFileType;

public class CreatePlantUMLFileAction extends CreateFileFromTemplateAction implements DumbAware {

public CreatePlantUMLFileAction() {
super("PlantUML File", "Creates new PlantUML file", PlantUmlFileType.PLANTUML_ICON);
}

@Override
protected String getDefaultTemplateProperty() {
return "DefaultPlantUmlFileTemplate";
}

@Override
protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) {
builder
.setTitle("New PlantUML File")
.addKind("Sequence", PlantUmlFileType.PLANTUML_ICON, "UML Sequence.puml")
.addKind("Use Case", PlantUmlFileType.PLANTUML_ICON, "UML Use Case.puml")
.addKind("Class", PlantUmlFileType.PLANTUML_ICON, "UML Class.puml")
.addKind("Activity", PlantUmlFileType.PLANTUML_ICON, "UML Activity.puml")
.addKind("Component", PlantUmlFileType.PLANTUML_ICON, "UML Component.puml")
.addKind("State", PlantUmlFileType.PLANTUML_ICON, "UML State.puml")
.addKind("Object", PlantUmlFileType.PLANTUML_ICON, "UML Object.puml")
.addKind("Gantt", PlantUmlFileType.PLANTUML_ICON, "UML Gantt.puml")
.addKind("MindMap", PlantUmlFileType.PLANTUML_ICON, "UML MindMap.puml")
.addKind("Wireframe", PlantUmlFileType.PLANTUML_ICON, "Salt Wireframe.puml");
}

@Override
protected String getActionName(PsiDirectory directory, @NotNull String newName, String templateName) {
return "PlantUML File";
}

@Override
public int hashCode() {
return 0;
}

@Override
public boolean equals(Object obj) {
return obj instanceof CreateHtmlFileAction;
}
}

0 comments on commit 8ca95f2

Please sign in to comment.