From 67710eca9372979fbb9facc7e14572def17da07e Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Fri, 19 Apr 2024 18:02:00 +0200 Subject: [PATCH] fix: corrected deprecated API (#254) Signed-off-by: Andre Dietisheim --- .../intellij/knative/func/FuncActionPipeline.java | 2 +- .../devtools/intellij/knative/func/FuncActionTask.java | 2 +- .../intellij/knative/func/RunFuncActionTask.java | 2 +- .../knative/tree/KnFunctionsTreeStructure.java | 4 +++- .../intellij/knative/tree/KnTreeStructure.java | 10 +++++----- .../ui/toolwindow/GettingStartedToolWindow.java | 4 +++- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionPipeline.java b/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionPipeline.java index 32ce56a7..2a386ded 100644 --- a/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionPipeline.java +++ b/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionPipeline.java @@ -48,7 +48,7 @@ public FuncActionPipeline(String name, Project project, Function function){ this.startTime = System.currentTimeMillis(); this.endTime = -1; this.actionTasks = new ArrayList<>(); - this.stateIcon = new Icon[]{new AnimatedIcon.FS()}; + this.stateIcon = new Icon[]{new AnimatedIcon.Default()}; this.state = new String[]{"run tasks ..."}; this.listenerList = new ArrayList<>(); } diff --git a/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionTask.java b/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionTask.java index 6ff5365a..c775b984 100644 --- a/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionTask.java +++ b/src/main/java/com/redhat/devtools/intellij/knative/func/FuncActionTask.java @@ -69,7 +69,7 @@ protected ProcessListener buildProcessListener() { @Override public void startNotified(@NotNull ProcessEvent event) { startTime = System.currentTimeMillis(); - stateIcon = new Icon[]{new AnimatedIcon.FS()}; + stateIcon = new Icon[]{new AnimatedIcon.Default()}; state = new String[]{""}; FuncActionTask.this.pipeline.fireChangeRunningStep(); } diff --git a/src/main/java/com/redhat/devtools/intellij/knative/func/RunFuncActionTask.java b/src/main/java/com/redhat/devtools/intellij/knative/func/RunFuncActionTask.java index 8b484ca0..e32782d7 100644 --- a/src/main/java/com/redhat/devtools/intellij/knative/func/RunFuncActionTask.java +++ b/src/main/java/com/redhat/devtools/intellij/knative/func/RunFuncActionTask.java @@ -40,7 +40,7 @@ protected ProcessListener buildProcessListener() { @Override public void startNotified(@NotNull ProcessEvent event) { startTime = System.currentTimeMillis(); - stateIcon = new Icon[]{new AnimatedIcon.FS()}; + stateIcon = new Icon[]{new AnimatedIcon.Default()}; state = new String[]{""}; pipeline.fireChangeRunningStep(); } diff --git a/src/main/java/com/redhat/devtools/intellij/knative/tree/KnFunctionsTreeStructure.java b/src/main/java/com/redhat/devtools/intellij/knative/tree/KnFunctionsTreeStructure.java index 55ca26d7..13475f6b 100644 --- a/src/main/java/com/redhat/devtools/intellij/knative/tree/KnFunctionsTreeStructure.java +++ b/src/main/java/com/redhat/devtools/intellij/knative/tree/KnFunctionsTreeStructure.java @@ -15,6 +15,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.project.ProjectUtil; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vfs.LocalFileSystem; @@ -230,7 +231,8 @@ private VirtualFile[] getModuleRoots(Module module) { roots.add(getModuleRootAsDirectory(contentRoot)); } if (roots.isEmpty()) { - roots.add(getModuleRootAsDirectory(LocalFileSystem.getInstance().findFileByPath(new File(module.getModuleFilePath()).getParent()))); + VirtualFile moduleDir = ProjectUtil.guessModuleDir(module); + roots.add(getModuleRootAsDirectory(moduleDir)); } return roots.toArray(new VirtualFile[roots.size()]); } diff --git a/src/main/java/com/redhat/devtools/intellij/knative/tree/KnTreeStructure.java b/src/main/java/com/redhat/devtools/intellij/knative/tree/KnTreeStructure.java index 2814df2f..78e3721e 100644 --- a/src/main/java/com/redhat/devtools/intellij/knative/tree/KnTreeStructure.java +++ b/src/main/java/com/redhat/devtools/intellij/knative/tree/KnTreeStructure.java @@ -14,6 +14,7 @@ import com.intellij.ide.util.treeView.NodeDescriptor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.Function; import com.redhat.devtools.intellij.common.tree.LabelAndIconDescriptor; @@ -33,7 +34,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import javax.swing.Icon; -import org.apache.commons.codec.binary.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -249,9 +249,9 @@ private boolean hasContextChanged(Config newConfig, Config currentConfig) { private boolean hasServerChanged(NamedContext newContext, NamedContext currentContext) { return newContext == null || currentContext == null - || !StringUtils.equals(currentContext.getContext().getCluster(), newContext.getContext().getCluster()) - || !StringUtils.equals(currentContext.getContext().getUser(), newContext.getContext().getUser()) - || !StringUtils.equals(currentContext.getContext().getNamespace(), newContext.getContext().getNamespace()); + || !StringUtil.equals(currentContext.getContext().getCluster(), newContext.getContext().getCluster()) + || !StringUtil.equals(currentContext.getContext().getUser(), newContext.getContext().getUser()) + || !StringUtil.equals(currentContext.getContext().getNamespace(), newContext.getContext().getNamespace()); } private boolean hasNewToken(NamedContext newContext, Config newConfig, NamedContext currentContext, Config currentConfig) { @@ -267,7 +267,7 @@ private boolean hasNewToken(NamedContext newContext, Config newConfig, NamedCont return false; } String currentToken = KubeConfigUtils.getUserToken(currentConfig, currentContext.getContext()); - return !StringUtils.equals(newToken, currentToken); + return !StringUtil.equals(newToken, currentToken); } protected void refresh() { diff --git a/src/main/java/com/redhat/devtools/intellij/knative/ui/toolwindow/GettingStartedToolWindow.java b/src/main/java/com/redhat/devtools/intellij/knative/ui/toolwindow/GettingStartedToolWindow.java index c19b77c2..55520507 100644 --- a/src/main/java/com/redhat/devtools/intellij/knative/ui/toolwindow/GettingStartedToolWindow.java +++ b/src/main/java/com/redhat/devtools/intellij/knative/ui/toolwindow/GettingStartedToolWindow.java @@ -19,6 +19,7 @@ import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.ex.ToolWindowManagerListener; import com.intellij.openapi.wm.impl.ToolWindowManagerImpl; +import com.intellij.ui.content.ContentManager; import com.redhat.devtools.intellij.common.gettingstarted.GettingStartedContent; import com.redhat.devtools.intellij.common.gettingstarted.GettingStartedCourse; import com.redhat.devtools.intellij.common.gettingstarted.GettingStartedCourseBuilder; @@ -38,7 +39,8 @@ public class GettingStartedToolWindow implements ToolWindowFactory { public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { toolWindow.setIcon(AllIcons.Toolwindows.Documentation); toolWindow.setStripeTitle("Getting Started"); - ((ToolWindowManagerImpl)ToolWindowManager.getInstance(project)).addToolWindowManagerListener(new ToolWindowManagerListener() { + ContentManager manager = toolWindow.getContentManager(); + project.getMessageBus().connect(manager).subscribe(ToolWindowManagerListener.TOPIC, new ToolWindowManagerListener() { @Override public void stateChanged(@NotNull ToolWindowManager toolWindowManager) { if (hasToShowToolWindow()) {