Skip to content

Commit

Permalink
fix: replaced helm png by svg, use resized, not scaled icon (redhat-d…
Browse files Browse the repository at this point in the history
…eveloper#874) (redhat-developer#920)

Signed-off-by: Andre Dietisheim <[email protected]>
  • Loading branch information
adietish authored Oct 2, 2024
1 parent a71743b commit 90bf911
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import com.intellij.ide.util.treeView.NodeDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.util.IconUtil;
import com.redhat.devtools.intellij.common.tree.LabelAndIconDescriptor;
import org.jboss.tools.intellij.openshift.ui.SwingUtils;
import java.util.function.Supplier;
import javax.swing.Icon;
import org.jboss.tools.intellij.openshift.ui.helm.ChartIcons;
import org.jboss.tools.intellij.openshift.utils.odo.Binding;
import org.jboss.tools.intellij.openshift.utils.odo.Component;
Expand All @@ -23,9 +25,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.Icon;
import java.util.function.Supplier;

public class DescriptorFactory {

private static final Supplier<Icon> CLUSTER_ICON = () -> IconLoader.findIcon("/images/cluster.svg", ApplicationsTreeStructure.class);
Expand Down Expand Up @@ -161,7 +160,7 @@ public class DescriptorFactory {
releaseNode,
releaseNode::getName,
() -> "Helm Release",
() -> SwingUtils.scaleIcon(ICON_WIDTH, ChartIcons.getIcon(releaseNode.getRelease())),
() -> IconUtil.resizeSquared(ChartIcons.getIcon(releaseNode.getRelease()), ICON_WIDTH),
parentDescriptor);
} else if (element instanceof HelmRepositoriesNode) {
HelmRepositoriesNode helmRepositoriesNode = (HelmRepositoriesNode) element;
Expand All @@ -170,7 +169,7 @@ public class DescriptorFactory {
helmRepositoriesNode,
helmRepositoriesNode::getName,
() -> "Repositories",
() -> SwingUtils.scaleIcon(ICON_WIDTH, ChartIcons.getHelmIcon()),
() -> IconUtil.resizeSquared(ChartIcons.getHelmIcon(), ICON_WIDTH),
parentDescriptor);
} else if (element instanceof HelmRepositoryNode) {
HelmRepositoryNode helmRepositoryNode = (HelmRepositoryNode) element;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
public class ChartIcons {

private static final Path BASE_PATH = Paths.get("images", "helm");
private static final String HELM_ICON = "helm.png";
private static final String HELM_ICON = "helm.svg";

public static Icon getHelmIcon() {
// IC-2023.3: IconManager.getInstance().getIcon(BASE_PATH.resolve(HELM_ICON_SVG).toString(), ChartIcons.class.getClassLoader())
return IconManager.getInstance().getIcon(BASE_PATH.resolve(HELM_ICON).toString(), ChartIcons.class);
}

Expand All @@ -41,8 +42,9 @@ private static Icon getIcon(String name) {
.filter((IconExpression available) -> available.isMatching(name))
.findFirst();
return found
// IC-2023.3: IconManager.getInstance().getIcon(BASE_PATH.resolve(HELM_ICON_SVG).toString(), ChartIcons.class.getClassLoader())
.map(iconExpression -> IconManager.getInstance().getIcon(iconExpression.filename, ChartIcons.class))
.orElseGet(ChartIcons::getHelmIcon);
.orElseGet(ChartIcons::getHelmIcon);
}

private enum IconExpression {
Expand Down
Binary file removed src/main/resources/images/helm/helm.png
Binary file not shown.
131 changes: 68 additions & 63 deletions src/main/resources/images/helm/helm.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 90bf911

Please sign in to comment.