Skip to content

Commit

Permalink
remove some code
Browse files Browse the repository at this point in the history
  • Loading branch information
fatjyc committed Mar 26, 2021
1 parent a23ce7e commit baeb3ad
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import dev.nocalhost.plugin.intellij.exception.NocalhostExecuteCmdException;
import dev.nocalhost.plugin.intellij.exception.NocalhostNotifier;
import dev.nocalhost.plugin.intellij.topic.DevSpaceListUpdatedNotifier;
import dev.nocalhost.plugin.intellij.utils.KubeConfigUtil;
import lombok.SneakyThrows;

public class InstallAppTask extends Task.Backgroundable {
Expand All @@ -58,10 +57,10 @@ public class InstallAppTask extends Task.Backgroundable {
private final Project project;
private final DevSpace devSpace;
private final Application application;
private NhctlInstallOptions opts;
private final NhctlInstallOptions opts;

private NhctlCommand nhctlCommand = ServiceManager.getService(NhctlCommand.class);
String productPagePort;
private final NhctlCommand nhctlCommand = ServiceManager.getService(NhctlCommand.class);
private String productPagePort;

public InstallAppTask(@Nullable Project project, DevSpace devSpace, Application application, NhctlInstallOptions opts) {
super(project, "Installing application: " + application.getContext().getApplicationName(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
}

private void errorPrint(String title, String contentMsg, String eMessage) {
NocalhostErrorWindow nocalhostErrorWindow = new NocalhostErrorWindow(project, toolWindow, title, contentMsg, eMessage);
NocalhostErrorWindow nocalhostErrorWindow = new NocalhostErrorWindow(project, title, contentMsg, eMessage);
ContentManager contentManager = toolWindow.getContentManager();
Content content = ContentFactory.SERVICE.getInstance().createContent(nocalhostErrorWindow.getPanel(), nocalhostErrorWindow.getTitle(), false);
contentManager.addContent(content);
contentManager.setSelectedContent(content);
}

private void createOutputWindow() {
NocalhostOutputWindow nocalhostOutputWindow = new NocalhostOutputWindow(project, toolWindow);
NocalhostOutputWindow nocalhostOutputWindow = new NocalhostOutputWindow(project);

ContentManager contentManager = toolWindow.getContentManager();
Content content = ContentFactory.SERVICE.getInstance().createContent(nocalhostOutputWindow.getPanel(), "OUTPUT", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,16 @@

public class NocalhostSettingComponent {
private final JPanel settingPanel;
private final JBTextField nhctlField;
private final TextFieldWithBrowseButton nhctlBinary;
private final JButton nhctlTestButton;
private final JPanel nhctlPanel;
private final JBTextField kubeField;
private final TextFieldWithBrowseButton kubectlBinary;
private final JButton kubectlTestButton;
private final JPanel kubectlPanel;
private final JBTextArea showVersion;


public NocalhostSettingComponent() {
nhctlField = new JBTextField();
JBTextField nhctlField = new JBTextField();
nhctlField.getEmptyText().appendText("nhctl");
nhctlBinary = new TextFieldWithBrowseButton(nhctlField);
kubeField = new JBTextField();
JBTextField kubeField = new JBTextField();
kubeField.getEmptyText().appendText("kubectl");
kubectlBinary = new TextFieldWithBrowseButton(kubeField);
nhctlBinary.addBrowseFolderListener("", "Select nhctl binary", null,
Expand All @@ -57,14 +51,14 @@ public NocalhostSettingComponent() {
kubectlBinary.addBrowseFolderListener("", "Select kubectl binary", null,
FileChooseUtil.singleFileChooserDescriptor(),
TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT);
nhctlTestButton = new JButton("Test");
JButton nhctlTestButton = new JButton("Test");
nhctlTestButton.addActionListener(new TestNhctlListener());
nhctlPanel = new JPanel(new BorderLayout());
JPanel nhctlPanel = new JPanel(new BorderLayout());
nhctlPanel.add(nhctlBinary, BorderLayout.CENTER);
nhctlPanel.add(nhctlTestButton, BorderLayout.EAST);
kubectlTestButton = new JButton("Test");
JButton kubectlTestButton = new JButton("Test");
kubectlTestButton.addActionListener(new TestKubectlListener());
kubectlPanel = new JPanel(new BorderLayout());
JPanel kubectlPanel = new JPanel(new BorderLayout());
kubectlPanel.add(kubectlBinary, BorderLayout.CENTER);
kubectlPanel.add(kubectlTestButton, BorderLayout.EAST);

Expand Down Expand Up @@ -115,12 +109,10 @@ public void actionPerformed(ActionEvent e) {
String nhctl = StringUtils.isBlank(nhctlBinary.getText()) ? "nhctl" : nhctlBinary.getText();
final Map<String, String> environment = new HashMap<>(EnvironmentUtil.getEnvironmentMap());
environment.put("DISABLE_SPINNER", "true");
if (SystemInfo.isMac || SystemInfo.isLinux) {
if (StringUtils.contains(nhctl, "/")) {
String path = environment.get("PATH");
path = nhctl.substring(0, nhctl.lastIndexOf("/")) + ":" + path;
environment.put("PATH", path);
}
if ((SystemInfo.isMac || SystemInfo.isLinux) && StringUtils.contains(nhctl, "/")) {
String path = environment.get("PATH");
path = nhctl.substring(0, nhctl.lastIndexOf("/")) + ":" + path;
environment.put("PATH", path);
}
GeneralCommandLine commandLine = new GeneralCommandLine(Lists.newArrayList(nhctl, "version")).withEnvironment(environment);
commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset());
Expand All @@ -143,12 +135,10 @@ public void actionPerformed(ActionEvent e) {
String kubectl = StringUtils.isBlank(kubectlBinary.getText()) ? "kubectl" : kubectlBinary.getText();
final Map<String, String> environment = new HashMap<>(EnvironmentUtil.getEnvironmentMap());
environment.put("DISABLE_SPINNER", "true");
if (SystemInfo.isMac || SystemInfo.isLinux) {
if (StringUtils.contains(kubectl, "/")) {
String path = environment.get("PATH");
path = kubectl.substring(0, kubectl.lastIndexOf("/")) + ":" + path;
environment.put("PATH", path);
}
if ((SystemInfo.isMac || SystemInfo.isLinux) && StringUtils.contains(kubectl, "/")) {
String path = environment.get("PATH");
path = kubectl.substring(0, kubectl.lastIndexOf("/")) + ":" + path;
environment.put("PATH", path);
}
GeneralCommandLine commandLine = new GeneralCommandLine(Lists.newArrayList(kubectl, "version")).withEnvironment(environment);
commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.ui.JBColor;
import com.intellij.ui.components.JBScrollPane;

Expand Down Expand Up @@ -41,15 +40,12 @@ public class NocalhostWindow {
private static final Logger LOG = Logger.getInstance(NocalhostWindow.class);

private final Project project;
private final ToolWindow toolWindow;

private SimpleToolWindowPanel panel;
private final SimpleToolWindowPanel panel;
private NocalhostTree tree;
private JBScrollPane scrollPane;

public NocalhostWindow(Project project, ToolWindow toolWindow) {
public NocalhostWindow(Project project) {
this.project = project;
this.toolWindow = toolWindow;

checkNocalhostVersion();

Expand Down Expand Up @@ -110,7 +106,7 @@ private void toggleContent() {
if (StringUtils.isNotBlank(jwt)) {
tree = new NocalhostTree(project);
tree.updateDevSpaces();
scrollPane = new JBScrollPane(tree);
JBScrollPane scrollPane = new JBScrollPane(tree);
scrollPane.setBorder(new TopLineBorder(new JBColor(0xD5D5D5, 0x323232), 1));
panel.add(scrollPane);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class NocalhostWindowFactory implements ToolWindowFactory, DumbAware {
@Override
public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
NocalhostWindow nocalhostWindow = new NocalhostWindow(project, toolWindow);
NocalhostWindow nocalhostWindow = new NocalhostWindow(project);

ContentManager contentManager = toolWindow.getContentManager();
Content content = ContentFactory.SERVICE.getInstance().createContent(nocalhostWindow.getPanel(), "", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ public class PortForwardConfigurationDialog extends DialogWrapper {
private final ResourceNode node;
private final Project project;

private JPanel dialogPanel;
private JScrollPane scrollPane;
private final JPanel dialogPanel;
private JPanel listPanel;

private JBTextField startTextField;
Expand Down Expand Up @@ -300,7 +299,7 @@ public void run(@NotNull ProgressIndicator indicator) {
private void setupStopPanel() {
listPanel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true));

scrollPane = new JBScrollPane(listPanel);
JScrollPane scrollPane = new JBScrollPane(listPanel);
scrollPane.setPreferredSize(new Dimension(-1, 400));

GridConstraints scrollPaneConstraints = new GridConstraints();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@

import java.io.IOException;

import dev.nocalhost.plugin.intellij.exception.NocalhostNotifier;
import dev.nocalhost.plugin.intellij.commands.NhctlCommand;
import dev.nocalhost.plugin.intellij.commands.OutputCapturedNhctlCommand;
import dev.nocalhost.plugin.intellij.commands.data.NhctlDescribeOptions;
import dev.nocalhost.plugin.intellij.commands.data.NhctlDescribeService;
import dev.nocalhost.plugin.intellij.commands.data.NhctlDevEndOptions;
import dev.nocalhost.plugin.intellij.exception.NocalhostExecuteCmdException;
import dev.nocalhost.plugin.intellij.exception.NocalhostNotifier;
import dev.nocalhost.plugin.intellij.topic.DevSpaceListUpdatedNotifier;
import dev.nocalhost.plugin.intellij.ui.tree.node.ResourceNode;
import dev.nocalhost.plugin.intellij.utils.KubeConfigUtil;
import icons.NocalhostIcons;

public class EndDevelopAction extends AnAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@

import java.io.IOException;

import dev.nocalhost.plugin.intellij.exception.NocalhostNotifier;
import dev.nocalhost.plugin.intellij.commands.NhctlCommand;
import dev.nocalhost.plugin.intellij.commands.data.NhctlResetOptions;
import dev.nocalhost.plugin.intellij.exception.NocalhostExecuteCmdException;
import dev.nocalhost.plugin.intellij.exception.NocalhostNotifier;
import dev.nocalhost.plugin.intellij.ui.tree.node.ResourceNode;
import dev.nocalhost.plugin.intellij.utils.KubeConfigUtil;

public class ResetAction extends AnAction {
private static final Logger LOG = Logger.getInstance(ResetAction.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import dev.nocalhost.plugin.intellij.ui.StartDevelopContainerChooseDialog;
import dev.nocalhost.plugin.intellij.ui.tree.node.ResourceNode;
import dev.nocalhost.plugin.intellij.utils.FileChooseUtil;
import dev.nocalhost.plugin.intellij.utils.KubeConfigUtil;
import icons.NocalhostIcons;

public class StartDevelopAction extends AnAction {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,19 @@
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;

import javax.swing.*;

public class NocalhostErrorWindow extends NocalhostConsoleWindow {

private final Project project;
private final ToolWindow toolWindow;
private final LogPanel panel;
private final String title;

private LogPanel panel;
private ConsoleView consoleView;

private String title;
private String content;
private String eMessage;

public NocalhostErrorWindow(Project project, ToolWindow toolWindow, String title, String content, String eMessage) {
this.project = project;
this.toolWindow = toolWindow;
public NocalhostErrorWindow(Project project, String title, String content, String eMessage) {
this.title = title;
this.content = content;
this.eMessage = eMessage;


consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();
ConsoleView consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();

panel = new LogPanel(false);
consoleView.print(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;

import org.apache.commons.lang3.ArrayUtils;

Expand All @@ -18,17 +17,11 @@
import dev.nocalhost.plugin.intellij.topic.NocalhostOutputAppendNotifier;

public class NocalhostOutputWindow {
private final Project project;
private final ToolWindow toolWindow;

private LogPanel panel;
private final LogPanel panel;
private final ConsoleView consoleView;


private ConsoleView consoleView;

public NocalhostOutputWindow(Project project, ToolWindow toolWindow) {
this.project = project;
this.toolWindow = toolWindow;
public NocalhostOutputWindow(Project project) {

consoleView = TextConsoleBuilderFactory.getInstance().createBuilder(project).getConsole();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import dev.nocalhost.plugin.intellij.exception.NocalhostNotifier;
import dev.nocalhost.plugin.intellij.ui.tree.node.ApplicationNode;
import dev.nocalhost.plugin.intellij.utils.DataUtils;
import dev.nocalhost.plugin.intellij.utils.KubeConfigUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import dev.nocalhost.plugin.intellij.exception.NocalhostNotifier;
import dev.nocalhost.plugin.intellij.ui.tree.node.ResourceNode;
import dev.nocalhost.plugin.intellij.utils.DataUtils;
import dev.nocalhost.plugin.intellij.utils.KubeConfigUtil;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;

Expand Down

0 comments on commit baeb3ad

Please sign in to comment.