diff --git a/files/settings.png b/files/settings.png index 00d5cd8..4e7d9c7 100644 Binary files a/files/settings.png and b/files/settings.png differ diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index fa4d495..25201f4 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ cn.luojunhui.touchfish Touch Fish - 2.2 + 2.3 luojunhui @@ -10,7 +10,7 @@

If you have nothing to do, why don't you try reading with this plugin?

  1. Find the "Touch Fish" settings interface under ide settings.
  2. -
  3. Enter the absolute path of the text file.
  4. +
  5. Choose the text file.
  6. Enter page number and number of rows per page.
  7. Shortcut key ↑ read content up
  8. Shortcut ↓ read content down
  9. @@ -20,7 +20,7 @@

    如果你无事可作,为何不试试用此插件看书呢?

    1. 在ide设置下找到“Touch Fish”设置界面。
    2. -
    3. 输入文本的绝对路径
    4. +
    5. 选择你想要阅读的txt文件
    6. 输入页码和每次阅读多少行
    7. 快捷键↑向上读取内容
    8. 快捷键↓向下读取内容
    9. @@ -34,6 +34,7 @@ +
    10. v2.3 change input file path to select file on settings form
    11. v2.2 add change notes description in English
    12. V2.1 add plugin description in English and modify the text of the settings interface.
    13. V2.0 change the way to turn pages.
    14. diff --git a/src/config/BookConfigurable.java b/src/config/BookConfigurable.java index a547ae8..5eeff3b 100644 --- a/src/config/BookConfigurable.java +++ b/src/config/BookConfigurable.java @@ -84,7 +84,7 @@ public JComponent createComponent() { if (this.form == null) { this.form = new PluginSettingForm(); } - return this.form.getPluginSettingPanel(); + return this.form.getSettingPanel(); } /** diff --git a/src/config/PluginSettingForm.form b/src/config/PluginSettingForm.form index 55b2203..642601c 100644 --- a/src/config/PluginSettingForm.form +++ b/src/config/PluginSettingForm.form @@ -1,76 +1,71 @@
      - - + + + + + + + + - + - - - - - - + - + - + + - + - + - - - + + - - - + - + - + + - + - + - - + + + - + - + + - + - + - + + - - - - - - - - diff --git a/src/config/PluginSettingForm.java b/src/config/PluginSettingForm.java index b57f513..380d219 100644 --- a/src/config/PluginSettingForm.java +++ b/src/config/PluginSettingForm.java @@ -1,8 +1,11 @@ package config; +import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; +import com.intellij.openapi.ui.TextFieldWithBrowseButton; import com.intellij.openapi.util.text.StringUtil; import javax.swing.*; +import java.io.File; /** * PluginSettingForm.class @@ -11,30 +14,55 @@ * @author junhui */ public class PluginSettingForm { - private JPanel pluginSettingPanel; - private JTextField pathField; - private JTextField pageTextField; + private JPanel settingPanel; + private TextFieldWithBrowseButton chooseFileBtn; private JTextField pageSizeTextField; + private JTextField pageTextField; + private JLabel filePath; + private JLabel pageSize; + private JLabel curPage; + + public PluginSettingForm() { + this.init(); + } - public JPanel getPluginSettingPanel() { - return this.pluginSettingPanel; + public JPanel getSettingPanel() { + return this.settingPanel; } /** * 读取xml获取历史配置 */ - private void createUIComponents() { + private void init() { + //按钮绑定事件 + this.chooseFileBtn.addBrowseFolderListener("选择文件", null, null, + FileChooserDescriptorFactory.createSingleFileDescriptor("txt")); + + Config config = ConfigService.getInstance().getState(); String bookPath = config.getBookPath().trim(); if (StringUtil.isNotEmpty(bookPath)) { - this.pathField.setText(bookPath); - this.pageTextField.setText(String.valueOf(config.getPage())); + this.chooseFileBtn.getTextField().setText(bookPath); this.pageSizeTextField.setText(String.valueOf(config.getPageSize())); + this.pageTextField.setText(String.valueOf(config.getPage())); } } + private void openFileAndSetPath(int selectedMode, Boolean isSupportMultiSelect) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(selectedMode); + fileChooser.setMultiSelectionEnabled(isSupportMultiSelect); + fileChooser.showOpenDialog(null); + + File chooseFile = fileChooser.getSelectedFile(); + String bookPath = chooseFile.getAbsolutePath(); + this.chooseFileBtn.getTextField().setText(bookPath); + + } + + public String getBookPath() { - return this.pathField.getText(); + return this.chooseFileBtn.getTextField().getText(); } /** @@ -52,7 +80,7 @@ public int getPage() { } public void setBookPath(String s) { - this.pathField.setText(s); + this.chooseFileBtn.getTextField().setText(s); } public void setPage(int line) { @@ -76,4 +104,5 @@ public int getPageSize() { public void setPageSize(int rowCount) { this.pageSizeTextField.setText(String.valueOf(rowCount)); } + }