From fd5554a5c0a48211225bb62d424478bb619dacf3 Mon Sep 17 00:00:00 2001 From: azerr Date: Fri, 22 Sep 2023 17:02:51 +0200 Subject: [PATCH] feat: Create a Quarkus Dev Explorer in the IDE Fixes #1175 Signed-off-by: azerr --- .../intellij/quarkus/QuarkusBundle.java | 45 ++++++ .../quarkus/explorer/QuarkusActionNode.java | 35 +++++ .../quarkus/explorer/QuarkusExplorer.java | 126 +++++++++++++++++ .../quarkus/explorer/QuarkusProjectNode.java | 25 ++++ .../explorer/QuarkusToolWindowFactory.java | 24 ++++ .../quarkus/explorer/QuarkusTreeRenderer.java | 133 ++++++++++++++++++ .../actions/QuarkusDevStartAction.java | 57 ++++++++ .../explorer/actions/QuarkusTreeAction.java | 73 ++++++++++ .../quarkus/lang/QuarkusIconProvider.java | 3 +- .../intellij/quarkus/lang/QuarkusIcons.java | 26 ++++ .../lang/QuarkusServerIconProvider.java | 2 +- .../run/QuarkusRunConfigurationType.java | 3 +- src/main/resources/META-INF/plugin.xml | 7 + .../messages/QuarkusBundle.properties | 15 ++ 14 files changed, 570 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusBundle.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusActionNode.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusExplorer.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusProjectNode.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusToolWindowFactory.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusTreeRenderer.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusDevStartAction.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusTreeAction.java create mode 100644 src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIcons.java create mode 100644 src/main/resources/messages/QuarkusBundle.properties diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusBundle.java b/src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusBundle.java new file mode 100644 index 000000000..714b7cd3a --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/QuarkusBundle.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2023 Red Hat Inc. and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 + * + * Contributors: + * Red Hat Inc. - initial API and implementation + *******************************************************************************/ +package com.redhat.devtools.intellij.quarkus; + +import com.intellij.DynamicBundle; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.PropertyKey; + +import java.util.function.Supplier; + +/** + * Quarkus messages bundle. + */ +public final class QuarkusBundle extends DynamicBundle { + + @NonNls public static final String BUNDLE = "messages.QuarkusBundle"; + private static final QuarkusBundle INSTANCE = new QuarkusBundle(); + + private QuarkusBundle() { + super(BUNDLE); + } + + @NotNull + public static @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { + return INSTANCE.getMessage(key, params); + } + + @NotNull + public static Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) { + return INSTANCE.getLazyMessage(key, params); + } +} \ No newline at end of file diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusActionNode.java b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusActionNode.java new file mode 100644 index 000000000..52c4d4246 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusActionNode.java @@ -0,0 +1,35 @@ +package com.redhat.devtools.intellij.quarkus.explorer; + +import com.intellij.icons.AllIcons; +import com.intellij.openapi.module.Module; + +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; + +public class QuarkusActionNode extends DefaultMutableTreeNode { + + private final String name; + + private final Module module; + + public QuarkusActionNode(String name, Module module) { + this.name = name; + this.module = module; + } + + public String getName() { + return name; + } + + public Module getModule() { + return module; + } + + public String getDisplayName() { + return name; + } + + public Icon getIcon() { + return AllIcons.Actions.InlayGear; + } +} diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusExplorer.java b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusExplorer.java new file mode 100644 index 000000000..b8cfc9734 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusExplorer.java @@ -0,0 +1,126 @@ +package com.redhat.devtools.intellij.quarkus.explorer; + +import com.intellij.ide.DataManager; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.application.ReadAction; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.project.DumbService; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.SimpleToolWindowPanel; +import com.intellij.ui.AnimatedIcon; +import com.intellij.ui.DoubleClickListener; +import com.intellij.ui.treeStructure.Tree; +import com.intellij.util.concurrency.AppExecutorUtil; +import com.redhat.devtools.intellij.lsp4ij.console.explorer.LanguageServerTreeRenderer; +import com.redhat.devtools.intellij.quarkus.explorer.actions.QuarkusDevStartAction; +import com.redhat.microprofile.psi.quarkus.PsiQuarkusUtils; +import org.jetbrains.annotations.NotNull; + +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreePath; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; + +public class QuarkusExplorer extends SimpleToolWindowPanel implements Disposable { + + private final Tree tree; + private final Project project; + + public QuarkusExplorer(@NotNull Project project) { + super(true, true); + this.project = project; + tree = buildTree(); + this.setContent(tree); + load(); + } + + /** + * Builds the Language server tree + * + * @return Tree object of all language servers + */ + private Tree buildTree() { + + DefaultMutableTreeNode top = new DefaultMutableTreeNode("Quarkus projects"); + + Tree tree = new Tree(top); + tree.setRootVisible(false); + tree.setCellRenderer(new QuarkusTreeRenderer()); + + tree.putClientProperty(AnimatedIcon.ANIMATION_IN_RENDERER_ALLOWED, true); + + ((DefaultTreeModel) tree.getModel()).reload(top); + + + var doubleClickListener = new DoubleClickListener() { + @Override + protected boolean onDoubleClick(@NotNull MouseEvent event) { + executeAction(tree); + return false; + } + }; + doubleClickListener.installOn(tree); + + tree.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + executeAction(tree); + } + } + }); + + return tree; + } + + private void load() { + var action = ReadAction.nonBlocking(() -> { + DefaultMutableTreeNode root = (DefaultMutableTreeNode) ((DefaultTreeModel) tree.getModel()).getRoot(); + Module[] modules = ModuleManager.getInstance(project).getModules(); + for (Module javaProject : modules) { + if (PsiQuarkusUtils.isQuarkusProject(javaProject)) { + QuarkusProjectNode projectNode = new QuarkusProjectNode(javaProject); + root.add(projectNode); + // Fill Quarkus actions + projectNode.add(new QuarkusActionNode("Start", javaProject)); + } + } + ((DefaultTreeModel) tree.getModel()).reload(root); + }); + var executeInSmartMode = DumbService.getInstance(project).isDumb(); + if (executeInSmartMode) { + action = action.inSmartMode(project); + } + action + .submit(AppExecutorUtil.getAppExecutorService()); + } + + private static void executeAction(Tree tree) { + final TreePath path = tree.getSelectionPath(); + Object node = path.getLastPathComponent(); + if (node instanceof QuarkusActionNode) { + ActionManager am = ActionManager.getInstance(); + String actionNodeName = ((QuarkusActionNode) node).getName(); + + String actionId = QuarkusDevStartAction.ACTION_ID; + + AnAction action = am.getAction(actionId); + if (action != null) { + action.actionPerformed(new AnActionEvent(null, + DataManager.getInstance().getDataContext(tree), + ActionPlaces.UNKNOWN, new Presentation(), + am, 0)); + } + + } + } + + @Override + public void dispose() { + + } +} diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusProjectNode.java b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusProjectNode.java new file mode 100644 index 000000000..b501c7d00 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusProjectNode.java @@ -0,0 +1,25 @@ +package com.redhat.devtools.intellij.quarkus.explorer; + +import com.intellij.openapi.module.Module; +import com.redhat.devtools.intellij.quarkus.lang.QuarkusIcons; + +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; + +public class QuarkusProjectNode extends DefaultMutableTreeNode { + + private final Module module; + + public QuarkusProjectNode(Module module) { + this.module = module; + } + + public String getDisplayName() { + return module.getName(); + } + + public Icon getIcon() { + return QuarkusIcons.Quarkus; + } + +} diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusToolWindowFactory.java b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusToolWindowFactory.java new file mode 100644 index 000000000..824ef7e60 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusToolWindowFactory.java @@ -0,0 +1,24 @@ +package com.redhat.devtools.intellij.quarkus.explorer; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.wm.ToolWindow; +import com.intellij.openapi.wm.ToolWindowFactory; +import com.intellij.ui.content.Content; +import com.intellij.ui.content.ContentManager; +import com.redhat.devtools.intellij.lsp4ij.LanguageServerBundle; +import com.redhat.devtools.intellij.quarkus.QuarkusBundle; +import org.jetbrains.annotations.NotNull; + +public class QuarkusToolWindowFactory implements ToolWindowFactory { + + @Override + public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { + QuarkusExplorer explorer = new QuarkusExplorer(project); + ContentManager contentManager = toolWindow.getContentManager(); + Content content = contentManager.getFactory().createContent(explorer, + QuarkusBundle.message("quarkus.tool.window.display.name"), false); + content.setDisposer(explorer); + contentManager.addContent(content); + + } +} diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusTreeRenderer.java b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusTreeRenderer.java new file mode 100644 index 000000000..f28626773 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/QuarkusTreeRenderer.java @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2023 Red Hat Inc. and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 + * + * Contributors: + * Red Hat Inc. - initial API and implementation + *******************************************************************************/ +package com.redhat.devtools.intellij.quarkus.explorer; + +import com.intellij.ide.ui.UISettings; +import com.intellij.ui.ColoredTreeCellRenderer; +import com.intellij.ui.RelativeFont; +import com.intellij.ui.SimpleTextAttributes; +import com.intellij.util.ui.UIUtil; +import com.redhat.devtools.intellij.lsp4ij.ServerStatus; +import com.redhat.devtools.intellij.lsp4ij.console.explorer.LanguageServerProcessTreeNode; +import com.redhat.devtools.intellij.lsp4ij.console.explorer.LanguageServerTreeNode; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.awt.*; + +/** + * Quarkus tree nodes renderer. + *

