From c8234b8896e1a5c0897fc61e141b733ee1f96bea Mon Sep 17 00:00:00 2001 From: zengkid Date: Fri, 1 May 2020 23:19:12 +0800 Subject: [PATCH] support 171+ version and remove Deprecated --- .../conf/TomcatConfigurationFactory.java | 6 +++ .../plugins/tomcat/runner/TomcatRunner.java | 4 +- .../plugins/tomcat/setting/TomcatSetting.java | 45 +++++++++---------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/poratu/idea/plugins/tomcat/conf/TomcatConfigurationFactory.java b/src/main/java/com/poratu/idea/plugins/tomcat/conf/TomcatConfigurationFactory.java index 424408e..c33c1b7 100644 --- a/src/main/java/com/poratu/idea/plugins/tomcat/conf/TomcatConfigurationFactory.java +++ b/src/main/java/com/poratu/idea/plugins/tomcat/conf/TomcatConfigurationFactory.java @@ -29,4 +29,10 @@ public RunConfiguration createTemplateConfiguration(@NotNull Project project) { public String getName() { return FACTORY_NAME; } + + @NotNull + @Override + public String getId() { + return getName(); + } } diff --git a/src/main/java/com/poratu/idea/plugins/tomcat/runner/TomcatRunner.java b/src/main/java/com/poratu/idea/plugins/tomcat/runner/TomcatRunner.java index 98f39c6..af59fb2 100644 --- a/src/main/java/com/poratu/idea/plugins/tomcat/runner/TomcatRunner.java +++ b/src/main/java/com/poratu/idea/plugins/tomcat/runner/TomcatRunner.java @@ -2,7 +2,7 @@ import com.intellij.execution.configurations.RunProfile; import com.intellij.execution.executors.DefaultRunExecutor; -import com.intellij.execution.runners.DefaultProgramRunner; +import com.intellij.execution.impl.DefaultJavaProgramRunner; import com.poratu.idea.plugins.tomcat.conf.TomcatRunConfiguration; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ * Date : 2017-02-17 * Time : 11:01 AM */ -public class TomcatRunner extends DefaultProgramRunner { +public class TomcatRunner extends DefaultJavaProgramRunner { private static final String RUNNER_ID = "SmartTomcatRunner"; @NotNull diff --git a/src/main/java/com/poratu/idea/plugins/tomcat/setting/TomcatSetting.java b/src/main/java/com/poratu/idea/plugins/tomcat/setting/TomcatSetting.java index e52f9d2..5a7039b 100644 --- a/src/main/java/com/poratu/idea/plugins/tomcat/setting/TomcatSetting.java +++ b/src/main/java/com/poratu/idea/plugins/tomcat/setting/TomcatSetting.java @@ -1,11 +1,11 @@ package com.poratu.idea.plugins.tomcat.setting; +import com.intellij.openapi.actionSystem.ActionToolbarPosition; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.AnActionButton; -import com.intellij.ui.AnActionButtonRunnable; import com.intellij.ui.ToolbarDecorator; +import com.intellij.util.ui.JBUI; import com.poratu.idea.plugins.tomcat.utils.PluginUtils; import javax.swing.*; @@ -41,33 +41,32 @@ public static TomcatSetting getInstance() { public void initComponent() { if (!inited) { - ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tomcatList).setAsUsualTopToolbar(); - decorator.setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton anActionButton) { + ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tomcatList) + .setToolbarPosition(ActionToolbarPosition.TOP) + .setPanelBorder(JBUI.Borders.empty()); + decorator.setAddAction(anActionButton -> { - DefaultListModel model = (DefaultListModel) tomcatList.getModel(); + DefaultListModel model = (DefaultListModel) tomcatList.getModel(); - VirtualFile virtualFile = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), null, null); - if (virtualFile == null) { // cancel to choose file - return; - } - String presentableUrl = virtualFile.getPresentableUrl(); + VirtualFile virtualFile = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), null, null); + if (virtualFile == null) { // cancel to choose file + return; + } + String presentableUrl = virtualFile.getPresentableUrl(); - TomcatInfo tomcatInfo = PluginUtils.getTomcatInfo(presentableUrl); - int size = model.size(); - if (model.contains(tomcatInfo)) { - TomcatInfo[] infos = new TomcatInfo[size]; - model.copyInto(infos); - int maxVersion = TomcatInfoConfigs.getInstance().getMaxVersion(tomcatInfo); - tomcatInfo.setNumber(maxVersion + 1); - } - model.add(size, tomcatInfo); - tomcatList.setSelectedIndex(size); + TomcatInfo tomcatInfo = PluginUtils.getTomcatInfo(presentableUrl); + int size = model.size(); + if (model.contains(tomcatInfo)) { + TomcatInfo[] infos = new TomcatInfo[size]; + model.copyInto(infos); + int maxVersion = TomcatInfoConfigs.getInstance().getMaxVersion(tomcatInfo); + tomcatInfo.setNumber(maxVersion + 1); + } + model.add(size, tomcatInfo); + tomcatList.setSelectedIndex(size); - } }); tomcatListPanel.add(decorator.createPanel(), BorderLayout.CENTER);