Browse Source

REPORT-64012 需求变更和代码优化

feature/x
xiqiu 3 years ago
parent
commit
04cda3cc93
  1. 34
      designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java
  2. 5
      designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java
  3. 5
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  4. 9
      designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java

34
designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java

@ -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, ""));
} }
} }
} }

5
designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java

@ -4,7 +4,6 @@ import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.security.ssl.Ssl; import com.fr.data.security.ssl.Ssl;
import com.fr.data.security.ssl.SslException; import com.fr.data.security.ssl.SslException;
import com.fr.data.security.ssl.SslType; import com.fr.data.security.ssl.SslType;
import com.fr.data.security.ssl.SslUtils;
import com.fr.data.security.ssl.impl.NormalSsl; import com.fr.data.security.ssl.impl.NormalSsl;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.data.datapane.connect.SshPane.KeyFileUITextField; import com.fr.design.data.datapane.connect.SshPane.KeyFileUITextField;
@ -154,8 +153,8 @@ public class SslPane extends BasicPane {
@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(SslPane.this); int type = fileChooser.showOpenDialog(SslPane.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) {

5
designer-base/src/main/java/com/fr/file/FILEChooserPane.java

@ -203,6 +203,9 @@ public class FILEChooserPane extends BasicPane {
} }
public static FILEChooserPane getInstanceWithDesignatePath(String path, FILEFilter filter) { public static FILEChooserPane getInstanceWithDesignatePath(String path, FILEFilter filter) {
INSTANCE.showLoc = false;
INSTANCE.showEnv = false;
INSTANCE.showWebReport = false;
INSTANCE.setDesignateModel(path); INSTANCE.setDesignateModel(path);
INSTANCE.removeAllFilter(); INSTANCE.removeAllFilter();
INSTANCE.addChooseFILEFilter(filter, 0); INSTANCE.addChooseFILEFilter(filter, 0);
@ -891,7 +894,7 @@ public class FILEChooserPane extends BasicPane {
saveDictionary(); saveDictionary();
dialogExit(); dialogExit();
} else { } else {
FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_App_Template_Report_Not_Exist")); FineJOptionPane.showMessageDialog(this, Toolkit.i18nText("Fine-Design_Basic_App_File_Not_Exist"));
return; return;
} }
} }

9
designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java

@ -31,6 +31,15 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter, java.io.
this(extension, null); this(extension, null);
} }
public ChooseFileFilter(boolean noRestrict) {
if (noRestrict) {
this.filters = null;
this.fullDescription = FileExtension.ALL.getExtension();
} else {
this.filters = new ArrayList<>();
}
}
public ChooseFileFilter(String extension, String description) { public ChooseFileFilter(String extension, String description) {
this(); this();
if (extension != null) { if (extension != null) {

Loading…
Cancel
Save