-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an action to create a new empty file
- Loading branch information
Showing
7 changed files
with
64 additions
and
21 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
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/dev/slint/ideaplugin/ide/actions/SlintCreateFileAction.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,36 @@ | ||
package dev.slint.ideaplugin.ide.actions | ||
|
||
import com.intellij.ide.actions.CreateFileFromTemplateAction | ||
import com.intellij.ide.actions.CreateFileFromTemplateDialog | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.actionSystem.DataContext | ||
import com.intellij.openapi.client.currentSession | ||
import com.intellij.openapi.project.DumbAware | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.VfsUtil | ||
import com.intellij.psi.PsiDirectory | ||
import dev.slint.ideaplugin.SlintBundle | ||
import dev.slint.ideaplugin.SlintIcons | ||
import org.jetbrains.annotations.Nls | ||
|
||
class SlintCreateFileAction : CreateFileFromTemplateAction(CAPTION, "", SlintIcons.SLINT), | ||
DumbAware { | ||
|
||
override fun getActionName(directory: PsiDirectory?, newName: String, templateName: String?): String = CAPTION | ||
|
||
override fun isAvailable(dataContext: DataContext): Boolean { | ||
if (!super.isAvailable(dataContext)) return false | ||
CommonDataKeys.PROJECT.getData(dataContext) ?: return false | ||
return true | ||
} | ||
|
||
override fun buildDialog(project: Project, directory: PsiDirectory, builder: CreateFileFromTemplateDialog.Builder) { | ||
builder.setTitle(CAPTION) | ||
.addKind(SlintBundle.message("list.item.empty.file"), SlintIcons.SLINT, "Slint File") | ||
} | ||
|
||
private companion object { | ||
@Nls | ||
private val CAPTION = SlintBundle.message("slint.file") | ||
} | ||
} |
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
Empty file.
5 changes: 5 additions & 0 deletions
5
src/main/resources/fileTemplates/internal/Slint File.slint.html
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,5 @@ | ||
<html> | ||
<body> | ||
Empty Slint file. | ||
</body> | ||
</html> |
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