From e3acfd3f5eac3550a8466be15e5387c961efa9aa Mon Sep 17 00:00:00 2001 From: xiqiu Date: Tue, 8 Mar 2022 09:58:02 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-67168=20=20=20=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=94=AF=E6=8C=81=E5=AD=90=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=BA=A7=E5=88=AB=E9=94=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/datapane/connect/SshPane.java | 12 ++++----- .../design/data/datapane/connect/SslPane.java | 5 ++-- .../java/com/fr/file/FILEChooserPane.java | 27 +++++++++++++++++-- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java index 9a870d07d2..48f710dfbf 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SshPane.java +++ b/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.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.constants.UIConstants; import com.fr.design.dialog.BasicPane; @@ -25,7 +26,6 @@ import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.filter.ChooseFileFilter; import com.fr.stable.StringUtils; -import com.fr.stable.project.ProjectConstants; import com.fr.third.guava.collect.HashBiMap; import javax.swing.ImageIcon; @@ -131,7 +131,7 @@ public class SshPane extends BasicPane { fileChooserButton.addActionListener(new ActionListener() { @Override 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); if (type == FILEChooserPane.OK_OPTION) { final FILE file = fileChooser.getSelectedFILE(); @@ -142,6 +142,7 @@ public class SshPane extends BasicPane { } } fileChooser.removeAllFilter(); + fileChooser.removeTopPath(); } }); } @@ -241,7 +242,6 @@ 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 = ".."; public KeyFileUITextField(int columns) { @@ -283,7 +283,7 @@ public class SshPane extends BasicPane { public String getText() { // 获取的时候,不为空,给他加上前缀就好了,否则还是空 if (!StringUtils.isEmpty(super.getText())) { - return PREFIX + super.getText(); + return SslUtils.PREFIX + super.getText(); } return StringUtils.EMPTY; } @@ -291,8 +291,8 @@ public class SshPane extends BasicPane { @Override public void setText(String text) { // 设置的时候,不为空,说明文件指定了(文件需要是resource下),替换掉前缀 - if (!StringUtils.isEmpty(text) && text.startsWith(PREFIX)) { - super.setText(text.replaceFirst(PREFIX, "")); + if (!StringUtils.isEmpty(text) && text.startsWith(SslUtils.PREFIX)) { + super.setText(text.replaceFirst(SslUtils.PREFIX, "")); } else { super.setText(text); } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java index 2d9c26e235..c440079911 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/SslPane.java +++ b/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.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.constants.UIConstants; @@ -21,7 +22,6 @@ import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.filter.ChooseFileFilter; import com.fr.stable.StringUtils; -import com.fr.stable.project.ProjectConstants; import javax.swing.ImageIcon; import javax.swing.JPanel; @@ -148,7 +148,7 @@ public class SslPane extends BasicPane { @Override 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); if (type == FILEChooserPane.OK_OPTION) { final FILE file = fileChooser.getSelectedFILE(); @@ -159,6 +159,7 @@ public class SslPane extends BasicPane { } } fileChooser.removeAllFilter(); + fileChooser.removeTopPath(); } } } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index 30f55d7ef0..0a1ab2aad5 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -202,10 +202,11 @@ public class FILEChooserPane extends BasicPane { return INSTANCE; } - public static FILEChooserPane getInstanceWithDesignatePath(String path, FILEFilter filter) { + public static FILEChooserPane getInstanceWithDesignatePath(String path, FILEFilter filter, String topPath) { INSTANCE.showLoc = false; INSTANCE.showEnv = false; INSTANCE.showWebReport = false; + INSTANCE.setTopPath(topPath); INSTANCE.setDesignateModel(path); INSTANCE.removeAllFilter(); INSTANCE.addChooseFILEFilter(filter, 0); @@ -633,6 +634,9 @@ public class FILEChooserPane extends BasicPane { this.filterList.clear(); } + public void removeTopPath() { + this.setTopPath(StringUtils.EMPTY); + } /** * 设置filter,刷新右侧subFileList中的items @@ -1045,9 +1049,14 @@ public class FILEChooserPane extends BasicPane { if (placesList == null) { return; } + setPlaceListModel(new DesignateRemotePlaceListModel(path)); } + private void setTopPath(String path) { + this.locationBtnPane.setTopPath(path); + } + private void setMultiPlaceListModel() { if (placesList == null) { @@ -1385,6 +1394,8 @@ public class FILEChooserPane extends BasicPane { private List buttonList = new ArrayList<>(); private int pathIndex = 0; private int maxPathIndex = 0; + // 对顶层目录进行的限制 + private String topPath; public LocationButtonPane() { 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) { for (int i = 0; i < this.buttonList.size(); i++) { this.buttonList.get(i).setForeground(null); @@ -1471,6 +1486,7 @@ public class FILEChooserPane extends BasicPane { } Matcher matcher = SEPARATOR_PATTERN.matcher(path); int node_start = 0; + boolean needTopPath = !StringUtils.isEmpty(topPath); while (matcher.find()) { int start = matcher.start(); String btn_text = path.substring(node_start, start); @@ -1478,11 +1494,18 @@ public class FILEChooserPane extends BasicPane { if (StringUtils.isBlank(btn_text) && isWebAppNamePath) { 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 + '/', // alex:dir.prefix不和btn_path一起参与pathJoin,因为btn_path是否以/打头在unix,linux // OS中意义很不一样 FILEFactory.createFolder(dir.prefix() + StableUtils.pathJoin(btn_path, "/")))))); - node_start = matcher.end(); } maxPathIndex = calculateMaxPathIndex();