Browse Source

Merge branch 'feature/x' of https://code.fineres.com/scm/~harrison/design into feature/x

feature/x
Harrison 3 years ago
parent
commit
3542699922
  1. 12
      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. 27
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java

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

@ -7,6 +7,7 @@ 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.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
@ -25,7 +26,6 @@ import com.fr.file.FILE;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.third.guava.collect.HashBiMap; import com.fr.third.guava.collect.HashBiMap;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
@ -131,7 +131,7 @@ 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(true)); FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(SslUtils.PREFIX, new ChooseFileFilter(true), SslUtils.CERTIFICATES);
int type = fileChooser.showOpenDialog(SshPane.this, StringUtils.EMPTY); 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();
@ -142,6 +142,7 @@ public class SshPane extends BasicPane {
} }
} }
fileChooser.removeAllFilter(); fileChooser.removeAllFilter();
fileChooser.removeTopPath();
} }
}); });
} }
@ -241,7 +242,6 @@ 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 ERROR_START = Pattern.compile("^([/\\\\.]+).*");
private static final Pattern MUTI_DOT = Pattern.compile("\\.+"); private static final Pattern MUTI_DOT = Pattern.compile("\\.+");
private static final String PREFIX = ProjectConstants.RESOURCES_NAME + "/";
private static final String UPPER = ".."; private static final String UPPER = "..";
public KeyFileUITextField(int columns) { public KeyFileUITextField(int columns) {
@ -283,7 +283,7 @@ public class SshPane extends BasicPane {
public String getText() { public String getText() {
// 获取的时候,不为空,给他加上前缀就好了,否则还是空 // 获取的时候,不为空,给他加上前缀就好了,否则还是空
if (!StringUtils.isEmpty(super.getText())) { if (!StringUtils.isEmpty(super.getText())) {
return PREFIX + super.getText(); return SslUtils.PREFIX + super.getText();
} }
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@ -291,8 +291,8 @@ public class SshPane extends BasicPane {
@Override @Override
public void setText(String text) { public void setText(String text) {
// 设置的时候,不为空,说明文件指定了(文件需要是resource下),替换掉前缀 // 设置的时候,不为空,说明文件指定了(文件需要是resource下),替换掉前缀
if (!StringUtils.isEmpty(text) && text.startsWith(PREFIX)) { if (!StringUtils.isEmpty(text) && text.startsWith(SslUtils.PREFIX)) {
super.setText(text.replaceFirst(PREFIX, "")); super.setText(text.replaceFirst(SslUtils.PREFIX, ""));
} else { } else {
super.setText(text); super.setText(text);
} }

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

@ -4,6 +4,7 @@ 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.constants.UIConstants; import com.fr.design.constants.UIConstants;
@ -21,7 +22,6 @@ import com.fr.file.FILE;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.file.filter.ChooseFileFilter; import com.fr.file.filter.ChooseFileFilter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -148,7 +148,7 @@ 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(true)); FILEChooserPane fileChooser = FILEChooserPane.getInstanceWithDesignatePath(SslUtils.PREFIX, new ChooseFileFilter(true), SslUtils.CERTIFICATES);
int type = fileChooser.showOpenDialog(SslPane.this, StringUtils.EMPTY); 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();
@ -159,6 +159,7 @@ public class SslPane extends BasicPane {
} }
} }
fileChooser.removeAllFilter(); fileChooser.removeAllFilter();
fileChooser.removeTopPath();
} }
} }
} }

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

