-
Notifications
You must be signed in to change notification settings - Fork 1
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
10 changed files
with
138 additions
and
20 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
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 |
---|---|---|
|
@@ -31,4 +31,4 @@ publishPlugin { | |
} | ||
|
||
group 'net.olegg' | ||
version '0.0.2' | ||
version '0.0.3' |
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,6 +1,6 @@ | ||
#Sat Feb 11 19:35:25 PST 2017 | ||
#Mon Feb 20 21:13:56 PST 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-all.zip |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.olegg.bodylookin | ||
|
||
/** | ||
* Created by olegg on 2/21/17. | ||
*/ | ||
object Constants { | ||
val ACTION_GROUP = "bodylookin.ActionGroup" | ||
val TOOL_WINDOW_ID = "bodylookin" | ||
} |
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,57 @@ | ||
package net.olegg.bodylookin.action | ||
|
||
import com.intellij.openapi.actionSystem.AnAction | ||
import com.intellij.openapi.actionSystem.AnActionEvent | ||
import com.intellij.openapi.actionSystem.CommonDataKeys | ||
import com.intellij.openapi.fileEditor.FileDocumentManager | ||
import com.intellij.openapi.wm.ToolWindowManager | ||
import net.olegg.bodylookin.Constants | ||
import net.olegg.bodylookin.isJson | ||
import net.olegg.bodylookin.toolwindow.BodylookinView | ||
|
||
/** | ||
* Created by olegg on 2/21/17. | ||
*/ | ||
class LoadAction : AnAction() { | ||
override fun actionPerformed(event: AnActionEvent) { | ||
val project = event.project | ||
if (project == null || project.isDefault || project.isDisposed) { | ||
return | ||
} | ||
|
||
val doc = event.getData(CommonDataKeys.EDITOR)?.document | ||
val file = event.getData(CommonDataKeys.VIRTUAL_FILE) | ||
val toolWindowManager = ToolWindowManager.getInstance(project) | ||
val toolWindow = toolWindowManager.getToolWindow(Constants.TOOL_WINDOW_ID) | ||
if (toolWindow.isVisible) { | ||
val content = toolWindow.contentManager.getContent(0)?.component as? BodylookinView ?: return | ||
if (doc != null) { | ||
content.loadJson(doc.text) | ||
} else if (file != null) { | ||
content.loadFile(file) | ||
} | ||
} else { | ||
toolWindow.show { | ||
val content = toolWindow.contentManager.getContent(0)?.component as? BodylookinView ?: return@show | ||
if (doc != null) { | ||
content.loadJson(doc.text) | ||
} else if (file != null) { | ||
content.loadFile(file) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun update(e: AnActionEvent) { | ||
val project = e.getData(CommonDataKeys.PROJECT) | ||
if (project == null || project.isDefault || project.isDisposed) { | ||
e.presentation.isEnabledAndVisible = false | ||
return | ||
} | ||
val doc = e.getData(CommonDataKeys.EDITOR)?.document | ||
val file = e.getData(CommonDataKeys.VIRTUAL_FILE) | ||
|
||
val docJson = doc != null && doc.textLength > 0 && FileDocumentManager.getInstance().getFile(doc).isJson | ||
e.presentation.isEnabledAndVisible = file.isJson || docJson | ||
} | ||
} |
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
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