Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Graphic/Table Wizards in generate actions #1770

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,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