@ -202,10 +202,11 @@ public class FILEChooserPane extends BasicPane {
return INSTANCE; return INSTANCE;
} }
public static FILEChooserPane getInstanceWithDesignatePath(String path, FILEFilter filter) { public static FILEChooserPane getInstanceWithDesignatePath(String path, FILEFilter filter, String topPath) {
INSTANCE.showLoc = false; INSTANCE.showLoc = false;
INSTANCE.showEnv = false; INSTANCE.showEnv = false;
INSTANCE.showWebReport = false; INSTANCE.showWebReport = false;
INSTANCE.setTopPath(topPath);
INSTANCE.setDesignateModel(path); INSTANCE.setDesignateModel(path);
INSTANCE.removeAllFilter(); INSTANCE.removeAllFilter();
INSTANCE.addChooseFILEFilter(filter, 0); INSTANCE.addChooseFILEFilter(filter, 0);
@ -633,6 +634,9 @@ public class FILEChooserPane extends BasicPane {
this.filterList.clear(); this.filterList.clear();
} }
public void removeTopPath() {
this.setTopPath(StringUtils.EMPTY);
}
/** /**
* 设置filter,刷新右侧subFileList中的items * 设置filter,刷新右侧subFileList中的items
@ -1045,9 +1049,14 @@ public class FILEChooserPane extends BasicPane {
if (placesList == null) { if (placesList == null) {
return; return;
} }
setPlaceListModel(new DesignateRemotePlaceListModel(path)); setPlaceListModel(new DesignateRemotePlaceListModel(path));
} }
private void setTopPath(String path) {
this.locationBtnPane.setTopPath(path);
}
private void setMultiPlaceListModel() { private void setMultiPlaceListModel() {
if (placesList == null) { if (placesList == null) {
@ -1385,6 +1394,8 @@ public class FILEChooserPane extends BasicPane {
private List<UIButton> buttonList = new ArrayList<>(); private List<UIButton> buttonList = new ArrayList<>();
private int pathIndex = 0; private int pathIndex = 0;
private int maxPathIndex = 0; private int maxPathIndex = 0;
// 对顶层目录进行的限制
private String topPath;
public LocationButtonPane() { public LocationButtonPane() {
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); this.setLayout(FRGUIPaneFactory.createBoxFlowLayout());
@ -1430,6 +1441,10 @@ public class FILEChooserPane extends BasicPane {
}); });
} }
public void setTopPath(String path) {
this.topPath = path;
}
public void highLightButton(FILE dir) { public void highLightButton(FILE dir) {
for (int i = 0; i < this.buttonList.size(); i++) { for (int i = 0; i < this.buttonList.size(); i++) {
this.buttonList.get(i).setForeground(null); this.buttonList.get(i).setForeground(null);
@ -1471,6 +1486,7 @@ public class FILEChooserPane extends BasicPane {
} }
Matcher matcher = SEPARATOR_PATTERN.matcher(path); Matcher matcher = SEPARATOR_PATTERN.matcher(path);
int node_start = 0; int node_start = 0;
boolean needTopPath = !StringUtils.isEmpty(topPath);
while (matcher.find()) { while (matcher.find()) {
int start = matcher.start(); int start = matcher.start();
String btn_text = path.substring(node_start, start); String btn_text = path.substring(node_start, start);
@ -1478,11 +1494,18 @@ public class FILEChooserPane extends BasicPane {
if (StringUtils.isBlank(btn_text) && isWebAppNamePath) { if (StringUtils.isBlank(btn_text) && isWebAppNamePath) {
btn_text = webAppName; btn_text = webAppName;
} }
node_start = matcher.end();
if (needTopPath) {
if (topPath.equals(btn_text)) {
needTopPath = false;
} else {
continue;
}
}
this.buttonList.add(createBlankButton((new SetDirectoryAction(btn_text + '/', this.buttonList.add(createBlankButton((new SetDirectoryAction(btn_text + '/',
// alex:dir.prefix不和btn_path一起参与pathJoin,因为btn_path是否以/打头在unix,linux // alex:dir.prefix不和btn_path一起参与pathJoin,因为btn_path是否以/打头在unix,linux
// OS中意义很不一样 // OS中意义很不一样
FILEFactory.createFolder(dir.prefix() + StableUtils.pathJoin(btn_path, "/")))))); FILEFactory.createFolder(dir.prefix() + StableUtils.pathJoin(btn_path, "/"))))));
node_start = matcher.end();
} }
maxPathIndex = calculateMaxPathIndex(); maxPathIndex = calculateMaxPathIndex();

Loading…
Cancel
Save