From d82be9b8260207ed48d17888f203570dc79f84e4 Mon Sep 17 00:00:00 2001 From: Bryant Date: Fri, 25 Sep 2020 11:52:42 +0800 Subject: [PATCH 1/8] =?UTF-8?q?REPORT-40472=20=E5=A4=87=E4=BB=BD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E5=86=85=E6=AE=8B=E5=AD=98=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E6=B2=A1=E6=9C=89=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../factory/DirectoryOperationFactory.java | 129 ------------------ .../update/ui/dialog/RestoreDialog.java | 4 +- .../update/ui/dialog/UpdateMainDialog.java | 4 +- .../com/fr/design/update/utils/FileUtils.java | 38 ++++++ .../fr/design/update/utils/FileUtilsTest.java | 22 +++ 5 files changed, 64 insertions(+), 133 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java create mode 100644 designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java create mode 100644 designer-base/src/test/java/com/fr/design/update/utils/FileUtilsTest.java diff --git a/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java b/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java deleted file mode 100644 index 48c151488a..0000000000 --- a/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.fr.design.update.factory; - -import com.fr.log.FineLoggerFactory; -import com.fr.stable.ArrayUtils; -import com.fr.stable.StableUtils; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Arrays; - -/** - * Created by XINZAI on 2018/8/21. - */ -public class DirectoryOperationFactory { - /** - * 新建一个目录 - * - * @param dirPath 目录路径 - */ - public static void createNewDirectory(String dirPath) { - try { - File newDirPath = new File(dirPath); - if (!newDirPath.exists()) { - StableUtils.mkdirs(newDirPath); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - - /** - * 删除目录 - * - * @param dirPath 目录路径 - */ - public static void deleteDirectory(String dirPath) { - try { - File dir = new File(dirPath); - if (dir.isDirectory()) { - File[] file = dir.listFiles(); - for (File fileTemp : file) { - deleteDirectory(fileTemp.toString()); - fileTemp.delete(); - } - } else { - dir.delete(); - } - dir.delete(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - - /** - * 复制目录 - * - * @param oldDirPath 被复制目录 - * @param newDirPath 新目录 - */ - public static void copyDirectory(String oldDirPath, String newDirPath) { - File oldDir = new File(oldDirPath); - if (oldDir.isDirectory()) { - StableUtils.mkdirs(new File(newDirPath)); - File[] files = oldDir.listFiles(); - for (File fileTemp : files) { - copyDirectory(fileTemp.toString(), newDirPath + "/" + fileTemp.getName()); - } - } else { - try { - copy(oldDirPath, newDirPath); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } - } - } - - private static void copy(String path1, String path2) throws IOException { - try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1))); - DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)))) { - byte[] date = new byte[in.available()]; - in.read(date); - out.write(date); - } - } - - /** - * 移动目录 - * - * @param oldDirPath 被移动目录 - * @param newDirPath 新目录 - */ - public static void moveDirectory(String oldDirPath, String newDirPath) { - copyDirectory(oldDirPath, newDirPath); - deleteDirectory(oldDirPath); - } - - /** - * 列出过滤后的文件 - * - * @param installHome 安装目录 - * @param backupdir 备份目录 - * @return String数组 - */ - public static String[] listFilteredFiles(String installHome, String backupdir) { - File backupDir = new File(StableUtils.pathJoin(installHome, backupdir)); - StableUtils.mkdirs(backupDir); - File[] fileNames = backupDir.listFiles(new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.isDirectory(); - } - }); - String[] jarFileName = new String[fileNames.length]; - int j = 0; - for (File fileName : fileNames) { - if ((fileName.isDirectory()) && (ArrayUtils.getLength(fileName.listFiles()) > 0)) {//判断备份文件夹中是否为空,为空不显示 - jarFileName[j++] = fileName.getName(); - } - } - return Arrays.copyOf(jarFileName, j); - } -} diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java index 8ffe8d4a41..c9d90f37a7 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java @@ -4,7 +4,7 @@ import com.fr.decision.update.data.UpdateConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.factory.DirectoryOperationFactory; +import com.fr.design.update.utils.FileUtils; import com.fr.design.update.ui.widget.ColorfulCellRender; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.ArrayUtils; @@ -86,7 +86,7 @@ public class RestoreDialog extends JDialog { JPanel jarListPane = new JPanel(); jarListPane.setLayout(new BoxLayout(jarListPane, BoxLayout.Y_AXIS)); - String[] jarBackupFiles = DirectoryOperationFactory.listFilteredFiles(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR); + String[] jarBackupFiles = FileUtils.listFilteredFiles(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR); ArrayUtils.reverse(jarBackupFiles); String[] jarFilesList = ((jarBackupFiles.length < NUMOFCELL_LEAST) ? Arrays.copyOf(jarBackupFiles, NUMOFCELL_LEAST) : jarBackupFiles); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 3992be6a91..efbba679d3 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -17,7 +17,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.update.actions.FileProcess; import com.fr.design.update.domain.UpdateInfoCachePropertyManager; -import com.fr.design.update.factory.DirectoryOperationFactory; +import com.fr.design.update.utils.FileUtils; import com.fr.design.update.ui.widget.LoadingLabel; import com.fr.design.update.ui.widget.UpdateActionLabel; import com.fr.design.update.ui.widget.UpdateInfoTable; @@ -320,7 +320,7 @@ public class UpdateMainDialog extends UIDialog { } }); //choose RestoreLabel to show - boolean isNeedRestore = ArrayUtils.isNotEmpty(DirectoryOperationFactory.listFilteredFiles(StableUtils.getInstallHome(), getBackupDirectory())); + boolean isNeedRestore = ArrayUtils.isNotEmpty(FileUtils.listFilteredFiles(StableUtils.getInstallHome(), getBackupDirectory())); jarRestoreLabel = isNeedRestore ? jarRestorePreviousRevision : noJarPreviousRevision; } diff --git a/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java b/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java new file mode 100644 index 0000000000..db12d2fcd6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java @@ -0,0 +1,38 @@ +package com.fr.design.update.utils; + +import com.fr.stable.StableUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Bryant + * @version 10.0 + * Created by Bryant on 2020-09-25 + */ +public class FileUtils { + + /** + * 列出过滤后的文件 + * + * @param installHome 安装目录 + * @param backupdir 备份目录 + * @return String数组 + */ + public static String[] listFilteredFiles(String installHome, String backupdir) { + File backupDir = new File(StableUtils.pathJoin(installHome, backupdir)); + StableUtils.mkdirs(backupDir); + File[] versionBackup = backupDir.listFiles(); + List versions = new ArrayList<>(); + if (versionBackup != null) { + for (File file : versionBackup) { + if (file.isDirectory() && file.length() > 0) { + versions.add(file.getName()); + } + } + } + String[] result = new String[versions.size()]; + return versions.toArray(result); + } +} diff --git a/designer-base/src/test/java/com/fr/design/update/utils/FileUtilsTest.java b/designer-base/src/test/java/com/fr/design/update/utils/FileUtilsTest.java new file mode 100644 index 0000000000..0560cc0281 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/update/utils/FileUtilsTest.java @@ -0,0 +1,22 @@ +package com.fr.design.update.utils; + +import com.fr.stable.StableUtils; +import org.junit.Assert; +import org.junit.Test; + +import java.io.File; + +/** + * @author Bryant + * @version 10.0 + * Created by Bryant on 2020-09-25 + */ +public class FileUtilsTest { + + @Test + public void testListFilteredFiles() { + String[] result = FileUtils.listFilteredFiles("home", "backup"); + Assert.assertEquals(0, result.length); + StableUtils.deleteFile(new File(StableUtils.pathJoin("home"))); + } +} From 135a214c1b23c4aca5aa21fb1ea5f6caa63d215e Mon Sep 17 00:00:00 2001 From: Bryant Date: Fri, 25 Sep 2020 11:53:17 +0800 Subject: [PATCH 2/8] =?UTF-8?q?REPORT-40472=20=E5=A4=87=E4=BB=BD=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E5=86=85=E6=AE=8B=E5=AD=98=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E6=B2=A1=E6=9C=89=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/update/utils/FileUtils.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java b/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java index db12d2fcd6..0dea603c54 100644 --- a/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java +++ b/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java @@ -29,6 +29,8 @@ public class FileUtils { for (File file : versionBackup) { if (file.isDirectory() && file.length() > 0) { versions.add(file.getName()); + } else { + StableUtils.deleteFile(file); } } } From cd8b852cb54d4a58b23deaffeb4e619fa203004c Mon Sep 17 00:00:00 2001 From: Bryant Date: Fri, 25 Sep 2020 17:20:49 +0800 Subject: [PATCH 3/8] =?UTF-8?q?REPORT-40472=20[=E5=9B=9E=E5=BD=92]?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E5=8D=87=E7=BA=A7=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=E5=88=B0=E4=BB=A5=E5=89=8D=E7=89=88=E6=9C=AC=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E8=BF=98=E5=8F=AF=E4=BB=A5=E8=BF=98=E5=8E=9F=E5=88=B0?= =?UTF-8?q?=E4=BB=A5=E5=89=8D=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/update/ui/dialog/RestoreDialog.java | 4 ++-- .../java/com/fr/design/update/ui/dialog/UpdateMainDialog.java | 4 ++-- .../update/utils/{FileUtils.java => UpdateFileUtils.java} | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename designer-base/src/main/java/com/fr/design/update/utils/{FileUtils.java => UpdateFileUtils.java} (97%) diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java index c9d90f37a7..f54b811852 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java @@ -4,7 +4,7 @@ import com.fr.decision.update.data.UpdateConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.utils.FileUtils; +import com.fr.design.update.utils.UpdateFileUtils; import com.fr.design.update.ui.widget.ColorfulCellRender; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.ArrayUtils; @@ -86,7 +86,7 @@ public class RestoreDialog extends JDialog { JPanel jarListPane = new JPanel(); jarListPane.setLayout(new BoxLayout(jarListPane, BoxLayout.Y_AXIS)); - String[] jarBackupFiles = FileUtils.listFilteredFiles(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR); + String[] jarBackupFiles = UpdateFileUtils.listFilteredFiles(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR); ArrayUtils.reverse(jarBackupFiles); String[] jarFilesList = ((jarBackupFiles.length < NUMOFCELL_LEAST) ? Arrays.copyOf(jarBackupFiles, NUMOFCELL_LEAST) : jarBackupFiles); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index efbba679d3..eb77bf9541 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -17,7 +17,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.update.actions.FileProcess; import com.fr.design.update.domain.UpdateInfoCachePropertyManager; -import com.fr.design.update.utils.FileUtils; +import com.fr.design.update.utils.UpdateFileUtils; import com.fr.design.update.ui.widget.LoadingLabel; import com.fr.design.update.ui.widget.UpdateActionLabel; import com.fr.design.update.ui.widget.UpdateInfoTable; @@ -320,7 +320,7 @@ public class UpdateMainDialog extends UIDialog { } }); //choose RestoreLabel to show - boolean isNeedRestore = ArrayUtils.isNotEmpty(FileUtils.listFilteredFiles(StableUtils.getInstallHome(), getBackupDirectory())); + boolean isNeedRestore = ArrayUtils.isNotEmpty(UpdateFileUtils.listFilteredFiles(StableUtils.getInstallHome(), getBackupDirectory())); jarRestoreLabel = isNeedRestore ? jarRestorePreviousRevision : noJarPreviousRevision; } diff --git a/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java b/designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java similarity index 97% rename from designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java rename to designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java index 0dea603c54..b2149be8f0 100644 --- a/designer-base/src/main/java/com/fr/design/update/utils/FileUtils.java +++ b/designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java @@ -11,7 +11,7 @@ import java.util.List; * @version 10.0 * Created by Bryant on 2020-09-25 */ -public class FileUtils { +public class UpdateFileUtils { /** * 列出过滤后的文件 From 27d5ffff59bad2531145c756177af14582a0abd3 Mon Sep 17 00:00:00 2001 From: Bryant Date: Fri, 25 Sep 2020 17:21:42 +0800 Subject: [PATCH 4/8] =?UTF-8?q?REPORT-40472=20[=E5=9B=9E=E5=BD=92]?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0=E5=8D=87=E7=BA=A7=E8=BF=98?= =?UTF-8?q?=E5=8E=9F=E5=88=B0=E4=BB=A5=E5=89=8D=E7=89=88=E6=9C=AC=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E8=BF=98=E5=8F=AF=E4=BB=A5=E8=BF=98=E5=8E=9F=E5=88=B0?= =?UTF-8?q?=E4=BB=A5=E5=89=8D=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/{FileUtilsTest.java => UpdateFileUtilsTest.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename designer-base/src/test/java/com/fr/design/update/utils/{FileUtilsTest.java => UpdateFileUtilsTest.java} (77%) diff --git a/designer-base/src/test/java/com/fr/design/update/utils/FileUtilsTest.java b/designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java similarity index 77% rename from designer-base/src/test/java/com/fr/design/update/utils/FileUtilsTest.java rename to designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java index 0560cc0281..0e91e9d684 100644 --- a/designer-base/src/test/java/com/fr/design/update/utils/FileUtilsTest.java +++ b/designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java @@ -11,11 +11,11 @@ import java.io.File; * @version 10.0 * Created by Bryant on 2020-09-25 */ -public class FileUtilsTest { +public class UpdateFileUtilsTest { @Test public void testListFilteredFiles() { - String[] result = FileUtils.listFilteredFiles("home", "backup"); + String[] result = UpdateFileUtils.listFilteredFiles("home", "backup"); Assert.assertEquals(0, result.length); StableUtils.deleteFile(new File(StableUtils.pathJoin("home"))); } From 6ab3029836b3e308bf42687afb272ff711a992ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 25 Sep 2020 17:23:33 +0800 Subject: [PATCH 5/8] CHART-15269 && CHART-15926 bugfix --- .../designer/component/VanChartUIListControlPane.java | 3 +-- .../map/designer/VanMapAreaPointAndLineGroupPane.java | 10 +--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java index 15e905e107..8a18814ebd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartUIListControlPane.java @@ -10,7 +10,6 @@ import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.Nameable; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -154,7 +153,7 @@ public abstract class VanChartUIListControlPane extends UIListControlPane implem HyperDialog(JComponent pane) { - super(DesignerContext.getDesignerFrame(), true); + super(SwingUtilities.getWindowAncestor(VanChartUIListControlPane.this)); pane.setBorder(BorderFactory.createEmptyBorder(20, 10, 10, 10)); this.editPane = pane; JPanel editPaneWrapper = new JPanel(new BorderLayout()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java index 569d0850cb..127ad29893 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java @@ -1,10 +1,7 @@ package com.fr.van.chart.map.designer; - -import javax.swing.BorderFactory; import javax.swing.JPanel; -import javax.swing.border.Border; /** * Created by Mitisky on 16/5/20. @@ -19,9 +16,4 @@ public class VanMapAreaPointAndLineGroupPane extends VanChartGroupPane { public VanMapAreaPointAndLineGroupPane(final JPanel areaPane, final JPanel pointPane, final JPanel linePane){ super(new String[]{AREA_MAP_STRING, POINT_MAP_STRING, LINE_MAP_STRING}, new JPanel[]{areaPane, pointPane, linePane}); } - - @Override - protected Border getButtonGroupBorder () { - return BorderFactory.createEmptyBorder(0,8,0,18); - } -} +} \ No newline at end of file From 219b1574e098179ea88838a21f02d785bb9b49fe Mon Sep 17 00:00:00 2001 From: Yyming Date: Fri, 25 Sep 2020 17:25:07 +0800 Subject: [PATCH 6/8] =?UTF-8?q?REPORT-39642=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=A0=8F-=E6=9C=8D=E5=8A=A1=E5=99=A8-?= =?UTF-8?q?=E9=A2=84=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F-=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/style/FormatPane.java | 46 +++++++++++-------- .../cell/settingpane/style/StylePane.java | 2 +- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/style/FormatPane.java index 255efe78c5..d1679561d7 100644 --- a/designer-base/src/main/java/com/fr/design/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/style/FormatPane.java @@ -45,7 +45,7 @@ import java.util.Date; */ public class FormatPane extends BasicPane { private static final long serialVersionUID = 724330854437726751L; - + private Format format; private UILabel sampleLabel; //preview label. private UIRadioButton nullRadioButton; @@ -59,14 +59,14 @@ public class FormatPane extends BasicPane { //content pane. private UITextField patternTextField = null; private JList patternList = null; - + /** * Constructor. */ public FormatPane() { this.initComponents(); } - + public UILabel getSampleLabel() { return sampleLabel; } @@ -74,7 +74,7 @@ public class FormatPane extends BasicPane { public void setSampleLabel(UILabel sampleLabel) { this.sampleLabel = sampleLabel; } - + protected void initComponents() { this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); @@ -172,7 +172,7 @@ public class FormatPane extends BasicPane { protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); } - + /** * Populate */ @@ -185,17 +185,17 @@ public class FormatPane extends BasicPane { } else { if (format instanceof DecimalFormat) { checkDecimalFormat(); - } else if (format instanceof SimpleDateFormat) { + } else if (format instanceof SimpleDateFormat) { //date and time - checkDateFormat(); - } else if (format instanceof TextFormat) { + checkDateFormat(); + } else if (format instanceof TextFormat) { //Text this.textRadioButton.setSelected(true); this.applyRadioActionListener(this.textRadioButton); } } } - + private void checkDateFormat() { String pattern = ((SimpleDateFormat) format).toPattern(); if(pattern == null) { @@ -276,7 +276,7 @@ public class FormatPane extends BasicPane { } } } - + /** * 百分比面板 */ @@ -296,7 +296,7 @@ public class FormatPane extends BasicPane { /** * 是否属于数组中的列表样式 - * + * * @param stringArray 格式数组 * @param pattern 输入的格式 * @return 返回在数组中的位置 @@ -323,7 +323,7 @@ public class FormatPane extends BasicPane { } return FormatField.getInstance().getFormat(getFormatContents(), text); } - + private int getFormatContents(){ if (nullRadioButton.isSelected()) return FormatContents.NULL; @@ -335,7 +335,7 @@ public class FormatPane extends BasicPane { return FormatContents.PERCENT; else if (scientificRadioButton.isSelected()) return FormatContents.SCIENTIFIC; - else if (dateRadioButton.isSelected()) + else if (dateRadioButton.isSelected()) return FormatContents.DATE; else if (timeRadioButton.isSelected()) return FormatContents.TIME; @@ -380,7 +380,7 @@ public class FormatPane extends BasicPane { ActionEvent evt = new ActionEvent(radioButton, 100, ""); this.radioActionListener.actionPerformed(evt); } - + /** * Radio selection listener. */ @@ -393,6 +393,7 @@ public class FormatPane extends BasicPane { patternTextField.setEditable(true); patternList.setEnabled(true); + int contents = getContents(source); String[] patternArray = FormatField.getInstance().getFormatArray(contents); @@ -407,6 +408,7 @@ public class FormatPane extends BasicPane { //maybe need to select the first item. String text = patternTextField.getText(); + if (hasPattenText(text, patternModel)) { String pattern = null; if (format instanceof DecimalFormat) { @@ -418,6 +420,10 @@ public class FormatPane extends BasicPane { if (pattern != null) { patternList.setSelectedValue(pattern, true); + if (patternList.getSelectedIndex() == -1) { + //patten不在下拉框里面 + patternList.setSelectedIndex(0); + } } else { patternList.setSelectedIndex(0); } @@ -426,13 +432,13 @@ public class FormatPane extends BasicPane { }; private boolean hasPattenText (String text, DefaultListModel patternModel) { - return (text == null || text.length() <= 0) && patternModel.size() > 0; + return StringUtils.isEmpty(text) && patternModel.size() > 0; } - + private void setPatternTextEnable() { patternTextField.setEnabled(false); patternTextField.setEditable(false); - patternTextField.setText(""); + patternTextField.setText(StringUtils.EMPTY); patternList.setEnabled(false); } @@ -459,7 +465,7 @@ public class FormatPane extends BasicPane { } return contents; } - + /** * text pattern document listener. */ @@ -477,7 +483,7 @@ public class FormatPane extends BasicPane { refreshPreviewLabel(); } }; - + /** * Pattern list selection listener. */ @@ -487,5 +493,5 @@ public class FormatPane extends BasicPane { patternTextField.setText((String) patternList.getSelectedValue()); } }; - + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index 2fdf1e5a6c..f1f916e05f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -61,7 +61,7 @@ public class StylePane extends UIComboBoxPane