Skip to content

Commit

Permalink
Fix issue when accessing plugin settings
Browse files Browse the repository at this point in the history
  • Loading branch information
abeade committed Mar 14, 2019
1 parent 9fe073a commit 2f9a7fe
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 30 additions & 2 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
<idea-plugin>
<id>com.abeade.plugin.figma.import</id>
<name>Import figma resources</name>
<version>1.0.5</version>
<version>1.0.6</version>
<vendor email="[email protected]" url="https://github.com/abeade">Albert Beade</vendor>

<description><![CDATA[
Import figma resources to dpi resource folders.<br>
]]></description>

<change-notes><![CDATA[
Fix plugin settings.<br>
<b>1.0.6</b>
<ul>
<li>Fix issue when accessing plugin settings</li>
</ul>
<b>1.0.5</b>
<ul>
<li>Use global settings for the plugin</li>
</ul>
<b>1.0.4</b>
<ul>
<li>New settings option to configure the prefix used for purposed resource name</li>
<li>Show Icons at suffixes to show matched and not matched resources</li>
</ul>
<b>1.0.3</b>
<ul>
<li>Adds configurable override confirmation for existing resources</li>
</ul>
<b>1.0.2</b>
<ul>
<li>Allow mixed file types in same zip</li>
</ul>
<b>1.0.1</b>
<ul>
<li>Fixes issue with xxxhdpi resources</li>
</ul>
<b>1.0</b>
<ul>
<li>First version</li>
</ul>
]]>
</change-notes>

Expand Down
10 changes: 2 additions & 8 deletions src/com/abeade/plugin/figma/ImportSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ import javax.swing.JComponent

class ImportSettings : SearchableConfigurable {

private val panel = ImportSettingsPanel()
private val panel = ImportSettingsPanel(PropertiesComponent.getInstance())

override fun getDisplayName(): String? = "Figma import"

override fun getHelpTopic(): String? = "Figma import"

override fun getId(): String = "Figma import"

override fun enableSearch(p0: String?): Runnable? = null

override fun createComponent(): JComponent? = panel.createPanel(PropertiesComponent.getInstance())
override fun createComponent(): JComponent? = panel

override fun isModified(): Boolean = panel.isModified

Expand All @@ -27,8 +25,4 @@ class ImportSettings : SearchableConfigurable {
override fun reset() {
panel.reset()
}

override fun disposeUIResources() {
// Empty
}
}
42 changes: 0 additions & 42 deletions src/com/abeade/plugin/figma/ImportSettingsPanel.form

This file was deleted.

38 changes: 0 additions & 38 deletions src/com/abeade/plugin/figma/ImportSettingsPanel.java

This file was deleted.

47 changes: 47 additions & 0 deletions src/com/abeade/plugin/figma/ImportSettingsPanel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.abeade.plugin.figma

import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.ui.panel.ComponentPanelBuilder
import com.intellij.ui.layout.LCFlags
import com.intellij.ui.layout.panel
import javax.swing.BoxLayout
import javax.swing.JPanel
import javax.swing.JTextField

class ImportSettingsPanel(private val propertiesComponent: PropertiesComponent) : JPanel() {

private val prefixField: JTextField = JTextField()

init {
createPanel()
layout = BoxLayout(this, BoxLayout.Y_AXIS)
}

private fun createPanel() {
add(
panel(LCFlags.fillX) {
row("Resource prefix") { prefixField() }
row("") { ComponentPanelBuilder.createCommentComponent("Prefix used in purposed resource name. When empty no prefix will be added.", false)() }
}
)
}

val isModified: Boolean
get() = prefixField.text != getCurrentPrefix()

fun apply() {
propertiesComponent.setValue(ImportDialogWrapper.PREFIX_KEY, prefixField.text)
}

fun reset() {
prefixField.text = getCurrentPrefix()
}

private fun getCurrentPrefix(): String {
var prefix = propertiesComponent.getValue(ImportDialogWrapper.PREFIX_KEY)
if (prefix == null) {
prefix = ImportDialogWrapper.RESOURCE_PREFIX
}
return prefix
}
}

0 comments on commit 2f9a7fe

Please sign in to comment.