-
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.
implement configuration to toggle force built-in compiler option
- Loading branch information
1 parent
0b64d12
commit 9550691
Showing
5 changed files
with
135 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
47 changes: 47 additions & 0 deletions
47
src/main/java/net/labymod/intellij/singlehotswap/storage/SingleHotswapConfiguration.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,47 @@ | ||
package net.labymod.intellij.singlehotswap.storage; | ||
|
||
import com.intellij.openapi.components.PersistentStateComponent; | ||
import com.intellij.openapi.components.State; | ||
import com.intellij.openapi.components.Storage; | ||
import com.intellij.util.xmlb.XmlSerializerUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Objects; | ||
|
||
@State( name = "SingleHotswapConfiguration", storages = @Storage( "singlehotswap.xml" ) ) | ||
public class SingleHotswapConfiguration implements PersistentStateComponent<SingleHotswapConfiguration> { | ||
|
||
private boolean forceBuiltInCompiler = false; | ||
|
||
@Override | ||
public @Nullable SingleHotswapConfiguration getState( ) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void loadState( @NotNull SingleHotswapConfiguration languageConfiguration ) { | ||
XmlSerializerUtil.copyBean( languageConfiguration, this ); | ||
} | ||
|
||
@Override | ||
public boolean equals( Object o ) { | ||
if ( this == o ) return true; | ||
if ( o == null || this.getClass() != o.getClass() ) return false; | ||
SingleHotswapConfiguration that = (SingleHotswapConfiguration) o; | ||
return this.forceBuiltInCompiler == that.forceBuiltInCompiler; | ||
} | ||
|
||
@Override | ||
public int hashCode( ) { | ||
return Objects.hash( this.forceBuiltInCompiler ); | ||
} | ||
|
||
public boolean isForceBuiltInCompiler( ) { | ||
return this.forceBuiltInCompiler; | ||
} | ||
|
||
public void setForceBuiltInCompiler( boolean forceBuiltInCompiler ) { | ||
this.forceBuiltInCompiler = forceBuiltInCompiler; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/net/labymod/intellij/singlehotswap/storage/SingleHotswapConfigurationGui.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,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="net.labymod.intellij.singlehotswap.storage.SingleHotswapConfigurationGui"> | ||
<grid id="5007" binding="panel" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="3"> | ||
<constraints> | ||
<xy x="0" y="0" width="712" height="79"/> | ||
</constraints> | ||
<properties> | ||
<alignmentY value="0.0"/> | ||
<minimumSize width="-1" height="-1"/> | ||
<preferredSize width="-1" height="-1"/> | ||
</properties> | ||
<border type="none"/> | ||
<children> | ||
<component id="a729c" class="javax.swing.JCheckBox" binding="checkBoxForceBuiltInCompiler"> | ||
<constraints/> | ||
<properties> | ||
<selected value="false"/> | ||
<text value="Force Built-In Compiler"/> | ||
<toolTipText value="Increases the speed of a hotswap for Gradle projects by using Intellij's internal compiler for single hotswaps."/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</form> |
52 changes: 52 additions & 0 deletions
52
src/main/java/net/labymod/intellij/singlehotswap/storage/SingleHotswapConfigurationGui.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,52 @@ | ||
package net.labymod.intellij.singlehotswap.storage; | ||
|
||
import com.intellij.openapi.components.ServiceManager; | ||
import com.intellij.openapi.options.Configurable; | ||
import com.intellij.openapi.options.SearchableConfigurable; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
|
||
public class SingleHotswapConfigurationGui implements SearchableConfigurable, Configurable.NoScroll { | ||
|
||
private final SingleHotswapConfiguration state; | ||
|
||
private JPanel panel; | ||
|
||
private JCheckBox checkBoxForceBuiltInCompiler; | ||
|
||
public SingleHotswapConfigurationGui( ) { | ||
this.state = ServiceManager.getService( SingleHotswapConfiguration.class ); | ||
} | ||
|
||
@Override | ||
public @NotNull String getId( ) { | ||
return "SingleHotswapGui"; | ||
} | ||
|
||
@Override | ||
public String getDisplayName( ) { | ||
return "Single Hotswap"; | ||
} | ||
|
||
@Override | ||
public @Nullable JComponent createComponent( ) { | ||
return this.panel; | ||
} | ||
|
||
@Override | ||
public boolean isModified( ) { | ||
return this.state.isForceBuiltInCompiler() != this.checkBoxForceBuiltInCompiler.isSelected(); | ||
} | ||
|
||
@Override | ||
public void apply( ) { | ||
this.state.setForceBuiltInCompiler( this.checkBoxForceBuiltInCompiler.isSelected() ); | ||
} | ||
|
||
@Override | ||
public void reset( ) { | ||
this.checkBoxForceBuiltInCompiler.setSelected( this.state.isForceBuiltInCompiler() ); | ||
} | ||
} |
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