Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HaleyWang committed Jun 12, 2022
1 parent 0d30e6a commit 5901dbf
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
Binary file modified build/libs/SpringRemote-0.1.jar
Binary file not shown.
70 changes: 69 additions & 1 deletion src/main/java/com/haleywang/putty/view/SpringRemoteView.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import org.unknown.tab.close.DnDCloseButtonTabbedPane;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
Expand All @@ -50,7 +52,10 @@
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.KeyboardFocusManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
Expand Down Expand Up @@ -535,10 +540,73 @@ private SideView getSideView(String key) {
}


public void onTypedString(String command) {
public void onTypedString(final String command) {
if (command.trim().contains("\n")) {
new RunCmdDialog("Run command dialog", "Are you sure you want to run the multiline commands?") {
private static final long serialVersionUID = 1725469319855455739L;

@Override
public void ok() {
typedString(command);
}
}.setVisible(true);
return;
}
typedString(command);
}


static abstract class RunCmdDialog extends JDialog implements ActionListener {
private static final long serialVersionUID = -4150879304928630217L;
String content;
String ok = "OK";
String cancel = "CANCEL";

public RunCmdDialog(String title, String content) {
this.content = content;

JLabel jLabel = new JLabel("<html><body>" + content + "</body></html>");
jLabel.setFont(new Font("", Font.PLAIN, 14));
jLabel.setForeground(Color.black);
jLabel.setBounds(75, 43, 220, 85);
JButton okBut = new JButton(ok);
JButton cancelBut = new JButton(cancel);
okBut.setBackground(Color.LIGHT_GRAY);
okBut.setBorderPainted(false);
okBut.setBounds(65, 126, 98, 31);
cancelBut.setBounds(175, 126, 98, 31);
cancelBut.setBackground(Color.LIGHT_GRAY);
cancelBut.setBorderPainted(false);
okBut.addActionListener(this);
cancelBut.addActionListener(this);

add(jLabel);
add(okBut);
add(cancelBut);
setLayout(null);
setTitle(title);
setModal(true);
setSize(350, 210);
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}

public abstract void ok();

@Override
public void actionPerformed(ActionEvent e) {
if (ok.equals(e.getActionCommand())) {
this.setVisible(false);
ok();
}
if (cancel.equals(e.getActionCommand())) {
this.setVisible(false);
this.dispose();
}
}
}

public void focusCurrentTerm() {
Component component = getCurrentTabPanel().getSelectedComponent();
if (component instanceof PuttyPane) {
Expand Down

0 comments on commit 5901dbf

Please sign in to comment.