-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
269 additions
and
1,140 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
44 changes: 40 additions & 4 deletions
44
src/main/kotlin/com/dvd/intellij/d2/ide/action/D2MessagesAction.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 |
---|---|---|
@@ -1,13 +1,49 @@ | ||
package com.dvd.intellij.d2.ide.action | ||
|
||
import com.dvd.intellij.d2.ide.toolWindow.D2ToolWindowService | ||
import com.dvd.intellij.d2.ide.utils.d2FileEditor | ||
import com.dvd.intellij.d2.ide.service.D2Service | ||
import com.dvd.intellij.d2.ide.utils.D2Bundle | ||
import com.intellij.execution.impl.ConsoleViewImpl | ||
import com.intellij.execution.ui.ConsoleViewContentType | ||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.DumbAware | ||
import com.intellij.openapi.util.Disposer | ||
import com.intellij.openapi.wm.ToolWindowId | ||
import com.intellij.openapi.wm.ToolWindowManager | ||
import com.intellij.ui.content.ContentFactory | ||
import com.intellij.ui.content.MessageView | ||
import java.awt.BorderLayout | ||
import javax.swing.JPanel | ||
|
||
class D2MessagesAction : AnAction() { | ||
private class D2MessagesAction : AnAction(), DumbAware { | ||
override fun actionPerformed(e: AnActionEvent) { | ||
e.project?.service<D2ToolWindowService>()?.show(e.d2FileEditor) | ||
val project = e.project ?: return | ||
|
||
val messageView = MessageView.getInstance(project) | ||
val displayName = D2Bundle.message("d2") | ||
|
||
var content = messageView.contentManager.findContent(displayName) | ||
if (content == null) { | ||
val panel = JPanel(BorderLayout()) | ||
val console = ConsoleViewImpl(project, true) | ||
panel.add(console.component, BorderLayout.CENTER) | ||
|
||
content = ContentFactory.getInstance().createContent(panel, displayName, true) | ||
messageView.contentManager.addContent(content) | ||
Disposer.register(content, console) | ||
} | ||
|
||
val console = content.component as ConsoleViewImpl | ||
console.clear() | ||
messageView.contentManager.setSelectedContent(content) | ||
for (command in service<D2Service>().map.values) { | ||
console.print(command.log, ConsoleViewContentType.LOG_INFO_OUTPUT) | ||
} | ||
|
||
val toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW) | ||
if (toolWindow != null && !toolWindow.isActive) { | ||
toolWindow.activate(null, false) | ||
} | ||
} | ||
} |
22 changes: 11 additions & 11 deletions
22
src/main/kotlin/com/dvd/intellij/d2/ide/action/D2ThemeChooser.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 |
---|---|---|
@@ -1,41 +1,41 @@ | ||
package com.dvd.intellij.d2.ide.action | ||
|
||
import com.dvd.intellij.d2.components.D2Theme | ||
import com.dvd.intellij.d2.ide.editor.images.D2FileEditorImpl.Companion.D2_FILE_THEME | ||
import com.dvd.intellij.d2.ide.editor.images.D2_FILE_THEME | ||
import com.dvd.intellij.d2.ide.service.D2Service | ||
import com.dvd.intellij.d2.ide.utils.D2Bundle | ||
import com.dvd.intellij.d2.ide.utils.d2FileEditor | ||
import com.intellij.icons.AllIcons | ||
import com.intellij.ide.BrowserUtil | ||
import com.intellij.openapi.actionSystem.* | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.DumbAware | ||
|
||
class D2ThemesActionGroup : ActionGroup() { | ||
private class D2ThemesActionGroup : ActionGroup() { | ||
override fun getChildren(e: AnActionEvent?): Array<AnAction> = arrayOf( | ||
*D2Theme.values().map(::D2ThemeAction).toTypedArray(), | ||
Separator(), | ||
OpenThemeOverviewAction() | ||
) | ||
} | ||
|
||
class D2ThemeAction(private val theme: D2Theme) : ToggleAction(theme.tName) { | ||
|
||
private class D2ThemeAction(private val theme: D2Theme) : ToggleAction(theme.tName), DumbAware { | ||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT | ||
|
||
override fun isSelected(e: AnActionEvent): Boolean = | ||
(e.d2FileEditor.getUserData(D2_FILE_THEME) ?: D2Theme.DEFAULT) == theme | ||
|
||
override fun setSelected(e: AnActionEvent, state: Boolean) { | ||
e.d2FileEditor.putUserData(D2_FILE_THEME, theme) | ||
e.d2FileEditor.refreshD2() | ||
service<D2Service>().compile(e.d2FileEditor) | ||
} | ||
} | ||
|
||
class OpenThemeOverviewAction : AnAction( | ||
private const val THEME_DOCS = "https://d2lang.com/tour/themes" | ||
|
||
private class OpenThemeOverviewAction : AnAction( | ||
D2Bundle.messagePointer("d2.open.theme.documentation"), | ||
AllIcons.General.Web | ||
) { | ||
companion object { | ||
private const val THEME_DOCS = "https://d2lang.com/tour/themes" | ||
} | ||
|
||
), DumbAware { | ||
override fun actionPerformed(e: AnActionEvent) = BrowserUtil.browse(THEME_DOCS) | ||
} |
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
105 changes: 0 additions & 105 deletions
105
src/main/kotlin/com/dvd/intellij/d2/ide/editor/images/D2FileEditorImpl.kt
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
src/main/kotlin/com/dvd/intellij/d2/ide/editor/images/D2FileEditorState.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.