Skip to content

Commit

Permalink
popup a dialog to tell user that the default url can't be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
LiLittleCat committed Mar 21, 2023
1 parent a59498a commit 3148630
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ public void addRow() {

@Override
public void removeRow(int idx) {
super.removeRow(idx);
// defaultUrlComboBox.remove(idx);
defaultUrlComboBox.removeItemAt(idx);
String item = getItem(idx);
if (item.equals(ChatGPTSettingsState.getInstance().defaultUrl)) {
// popup a dialog to tell user that the default url can't be removed
JOptionPane.showMessageDialog(null, ChatGPTBundle.message("chatgpt.settings.defaultUrlCanNotBeRemoved"));
} else {
super.removeRow(idx);
defaultUrlComboBox.removeItemAt(idx);
}
}

@NotNull
Expand Down Expand Up @@ -92,9 +97,9 @@ public void editingCanceled(ChangeEvent e) {
table.setPreferredSize(new Dimension(500, 200));
createComboBox();
myMainPanel = FormBuilder.createFormBuilder()
.addLabeledComponent(new JBLabel("Default website: "), defaultUrlComboBox, 1, false)
.addLabeledComponent(new JBLabel(ChatGPTBundle.message("default.url.message") ), defaultUrlComboBox, 1, false)
.addLabeledComponent(new SeparatorComponent(), new JPanel(), 1, false)
.addLabeledComponent(new JBLabel("Website list: "), table, 3, true)
.addLabeledComponent(new JBLabel(ChatGPTBundle.message("url.list.message")), table, 3, true)
.addComponentFillVertically(new JPanel(), 0)
.getPanel();
return myMainPanel;
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/messages/ChatGPTBundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name=ChatGPT Tool
setting.session.token.label=Session token:
setting.menu.text=ChatGPT Tool
browser.tab.name=https://chat.openai.com
url.list.message=URL list:
default.url=https://chat.openai.com
url1=https://baidu.com
url2=https://jd.com
url3=https://bilibili.com
url4=https://douyu.com

jBCefApp.not.supported=Not supported. Please check your IDE version.
jBCefApp.not.supported=Not supported. Please check your IDE version.
chatgpt.settings.defaultUrlCanNotBeRemoved=Default URL can not be removed. see http://baidu.com
default.url.message=Default URL:

0 comments on commit 3148630

Please sign in to comment.