|
|
|
@ -129,6 +129,10 @@ public class FILEChooserPane extends BasicPane {
|
|
|
|
|
|
|
|
|
|
public static final int JOPTIONPANE_CANCEL_OPTION = 3; |
|
|
|
|
|
|
|
|
|
public static final String SEPARATOR_STRING = "/"; |
|
|
|
|
|
|
|
|
|
public static final char SEPARATOR_CHAR = '/'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* alex:之所以在Pattern那里加个+,是因为有些路径会有两个甚至多个分隔符放在一起 |
|
|
|
@ -1466,20 +1470,27 @@ public class FILEChooserPane extends BasicPane {
|
|
|
|
|
for (int i = 0; i < this.buttonList.size(); i++) { |
|
|
|
|
this.buttonList.get(i).setForeground(null); |
|
|
|
|
if (((SetDirectoryAction) this.buttonList.get(i).getAction()).getDir() != null |
|
|
|
|
&& this.buttonList.get(i).getAction() instanceof SetDirectoryAction |
|
|
|
|
&& (ComparatorUtils.equals(((SetDirectoryAction) this.buttonList.get(i).getAction()).getDir().getPath(), dir.getPath()))) { |
|
|
|
|
|
|
|
|
|
&& this.buttonList.get(i).getAction() instanceof SetDirectoryAction) { |
|
|
|
|
String actionPath = ((SetDirectoryAction) this.buttonList.get(i).getAction()).getDir().getPath(); |
|
|
|
|
String dirPath = dir.getPath(); |
|
|
|
|
//如果是报表环境,button的Action最后会跟上"/",这个是特意处理的,但是对应代码没有说明原因,不做修改
|
|
|
|
|
//FILE的getPath不会带"/",这边针对这种情况加个处理,不建议直接改FILE
|
|
|
|
|
if (actionPath.endsWith(SEPARATOR_STRING) && !dirPath.endsWith(SEPARATOR_STRING)) { |
|
|
|
|
dirPath = dirPath + SEPARATOR_STRING; |
|
|
|
|
} |
|
|
|
|
if (ComparatorUtils.equals(actionPath, dirPath)) { |
|
|
|
|
this.buttonList.get(i).setForeground(Color.BLUE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setPopDir(FILE file) { |
|
|
|
|
popDir = file; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populate(FILE dir) { |
|
|
|
|
if (popDir != null && dir != null && popDir.toString().indexOf(dir.toString()) == 0) { |
|
|
|
|
if (checkOnlyHighLight(dir)) { |
|
|
|
|
highLightButton(dir); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -1530,6 +1541,24 @@ public class FILEChooserPane extends BasicPane {
|
|
|
|
|
highLightButton(dir); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查是不是只需要设置高亮即可 |
|
|
|
|
* |
|
|
|
|
* @param dir FILE |
|
|
|
|
* @return 如果还要进行别的设置就返回false,如果只需要更新下高亮(通过点击上面的路径才会只需要更新高亮),返回true |
|
|
|
|
*/ |
|
|
|
|
private boolean checkOnlyHighLight(FILE dir) { |
|
|
|
|
if (popDir == null || dir == null) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
String popDirStr = popDir.toString(); |
|
|
|
|
String dirStr = dir.toString(); |
|
|
|
|
//前缀匹配是不够的,还要看下前缀匹配的下一位是不是'/'
|
|
|
|
|
//否则"test"和"test副本"明明不属于同个路径逻辑,也只更新高亮,应该是"test"和"test/副本"这样才可以通过
|
|
|
|
|
//如果通过了indexOf的检查,因为不会存在相同的路径,popDirStr只会比dirStr大,看一下前缀匹配的下一位是不是'/',如果不是就得更新路径文本,不能只设置高亮
|
|
|
|
|
return popDirStr.indexOf(dirStr) == 0 && popDirStr.length() > dirStr.length() && popDirStr.charAt(dirStr.length()) == SEPARATOR_CHAR; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// doLayout
|
|
|
|
|
@Override |
|
|
|
|
public void doLayout() { |
|
|
|
|