Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #65 - added the settings page with dot executable path.
- Loading branch information
Max Gorbunov
committed
Sep 3, 2014
1 parent
23eb1d4
commit 9886a88
Showing
7 changed files
with
142 additions
and
2 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
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,42 @@ | ||
package org.plantuml.idea.lang.settings; | ||
|
||
import com.intellij.openapi.components.*; | ||
import com.intellij.util.xmlb.XmlSerializerUtil; | ||
import net.sourceforge.plantuml.OptionFlags; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* @author Max Gorbunov | ||
*/ | ||
@State(name = "PlantUmlSettings", storages = {@Storage(file = StoragePathMacros.APP_CONFIG + "/plantuml.cfg")}) | ||
public class PlantUmlSettings implements PersistentStateComponent<PlantUmlSettings> { | ||
private String dotExecutable = null; | ||
|
||
public static PlantUmlSettings getInstance() { | ||
return ServiceManager.getService(PlantUmlSettings.class); | ||
} | ||
|
||
public String getDotExecutable() { | ||
return dotExecutable; | ||
} | ||
|
||
public void setDotExecutable(String dotExecutable) { | ||
this.dotExecutable = dotExecutable; | ||
if ("".equals(dotExecutable)) { | ||
this.dotExecutable = null; | ||
} | ||
OptionFlags.getInstance().setDotExecutable(this.dotExecutable); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public PlantUmlSettings getState() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void loadState(PlantUmlSettings state) { | ||
XmlSerializerUtil.copyBean(state, this); | ||
OptionFlags.getInstance().setDotExecutable(dotExecutable); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/org/plantuml/idea/lang/settings/PlantUmlSettingsPage.form
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,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.plantuml.idea.lang.settings.PlantUmlSettingsPage"> | ||
<grid id="27dc6" binding="panel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<xy x="20" y="20" width="500" height="400"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="36d0" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Graphviz dot executable:"/> | ||
</properties> | ||
</component> | ||
<vspacer id="68158"> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
</vspacer> | ||
<component id="c9516" class="javax.swing.JTextField" binding="textFieldDotExecutable"> | ||
<constraints> | ||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="-1"/> | ||
</grid> | ||
</constraints> | ||
<properties/> | ||
</component> | ||
</children> | ||
</grid> | ||
</form> |
53 changes: 53 additions & 0 deletions
53
src/org/plantuml/idea/lang/settings/PlantUmlSettingsPage.java
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,53 @@ | ||
package org.plantuml.idea.lang.settings; | ||
|
||
import com.intellij.openapi.options.Configurable; | ||
import com.intellij.openapi.options.ConfigurationException; | ||
import org.jetbrains.annotations.Nls; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
|
||
/** | ||
* @author Max Gorbunov | ||
*/ | ||
public class PlantUmlSettingsPage implements Configurable { | ||
private JPanel panel; | ||
private JTextField textFieldDotExecutable; | ||
|
||
@Nls | ||
@Override | ||
public String getDisplayName() { | ||
return "PlantUML"; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public String getHelpTopic() { | ||
return null; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public JComponent createComponent() { | ||
return panel; | ||
} | ||
|
||
@Override | ||
public boolean isModified() { | ||
return !textFieldDotExecutable.getText().equals(PlantUmlSettings.getInstance().getDotExecutable()); | ||
} | ||
|
||
@Override | ||
public void apply() throws ConfigurationException { | ||
PlantUmlSettings.getInstance().setDotExecutable(textFieldDotExecutable.getText()); | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
textFieldDotExecutable.setText(PlantUmlSettings.getInstance().getDotExecutable()); | ||
} | ||
|
||
@Override | ||
public void disposeUIResources() { | ||
} | ||
} |
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