generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from shyim/add-real-file-templates
feat: Improve file template handling, add Changelog action
- Loading branch information
Showing
22 changed files
with
457 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/de/shyim/shopware6/ui/NewChangelogDialog.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.shyim.shopware6.ui.NewChangelogDialog"> | ||
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<xy x="20" y="20" width="500" height="400"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="1ddb8" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Title:"/> | ||
</properties> | ||
</component> | ||
<component id="8686f" class="javax.swing.JTextField" binding="titleField"> | ||
<constraints> | ||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="-1"/> | ||
</grid> | ||
</constraints> | ||
<properties/> | ||
</component> | ||
<component id="ecfbe" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Ticket:"/> | ||
</properties> | ||
</component> | ||
<component id="13b7b" class="javax.swing.JTextField" binding="ticketField"> | ||
<constraints> | ||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="-1"/> | ||
</grid> | ||
</constraints> | ||
<properties/> | ||
</component> | ||
<component id="8ad3d" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Flag:"/> | ||
</properties> | ||
</component> | ||
<component id="e4a1d" class="javax.swing.JTextField" binding="flagField"> | ||
<constraints> | ||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="-1"/> | ||
</grid> | ||
</constraints> | ||
<properties/> | ||
</component> | ||
<vspacer id="bf0a7"> | ||
<constraints> | ||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
</vspacer> | ||
</children> | ||
</grid> | ||
</form> |
10 changes: 10 additions & 0 deletions
10
src/main/java/de/shyim/shopware6/ui/NewChangelogDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package de.shyim.shopware6.ui; | ||
|
||
import javax.swing.*; | ||
|
||
public class NewChangelogDialog { | ||
public JTextField titleField; | ||
public JTextField ticketField; | ||
public JTextField flagField; | ||
public JPanel panel; | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/java/de/shyim/shopware6/ui/NewComponentDialog.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.shyim.shopware6.ui.NewComponentDialog"> | ||
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<xy x="20" y="20" width="500" height="400"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="5d067" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Name"/> | ||
</properties> | ||
</component> | ||
<component id="4880f" class="javax.swing.JTextField" binding="componentName"> | ||
<constraints> | ||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="-1"/> | ||
</grid> | ||
</constraints> | ||
<properties/> | ||
</component> | ||
<component id="97ced" class="javax.swing.JCheckBox" binding="createSCSSFile"> | ||
<constraints> | ||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<enabled value="true"/> | ||
<selected value="true"/> | ||
<text value="Create SCSS file?"/> | ||
</properties> | ||
</component> | ||
<vspacer id="8f1d9"> | ||
<constraints> | ||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
</vspacer> | ||
<component id="42946" class="javax.swing.JCheckBox" binding="createTwigFileCheckBox" default-binding="true"> | ||
<constraints> | ||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<selected value="true"/> | ||
<text value="Create Twig file?"/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</form> |
10 changes: 10 additions & 0 deletions
10
src/main/java/de/shyim/shopware6/ui/NewComponentDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package de.shyim.shopware6.ui; | ||
|
||
import javax.swing.*; | ||
|
||
public class NewComponentDialog { | ||
public JTextField componentName; | ||
public JCheckBox createSCSSFile; | ||
public JCheckBox createTwigFileCheckBox; | ||
public JPanel panel; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/de/shyim/shopware6/action/generator/NewChangelogAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package de.shyim.shopware6.action.generator | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.fileTypes.PlainTextFileType | ||
import com.intellij.openapi.project.DumbAwareAction | ||
import de.shyim.shopware6.action.generator.ui.NewChangelogDialogWrapper | ||
import de.shyim.shopware6.templates.ShopwareTemplates | ||
import git4idea.branch.GitBranchUtil | ||
import org.apache.commons.lang.StringUtils | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
class NewChangelogAction: DumbAwareAction("Create a Changelog", "Create a new Changelog file", AllIcons.FileTypes.Text) { | ||
override fun actionPerformed(e: AnActionEvent) { | ||
if (e.project == null) { | ||
return | ||
} | ||
|
||
val currentBranch = GitBranchUtil.getCurrentRepository(e.project!!)?.currentBranch | ||
var defaultTitle = "" | ||
var defaultTicket = "" | ||
|
||
if (currentBranch != null && currentBranch.name.startsWith("next-")) { | ||
val branchParts = currentBranch.name.split("/") | ||
|
||
if (branchParts.count() == 2) { | ||
defaultTicket = branchParts[0].uppercase() | ||
defaultTitle = StringUtils.capitalize(branchParts[1]) | ||
} | ||
} | ||
|
||
val dialog = NewChangelogDialogWrapper(defaultTitle, defaultTicket) | ||
val dialogResult = dialog.showAndGetConfig() ?: return | ||
|
||
val date = Date() | ||
val modifiedDate: String = SimpleDateFormat("yyyy-MM-dd").format(date) | ||
|
||
val fileName = modifiedDate + "-" + dialogResult.title.lowercase() + ".md" | ||
|
||
ActionUtil.buildFile( | ||
e, | ||
e.project!!, | ||
ShopwareTemplates.applyChangelogTemplate(e.project!!, dialogResult), | ||
fileName, | ||
PlainTextFileType.INSTANCE | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.