|
|
@ -7,7 +7,6 @@ import com.fr.data.security.ssh.SshException; |
|
|
|
import com.fr.data.security.ssh.SshType; |
|
|
|
import com.fr.data.security.ssh.SshType; |
|
|
|
import com.fr.data.security.ssh.impl.KeyVerifySsh; |
|
|
|
import com.fr.data.security.ssh.impl.KeyVerifySsh; |
|
|
|
import com.fr.data.security.ssh.impl.NormalSsh; |
|
|
|
import com.fr.data.security.ssh.impl.NormalSsh; |
|
|
|
import com.fr.data.security.ssl.SslUtils; |
|
|
|
|
|
|
|
import com.fr.design.border.UITitledBorder; |
|
|
|
import com.fr.design.border.UITitledBorder; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.dialog.BasicPane; |
|
|
|
import com.fr.design.editor.editor.NotNegativeIntegerEditor; |
|
|
|
import com.fr.design.editor.editor.NotNegativeIntegerEditor; |
|
|
@ -38,6 +37,8 @@ import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
import static com.fr.design.i18n.Toolkit.i18nText; |
|
|
|
import static com.fr.design.i18n.Toolkit.i18nText; |
|
|
|
|
|
|
|
|
|
|
@ -130,8 +131,8 @@ public class SshPane extends BasicPane { |
|
|
|
fileChooserButton.addActionListener(new ActionListener() { |
|
|
|
fileChooserButton.addActionListener(new ActionListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(SslUtils.KEY_FILE_EXTENSION)); |
|
|
|
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(true)); |
|
|
|
int type = fileChooser.showOpenDialog(SshPane.this); |
|
|
|
int type = fileChooser.showOpenDialog(SshPane.this, StringUtils.EMPTY); |
|
|
|
if (type == FILEChooserPane.OK_OPTION) { |
|
|
|
if (type == FILEChooserPane.OK_OPTION) { |
|
|
|
final FILE file = fileChooser.getSelectedFILE(); |
|
|
|
final FILE file = fileChooser.getSelectedFILE(); |
|
|
|
if (file == null) { |
|
|
|
if (file == null) { |
|
|
@ -238,6 +239,8 @@ public class SshPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static class KeyFileUITextField extends UITextField { |
|
|
|
public static class KeyFileUITextField extends UITextField { |
|
|
|
|
|
|
|
private static final Pattern ERROR_START = Pattern.compile("^([/\\\\.]+).*"); |
|
|
|
|
|
|
|
private static final Pattern MUTI_DOT = Pattern.compile("\\.+"); |
|
|
|
private static final String PREFIX = ProjectConstants.RESOURCES_NAME + "/"; |
|
|
|
private static final String PREFIX = ProjectConstants.RESOURCES_NAME + "/"; |
|
|
|
private static final String UPPER = ".."; |
|
|
|
private static final String UPPER = ".."; |
|
|
|
|
|
|
|
|
|
|
@ -246,14 +249,29 @@ public class SshPane extends BasicPane { |
|
|
|
this.addKeyListener(new KeyAdapter() { |
|
|
|
this.addKeyListener(new KeyAdapter() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
public void keyReleased(KeyEvent e) { |
|
|
|
String text = KeyFileUITextField.this.getText(); |
|
|
|
String text = KeyFileUITextField.this.getTextOrigin(); |
|
|
|
if (text != null && text.contains(UPPER)) { |
|
|
|
if (text != null) { |
|
|
|
KeyFileUITextField.this.setText(text.replace(UPPER, ".")); |
|
|
|
if (text.contains(UPPER)) { |
|
|
|
|
|
|
|
text = MUTI_DOT.matcher(text).replaceAll("."); |
|
|
|
|
|
|
|
KeyFileUITextField.this.setTextOrigin(text); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Matcher matcher = ERROR_START.matcher(text); |
|
|
|
|
|
|
|
if (matcher.matches()) { |
|
|
|
|
|
|
|
text = text.substring(matcher.group(1).length()); |
|
|
|
|
|
|
|
KeyFileUITextField.this.setTextOrigin(text); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getTextOrigin() { |
|
|
|
|
|
|
|
return super.getText(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setTextOrigin(String text) { |
|
|
|
|
|
|
|
super.setText(text); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getText() { |
|
|
|
public String getText() { |
|
|
@ -267,8 +285,8 @@ public class SshPane extends BasicPane { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setText(String text) { |
|
|
|
public void setText(String text) { |
|
|
|
// 设置的时候,不为空,说明文件指定了(文件需要是resource下),替换掉前缀
|
|
|
|
// 设置的时候,不为空,说明文件指定了(文件需要是resource下),替换掉前缀
|
|
|
|
if (!StringUtils.isEmpty(text)) { |
|
|
|
if (!StringUtils.isEmpty(text) && text.startsWith(PREFIX)) { |
|
|
|
super.setText(text.replace(PREFIX, "")); |
|
|
|
super.setText(text.replaceFirst(PREFIX, "")); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|