+ * Some piece of code has been copied/pasted from https://github.com/JetBrains/intellij-community/blob/master/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/TestTreeRenderer.java and adapted for Language Server case. + */ +public class QuarkusTreeRenderer extends ColoredTreeCellRenderer { + + @NonNls + private static final String SPACE_STRING = " "; + private String myDurationText; + private Color myDurationColor; + private int myDurationWidth; + private int myDurationOffset; + + @Override + public void customizeCellRenderer(@NotNull final JTree tree, + final Object value, + final boolean selected, + final boolean expanded, + final boolean leaf, + final int row, + final boolean hasFocus) { + myDurationText = null; + myDurationColor = null; + myDurationWidth = 0; + myDurationOffset = 0; + + if (value instanceof QuarkusProjectNode) { + // Render of Quarkus project + QuarkusProjectNode projectNode = (QuarkusProjectNode) value; + setIcon(projectNode.getIcon()); + append(projectNode.getDisplayName()); + return; + } + + if (value instanceof QuarkusActionNode) { + // Render of Quarkus action + QuarkusActionNode actionNode = (QuarkusActionNode) value; + setIcon(actionNode.getIcon()); + append(actionNode.getDisplayName()); + return; + } + + /*if (value instanceof LanguageServerProcessTreeNode) { + // Render of language server process + LanguageServerProcessTreeNode languageProcessTreeNode = (LanguageServerProcessTreeNode) value; + setIcon(languageProcessTreeNode.getIcon()); + append(languageProcessTreeNode.getDisplayName()); + + if (languageProcessTreeNode.getServerStatus() == ServerStatus.starting + || languageProcessTreeNode.getServerStatus() == ServerStatus.stopping) { + // Display elapsed time when language server is starting/stopping + myDurationText = languageProcessTreeNode.getElapsedTime(); + final var durationText = myDurationText; + if (durationText != null) { + FontMetrics metrics = getFontMetrics(RelativeFont.SMALL.derive(getFont())); + myDurationWidth = metrics.stringWidth(durationText); + myDurationOffset = metrics.getHeight() / 2; // an empty area before and after the text + myDurationColor = selected ? UIUtil.getTreeSelectionForeground(hasFocus) : SimpleTextAttributes.GRAYED_ATTRIBUTES.getFgColor(); + } + } + return; + }*/ + //strange node + final String text = value.toString(); + //no icon + append(text != null ? text : SPACE_STRING, SimpleTextAttributes.GRAYED_ATTRIBUTES); + } + + @NotNull + @Override + public Dimension getPreferredSize() { + final Dimension preferredSize = super.getPreferredSize(); + if (myDurationWidth > 0) preferredSize.width += myDurationWidth + myDurationOffset; + return preferredSize; + } + + @Override + protected void paintComponent(Graphics g) { + UISettings.setupAntialiasing(g); + Shape clip = null; + int width = getWidth(); + int height = getHeight(); + if (isOpaque()) { + // paint background for expanded row + g.setColor(getBackground()); + g.fillRect(0, 0, width, height); + } + if (myDurationWidth > 0) { + width -= myDurationWidth + myDurationOffset; + if (width > 0 && height > 0) { + g.setColor(myDurationColor); + g.setFont(RelativeFont.SMALL.derive(getFont())); + g.drawString(myDurationText, width + myDurationOffset / 2, getTextBaseLine(g.getFontMetrics(), height)); + clip = g.getClip(); + g.clipRect(0, 0, width, height); + } + } + super.paintComponent(g); + // restore clip area if needed + if (clip != null) g.setClip(clip); + } +} + diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusDevStartAction.java b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusDevStartAction.java new file mode 100644 index 000000000..d88db86f1 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusDevStartAction.java @@ -0,0 +1,57 @@ +package com.redhat.devtools.intellij.quarkus.explorer.actions; + +import com.intellij.execution.ExecutorRegistryImpl; +import com.intellij.execution.RunManager; +import com.intellij.execution.RunnerAndConfigurationSettings; +import com.intellij.execution.configurations.RunConfigurationBase; +import com.intellij.execution.executors.DefaultRunExecutor; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.project.Project; +import com.intellij.ui.treeStructure.Tree; +import com.redhat.devtools.intellij.quarkus.run.QuarkusRunConfiguration; +import com.redhat.devtools.intellij.quarkus.run.QuarkusRunConfigurationType; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class QuarkusDevStartAction extends QuarkusTreeAction { + + public static final String ACTION_ID = "com.redhat.devtools.intellij.quarkus.explorer.actions.QuarkusDevStartAction"; + + public QuarkusDevStartAction() { + + } + + @Override + protected void actionPerformed(@NotNull Tree tree, @NotNull AnActionEvent e) { + Module module = getModule(tree); + if (module == null) { + return; + } + Project project = e.getProject(); + + RunnerAndConfigurationSettings quarkusSettings = null; + List list = RunManager.getInstance(project).getConfigurationSettingsList(QuarkusRunConfigurationType.class); + if (!list.isEmpty()) { + for (RunnerAndConfigurationSettings settings : list) { + QuarkusRunConfiguration configuration = (QuarkusRunConfiguration) settings.getConfiguration(); + if (module.equals(configuration.getModule())) { + quarkusSettings = settings; + break; + } + } + } + if (quarkusSettings == null) { + quarkusSettings = RunManager.getInstance(project).createConfiguration(module.getName(), QuarkusRunConfigurationType.class); + ((QuarkusRunConfiguration) quarkusSettings.getConfiguration()).setModule(module); + } + var dataContext = e.getDataContext(); + var executor = new DefaultRunExecutor(); + ExecutorRegistryImpl.RunnerHelper.run(project, quarkusSettings.getConfiguration(), quarkusSettings, dataContext, executor); + } + + +} diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusTreeAction.java b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusTreeAction.java new file mode 100644 index 000000000..74766cbc9 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/explorer/actions/QuarkusTreeAction.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * Copyright (c) 2023 Red Hat Inc. and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 + * + * Contributors: + * Red Hat Inc. - initial API and implementation + *******************************************************************************/ +package com.redhat.devtools.intellij.quarkus.explorer.actions; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.module.Module; +import com.intellij.ui.treeStructure.Tree; +import com.redhat.devtools.intellij.lsp4ij.LanguageServerWrapper; +import com.redhat.devtools.intellij.lsp4ij.console.explorer.LanguageServerProcessTreeNode; +import com.redhat.devtools.intellij.quarkus.explorer.QuarkusActionNode; +import org.jetbrains.annotations.NotNull; + +import javax.swing.tree.TreePath; +import java.awt.*; + +/** + * Base class for Actions processed from the Language Server tree. + */ +public abstract class QuarkusTreeAction extends AnAction { + + public final void actionPerformed(@NotNull AnActionEvent e) { + Tree tree = getTree(e); + if (tree == null) { + return; + } + actionPerformed(tree, e); + } + + /** + * Returns the language server tree and null otherwise. + * + * @param e the action event. + * @return the language server tree and null otherwise. + */ + private Tree getTree(AnActionEvent e) { + Component component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT); + if (component instanceof Tree) { + return (Tree) component; + } + return null; + } + + /** + * Returns the selected language server tree node and null otherwise. + * + * @param tree the tree. + * @return the selected language server tree node and null otherwise. + */ + protected Module getModule(Tree tree) { + TreePath path = tree.getSelectionPath(); + Object node = path != null ? path.getLastPathComponent() : null; + if (node instanceof QuarkusActionNode) { + return ((QuarkusActionNode) node).getModule(); + } + return null; + } + + protected abstract void actionPerformed(@NotNull Tree tree, @NotNull AnActionEvent e); + +} diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIconProvider.java b/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIconProvider.java index 1d089b9a7..426790577 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIconProvider.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIconProvider.java @@ -24,7 +24,6 @@ * Quarkus icon provider. */ public class QuarkusIconProvider extends IconProvider { - public static final Icon QUARKUS_ICON = IconLoader.findIcon("/quarkus_icon_rgb_16px_default.png", QuarkusIconProvider.class); @Nullable @Override @@ -34,7 +33,7 @@ public Icon getIcon(@NotNull PsiElement element, int flags) { VirtualFile file = element.getContainingFile().getVirtualFile(); if (QuarkusModuleUtil.isQuarkusPropertiesFile(file, element.getProject()) || QuarkusModuleUtil.isQuarkusYAMLFile(file, element.getProject())) { - return QUARKUS_ICON; + return QuarkusIcons.Quarkus; } } return null; diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIcons.java b/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIcons.java new file mode 100644 index 000000000..4f70d0d63 --- /dev/null +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusIcons.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2023 Red Hat Inc. and others. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 + * which is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 + * + * Contributors: + * Red Hat Inc. - initial API and implementation + *******************************************************************************/ +package com.redhat.devtools.intellij.quarkus.lang; + +import com.intellij.openapi.util.IconLoader; + +import javax.swing.*; + +/** + * Quarkus icons. + */ +public class QuarkusIcons { + + public static final Icon Quarkus = IconLoader.findIcon("/quarkus_icon_rgb_16px_default.png", QuarkusIcons.class); +} diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusServerIconProvider.java b/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusServerIconProvider.java index 4f7bc9ae6..dc5169e51 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusServerIconProvider.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/lang/QuarkusServerIconProvider.java @@ -24,6 +24,6 @@ public class QuarkusServerIconProvider implements ServerIconProvider { @Override public Icon getIcon() { - return QuarkusIconProvider.QUARKUS_ICON; + return QuarkusIcons.Quarkus; } } diff --git a/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusRunConfigurationType.java b/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusRunConfigurationType.java index 843f5a4f0..d16907f88 100644 --- a/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusRunConfigurationType.java +++ b/src/main/java/com/redhat/devtools/intellij/quarkus/run/QuarkusRunConfigurationType.java @@ -13,6 +13,7 @@ import com.intellij.execution.configurations.ConfigurationFactory; import com.intellij.execution.configurations.ConfigurationType; import com.intellij.openapi.util.IconLoader; +import com.redhat.devtools.intellij.quarkus.lang.QuarkusIcons; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -35,7 +36,7 @@ public String getConfigurationTypeDescription() { @Override public Icon getIcon() { - return IconLoader.findIcon("/quarkus_icon_rgb_16px_default.png", QuarkusRunConfigurationType.class); + return QuarkusIcons.Quarkus; } @NotNull diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index cc3157114..41620457e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -335,6 +335,10 @@ + @@ -582,5 +586,8 @@ + diff --git a/src/main/resources/messages/QuarkusBundle.properties b/src/main/resources/messages/QuarkusBundle.properties new file mode 100644 index 000000000..56f2ddf4a --- /dev/null +++ b/src/main/resources/messages/QuarkusBundle.properties @@ -0,0 +1,15 @@ +############################################################################### +# Copyright (c) 2023 Red Hat Inc. and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v2.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v20.html +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# Red Hat Inc. - initial API and implementation +############################################################################### + +## Quarkus explorer +quarkus.tool.window.display.name=Projects \ No newline at end of file