Skip to content

Commit

Permalink
support 171+ version and remove Deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
zengkid committed May 1, 2020
1 parent 802ced5 commit c8234b8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,10 @@ public RunConfiguration createTemplateConfiguration(@NotNull Project project) {
public String getName() {
return FACTORY_NAME;
}

@NotNull
@Override
public String getId() {
return getName();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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<TomcatInfo> model = (DefaultListModel<TomcatInfo>) tomcatList.getModel();
DefaultListModel<TomcatInfo> model = (DefaultListModel<TomcatInfo>) 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);
Expand Down

0 comments on commit c8234b8

Please sign in to comment.