mirror of
https://github.com/carlrobertoh/ProxyAI.git
synced 2026-05-09 11:01:22 +00:00
Gather icons in one place
This commit is contained in:
parent
8e4d836e08
commit
53e8ceeb06
7 changed files with 34 additions and 28 deletions
|
|
@ -6,14 +6,14 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
|||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import ee.carlrobert.chatgpt.ide.settings.SettingsState;
|
||||
import icons.SdkIcons;
|
||||
import icons.Icons;
|
||||
|
||||
public class ActionGroup extends DefaultActionGroup {
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent event) {
|
||||
Editor editor = event.getData(PlatformDataKeys.EDITOR);
|
||||
event.getPresentation().setIcon(SdkIcons.Sdk_default_icon);
|
||||
event.getPresentation().setIcon(Icons.DefaultIcon);
|
||||
Project project = event.getProject();
|
||||
boolean menuAllowed = false;
|
||||
if (editor != null && project != null) {
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ import ee.carlrobert.chatgpt.EmptyCallback;
|
|||
import ee.carlrobert.chatgpt.client.ApiClient;
|
||||
import ee.carlrobert.chatgpt.ide.settings.SettingsConfigurable;
|
||||
import ee.carlrobert.chatgpt.ide.settings.SettingsState;
|
||||
import icons.Icons;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
|
|
@ -47,14 +47,14 @@ public class ToolWindowService {
|
|||
if (isLandingViewVisible) {
|
||||
removeAll();
|
||||
}
|
||||
addIconLabel("/icons/user-icon.png", "User:");
|
||||
addIconLabel(Icons.UserImageIcon, "User:");
|
||||
addSpacing(8);
|
||||
scrollablePanel.add(createTextArea(userMessage, true));
|
||||
}
|
||||
|
||||
public void sendMessage(String prompt, Project project, @Nullable EmptyCallback scrollToBottom) {
|
||||
addSpacing(16);
|
||||
addIconLabel("/icons/chatgpt-icon.png", "ChatGPT:");
|
||||
addIconLabel(Icons.DefaultImageIcon, "ChatGPT:");
|
||||
addSpacing(8);
|
||||
|
||||
var secretKey = SettingsState.getInstance().secretKey;
|
||||
|
|
@ -87,7 +87,7 @@ public class ToolWindowService {
|
|||
|
||||
var imageIconPanel = new JPanel();
|
||||
imageIconPanel.setLayout(new GridBagLayout());
|
||||
var imageIconLabel = new JLabel(new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/sun-icon.png"))));
|
||||
var imageIconLabel = new JLabel(Icons.SunImageIcon);
|
||||
imageIconLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||
imageIconPanel.add(imageIconLabel);
|
||||
scrollablePanel.add(imageIconPanel);
|
||||
|
|
@ -118,7 +118,7 @@ public class ToolWindowService {
|
|||
scrollablePanel.add(Box.createVerticalStrut(height));
|
||||
}
|
||||
|
||||
public void addIconLabel(String path, String text) {
|
||||
scrollablePanel.add(justifyLeft(createIconLabel(Objects.requireNonNull(getClass().getResource(path)), text)));
|
||||
public void addIconLabel(ImageIcon imageIcon, String text) {
|
||||
scrollablePanel.add(justifyLeft(createIconLabel(imageIcon, text)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package ee.carlrobert.chatgpt.ide.toolwindow;
|
|||
import com.intellij.ui.JBColor;
|
||||
import java.awt.Component;
|
||||
import java.awt.Font;
|
||||
import java.net.URL;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLabel;
|
||||
|
|
@ -24,8 +23,8 @@ public class ToolWindowUtil {
|
|||
return textArea;
|
||||
}
|
||||
|
||||
public static JLabel createIconLabel(URL iconLocation, String text) {
|
||||
var iconLabel = new JLabel(new ImageIcon(iconLocation));
|
||||
public static JLabel createIconLabel(ImageIcon imageIcon, String text) {
|
||||
var iconLabel = new JLabel(imageIcon);
|
||||
iconLabel.setText(text);
|
||||
iconLabel.setFont(iconLabel.getFont().deriveFont(iconLabel.getFont().getStyle() | Font.BOLD));
|
||||
iconLabel.setIconTextGap(8);
|
||||
|
|
|
|||
|
|
@ -2,17 +2,14 @@ package ee.carlrobert.chatgpt.ide.toolwindow.components;
|
|||
|
||||
import com.intellij.ui.JBColor;
|
||||
import ee.carlrobert.chatgpt.EmptyCallback;
|
||||
import icons.Icons;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.Objects;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTextArea;
|
||||
|
|
@ -47,11 +44,11 @@ public class TextArea extends JTextArea {
|
|||
}
|
||||
|
||||
private JButton createSubmitButton(ActionListener submitButtonListener) {
|
||||
var imageIcon = new ImageIcon(Objects.requireNonNull(getClass().getResource("/icons/send-icon.png")));
|
||||
var button = new JButton(imageIcon);
|
||||
var sendIcon = Icons.SendImageIcon;
|
||||
var button = new JButton(sendIcon);
|
||||
button.setBorder(BorderFactory.createEmptyBorder());
|
||||
button.setContentAreaFilled(false);
|
||||
button.setPreferredSize(new Dimension(imageIcon.getIconWidth(), imageIcon.getIconHeight()));
|
||||
button.setPreferredSize(new Dimension(sendIcon.getIconWidth(), sendIcon.getIconHeight()));
|
||||
button.addActionListener(submitButtonListener);
|
||||
return button;
|
||||
}
|
||||
|
|
|
|||
19
src/main/java/icons/Icons.java
Normal file
19
src/main/java/icons/Icons.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package icons;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import java.util.Objects;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class Icons {
|
||||
|
||||
public static final Icon DefaultIcon = IconLoader.getIcon("/icons/chatgpt-icon.svg", Icons.class);
|
||||
public static final ImageIcon DefaultImageIcon = getImageIcon("/icons/chatgpt-icon.png");
|
||||
public static final ImageIcon SendImageIcon = getImageIcon("/icons/send-icon.png");
|
||||
public static final ImageIcon SunImageIcon = getImageIcon("/icons/sun-icon.png");
|
||||
public static final ImageIcon UserImageIcon = getImageIcon("/icons/user-icon.png");
|
||||
|
||||
private static ImageIcon getImageIcon(String path) {
|
||||
return new ImageIcon(Objects.requireNonNull(Icons.class.getResource(path)));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package icons;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import javax.swing.Icon;
|
||||
|
||||
public class SdkIcons {
|
||||
|
||||
public static final Icon Sdk_default_icon = IconLoader.getIcon("/icons/chatgpt-icon.svg", SdkIcons.class);
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
class="ee.carlrobert.chatgpt.ide.action.AskAction"
|
||||
text="Ask ChatGPT"
|
||||
description="TBD"
|
||||
icon="SdkIcons.Sdk_default_icon">
|
||||
icon="Icons.DefaultIcon">
|
||||
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue