-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for file jump configuration
- Loading branch information
1 parent
d808f45
commit e9bfbbc
Showing
11 changed files
with
211 additions
and
9 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
33 changes: 33 additions & 0 deletions
33
src/main/java/io/github/linyimin/plugin/settings/SqlViewerSettingsState.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,33 @@ | ||
package io.github.linyimin.plugin.settings; | ||
|
||
import com.intellij.openapi.application.ApplicationManager; | ||
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; | ||
|
||
/** | ||
* @author yiminlin | ||
* @date 2023/04/16 14:18 | ||
**/ | ||
@State(name = "io.github.linyimin.plugin.settings.SqlViewerSettingsState", storages = {@Storage("mybatis-sql-config.xml")}) | ||
public class SqlViewerSettingsState implements PersistentStateComponent<SqlViewerSettingsState> { | ||
|
||
public boolean fileJumpEnable = true; | ||
|
||
@Override | ||
public @Nullable SqlViewerSettingsState getState() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public void loadState(@NotNull SqlViewerSettingsState state) { | ||
XmlSerializerUtil.copyBean(state, this); | ||
} | ||
|
||
public static SqlViewerSettingsState getInstance() { | ||
return ApplicationManager.getApplication().getService(SqlViewerSettingsState.class); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/io/github/linyimin/plugin/ui/SqlViewerSettingsPanel.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,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="io.github.linyimin.plugin.ui.SqlViewerSettingsPanel"> | ||
<grid id="27dc6" binding="myMainPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" 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> | ||
<grid id="e9527" binding="functionalityTitledBorderPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children/> | ||
</grid> | ||
<vspacer id="1632e"> | ||
<constraints> | ||
<grid row="2" 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> | ||
<grid id="73245" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> | ||
<margin top="0" left="0" bottom="0" right="0"/> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="4" use-parent-layout="false"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="cfc8c" class="javax.swing.JCheckBox" binding="fileJumpEnableBox"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
</constraints> | ||
<properties> | ||
<text value="Enable File Jump"/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</children> | ||
</grid> | ||
</form> |
93 changes: 93 additions & 0 deletions
93
src/main/java/io/github/linyimin/plugin/ui/SqlViewerSettingsPanel.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,93 @@ | ||
package io.github.linyimin.plugin.ui; | ||
|
||
import com.intellij.openapi.Disposable; | ||
import com.intellij.openapi.application.ex.ApplicationManagerEx; | ||
import com.intellij.openapi.options.Configurable; | ||
import com.intellij.openapi.options.ConfigurationException; | ||
import com.intellij.openapi.ui.MessageDialogBuilder; | ||
import com.intellij.openapi.ui.Messages; | ||
import com.intellij.ui.TitledSeparator; | ||
import io.github.linyimin.plugin.settings.SqlViewerSettingsState; | ||
import org.jetbrains.annotations.Nls; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
/** | ||
* @author yiminlin | ||
* @date 2023/04/16 14:30 | ||
**/ | ||
public class SqlViewerSettingsPanel implements Configurable, Disposable { | ||
private JPanel functionalityTitledBorderPanel; | ||
private JCheckBox fileJumpEnableBox; | ||
private JPanel myMainPanel; | ||
|
||
private boolean needRestart = false; | ||
|
||
public SqlViewerSettingsPanel() { | ||
init(); | ||
} | ||
|
||
private void init() { | ||
|
||
} | ||
|
||
@Override | ||
public @Nls(capitalization = Nls.Capitalization.Title) String getDisplayName() { | ||
return "Mybatis Sql Viewer"; | ||
} | ||
|
||
@Override | ||
public @Nullable JComponent createComponent() { | ||
return myMainPanel; | ||
} | ||
|
||
@Override | ||
public boolean isModified() { | ||
SqlViewerSettingsState state = SqlViewerSettingsState.getInstance(); | ||
|
||
needRestart = state.fileJumpEnable != fileJumpEnableBox.isSelected(); | ||
|
||
return needRestart; | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
SqlViewerSettingsState state = SqlViewerSettingsState.getInstance(); | ||
fileJumpEnableBox.setSelected(state.fileJumpEnable); | ||
} | ||
|
||
@Override | ||
public void apply() throws ConfigurationException { | ||
|
||
SqlViewerSettingsState state = SqlViewerSettingsState.getInstance(); | ||
|
||
state.fileJumpEnable = fileJumpEnableBox.isSelected(); | ||
|
||
if (!needRestart) { | ||
return; | ||
} | ||
|
||
int yesNo = MessageDialogBuilder.yesNo("Settings changed!", "Requires restarting the IDE to take effect. " + | ||
"Do you want to restart to apply the settings?") | ||
.yesText("Restart") | ||
.noText("Not Now").show(); | ||
|
||
if (yesNo == Messages.YES) { | ||
ApplicationManagerEx.getApplicationEx().restart(true); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void dispose() { | ||
|
||
} | ||
|
||
private void createUIComponents() { | ||
functionalityTitledBorderPanel = new JPanel(new BorderLayout()); | ||
TitledSeparator functionalitySeparator = new TitledSeparator("Functionality Settings"); | ||
functionalityTitledBorderPanel.add(functionalitySeparator, BorderLayout.CENTER); | ||
} | ||
} |
Empty file.
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