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