Browse Source

Pull request #7551: REPORT-64012 需求变更和代码优化

Merge in DESIGN/design from ~XIQIU/design:feature/x to feature/x

* commit '9820584c14ff08f1b166f77b103a655f901cc67f':
  REPORT-64012 改一行代码
  REPORT-64012  需求变更和代码优化
feature/x
Xiqiu 3 years ago
parent
commit
5e8d725876
  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. 11
      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.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 (!StringUtils.isEmpty(text)) {
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, ""));
}
}
}

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.SslException;
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.design.border.UITitledBorder;
import com.fr.design.data.datapane.connect.SshPane.KeyFileUITextField;
@ -154,8 +153,8 @@ public class SslPane extends BasicPane {
@Override
public void actionPerformed(ActionEvent e) {
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(SslUtils.KEY_FILE_EXTENSION));
int type = fileChooser.showOpenDialog(SslPane.this);
FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(ProjectConstants.RESOURCES_NAME, new ChooseFileFilter(true));
int type = fileChooser.showOpenDialog(SslPane.this, StringUtils.EMPTY);
if (type == FILEChooserPane.OK_OPTION) {
final FILE file = fileChooser.getSelectedFILE();
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) {
INSTANCE.showLoc = false;
INSTANCE.showEnv = false;
INSTANCE.showWebReport = false;
INSTANCE.setDesignateModel(path);
INSTANCE.removeAllFilter();
INSTANCE.addChooseFILEFilter(filter, 0);
@ -891,7 +894,7 @@ public class FILEChooserPane extends BasicPane {
saveDictionary();
dialogExit();
} 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;
}
}

11
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);
}
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) {
this();
if (extension != null) {
@ -314,4 +323,4 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter, java.io.
return (o instanceof ChooseFileFilter)
&& ComparatorUtils.equals(((ChooseFileFilter) o).getDescription(), getDescription());
}
}
}

Loading…
Cancel
Save