From 526a43c7c6ba0bad42a3611795516cb54370b19d Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Oct 2019 11:42:44 +0800 Subject: [PATCH 01/15] =?UTF-8?q?REPORT-21017=E3=80=90=E6=96=B0=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E3=80=91=E5=A2=9E=E5=8A=A0cptx=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=8F=8A=E7=9B=B8=E5=85=B3=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/itree/filetree/FileNodeConstants.java | 4 +- .../gui/itree/filetree/FileTreeIcon.java | 29 ++++++++++-- .../AbstractNewTemplateFileProvider.java | 20 ++++++++ .../com/fr/design/mainframe/JTemplate.java | 32 +++++++++++-- .../mainframe/NewTemplateFileProvider.java | 46 +++++++++++++++++++ .../java/com/fr/file/FILEChooserPane.java | 25 +++++----- .../itree/filetree/FileNodeConstantsTest.java | 39 ++++++++++++---- .../java/com/fr/file/FILEChooserPaneTest.java | 38 +++++++++++++++ .../java/com/fr/design/mainframe/JForm.java | 14 ++++++ .../com/fr/design/mainframe/JWorkBook.java | 9 ++++ 10 files changed, 226 insertions(+), 30 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java create mode 100644 designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java index 8c5f0e154a..256fee21bc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java @@ -55,12 +55,14 @@ public class FileNodeConstants { private static void initSupportedTypes() { try { rwl.writeLock().lock(); - supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); + supportFileType = new ArrayList(); //通过插件扩展的 Set apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); for (App app : apps) { addAppExtensions(app.defaultExtensions()); } + supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); + } finally { rwl.writeLock().unlock(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index b0e26cc80e..1a84fa1695 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -1,7 +1,9 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.BaseUtils; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.icon.LockIcon; +import com.fr.design.mainframe.NewTemplateFileProvider; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; @@ -11,6 +13,7 @@ import javax.swing.Icon; import javax.swing.UIManager; import javax.swing.filechooser.FileSystemView; import java.io.File; +import java.util.Set; public class FileTreeIcon { private FileTreeIcon() { @@ -146,16 +149,36 @@ public class FileTreeIcon { if (node.isDirectory()) { return FileTreeIcon.FOLDER_IMAGE_ICON; } - return FileSystemView.getFileSystemView().getSystemIcon(new File(path)); + return getLocalFileIcon(path); } } if (node.isDirectory()) { return FileTreeIcon.FOLDER_IMAGE_ICON; } else { - return FileTreeIcon.getIcon(FileTreeIcon.getFileType(node.getName()), isShowLock); + return getRemoteFileIcon(node, isShowLock); } } + private static Icon getLocalFileIcon(String path) { + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); + for (NewTemplateFileProvider provider : providers) { + if (provider.getLocalFileIcon(path) != null) { + return provider.getLocalFileIcon(path); + } + } + return FileSystemView.getFileSystemView().getSystemIcon(new File(path)); + } + + private static Icon getRemoteFileIcon(FileNode node, boolean isShowLock){ + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); + for (NewTemplateFileProvider provider : providers) { + if (provider.getRemoteFileIcon(node, isShowLock) != null) { + return provider.getRemoteFileIcon(node, isShowLock); + } + } + return FileTreeIcon.getIcon(FileTreeIcon.getFileType(node.getName()), isShowLock); + } + private static Icon getIcon(int fileType, boolean isLocked) { if (fileType == JAVA_FILE) { if (isLocked) { @@ -293,4 +316,4 @@ public class FileTreeIcon { return TEXT_FILE; } } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java new file mode 100644 index 0000000000..64a6f480fb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java @@ -0,0 +1,20 @@ +package com.fr.design.mainframe; + +import com.fr.stable.fun.mark.API; + +/** + * Created by kerry on 2019-10-14 + */ +@API(level = NewTemplateFileProvider.CURRENT_LEVEL) +public abstract class AbstractNewTemplateFileProvider implements NewTemplateFileProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 852130c1e0..1daeb4d81e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.FRContext; import com.fr.base.Parameter; import com.fr.base.ScreenResolution; +import com.fr.base.extension.FileExtension; import com.fr.base.io.BaseBook; import com.fr.base.iofile.attr.DesignBanCopyAttrMark; import com.fr.base.iofile.attr.TemplateIdAttrMark; @@ -12,7 +13,6 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.TableDataSourceAction; import com.fr.design.actions.edit.RedoAction; import com.fr.design.actions.edit.UndoAction; @@ -49,6 +49,7 @@ import com.fr.design.write.submit.DBManipulationPane; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; import com.fr.file.MemFILE; +import com.fr.file.filter.ChooseFileFilter; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; @@ -575,6 +576,7 @@ public abstract class JTemplate> String oldName = this.getPath(); // alex:如果是SaveAs的话需要让用户来选择路径了 FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc); + addChooseFILEFilter(fileChooser); fileChooser.setFileNameTextField(fileName, this.suffix()); int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); @@ -625,6 +627,16 @@ public abstract class JTemplate> } } + protected void addChooseFILEFilter(FILEChooserPane fileChooser){ + String appName = ProductConstants.APP_NAME; + fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + if (FileExtension.FRM.matchExtension(this.suffix())) { + // richer:form文件 daniel 改成三个字 + fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + } + + } + // 保存新模板时会进入此方法(新建模板直接保存,或者另存为) protected boolean saveNewFile(FILE editingFILE, String oldName) { String originID = StringUtils.EMPTY; @@ -635,13 +647,25 @@ public abstract class JTemplate> initForCollect(); this.editingFILE = editingFILE; - boolean result = this.saveFile(); + boolean result = this.saveToNewFile(oldName); if (result) { DesignerFrameFileDealerPane.getInstance().refresh(); collectInfo(originID); } - //更换最近打开 - DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); + return result; + } + + protected boolean saveToNewFile(String oldName){ + boolean result = false; + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); + for (NewTemplateFileProvider provider : providers) { + result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); + } + if(!result && FileExtension.CPT.matchExtension(this.editingFILE.getPath())){ + result = result || this.saveFile(); + //更换最近打开 + DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); + } return result; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java new file mode 100644 index 0000000000..e14a54d7b5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java @@ -0,0 +1,46 @@ +package com.fr.design.mainframe; + +import com.fr.file.FILEChooserPane; +import com.fr.file.filetree.FileNode; +import com.fr.stable.fun.mark.Mutable; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-11 + */ +public interface NewTemplateFileProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "NewFileTypeProvider"; + + /** + * 向文件选择器中添加指定文件类型过滤器 + * @param fileChooser 文件选择器 + * @param suffix 文件后缀 + */ + void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); + + /** + * 获取本地目录文件关联的icon + * @param path 文件路径 + * @return 对应的图标 + */ + Icon getLocalFileIcon(String path); + + /** + * 获取远程目录文件关联的icon + * @param node 文件节点 + * @param isShowLock 是否显示被锁住 + * @return 对应的图标 + */ + Icon getRemoteFileIcon(FileNode node, boolean isShowLock); + + /** + * 保存为新类型文件 + * @param targetPath 目标路径 + * @param jTemplate 模板对象 + */ + boolean saveToNewFile(String targetPath, JTemplate jTemplate); +} 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 fc4a5dfea0..7c6e56bb7d 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -782,12 +782,7 @@ public class FILEChooserPane extends BasicPane { } } //jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑 - if (type == JFileChooser.OPEN_DIALOG) { - postfixComboBox.setEnabled(true); - } else { - postfixComboBox.setEnabled(false); - } - + postfixComboBox.setEnabled(true); //只有一个类型时不可下拉 if (filterList.size() == 1) { postfixComboBox.setEnabled(false); @@ -841,14 +836,7 @@ public class FILEChooserPane extends BasicPane { private void saveDialog() { String filename = fileNameTextField.getText(); - if (!filename.endsWith(suffix)) { - ChooseFileFilter chooseFileFilter = (ChooseFileFilter) (postfixComboBox.getSelectedItem()); - if (chooseFileFilter != null && StringUtils.isNotEmpty(chooseFileFilter.getExtensionString())) { - fileNameTextField.setText(filename + chooseFileFilter.getExtensionString()); - } else { - fileNameTextField.setText(filename + this.suffix); - } - } + fileNameTextField.setText(calFileNameText(filename, (ChooseFileFilter) (postfixComboBox.getSelectedItem()))); option = OK_OPTION; FILE selectedFile = this.getSelectedFILE(); @@ -874,6 +862,15 @@ public class FILEChooserPane extends BasicPane { } } + private String calFileNameText(String currentValue, ChooseFileFilter selectFileFilter) { + if (selectFileFilter == null || StringUtils.isEmpty(selectFileFilter.getExtensionString())) { + return currentValue + this.suffix; + } else if (!currentValue.endsWith(selectFileFilter.getExtensionString())) { + return currentValue + selectFileFilter.getExtensionString(); + } + return currentValue; + } + private boolean access(FILE selectedFile) { boolean access = false; try { diff --git a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java index 67f0824567..a12ae6c14e 100644 --- a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java @@ -11,6 +11,10 @@ import com.fr.stable.fun.mark.Mutable; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashSet; import java.util.Set; @@ -18,23 +22,42 @@ import java.util.Set; /** * Created by alex sung on 2019/7/25. */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(ExtraDesignClassManager.class) public class FileNodeConstantsTest { @Test - public void supportFileTypesTest(){ - ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); - Set apps = new HashSet(){{add(new MockCptxApp());}}; - EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); - EasyMock.replay(extra); - + public void supportFileTypesTest() { + ExtraDesignClassManager extra = mockExtraDesignClassManager(); Assert.assertEquals(1, extra.getArray(App.MARK_STRING).size()); App app = (App) extra.getArray(App.MARK_STRING).iterator().next(); Assert.assertEquals("cptx", app.defaultExtensions()[0]); } - private class MockCptxApp extends AbstractAppProvider{ + @Test + public void testSupportFileTypesOrder() { + ExtraDesignClassManager extra = mockExtraDesignClassManager(); + PowerMock.mockStatic(ExtraDesignClassManager.class); + EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(extra).once(); + PowerMock.replayAll(); + String[] fileTypes = FileNodeConstants.getSupportFileTypes(); + Assert.assertEquals("cptx", fileTypes[0]); + Assert.assertEquals("cpt", fileTypes[1]); + } + + private ExtraDesignClassManager mockExtraDesignClassManager() { + ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); + Set apps = new HashSet() {{ + add(new MockCptxApp()); + }}; + EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); + EasyMock.replay(extra); + return extra; + } + + private class MockCptxApp extends AbstractAppProvider { @Override public String[] defaultExtensions() { - return new String[] {FileExtension.CPTX.getExtension()}; + return new String[]{FileExtension.CPTX.getExtension()}; } @Override diff --git a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java new file mode 100644 index 0000000000..d3d601c288 --- /dev/null +++ b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java @@ -0,0 +1,38 @@ +package com.fr.file; + +import com.fr.base.extension.FileExtension; +import com.fr.file.filter.ChooseFileFilter; +import com.fr.invoke.Reflect; +import com.fr.stable.StringUtils; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by kerry on 2019-10-15 + */ + +public class FILEChooserPaneTest { + @Test + public void testAddChooseFileFilter() { + FILEChooserPane chooserPane = Reflect.on(FILEChooserPane.class).field("INSTANCE").get(); + String result1 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cpt", null).get(); + Assert.assertEquals("WorkBook1.cptnull", result1); + + ChooseFileFilter chooseFileFilter1 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + String result2 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cpt", chooseFileFilter1).get(); + Assert.assertEquals("WorkBook1.cpt", result2); + + ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); + String result3 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cpt", chooseFileFilter2).get(); + Assert.assertEquals("WorkBook1.cpt.cptx", result3); + + ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + String result4 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cptx", chooseFileFilter3).get(); + Assert.assertEquals("WorkBook1.cptx.cpt", result4); + + ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); + String result5 = Reflect.on(chooserPane).call("calFileNameText", "WorkBook1.cptx", chooseFileFilter5).get(); + Assert.assertEquals("WorkBook1.cptx", result5); + } + +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 6b8cbbe5d5..0abafdabdd 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.PaperSize; import com.fr.base.Parameter; +import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; import com.fr.design.actions.FormMobileAttrAction; @@ -34,6 +35,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.xpane.FormHyperlinkGroupPane; import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; @@ -52,6 +54,8 @@ import com.fr.design.report.fit.menupane.ReportFitAttrAction; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.file.FILE; +import com.fr.file.FILEChooserPane; +import com.fr.file.filter.ChooseFileFilter; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.main.Form; @@ -66,6 +70,7 @@ import com.fr.report.cell.cellattr.CellImage; import com.fr.report.worksheet.FormElementCase; import com.fr.stable.ArrayUtils; import com.fr.stable.Constants; +import com.fr.stable.ProductConstants; import com.fr.stable.bridge.StableFactory; import com.fr.web.controller.ViewRequestConstants; @@ -949,4 +954,13 @@ public class JForm extends JTemplate implements BaseJForm { public String route() { return ViewRequestConstants.REPORT_VIEW_PATH; } + + protected void addChooseFILEFilter(FILEChooserPane fileChooser){ + super.addChooseFILEFilter(fileChooser); + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); + for (NewTemplateFileProvider provider : providers) { + provider.addChooseFileFilter(fileChooser, this.suffix()); + } + } } From 157a846b219496b6b88daaed35e3020029bf5761 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Oct 2019 11:52:04 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/NewTemplateFileProvider.java | 47 +++++++++++++++++++ .../impl/AbstractNewTemplateFileProvider.java | 21 +++++++++ .../gui/itree/filetree/FileTreeIcon.java | 2 +- .../com/fr/design/mainframe/JTemplate.java | 1 + .../com/fr/design/mainframe/JWorkBook.java | 1 + 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java diff --git a/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java new file mode 100644 index 0000000000..34f811ae0a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java @@ -0,0 +1,47 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILEChooserPane; +import com.fr.file.filetree.FileNode; +import com.fr.stable.fun.mark.Mutable; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-11 + */ +public interface NewTemplateFileProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "NewFileTypeProvider"; + + /** + * 向文件选择器中添加指定文件类型过滤器 + * @param fileChooser 文件选择器 + * @param suffix 文件后缀 + */ + void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); + + /** + * 获取本地目录文件关联的icon + * @param path 文件路径 + * @return 对应的图标 + */ + Icon getLocalFileIcon(String path); + + /** + * 获取远程目录文件关联的icon + * @param node 文件节点 + * @param isShowLock 是否显示被锁住 + * @return 对应的图标 + */ + Icon getRemoteFileIcon(FileNode node, boolean isShowLock); + + /** + * 保存为新类型文件 + * @param targetPath 目标路径 + * @param jTemplate 模板对象 + */ + boolean saveToNewFile(String targetPath, JTemplate jTemplate); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java new file mode 100644 index 0000000000..d460c7b959 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java @@ -0,0 +1,21 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.NewTemplateFileProvider; +import com.fr.stable.fun.mark.API; + +/** + * Created by kerry on 2019-10-14 + */ +@API(level = NewTemplateFileProvider.CURRENT_LEVEL) +public abstract class AbstractNewTemplateFileProvider implements NewTemplateFileProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index 1a84fa1695..a453d0a947 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -3,7 +3,7 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.icon.LockIcon; -import com.fr.design.mainframe.NewTemplateFileProvider; +import com.fr.design.fun.NewTemplateFileProvider; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 1daeb4d81e..c862b0caa2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -27,6 +27,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; +import com.fr.design.fun.NewTemplateFileProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 90e30c0c96..7822f7d859 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -34,6 +34,7 @@ import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; +import com.fr.design.fun.NewTemplateFileProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; From 83b322a9cb9c16eeaf31992e60252c46f44d2c48 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 15 Oct 2019 11:52:13 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E6=97=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractNewTemplateFileProvider.java | 20 -------- .../mainframe/NewTemplateFileProvider.java | 46 ------------------- 2 files changed, 66 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java delete mode 100644 designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java deleted file mode 100644 index 64a6f480fb..0000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/AbstractNewTemplateFileProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fr.design.mainframe; - -import com.fr.stable.fun.mark.API; - -/** - * Created by kerry on 2019-10-14 - */ -@API(level = NewTemplateFileProvider.CURRENT_LEVEL) -public abstract class AbstractNewTemplateFileProvider implements NewTemplateFileProvider { - - @Override - public int currentAPILevel() { - return CURRENT_LEVEL; - } - - @Override - public String mark4Provider() { - return getClass().getName(); - } -} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java deleted file mode 100644 index e14a54d7b5..0000000000 --- a/designer-base/src/main/java/com/fr/design/mainframe/NewTemplateFileProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.fr.design.mainframe; - -import com.fr.file.FILEChooserPane; -import com.fr.file.filetree.FileNode; -import com.fr.stable.fun.mark.Mutable; - -import javax.swing.Icon; - -/** - * Created by kerry on 2019-10-11 - */ -public interface NewTemplateFileProvider extends Mutable { - - int CURRENT_LEVEL = 1; - - String XML_TAG = "NewFileTypeProvider"; - - /** - * 向文件选择器中添加指定文件类型过滤器 - * @param fileChooser 文件选择器 - * @param suffix 文件后缀 - */ - void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); - - /** - * 获取本地目录文件关联的icon - * @param path 文件路径 - * @return 对应的图标 - */ - Icon getLocalFileIcon(String path); - - /** - * 获取远程目录文件关联的icon - * @param node 文件节点 - * @param isShowLock 是否显示被锁住 - * @return 对应的图标 - */ - Icon getRemoteFileIcon(FileNode node, boolean isShowLock); - - /** - * 保存为新类型文件 - * @param targetPath 目标路径 - * @param jTemplate 模板对象 - */ - boolean saveToNewFile(String targetPath, JTemplate jTemplate); -} From 5220af6b8320ef3a83f4d4c31d16fd44d3e8f928 Mon Sep 17 00:00:00 2001 From: pengda Date: Wed, 16 Oct 2019 10:24:05 +0800 Subject: [PATCH 04/15] =?UTF-8?q?REPORT-22779=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=90=8E=E9=87=8D=E5=90=AF=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/RestartHelper.java | 44 ++++--------------- .../fr/start/module/DesignerActivator.java | 2 + 2 files changed, 10 insertions(+), 36 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 4a0813f320..1fef32bb30 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -33,7 +33,7 @@ public class RestartHelper { public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties"); public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties"); - + private static OSBasedAction restartAction; /** * 把要删除的文件都记录到delete.properties中 @@ -171,8 +171,8 @@ public class RestartHelper { }catch (Exception e){ FineLoggerFactory.getLogger().error(e.getMessage(), e); } - OSBasedAction osBasedAction = OSSupportCenter.getAction(RestartAction.class); - osBasedAction.execute(filesToBeDelete); + + restartAction.execute(filesToBeDelete); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { @@ -187,39 +187,11 @@ public class RestartHelper { } } - /* private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList(); - commands.add("open"); - commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add("--args"); - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); - } - - private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList(); - commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); + /** + * 提前初始化重启动作 + */ + public static void initRestartAction(){ + restartAction = OSSupportCenter.getAction(RestartAction.class); } - private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList(); - //现在先写的是restart.sh - commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); - }*/ } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 1727906fb0..051857c330 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -11,6 +11,7 @@ import com.fr.config.MarketConfig; import com.fr.decision.update.backup.RecoverManager; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.RestartHelper; import com.fr.design.actions.NewFormAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.insert.cell.BiasCellAction; @@ -139,6 +140,7 @@ public class DesignerActivator extends Activator { storePassport(); AlphaFineHelper.switchConfig4Locale(); RecoverManager.register(new RecoverForDesigner()); + RestartHelper.initRestartAction(); } @Override From 987c17b553417e9bf906b6bfb4efba7c9d9778ef Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 16 Oct 2019 14:03:33 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/NewTemplateFileOptionProvider.java | 47 +++++++++++++++++++ ...AbstractNewTemplateFileOptionProvider.java | 45 ++++++++++++++++++ .../gui/itree/filetree/FileNodeConstants.java | 15 +++--- .../gui/itree/filetree/FileTreeIcon.java | 30 +++++++----- .../com/fr/design/mainframe/JTemplate.java | 6 +-- .../itree/filetree/FileNodeConstantsTest.java | 39 +++++++-------- .../com/fr/design/mainframe/JWorkBook.java | 6 +-- 7 files changed, 140 insertions(+), 48 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java diff --git a/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java new file mode 100644 index 0000000000..feec821ba0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java @@ -0,0 +1,47 @@ +package com.fr.design.fun; + +import com.fr.decision.extension.report.ReportSupportedFileProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILEChooserPane; +import com.fr.stable.fun.mark.Mutable; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-11 + */ +public interface NewTemplateFileOptionProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "NewTemplateFileOptionProvider"; + + /** + * 向文件选择器中添加指定文件类型过滤器 + * @param fileChooser 文件选择器 + * @param suffix 文件后缀 + */ + void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); + + + /** + * 获取对应的新增的支持文件类型 + * @return ReportTemplateFileProvider + */ + ReportSupportedFileProvider getSupportedFile(); + + /** + * 获取文件关联的icon + * @param path 文件路径 + * @param isShowLock 是否显示被锁住 + * @return 对应的图标 + */ + Icon getFileIcon(String path,boolean isShowLock); + + /** + * 保存为新类型文件 + * @param targetPath 目标路径 + * @param jTemplate 模板对象 + */ + boolean saveToNewFile(String targetPath, JTemplate jTemplate); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java new file mode 100644 index 0000000000..931c4bc656 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java @@ -0,0 +1,45 @@ +package com.fr.design.fun.impl; + +import com.fr.decision.extension.report.ReportSupportedFileProvider; +import com.fr.design.fun.NewTemplateFileOptionProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILEChooserPane; +import com.fr.stable.fun.mark.API; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-14 + */ +@API(level = NewTemplateFileOptionProvider.CURRENT_LEVEL) +public abstract class AbstractNewTemplateFileOptionProvider implements NewTemplateFileOptionProvider { + @Override + public void addChooseFileFilter(FILEChooserPane fileChooser, String suffix) { + + } + + @Override + public ReportSupportedFileProvider getSupportedFile() { + return null; + } + + @Override + public Icon getFileIcon(String path, boolean isShowLock) { + return null; + } + + @Override + public boolean saveToNewFile(String targetPath, JTemplate jTemplate) { + return false; + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java index 256fee21bc..d0b14804aa 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java @@ -1,8 +1,9 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.FRContext; +import com.fr.base.extension.FileExtension; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.mainframe.App; +import com.fr.design.fun.NewTemplateFileOptionProvider; import com.fr.general.GeneralContext; import com.fr.plugin.context.PluginContext; import com.fr.plugin.injectable.PluginModule; @@ -44,10 +45,10 @@ public class FileNodeConstants { }); } - private static void addAppExtensions(String[] extensions) { + private static void addAppExtensions(FileExtension[] extensions) { for (int i = 0, size = extensions.length; i < size; i++) { - if (!supportFileType.contains(extensions[i])) { - supportFileType.add(extensions[i]); + if (!supportFileType.contains(extensions[i].getExtension())) { + supportFileType.add(extensions[i].getExtension()); } } } @@ -57,9 +58,9 @@ public class FileNodeConstants { rwl.writeLock().lock(); supportFileType = new ArrayList(); //通过插件扩展的 - Set apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); - for (App app : apps) { - addAppExtensions(app.defaultExtensions()); + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); + for (NewTemplateFileOptionProvider provider : providers) { + addAppExtensions(provider.getSupportedFile().getFileExtensions()); } supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index a453d0a947..68c877fb6c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -3,7 +3,7 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.icon.LockIcon; -import com.fr.design.fun.NewTemplateFileProvider; +import com.fr.design.fun.NewTemplateFileOptionProvider; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; @@ -160,25 +160,31 @@ public class FileTreeIcon { } private static Icon getLocalFileIcon(String path) { - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); - for (NewTemplateFileProvider provider : providers) { - if (provider.getLocalFileIcon(path) != null) { - return provider.getLocalFileIcon(path); - } + Icon icon = getExtraIcon(path, false); + if (icon != null) { + return icon; } return FileSystemView.getFileSystemView().getSystemIcon(new File(path)); } - private static Icon getRemoteFileIcon(FileNode node, boolean isShowLock){ - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); - for (NewTemplateFileProvider provider : providers) { - if (provider.getRemoteFileIcon(node, isShowLock) != null) { - return provider.getRemoteFileIcon(node, isShowLock); - } + private static Icon getRemoteFileIcon(FileNode node, boolean isShowLock) { + Icon icon = getExtraIcon(node.getName(), isShowLock); + if (icon != null) { + return icon; } return FileTreeIcon.getIcon(FileTreeIcon.getFileType(node.getName()), isShowLock); } + private static Icon getExtraIcon(String path, boolean isShowLock) { + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); + for (NewTemplateFileOptionProvider provider : providers) { + if (provider.getFileIcon(path, isShowLock) != null) { + return provider.getFileIcon(path, isShowLock); + } + } + return null; + } + private static Icon getIcon(int fileType, boolean isLocked) { if (fileType == JAVA_FILE) { if (isLocked) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index c862b0caa2..85bd81a721 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -27,7 +27,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; -import com.fr.design.fun.NewTemplateFileProvider; +import com.fr.design.fun.NewTemplateFileOptionProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; @@ -658,8 +658,8 @@ public abstract class JTemplate> protected boolean saveToNewFile(String oldName){ boolean result = false; - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); - for (NewTemplateFileProvider provider : providers) { + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); + for (NewTemplateFileOptionProvider provider : providers) { result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); } if(!result && FileExtension.CPT.matchExtension(this.editingFILE.getPath())){ diff --git a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java index a12ae6c14e..8431344bae 100644 --- a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java @@ -1,12 +1,10 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.extension.FileExtension; -import com.fr.base.io.BaseBook; +import com.fr.decision.extension.report.ReportSupportedFileProvider; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.mainframe.AbstractAppProvider; -import com.fr.design.mainframe.App; -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILE; +import com.fr.design.fun.NewTemplateFileOptionProvider; +import com.fr.design.fun.impl.AbstractNewTemplateFileOptionProvider; import com.fr.stable.fun.mark.Mutable; import org.easymock.EasyMock; import org.junit.Assert; @@ -15,7 +13,6 @@ import org.junit.runner.RunWith; import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; - import java.util.HashSet; import java.util.Set; @@ -28,9 +25,9 @@ public class FileNodeConstantsTest { @Test public void supportFileTypesTest() { ExtraDesignClassManager extra = mockExtraDesignClassManager(); - Assert.assertEquals(1, extra.getArray(App.MARK_STRING).size()); - App app = (App) extra.getArray(App.MARK_STRING).iterator().next(); - Assert.assertEquals("cptx", app.defaultExtensions()[0]); + Assert.assertEquals(1, extra.getArray(NewTemplateFileOptionProvider.XML_TAG).size()); + NewTemplateFileOptionProvider option = (NewTemplateFileOptionProvider) extra.getArray(NewTemplateFileOptionProvider.XML_TAG).iterator().next(); + Assert.assertEquals(FileExtension.CPTX, option.getSupportedFile().getFileExtensions()[0]); } @Test @@ -46,29 +43,25 @@ public class FileNodeConstantsTest { private ExtraDesignClassManager mockExtraDesignClassManager() { ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class); - Set apps = new HashSet() {{ - add(new MockCptxApp()); + Set options = new HashSet() {{ + add(new MockNewTemplateFileOption()); }}; - EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); + EasyMock.expect(extra.getArray(NewTemplateFileOptionProvider.XML_TAG)).andReturn(options).anyTimes(); EasyMock.replay(extra); return extra; } - private class MockCptxApp extends AbstractAppProvider { - @Override - public String[] defaultExtensions() { - return new String[]{FileExtension.CPTX.getExtension()}; - } + private class MockNewTemplateFileOption extends AbstractNewTemplateFileOptionProvider { @Override - public JTemplate openTemplate(FILE tplFile) { - return null; + public ReportSupportedFileProvider getSupportedFile() { + ReportSupportedFileProvider supportedFileProvider = EasyMock.mock(ReportSupportedFileProvider.class); + EasyMock.expect(supportedFileProvider.getFileExtensions()).andReturn(new FileExtension[]{FileExtension.CPTX}).anyTimes(); + EasyMock.replay(supportedFileProvider); + return supportedFileProvider; } - @Override - public BaseBook asIOFile(FILE tplFile) { - return null; - } + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 7822f7d859..4edae780b2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -34,7 +34,7 @@ import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.fun.NewTemplateFileProvider; +import com.fr.design.fun.NewTemplateFileOptionProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; @@ -1171,8 +1171,8 @@ public class JWorkBook extends JTemplate { protected void addChooseFILEFilter(FILEChooserPane fileChooser){ super.addChooseFILEFilter(fileChooser); - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileProvider.XML_TAG); - for (NewTemplateFileProvider provider : providers) { + Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); + for (NewTemplateFileOptionProvider provider : providers) { provider.addChooseFileFilter(fileChooser, this.suffix()); } } From 8bf2a5e0addd3f7a03682868f5237bad08957c27 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 16 Oct 2019 14:03:39 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/NewTemplateFileProvider.java | 47 ------------------- .../impl/AbstractNewTemplateFileProvider.java | 21 --------- 2 files changed, 68 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java delete mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java diff --git a/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java deleted file mode 100644 index 34f811ae0a..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fr.design.fun; - -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILEChooserPane; -import com.fr.file.filetree.FileNode; -import com.fr.stable.fun.mark.Mutable; - -import javax.swing.Icon; - -/** - * Created by kerry on 2019-10-11 - */ -public interface NewTemplateFileProvider extends Mutable { - - int CURRENT_LEVEL = 1; - - String XML_TAG = "NewFileTypeProvider"; - - /** - * 向文件选择器中添加指定文件类型过滤器 - * @param fileChooser 文件选择器 - * @param suffix 文件后缀 - */ - void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); - - /** - * 获取本地目录文件关联的icon - * @param path 文件路径 - * @return 对应的图标 - */ - Icon getLocalFileIcon(String path); - - /** - * 获取远程目录文件关联的icon - * @param node 文件节点 - * @param isShowLock 是否显示被锁住 - * @return 对应的图标 - */ - Icon getRemoteFileIcon(FileNode node, boolean isShowLock); - - /** - * 保存为新类型文件 - * @param targetPath 目标路径 - * @param jTemplate 模板对象 - */ - boolean saveToNewFile(String targetPath, JTemplate jTemplate); -} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java deleted file mode 100644 index d460c7b959..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fr.design.fun.impl; - -import com.fr.design.fun.NewTemplateFileProvider; -import com.fr.stable.fun.mark.API; - -/** - * Created by kerry on 2019-10-14 - */ -@API(level = NewTemplateFileProvider.CURRENT_LEVEL) -public abstract class AbstractNewTemplateFileProvider implements NewTemplateFileProvider { - - @Override - public int currentAPILevel() { - return CURRENT_LEVEL; - } - - @Override - public String mark4Provider() { - return getClass().getName(); - } -} From 5951735bb920aac6994ea7c387bed99aca68abbd Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 16 Oct 2019 14:35:03 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E7=BB=A7=E6=89=BFAbstractProvider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/impl/AbstractNewTemplateFileOptionProvider.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java index 931c4bc656..4d420ada09 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java @@ -4,6 +4,7 @@ import com.fr.decision.extension.report.ReportSupportedFileProvider; import com.fr.design.fun.NewTemplateFileOptionProvider; import com.fr.design.mainframe.JTemplate; import com.fr.file.FILEChooserPane; +import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; import javax.swing.Icon; @@ -12,7 +13,7 @@ import javax.swing.Icon; * Created by kerry on 2019-10-14 */ @API(level = NewTemplateFileOptionProvider.CURRENT_LEVEL) -public abstract class AbstractNewTemplateFileOptionProvider implements NewTemplateFileOptionProvider { +public abstract class AbstractNewTemplateFileOptionProvider extends AbstractProvider implements NewTemplateFileOptionProvider { @Override public void addChooseFileFilter(FILEChooserPane fileChooser, String suffix) { From be9619fc990bc0be43f9d4961f94858f52f4dc96 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 16 Oct 2019 14:57:49 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/ReportSupportedFileUIProvider.java | 47 +++++++++++++++++++ ...AbstractReportSupportedFileUIProvider.java | 46 ++++++++++++++++++ .../gui/itree/filetree/FileNodeConstants.java | 6 +-- .../gui/itree/filetree/FileTreeIcon.java | 6 +-- .../com/fr/design/mainframe/JTemplate.java | 6 +-- .../itree/filetree/FileNodeConstantsTest.java | 12 ++--- .../com/fr/design/mainframe/JWorkBook.java | 6 +-- 7 files changed, 111 insertions(+), 18 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java create mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java diff --git a/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java new file mode 100644 index 0000000000..c68c8813dd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java @@ -0,0 +1,47 @@ +package com.fr.design.fun; + +import com.fr.decision.extension.report.ReportSupportedFileProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILEChooserPane; +import com.fr.stable.fun.mark.Mutable; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-11 + */ +public interface ReportSupportedFileUIProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "ReportSupportedFileUIProvider"; + + /** + * 向文件选择器中添加指定文件类型过滤器 + * @param fileChooser 文件选择器 + * @param suffix 文件后缀 + */ + void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); + + + /** + * 获取对应的新增的支持文件类型 + * @return ReportTemplateFileProvider + */ + ReportSupportedFileProvider getSupportedFile(); + + /** + * 获取文件关联的icon + * @param path 文件路径 + * @param isShowLock 是否显示被锁住 + * @return 对应的图标 + */ + Icon getFileIcon(String path,boolean isShowLock); + + /** + * 保存为新类型文件 + * @param targetPath 目标路径 + * @param jTemplate 模板对象 + */ + boolean saveToNewFile(String targetPath, JTemplate jTemplate); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java new file mode 100644 index 0000000000..f307a91e28 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java @@ -0,0 +1,46 @@ +package com.fr.design.fun.impl; + +import com.fr.decision.extension.report.ReportSupportedFileProvider; +import com.fr.design.fun.ReportSupportedFileUIProvider; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILEChooserPane; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +import javax.swing.Icon; + +/** + * Created by kerry on 2019-10-14 + */ +@API(level = ReportSupportedFileUIProvider.CURRENT_LEVEL) +public abstract class AbstractReportSupportedFileUIProvider extends AbstractProvider implements ReportSupportedFileUIProvider { + @Override + public void addChooseFileFilter(FILEChooserPane fileChooser, String suffix) { + + } + + @Override + public ReportSupportedFileProvider getSupportedFile() { + return null; + } + + @Override + public Icon getFileIcon(String path, boolean isShowLock) { + return null; + } + + @Override + public boolean saveToNewFile(String targetPath, JTemplate jTemplate) { + return false; + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java index d0b14804aa..82cae94c1c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java @@ -3,7 +3,7 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.fun.NewTemplateFileOptionProvider; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.general.GeneralContext; import com.fr.plugin.context.PluginContext; import com.fr.plugin.injectable.PluginModule; @@ -58,8 +58,8 @@ public class FileNodeConstants { rwl.writeLock().lock(); supportFileType = new ArrayList(); //通过插件扩展的 - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); - for (NewTemplateFileOptionProvider provider : providers) { + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { addAppExtensions(provider.getSupportedFile().getFileExtensions()); } supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java index 68c877fb6c..b418c1db4c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java @@ -3,7 +3,7 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.BaseUtils; import com.fr.design.ExtraDesignClassManager; import com.fr.design.icon.LockIcon; -import com.fr.design.fun.NewTemplateFileOptionProvider; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; @@ -176,8 +176,8 @@ public class FileTreeIcon { } private static Icon getExtraIcon(String path, boolean isShowLock) { - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); - for (NewTemplateFileOptionProvider provider : providers) { + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { if (provider.getFileIcon(path, isShowLock) != null) { return provider.getFileIcon(path, isShowLock); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 85bd81a721..4118578dec 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -27,7 +27,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.TemplateTreePane; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.MenuHandler; -import com.fr.design.fun.NewTemplateFileOptionProvider; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; @@ -658,8 +658,8 @@ public abstract class JTemplate> protected boolean saveToNewFile(String oldName){ boolean result = false; - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); - for (NewTemplateFileOptionProvider provider : providers) { + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); } if(!result && FileExtension.CPT.matchExtension(this.editingFILE.getPath())){ diff --git a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java index 8431344bae..5ddc3b8b29 100644 --- a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java @@ -3,8 +3,8 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.extension.FileExtension; import com.fr.decision.extension.report.ReportSupportedFileProvider; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.fun.NewTemplateFileOptionProvider; -import com.fr.design.fun.impl.AbstractNewTemplateFileOptionProvider; +import com.fr.design.fun.ReportSupportedFileUIProvider; +import com.fr.design.fun.impl.AbstractReportSupportedFileUIProvider; import com.fr.stable.fun.mark.Mutable; import org.easymock.EasyMock; import org.junit.Assert; @@ -25,8 +25,8 @@ public class FileNodeConstantsTest { @Test public void supportFileTypesTest() { ExtraDesignClassManager extra = mockExtraDesignClassManager(); - Assert.assertEquals(1, extra.getArray(NewTemplateFileOptionProvider.XML_TAG).size()); - NewTemplateFileOptionProvider option = (NewTemplateFileOptionProvider) extra.getArray(NewTemplateFileOptionProvider.XML_TAG).iterator().next(); + Assert.assertEquals(1, extra.getArray(ReportSupportedFileUIProvider.XML_TAG).size()); + ReportSupportedFileUIProvider option = (ReportSupportedFileUIProvider) extra.getArray(ReportSupportedFileUIProvider.XML_TAG).iterator().next(); Assert.assertEquals(FileExtension.CPTX, option.getSupportedFile().getFileExtensions()[0]); } @@ -46,12 +46,12 @@ public class FileNodeConstantsTest { Set options = new HashSet() {{ add(new MockNewTemplateFileOption()); }}; - EasyMock.expect(extra.getArray(NewTemplateFileOptionProvider.XML_TAG)).andReturn(options).anyTimes(); + EasyMock.expect(extra.getArray(ReportSupportedFileUIProvider.XML_TAG)).andReturn(options).anyTimes(); EasyMock.replay(extra); return extra; } - private class MockNewTemplateFileOption extends AbstractNewTemplateFileOptionProvider { + private class MockNewTemplateFileOption extends AbstractReportSupportedFileUIProvider { @Override public ReportSupportedFileProvider getSupportedFile() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 4edae780b2..713b34c542 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -34,7 +34,7 @@ import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.fun.NewTemplateFileOptionProvider; +import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.fun.PreviewProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; @@ -1171,8 +1171,8 @@ public class JWorkBook extends JTemplate { protected void addChooseFILEFilter(FILEChooserPane fileChooser){ super.addChooseFILEFilter(fileChooser); - Set providers = ExtraDesignClassManager.getInstance().getArray(NewTemplateFileOptionProvider.XML_TAG); - for (NewTemplateFileOptionProvider provider : providers) { + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); + for (ReportSupportedFileUIProvider provider : providers) { provider.addChooseFileFilter(fileChooser, this.suffix()); } } From f8cf8a8a7a65d1fdee197e905ada3e91cb8c6eb5 Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 16 Oct 2019 14:57:55 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/NewTemplateFileOptionProvider.java | 47 ------------------- ...AbstractNewTemplateFileOptionProvider.java | 46 ------------------ 2 files changed, 93 deletions(-) delete mode 100644 designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java delete mode 100644 designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java diff --git a/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java deleted file mode 100644 index feec821ba0..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/NewTemplateFileOptionProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fr.design.fun; - -import com.fr.decision.extension.report.ReportSupportedFileProvider; -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILEChooserPane; -import com.fr.stable.fun.mark.Mutable; - -import javax.swing.Icon; - -/** - * Created by kerry on 2019-10-11 - */ -public interface NewTemplateFileOptionProvider extends Mutable { - - int CURRENT_LEVEL = 1; - - String XML_TAG = "NewTemplateFileOptionProvider"; - - /** - * 向文件选择器中添加指定文件类型过滤器 - * @param fileChooser 文件选择器 - * @param suffix 文件后缀 - */ - void addChooseFileFilter(FILEChooserPane fileChooser, String suffix); - - - /** - * 获取对应的新增的支持文件类型 - * @return ReportTemplateFileProvider - */ - ReportSupportedFileProvider getSupportedFile(); - - /** - * 获取文件关联的icon - * @param path 文件路径 - * @param isShowLock 是否显示被锁住 - * @return 对应的图标 - */ - Icon getFileIcon(String path,boolean isShowLock); - - /** - * 保存为新类型文件 - * @param targetPath 目标路径 - * @param jTemplate 模板对象 - */ - boolean saveToNewFile(String targetPath, JTemplate jTemplate); -} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java deleted file mode 100644 index 4d420ada09..0000000000 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractNewTemplateFileOptionProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.fr.design.fun.impl; - -import com.fr.decision.extension.report.ReportSupportedFileProvider; -import com.fr.design.fun.NewTemplateFileOptionProvider; -import com.fr.design.mainframe.JTemplate; -import com.fr.file.FILEChooserPane; -import com.fr.stable.fun.impl.AbstractProvider; -import com.fr.stable.fun.mark.API; - -import javax.swing.Icon; - -/** - * Created by kerry on 2019-10-14 - */ -@API(level = NewTemplateFileOptionProvider.CURRENT_LEVEL) -public abstract class AbstractNewTemplateFileOptionProvider extends AbstractProvider implements NewTemplateFileOptionProvider { - @Override - public void addChooseFileFilter(FILEChooserPane fileChooser, String suffix) { - - } - - @Override - public ReportSupportedFileProvider getSupportedFile() { - return null; - } - - @Override - public Icon getFileIcon(String path, boolean isShowLock) { - return null; - } - - @Override - public boolean saveToNewFile(String targetPath, JTemplate jTemplate) { - return false; - } - - @Override - public int currentAPILevel() { - return CURRENT_LEVEL; - } - - @Override - public String mark4Provider() { - return getClass().getName(); - } -} From f791ce188fef01026e7db8225b6609390cdd468b Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 17 Oct 2019 11:08:31 +0800 Subject: [PATCH 10/15] =?UTF-8?q?REPORT-22795=20=E3=80=901004=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E3=80=91=E8=AE=BE=E8=AE=A1=E9=9D=A2=E6=9D=BF-?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E8=AE=BE=E7=BD=AE-=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E5=9F=BA=E6=9C=AC=E8=AE=BE=E7=BD=AE=20&&=20R?= =?UTF-8?q?EPORT-21152=20=E8=8B=B1=E6=96=87=E3=80=81=E9=9F=A9=E6=96=87?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8cell->other=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/gui/frpane/RegPane.java | 2 +- .../java/com/fr/design/actions/cell/CellAttributeAction.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java index 2df45f8923..f84d0f5fdb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java @@ -111,8 +111,8 @@ public class RegPane extends BasicPane { cardPane.setPreferredSize(new Dimension(0,0 )); detailedCardLayout.show(cardPane, "Default"); } - fireRegChangeAction(); } + fireRegChangeAction(); } }); } diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/CellAttributeAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/CellAttributeAction.java index 4e4cdb0cc7..e9d5501a4f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/CellAttributeAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/CellAttributeAction.java @@ -17,7 +17,7 @@ public class CellAttributeAction extends CellAttributeTableAction { @Override protected String getID() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Other_Attributes"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Datasource_Other_Attributes"); } } \ No newline at end of file From ee1f910ccdb8750c298df118d697cb712ea4abfe Mon Sep 17 00:00:00 2001 From: Bryant Date: Thu, 17 Oct 2019 13:23:25 +0800 Subject: [PATCH 11/15] =?UTF-8?q?REPORT-22779=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E9=87=8D=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/RestartHelper.java | 57 ++++++++++++++++- .../fr/design/mainframe/DesignerFrame.java | 64 ++++++++++--------- .../update/actions/RecoverForDesigner.java | 4 +- .../update/ui/dialog/UpdateMainDialog.java | 11 ++-- 4 files changed, 97 insertions(+), 39 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 1fef32bb30..8a6d02823f 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -6,11 +6,12 @@ import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; -import com.fr.stable.os.OperatingSystem; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; +import com.fr.workspace.WorkContext; import java.io.File; import java.io.FileInputStream; @@ -146,6 +147,59 @@ public class RestartHelper { restart(ArrayUtils.EMPTY_STRING_ARRAY); } + public static void restartForUpdate(String installHome) { + try { + if (OperatingSystem.isMacos()) { + restartInMacOS(installHome, ArrayUtils.EMPTY_STRING_ARRAY); + } else if (OperatingSystem.isLinux()){ + restartInLinux(installHome, ArrayUtils.EMPTY_STRING_ARRAY); + } else { + restartInWindows(installHome,ArrayUtils.EMPTY_STRING_ARRAY); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage()); + } finally { + WorkContext.getCurrent().close(); + System.exit(0); + } + } + + private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList<>(); + commands.add("open"); + commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add("--args"); + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList<>(); + commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + + private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { + ProcessBuilder builder = new ProcessBuilder(); + List commands = new ArrayList<>(); + //现在先写的是restart.sh + commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); + if (ArrayUtils.isNotEmpty(filesToBeDelete)) { + commands.add(StableUtils.join(filesToBeDelete, "+")); + } + builder.command(commands); + builder.start(); + } + /** * 重启设计器并删除某些特定的文件 * @@ -171,7 +225,6 @@ public class RestartHelper { }catch (Exception e){ FineLoggerFactory.getLogger().error(e.getMessage(), e); } - restartAction.execute(filesToBeDelete); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 56e119d6a7..082775a62d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -4,7 +4,6 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; -import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; @@ -113,9 +112,9 @@ import java.util.Set; public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { - public static final String DESIGNER_FRAME_NAME = "designer_frame"; + private static final String DESIGNER_FRAME_NAME = "designer_frame"; - public static final Dimension MIN_SIZE = new Dimension(100, 100); + private static final Dimension MIN_SIZE = new Dimension(100, 100); private static final long serialVersionUID = -8732559571067484460L; @@ -145,9 +144,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private UIToolbar combineUp; - private NewTemplatePane newWorkBookPane = null; + private NewTemplatePane newWorkBookPane; - private Icon closeMode = UIConstants.CLOSE_OF_AUTHORITY; + private Icon closeMode; private JLayeredPane layeredPane = this.getLayeredPane(); @@ -184,7 +183,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); // 只有一个文件未保存时 - if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) { + if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { int choose = saveSomeTempaltePane.saveLastOneTemplate(); if (choose != JOptionPane.CANCEL_OPTION) { DesignerFrame.this.exit(); @@ -318,7 +317,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void componentResized(ComponentEvent e) { reCalculateFrameSize(); - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { doResize(); } } @@ -334,9 +333,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void resizeFrame() { - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().setComposite(); reCalculateFrameSize(); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().doResize(); } public void closeAuthorityEditing() { @@ -416,8 +415,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } /** - * @param ad - * @return + * @param ad 菜单栏 + * @return panel */ protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { //hugh: private修改为protected方便oem的时候修改右上的组件构成 @@ -515,7 +514,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta protected ArrayList getFrameListeners() { - ArrayList arrayList = new ArrayList(); + ArrayList arrayList = new ArrayList<>(); arrayList.add(windowAdapter); return arrayList; } @@ -593,7 +592,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void refreshDottedLine() { - if (DesignerMode.isAuthorityEditing()) { + if (DesignModeContext.isAuthorityEditing()) { populateAuthorityArea(); populateCloseButton(); addDottedLine(); @@ -633,7 +632,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ private void fireAuthorityStateToNormal() { - java.util.List> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); + List> opendedTemplate = HistoryTemplateListCache.getInstance().getHistoryList(); for (JTemplate jTemplate : opendedTemplate) { // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 if (jTemplate.isDoSomethingInAuthority()) { @@ -676,7 +675,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta for (UIButton fixButton : fixButtons) { combineUp.add(fixButton); } - if (!DesignerMode.isAuthorityEditing()) { + if (!DesignModeContext.isAuthorityEditing()) { combineUp.addSeparator(new Dimension(2, 16)); if (toolbar4Form != null) { for (JComponent jComponent : toolbar4Form) { @@ -692,7 +691,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private void addExtraButtons() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null) { return; } @@ -709,7 +708,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private void addShareButton() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null) { return; } @@ -784,13 +783,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void needToAddAuhtorityPaint() { - newWorkBookPane.setButtonGray(DesignerMode.isAuthorityEditing()); + newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing()); // 进入或退出权限编辑模式,通知插件 Set extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); for (ShortCut shortCut : extraShortCuts) { if (shortCut instanceof AbstractTemplateTreeShortCutProvider) { - shortCut.notifyFromAuhtorityChange(DesignerMode.isAuthorityEditing()); + shortCut.notifyFromAuhtorityChange(DesignModeContext.isAuthorityEditing()); } } } @@ -811,7 +810,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ public void setTitle() { - JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); StringBuilder defaultTitleSB = new StringBuilder(); defaultTitleSB.append(ProductConstants.PRODUCT_NAME); defaultTitleSB.append(" "); @@ -909,7 +908,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public void saveCurrentEditingTemplate() { - JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (editingTemplate == null) { return; } @@ -1092,7 +1091,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta if (inValidDesigner(jt)) { this.addAndActivateJTemplate(); MutilTempalteTabPane.getInstance().setTemTemplate( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); } else { activeTemplate(jt); } @@ -1106,8 +1105,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ private void activeTemplate(JTemplate jt) { // 如果该模板已经打开,则进行激活就可以了 - int index = HistoryTemplateListPane.getInstance().contains(jt); - List> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); + int index = HistoryTemplateListCache.getInstance().contains(jt); + List> historyList = HistoryTemplateListCache.getInstance().getHistoryList(); if (index != -1) { historyList.get(index).activeJTemplate(index, jt); } else { @@ -1115,11 +1114,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } - /** - * Exit退出 - */ - public void exit() { - + public void prepareForExit() { Thread thread = new Thread() { @Override @@ -1138,7 +1133,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } DesignerEnvManager.getEnvManager().setLastOpenFile( - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( WestRegionContainerPane.getInstance().getToolPaneY()); @@ -1150,6 +1145,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta EastRegionContainerPane.getInstance().getContainerWidth()); DesignerEnvManager.getEnvManager().saveXMLFile(); + } + + /** + * Exit退出 + */ + public void exit() { + prepareForExit(); //关闭当前环境 WorkContext.getCurrent().close(); @@ -1251,7 +1253,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta /** * 更新进度框进度 * - * @param progress + * @param progress 进度值 */ public void updateProgress(int progress) { diff --git a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java index 318beb5fc7..75b5e3fadd 100644 --- a/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java +++ b/designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java @@ -3,6 +3,7 @@ package com.fr.design.update.actions; import com.fr.decision.update.backup.Recover; import com.fr.decision.update.data.UpdateConstants; import com.fr.decision.update.exception.UpdateException; +import com.fr.design.mainframe.DesignerContext; import com.fr.general.CommonIOUtils; import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; @@ -46,8 +47,9 @@ public class RecoverForDesigner implements Recover { CommonUtils.mkdirs(file); IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); + DesignerContext.getDesignerFrame().prepareForExit(); return true; - }catch (IOException e) { + } catch (IOException e) { UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); FineLoggerFactory.getLogger().error(exception.getMessage(),exception); return false; 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 e8f3e5986b..8633c0616d 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 @@ -30,6 +30,7 @@ import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.*; +import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; @@ -47,10 +48,8 @@ import java.io.*; import java.nio.charset.StandardCharsets; import java.text.ParsePosition; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; +import java.util.*; import java.util.List; -import java.util.Locale; import java.util.concurrent.ExecutionException; import static java.nio.charset.StandardCharsets.*; @@ -594,19 +593,21 @@ public class UpdateMainDialog extends UIDialog { UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); updateButton.setEnabled(false); updateLabel.setVisible(false); + RestoreResultDialog.deletePreviousPropertyFile(); + final String installHome = StableUtils.getInstallHome(); new FileProcess(callBack) { @Override public void onDownloadSuccess() { progressBar.setVisible(false); deleteForDesignerUpdate(); - RestartHelper.restart(); + RestartHelper.restartForUpdate(installHome); } @Override public void onDownloadFailed() { progressBar.setVisible(false); deleteForDesignerUpdate(); JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); - RestartHelper.restart(); + RestartHelper.restartForUpdate(installHome); } }.execute(); } From 39fbddc8ca48019f6ff99e745c1ad6c704cb1dfc Mon Sep 17 00:00:00 2001 From: "Hugh.C" Date: Thu, 17 Oct 2019 13:57:03 +0800 Subject: [PATCH 12/15] =?UTF-8?q?REPORT-22877=20=E3=80=9010.0.4=E5=9B=9E?= =?UTF-8?q?=E5=BD=92=E3=80=91=E6=A8=A1=E7=89=88=E7=89=88=E6=9C=AC=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=EF=BC=8C=E9=9B=86=E7=BE=A4=E7=8E=AF=E5=A2=83=E4=BB=8D?= =?UTF-8?q?=E7=84=B6=E8=83=BD=E8=BF=9B=E5=85=A5=E7=89=88=E6=9C=AC=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/DesignerFrameFileDealerPane.java | 3 ++- .../java/com/fr/design/mainframe/vcs/common/VcsHelper.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index c8f8280a49..a3bca31aa3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.cluster.ClusterBridge; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -367,7 +368,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt private void fireVcsActionChange() { if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() - || ClusterBridge.isClusterMode()) { + || FineClusterConfig.getInstance().isCluster()) { setEnabled(false); return; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index dc4af8750e..547ddf6ae6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.vcs.common; import com.fr.cluster.ClusterBridge; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.file.HistoryTemplateListCache; @@ -173,7 +174,7 @@ public class VcsHelper implements JTemplateActionListener { public void templateSaved(JTemplate jt) { if (needInit() && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() - && !ClusterBridge.isClusterMode()) { + && !FineClusterConfig.getInstance().isCluster()) { fireVcs(jt); } } From ae154d063c68d88a3c264679f49e22e81596c4b8 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 17 Oct 2019 14:56:53 +0800 Subject: [PATCH 13/15] =?UTF-8?q?REPORT-21017=E3=80=90=E6=96=B0=E5=BC=95?= =?UTF-8?q?=E6=93=8E=E3=80=91=E5=A2=9E=E5=8A=A0cptx=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=8F=8A=E7=9B=B8=E5=85=B3=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/DesignerFrameFileDealerPane.java | 13 +++++++++++-- .../java/com/fr/design/mainframe/JTemplate.java | 10 ++++++++-- .../src/main/java/com/fr/file/FILEChooserPane.java | 2 -- .../java/com/fr/design/mainframe/JPolyWorkBook.java | 7 ++++++- .../java/com/fr/design/mainframe/JWorkBook.java | 9 +++++---- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index c8f8280a49..8f79649067 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; import com.fr.cluster.ClusterBridge; import com.fr.design.DesignModelAdapter; @@ -374,10 +375,11 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt if (WorkContext.getCurrent() != null) { + boolean pathSupportVcsAction = selectedOperation.getFilePath() != null && pathSupportVcsAction(selectedOperation.getFilePath()); if (!WorkContext.getCurrent().isLocal()) { //当前环境为远程环境时 FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode(); - if (selectedOperation.getFilePath() != null) { + if (pathSupportVcsAction) { if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) { setEnabled(false); } else { @@ -388,11 +390,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } else { //当前环境为本地环境时 - setEnabled(selectedOperation.getFilePath() != null); + setEnabled(pathSupportVcsAction); } } } + private boolean pathSupportVcsAction(String path) { + if (FileExtension.CPT.matchExtension(path) || FileExtension.FRM.matchExtension(path)) { + return true; + } + return false; + } + private void closeOpenedTemplate(String path, boolean isCurrentEditing) { for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) { if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 4118578dec..22ffc54036 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -628,13 +628,19 @@ public abstract class JTemplate> } } - protected void addChooseFILEFilter(FILEChooserPane fileChooser){ + private void addChooseFILEFilter(FILEChooserPane fileChooser){ String appName = ProductConstants.APP_NAME; - fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + if (FileExtension.CPT.matchExtension(this.suffix())){ + fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); + } if (FileExtension.FRM.matchExtension(this.suffix())) { // richer:form文件 daniel 改成三个字 fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); } + addExtraChooseFILEFilter(fileChooser); + } + + protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser){ } 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 7c6e56bb7d..7f03b6672d 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -725,11 +725,9 @@ public class FILEChooserPane extends BasicPane { // ben:filefilter设置初值为cpt过滤 this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPTX, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); // richer:form文件 daniel 改成三个字 this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); - this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRMX, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); } else { if (type == JFileChooser.OPEN_DIALOG) { this.addChooseFILEFilter(new ChooseFileFilter(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source"))); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java index f93d473f6e..b68e49e168 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java @@ -3,6 +3,7 @@ */ package com.fr.design.mainframe; +import com.fr.file.FILEChooserPane; import com.fr.main.impl.WorkBook; import com.fr.report.poly.PolyWorkSheet; @@ -44,4 +45,8 @@ public class JPolyWorkBook extends JWorkBook { public void refreshEastPropertiesPane() { EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.POLY); } -} \ No newline at end of file + + protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser) { + + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 713b34c542..f06a5ef2c2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -671,11 +671,13 @@ public class JWorkBook extends JTemplate { // Export - MenuDef MenuDef exportMenuDef = new MenuDef(KeySetUtils.EXPORT.getMenuName()); exportMenuDef.setIconPath("/com/fr/design/images/m_file/export.png"); + addShortCut(exportMenuDef, excelExportMenuDef); + return exportMenuDef; + } + protected void addShortCut(MenuDef exportMenuDef, MenuDef excelExportMenuDef) { exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), new CSVExportAction(this), new TextExportAction(this), new EmbeddedExportExportAction(this)); - - return exportMenuDef; } /** @@ -1169,8 +1171,7 @@ public class JWorkBook extends JTemplate { return ViewRequestConstants.REPORT_VIEW_PATH; } - protected void addChooseFILEFilter(FILEChooserPane fileChooser){ - super.addChooseFILEFilter(fileChooser); + protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser){ Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); for (ReportSupportedFileUIProvider provider : providers) { provider.addChooseFileFilter(fileChooser, this.suffix()); From be4d346eb2eabc66a41f10fe4bc2885217858e90 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 17 Oct 2019 15:14:48 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/fun/ReportSupportedFileUIProvider.java | 9 +++++---- .../impl/AbstractReportSupportedFileUIProvider.java | 7 ++++--- .../design/gui/itree/filetree/FileNodeConstants.java | 2 +- .../gui/itree/filetree/FileNodeConstantsTest.java | 12 ++++-------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java index c68c8813dd..2ccfd9363e 100644 --- a/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun; -import com.fr.decision.extension.report.ReportSupportedFileProvider; +import com.fr.base.extension.FileExtension; import com.fr.design.mainframe.JTemplate; import com.fr.file.FILEChooserPane; import com.fr.stable.fun.mark.Mutable; @@ -25,10 +25,11 @@ public interface ReportSupportedFileUIProvider extends Mutable { /** - * 获取对应的新增的支持文件类型 - * @return ReportTemplateFileProvider + * 获取可支持的文件类型 + * @return 文件扩展 */ - ReportSupportedFileProvider getSupportedFile(); + FileExtension[] getFileExtensions(); + /** * 获取文件关联的icon diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java index f307a91e28..3e8046e6f7 100644 --- a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java @@ -1,6 +1,6 @@ package com.fr.design.fun.impl; -import com.fr.decision.extension.report.ReportSupportedFileProvider; +import com.fr.base.extension.FileExtension; import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.mainframe.JTemplate; import com.fr.file.FILEChooserPane; @@ -20,10 +20,11 @@ public abstract class AbstractReportSupportedFileUIProvider extends AbstractProv } @Override - public ReportSupportedFileProvider getSupportedFile() { - return null; + public FileExtension[] getFileExtensions() { + return new FileExtension[0]; } + @Override public Icon getFileIcon(String path, boolean isShowLock) { return null; diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java index 82cae94c1c..617051dc63 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java @@ -60,7 +60,7 @@ public class FileNodeConstants { //通过插件扩展的 Set providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG); for (ReportSupportedFileUIProvider provider : providers) { - addAppExtensions(provider.getSupportedFile().getFileExtensions()); + addAppExtensions(provider.getFileExtensions()); } supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); diff --git a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java index 5ddc3b8b29..e62091048f 100644 --- a/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java @@ -1,7 +1,6 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.extension.FileExtension; -import com.fr.decision.extension.report.ReportSupportedFileProvider; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.ReportSupportedFileUIProvider; import com.fr.design.fun.impl.AbstractReportSupportedFileUIProvider; @@ -27,7 +26,7 @@ public class FileNodeConstantsTest { ExtraDesignClassManager extra = mockExtraDesignClassManager(); Assert.assertEquals(1, extra.getArray(ReportSupportedFileUIProvider.XML_TAG).size()); ReportSupportedFileUIProvider option = (ReportSupportedFileUIProvider) extra.getArray(ReportSupportedFileUIProvider.XML_TAG).iterator().next(); - Assert.assertEquals(FileExtension.CPTX, option.getSupportedFile().getFileExtensions()[0]); + Assert.assertEquals(FileExtension.CPTX, option.getFileExtensions()[0]); } @Test @@ -54,14 +53,11 @@ public class FileNodeConstantsTest { private class MockNewTemplateFileOption extends AbstractReportSupportedFileUIProvider { @Override - public ReportSupportedFileProvider getSupportedFile() { - ReportSupportedFileProvider supportedFileProvider = EasyMock.mock(ReportSupportedFileProvider.class); - EasyMock.expect(supportedFileProvider.getFileExtensions()).andReturn(new FileExtension[]{FileExtension.CPTX}).anyTimes(); - EasyMock.replay(supportedFileProvider); - return supportedFileProvider; + public FileExtension[] getFileExtensions() { + return new FileExtension[]{FileExtension.CPTX + }; } - } } From 1bca44b7c73e5d7c244509008d8fff987496a2f9 Mon Sep 17 00:00:00 2001 From: Bryant Date: Thu, 17 Oct 2019 16:16:18 +0800 Subject: [PATCH 15/15] =?UTF-8?q?REPORT-22779=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=90=8E=E6=97=A0=E6=B3=95=E9=87=8D=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/RestartHelper.java | 60 ++----------------- .../com/fr/design/os/impl/RestartAction.java | 11 +++- .../update/ui/dialog/UpdateMainDialog.java | 8 +-- .../fr/start/module/DesignerActivator.java | 2 - 4 files changed, 19 insertions(+), 62 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 8a6d02823f..cdb4fc532e 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -8,11 +8,10 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.support.OSBasedAction; -import com.fr.stable.os.support.OSSupportCenter; import com.fr.workspace.WorkContext; +import javax.swing.*; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -20,8 +19,6 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.nio.channels.FileChannel; import java.nio.channels.FileLock; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.Properties; @@ -34,7 +31,7 @@ public class RestartHelper { public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties"); public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties"); - private static OSBasedAction restartAction; + private static final OSBasedAction restartAction = new RestartAction(); /** * 把要删除的文件都记录到delete.properties中 @@ -147,58 +144,19 @@ public class RestartHelper { restart(ArrayUtils.EMPTY_STRING_ARRAY); } - public static void restartForUpdate(String installHome) { + public static void restartForUpdate(JFrame frame) { try { - if (OperatingSystem.isMacos()) { - restartInMacOS(installHome, ArrayUtils.EMPTY_STRING_ARRAY); - } else if (OperatingSystem.isLinux()){ - restartInLinux(installHome, ArrayUtils.EMPTY_STRING_ARRAY); - } else { - restartInWindows(installHome,ArrayUtils.EMPTY_STRING_ARRAY); - } + restartAction.execute(ArrayUtils.EMPTY_STRING_ARRAY); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage()); } finally { WorkContext.getCurrent().close(); + frame.dispose(); System.exit(0); } } - private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList<>(); - commands.add("open"); - commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add("--args"); - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); - } - private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList<>(); - commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); - } - - private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { - ProcessBuilder builder = new ProcessBuilder(); - List commands = new ArrayList<>(); - //现在先写的是restart.sh - commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); - if (ArrayUtils.isNotEmpty(filesToBeDelete)) { - commands.add(StableUtils.join(filesToBeDelete, "+")); - } - builder.command(commands); - builder.start(); - } /** * 重启设计器并删除某些特定的文件 @@ -239,12 +197,4 @@ public class RestartHelper { DesignerContext.getDesignerFrame().exit(); } } - - /** - * 提前初始化重启动作 - */ - public static void initRestartAction(){ - restartAction = OSSupportCenter.getAction(RestartAction.class); - } - } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java b/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java index b18254c113..47a7ae43bf 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java @@ -10,10 +10,19 @@ import java.util.ArrayList; import java.util.List; public class RestartAction implements OSBasedAction { + + private static String installHome; + + public RestartAction() { + installHome = StableUtils.getInstallHome(); + } + @Override public void execute(Object... objects) { String[] filesToBeDelete = (String[])objects; - String installHome = StableUtils.getInstallHome(); + if (installHome == null) { + installHome = StableUtils.getInstallHome(); + } try{ if (OperatingSystem.isMacos()) { restartInMacOS(installHome, filesToBeDelete); 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 8633c0616d..c736b6383b 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 @@ -30,7 +30,6 @@ import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.*; -import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; import com.fr.third.org.apache.http.client.methods.HttpGet; import com.fr.third.org.apache.http.impl.client.CloseableHttpClient; @@ -594,20 +593,21 @@ public class UpdateMainDialog extends UIDialog { updateButton.setEnabled(false); updateLabel.setVisible(false); RestoreResultDialog.deletePreviousPropertyFile(); - final String installHome = StableUtils.getInstallHome(); + final JFrame frame = DesignerContext.getDesignerFrame(); + final RestartHelper helper = new RestartHelper(); new FileProcess(callBack) { @Override public void onDownloadSuccess() { progressBar.setVisible(false); deleteForDesignerUpdate(); - RestartHelper.restartForUpdate(installHome); + helper.restartForUpdate(frame); } @Override public void onDownloadFailed() { progressBar.setVisible(false); deleteForDesignerUpdate(); JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); - RestartHelper.restartForUpdate(installHome); + helper.restartForUpdate(frame); } }.execute(); } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 051857c330..1727906fb0 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -11,7 +11,6 @@ import com.fr.config.MarketConfig; import com.fr.decision.update.backup.RecoverManager; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; -import com.fr.design.RestartHelper; import com.fr.design.actions.NewFormAction; import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.insert.cell.BiasCellAction; @@ -140,7 +139,6 @@ public class DesignerActivator extends Activator { storePassport(); AlphaFineHelper.switchConfig4Locale(); RecoverManager.register(new RecoverForDesigner()); - RestartHelper.initRestartAction(); } @Override