Skip to content

Commit

Permalink
Add Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
LiLittleCat committed Mar 21, 2023
1 parent 575a7e7 commit a160cfd
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 26 deletions.
36 changes: 18 additions & 18 deletions .idea/gradle.xml

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

8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pluginVersion = 1.0.3

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 202
pluginUntilBuild = 223.*
pluginUntilBuild =

# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
platformType = IC
Expand All @@ -27,3 +27,9 @@ kotlin.stdlib.default.dependency = false

# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.unsafe.configuration-cache = true


systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=7890
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=7890
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import java.util.function.Supplier;

/**
* @author LiLittleCat
* @link <a href="https://github.com/LiLittleCat">https://github.com/LiLittleCat</a>
* @author <a href="https://github.com/LiLittleCat">LiLittleCat</a>
* @since 2022/12/10
*/
public class ChatGPTBundle extends DynamicBundle {
Expand Down
85 changes: 85 additions & 0 deletions src/main/java/com/lilittlecat/chatgpt/setting/AddOrEditUrl.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.lilittlecat.chatgpt.setting.AddOrEditUrl">
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="436" height="297"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" 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>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="98af6">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="9538f" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="true" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="1" 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>
<component id="e7465" class="javax.swing.JButton" binding="buttonOK">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="OK"/>
</properties>
</component>
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Cancel"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
<grid id="e3588" 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>
<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>
<component id="45ebb" class="javax.swing.JTextField" binding="textField1" default-binding="true">
<constraints>
<grid row="1" column="0" row-span="1" col-span="2" 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>
<vspacer id="22b09">
<constraints>
<grid row="0" column="1" 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="f9ce4" 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="Url"/>
</properties>
</component>
</children>
</grid>
</children>
</grid>
</form>
61 changes: 61 additions & 0 deletions src/main/java/com/lilittlecat/chatgpt/setting/AddOrEditUrl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.lilittlecat.chatgpt.setting;

import javax.swing.*;
import java.awt.event.*;

public class AddOrEditUrl extends JDialog {
private JPanel contentPane;
private JButton buttonOK;
private JButton buttonCancel;
private JTextField textField1;

public AddOrEditUrl() {
setContentPane(contentPane);
setModal(true);
getRootPane().setDefaultButton(buttonOK);

buttonOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onOK();
}
});

buttonCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onCancel();
}
});

// call onCancel() when cross is clicked
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
onCancel();
}
});

// call onCancel() on ESCAPE
contentPane.registerKeyboardAction(new ActionListener() {
public void actionPerformed(ActionEvent e) {
onCancel();
}
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
}

private void onOK() {
// add your code here
dispose();
}

private void onCancel() {
// add your code here if necessary
dispose();
}

public static void main(String[] args) {
AddOrEditUrl dialog = new AddOrEditUrl();
dialog.pack();
dialog.setVisible(true);
System.exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.intellij.ui.components.JBList;
import com.intellij.ui.components.JBScrollPane;
import com.intellij.ui.components.JBTextArea;
import com.intellij.ui.table.JBTable;
import com.intellij.util.ui.FormBuilder;
import com.intellij.util.ui.ListTableModel;
import com.intellij.util.ui.UIUtil;
import com.lilittlecat.chatgpt.message.ChatGPTBundle;

Expand All @@ -18,8 +20,8 @@
public class ChatGPTSettingsComponent {
private final JPanel myMainPanel;
private final JBTextArea sessionToken = new JBTextArea();

private JBList<String> urlList;
private final JBTextArea defaultUrl = new JBTextArea();
private final JBTable urlTable = new JBTable();

public ChatGPTSettingsComponent() {
sessionToken.setFont(UIUtil.getLabelFont());
Expand All @@ -28,7 +30,9 @@ public ChatGPTSettingsComponent() {
ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
myMainPanel = FormBuilder.createFormBuilder()
.addLabeledComponent(new JBLabel(ChatGPTBundle.message("setting.session.token.label")), scrollPane, 1, false)
// .addLabeledComponent(new JBLabel(ChatGPTBundle.message("setting.session.token.label")), scrollPane, 1, false)
.addLabeledComponent(new JBLabel(ChatGPTBundle.message("setting.session.token.label")), sessionToken, 1, false)
.addLabeledComponent(new JBLabel("Table"), urlTable)
.addComponentFillVertically(new JPanel(), 0)
.getPanel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public JComponent createComponent() {
@Override
public boolean isModified() {
ChatGPTSettingsState settings = ChatGPTSettingsState.getInstance();
return !settingComponent.getSessionToken().equals(settings.sessionToken);
return !settingComponent.getSessionToken().equals(settings.sessionToken)
;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
parentId="tools"
instance="com.lilittlecat.chatgpt.setting.ChatGPTSettingsConfigurable"
id="com.lilittlecat.chatgpt.setting.ChatGPTSettingsConfigurable"
displayName="ChatGPT Tool"/>
displayName="ChatGPT Free"/>
<applicationService serviceImplementation="com.lilittlecat.chatgpt.setting.ChatGPTSettingsState"/>
</extensions>
</idea-plugin>

0 comments on commit a160cfd

Please sign in to comment.