Skip to content

Commit

Permalink
Merge pull request #1770 from Hannah-Sten/generate-menu
Browse files Browse the repository at this point in the history
Added Graphic/Table Wizards in generate actions
  • Loading branch information
PHPirates authored Feb 5, 2021
2 parents 18c7212 + 760ae9b commit 23d906a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@
<group id="texify.LatexGenerate" text="_LaTeX" description="Latex generation actions" popup="true">
<add-to-group group-id="GenerateGroup" anchor="last"/>

<!-- Table wizard -->
<action class="nl.hannahsten.texifyidea.action.wizard.table.LatexTableWizardAction" id="texify.TableWizardPopup" text="_Table..."
description="Shows a wizard to insert a table."/>

<!-- Figure/graphic wizard -->
<action class="nl.hannahsten.texifyidea.action.wizard.graphic.InsertGraphicWizardAction" id="texify.GraphicsWizardPopup" text="_Graphic..."
description="Shows a wizard to insert a graphic."/>

<!-- Dummy text -->
<action class="nl.hannahsten.texifyidea.action.wizard.ipsum.InsertDummyTextAction" id="texify.DummyTextWizardPopup" text="_Dummy Text..."
description="Shows a popup to insert dummy text."/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ class InsertGraphicWizardAction(val initialFile: File? = null) : AnAction() {
executeAction(file, project)
}

override fun update(e: AnActionEvent) {
super.update(e)

val file = e.getData(PlatformDataKeys.PSI_FILE)
val shouldDisplayMenu = file?.isLatexFile() == true
e.presentation.isVisible = shouldDisplayMenu
}

private fun Editor.insertGraphic(project: Project, data: InsertGraphicData, indent: String, tab: String = " ") {
// Only the graphics (non-centered).
val toInsert = if (data.center.not() && data.placeInFigure.not()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import nl.hannahsten.texifyidea.action.insert.InsertTable
import nl.hannahsten.texifyidea.lang.LatexPackage
import nl.hannahsten.texifyidea.util.caretOffset
import nl.hannahsten.texifyidea.util.currentTextEditor
import nl.hannahsten.texifyidea.util.files.isLatexFile
import nl.hannahsten.texifyidea.util.files.psiFile
import nl.hannahsten.texifyidea.util.insertUsepackage
import nl.hannahsten.texifyidea.util.lineIndentationByOffset
Expand Down Expand Up @@ -59,6 +60,14 @@ class LatexTableWizardAction : AnAction() {
executeAction(file, project)
}

override fun update(e: AnActionEvent) {
super.update(e)

val file = e.getData(PlatformDataKeys.PSI_FILE)
val shouldDisplayMenu = file?.isLatexFile() == true
e.presentation.isVisible = shouldDisplayMenu
}

/**
* Convert the table information to a latex table that can be inserted into the file.
*
Expand Down

0 comments on commit 23d906a

Please sign in to comment.