Browse Source

Merge branch 'release/10.0' of https://cloud.finedevelop.com/scm/~joe.jiang/design into release/10.0

feature/big-screen
Joe.Jiang 5 years ago
parent
commit
4e003bcf44
  1. 61
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  2. 48
      designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java
  3. 47
      designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java
  4. 2
      designer-base/src/main/java/com/fr/design/gui/frpane/RegPane.java
  5. 19
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java
  6. 35
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java
  7. 64
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  8. 16
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  9. 39
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  10. 3
      designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java
  11. 11
      designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java
  12. 4
      designer-base/src/main/java/com/fr/design/update/actions/RecoverForDesigner.java
  13. 11
      designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java
  14. 27
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  15. 60
      designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java
  16. 38
      designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java
  17. 14
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  18. 2
      designer-realize/src/main/java/com/fr/design/actions/cell/CellAttributeAction.java
  19. 7
      designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java
  20. 15
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

61
designer-base/src/main/java/com/fr/design/RestartHelper.java

@ -6,12 +6,12 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.support.OSBasedAction; 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.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -19,8 +19,6 @@ import java.io.IOException;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.channels.FileLock; import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -33,7 +31,7 @@ public class RestartHelper {
public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties"); public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties");
public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties"); public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties");
private static final OSBasedAction restartAction = new RestartAction();
/** /**
* 把要删除的文件都记录到delete.properties中 * 把要删除的文件都记录到delete.properties中
@ -146,6 +144,20 @@ public class RestartHelper {
restart(ArrayUtils.EMPTY_STRING_ARRAY); restart(ArrayUtils.EMPTY_STRING_ARRAY);
} }
public static void restartForUpdate(JFrame frame) {
try {
restartAction.execute(ArrayUtils.EMPTY_STRING_ARRAY);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
} finally {
WorkContext.getCurrent().close();
frame.dispose();
System.exit(0);
}
}
/** /**
* 重启设计器并删除某些特定的文件 * 重启设计器并删除某些特定的文件
* *
@ -171,8 +183,7 @@ public class RestartHelper {
}catch (Exception e){ }catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
OSBasedAction osBasedAction = OSSupportCenter.getAction(RestartAction.class); restartAction.execute(filesToBeDelete);
osBasedAction.execute(filesToBeDelete);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally { } finally {
@ -186,40 +197,4 @@ public class RestartHelper {
DesignerContext.getDesignerFrame().exit(); DesignerContext.getDesignerFrame().exit();
} }
} }
/* private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception {
ProcessBuilder builder = new ProcessBuilder();
List<String> commands = new ArrayList<String>();
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<String> commands = new ArrayList<String>();
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<String> commands = new ArrayList<String>();
//现在先写的是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();
}*/
} }

48
designer-base/src/main/java/com/fr/design/fun/ReportSupportedFileUIProvider.java

@ -0,0 +1,48 @@
package com.fr.design.fun;
import com.fr.base.extension.FileExtension;
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 文件扩展
*/
FileExtension[] getFileExtensions();
/**
* 获取文件关联的icon
* @param path 文件路径
* @param isShowLock 是否显示被锁住
* @return 对应的图标
*/
Icon getFileIcon(String path,boolean isShowLock);
/**
* 保存为新类型文件
* @param targetPath 目标路径
* @param jTemplate 模板对象
*/
boolean saveToNewFile(String targetPath, JTemplate jTemplate);
}

47
designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportSupportedFileUIProvider.java

@ -0,0 +1,47 @@
package com.fr.design.fun.impl;
import com.fr.base.extension.FileExtension;
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 FileExtension[] getFileExtensions() {
return new FileExtension[0];
}
@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();
}
}

2
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 )); cardPane.setPreferredSize(new Dimension(0,0 ));
detailedCardLayout.show(cardPane, "Default"); detailedCardLayout.show(cardPane, "Default");
} }
fireRegChangeAction();
} }
fireRegChangeAction();
} }
}); });
} }

19
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileNodeConstants.java

@ -1,8 +1,9 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.mainframe.App; import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule; 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++) { for (int i = 0, size = extensions.length; i < size; i++) {
if (!supportFileType.contains(extensions[i])) { if (!supportFileType.contains(extensions[i].getExtension())) {
supportFileType.add(extensions[i]); supportFileType.add(extensions[i].getExtension());
} }
} }
} }
@ -55,12 +56,14 @@ public class FileNodeConstants {
private static void initSupportedTypes() { private static void initSupportedTypes() {
try { try {
rwl.writeLock().lock(); rwl.writeLock().lock();
supportFileType = new ArrayList<>(Arrays.asList(FRContext.getFileNodes().getSupportedTypes())); supportFileType = new ArrayList<String>();
//通过插件扩展的 //通过插件扩展的
Set<App> apps = ExtraDesignClassManager.getInstance().getArray(App.MARK_STRING); Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (App app : apps) { for (ReportSupportedFileUIProvider provider : providers) {
addAppExtensions(app.defaultExtensions()); addAppExtensions(provider.getFileExtensions());
} }
supportFileType.addAll(Arrays.asList(FRContext.getFileNodes().getSupportedTypes()));
} finally { } finally {
rwl.writeLock().unlock(); rwl.writeLock().unlock();
} }

35
designer-base/src/main/java/com/fr/design/gui/itree/filetree/FileTreeIcon.java

@ -1,7 +1,9 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.icon.LockIcon; import com.fr.design.icon.LockIcon;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
@ -11,6 +13,7 @@ import javax.swing.Icon;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.filechooser.FileSystemView; import javax.swing.filechooser.FileSystemView;
import java.io.File; import java.io.File;
import java.util.Set;
public class FileTreeIcon { public class FileTreeIcon {
private FileTreeIcon() { private FileTreeIcon() {
@ -146,16 +149,42 @@ public class FileTreeIcon {
if (node.isDirectory()) { if (node.isDirectory()) {
return FileTreeIcon.FOLDER_IMAGE_ICON; return FileTreeIcon.FOLDER_IMAGE_ICON;
} }
return FileSystemView.getFileSystemView().getSystemIcon(new File(path)); return getLocalFileIcon(path);
} }
} }
if (node.isDirectory()) { if (node.isDirectory()) {
return FileTreeIcon.FOLDER_IMAGE_ICON; return FileTreeIcon.FOLDER_IMAGE_ICON;
} else { } else {
return FileTreeIcon.getIcon(FileTreeIcon.getFileType(node.getName()), isShowLock); return getRemoteFileIcon(node, isShowLock);
} }
} }
private static Icon getLocalFileIcon(String 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) {
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<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
if (provider.getFileIcon(path, isShowLock) != null) {
return provider.getFileIcon(path, isShowLock);
}
}
return null;
}
private static Icon getIcon(int fileType, boolean isLocked) { private static Icon getIcon(int fileType, boolean isLocked) {
if (fileType == JAVA_FILE) { if (fileType == JAVA_FILE) {
if (isLocked) { if (isLocked) {
@ -293,4 +322,4 @@ public class FileTreeIcon {
return TEXT_FILE; return TEXT_FILE;
} }
} }
} }

64
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -4,7 +4,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -113,9 +112,9 @@ import java.util.Set;
public class DesignerFrame extends JFrame implements JTemplateActionListener, TargetModifiedListener { 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; private static final long serialVersionUID = -8732559571067484460L;
@ -145,9 +144,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private UIToolbar combineUp; 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(); private JLayeredPane layeredPane = this.getLayeredPane();
@ -184,7 +183,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时 // 只有一个文件未保存时
if (HistoryTemplateListPane.getInstance().getHistoryCount() == 1) { if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) {
int choose = saveSomeTempaltePane.saveLastOneTemplate(); int choose = saveSomeTempaltePane.saveLastOneTemplate();
if (choose != JOptionPane.CANCEL_OPTION) { if (choose != JOptionPane.CANCEL_OPTION) {
DesignerFrame.this.exit(); DesignerFrame.this.exit();
@ -318,7 +317,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void componentResized(ComponentEvent e) { public void componentResized(ComponentEvent e) {
reCalculateFrameSize(); reCalculateFrameSize();
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
doResize(); doResize();
} }
} }
@ -334,9 +333,9 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void resizeFrame() { public void resizeFrame() {
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite(); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().setComposite();
reCalculateFrameSize(); reCalculateFrameSize();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize(); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().doResize();
} }
public void closeAuthorityEditing() { public void closeAuthorityEditing() {
@ -416,8 +415,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
/** /**
* @param ad * @param ad 菜单栏
* @return * @return panel
*/ */
protected JPanel initNorthEastPane(final ToolBarMenuDock ad) { protected JPanel initNorthEastPane(final ToolBarMenuDock ad) {
//hugh: private修改为protected方便oem的时候修改右上的组件构成 //hugh: private修改为protected方便oem的时候修改右上的组件构成
@ -515,7 +514,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
protected ArrayList<WindowListener> getFrameListeners() { protected ArrayList<WindowListener> getFrameListeners() {
ArrayList<WindowListener> arrayList = new ArrayList<WindowListener>(); ArrayList<WindowListener> arrayList = new ArrayList<>();
arrayList.add(windowAdapter); arrayList.add(windowAdapter);
return arrayList; return arrayList;
} }
@ -593,7 +592,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void refreshDottedLine() { public void refreshDottedLine() {
if (DesignerMode.isAuthorityEditing()) { if (DesignModeContext.isAuthorityEditing()) {
populateAuthorityArea(); populateAuthorityArea();
populateCloseButton(); populateCloseButton();
addDottedLine(); addDottedLine();
@ -633,7 +632,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
private void fireAuthorityStateToNormal() { private void fireAuthorityStateToNormal() {
java.util.List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> opendedTemplate = HistoryTemplateListCache.getInstance().getHistoryList();
for (JTemplate<?, ?> jTemplate : opendedTemplate) { for (JTemplate<?, ?> jTemplate : opendedTemplate) {
// 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表 // 如果在权限编辑时做过操作,则将做过的操作作为一个整体状态赋给正在报表
if (jTemplate.isDoSomethingInAuthority()) { if (jTemplate.isDoSomethingInAuthority()) {
@ -676,7 +675,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
for (UIButton fixButton : fixButtons) { for (UIButton fixButton : fixButtons) {
combineUp.add(fixButton); combineUp.add(fixButton);
} }
if (!DesignerMode.isAuthorityEditing()) { if (!DesignModeContext.isAuthorityEditing()) {
combineUp.addSeparator(new Dimension(2, 16)); combineUp.addSeparator(new Dimension(2, 16));
if (toolbar4Form != null) { if (toolbar4Form != null) {
for (JComponent jComponent : toolbar4Form) { for (JComponent jComponent : toolbar4Form) {
@ -692,7 +691,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private void addExtraButtons() { private void addExtraButtons() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) { if (jt == null) {
return; return;
} }
@ -709,7 +708,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
private void addShareButton() { private void addShareButton() {
JTemplate<?, ?> jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt == null) { if (jt == null) {
return; return;
} }
@ -784,13 +783,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
public void needToAddAuhtorityPaint() { public void needToAddAuhtorityPaint() {
newWorkBookPane.setButtonGray(DesignerMode.isAuthorityEditing()); newWorkBookPane.setButtonGray(DesignModeContext.isAuthorityEditing());
// 进入或退出权限编辑模式,通知插件 // 进入或退出权限编辑模式,通知插件
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts(); Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) { for (ShortCut shortCut : extraShortCuts) {
if (shortCut instanceof AbstractTemplateTreeShortCutProvider) { 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() { public void setTitle() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
StringBuilder defaultTitleSB = new StringBuilder(); StringBuilder defaultTitleSB = new StringBuilder();
defaultTitleSB.append(ProductConstants.PRODUCT_NAME); defaultTitleSB.append(ProductConstants.PRODUCT_NAME);
defaultTitleSB.append(" "); defaultTitleSB.append(" ");
@ -909,7 +908,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
public void saveCurrentEditingTemplate() { public void saveCurrentEditingTemplate() {
JTemplate<?, ?> editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> editingTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (editingTemplate == null) { if (editingTemplate == null) {
return; return;
} }
@ -1092,7 +1091,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (inValidDesigner(jt)) { if (inValidDesigner(jt)) {
this.addAndActivateJTemplate(); this.addAndActivateJTemplate();
MutilTempalteTabPane.getInstance().setTemTemplate( MutilTempalteTabPane.getInstance().setTemTemplate(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
} else { } else {
activeTemplate(jt); activeTemplate(jt);
} }
@ -1106,8 +1105,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
*/ */
private void activeTemplate(JTemplate jt) { private void activeTemplate(JTemplate jt) {
// 如果该模板已经打开,则进行激活就可以了 // 如果该模板已经打开,则进行激活就可以了
int index = HistoryTemplateListPane.getInstance().contains(jt); int index = HistoryTemplateListCache.getInstance().contains(jt);
List<JTemplate<?, ?>> historyList = HistoryTemplateListPane.getInstance().getHistoryList(); List<JTemplate<?, ?>> historyList = HistoryTemplateListCache.getInstance().getHistoryList();
if (index != -1) { if (index != -1) {
historyList.get(index).activeJTemplate(index, jt); historyList.get(index).activeJTemplate(index, jt);
} else { } else {
@ -1115,11 +1114,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
} }
/** public void prepareForExit() {
* Exit退出
*/
public void exit() {
Thread thread = new Thread() { Thread thread = new Thread() {
@Override @Override
@ -1138,7 +1133,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
DesignerEnvManager.getEnvManager().setLastOpenFile( DesignerEnvManager.getEnvManager().setLastOpenFile(
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath());
DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY(
WestRegionContainerPane.getInstance().getToolPaneY()); WestRegionContainerPane.getInstance().getToolPaneY());
@ -1150,6 +1145,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
EastRegionContainerPane.getInstance().getContainerWidth()); EastRegionContainerPane.getInstance().getContainerWidth());
DesignerEnvManager.getEnvManager().saveXMLFile(); DesignerEnvManager.getEnvManager().saveXMLFile();
}
/**
* Exit退出
*/
public void exit() {
prepareForExit();
//关闭当前环境 //关闭当前环境
WorkContext.getCurrent().close(); WorkContext.getCurrent().close();
@ -1251,7 +1253,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
/** /**
* 更新进度框进度 * 更新进度框进度
* *
* @param progress * @param progress 进度值
*/ */
public void updateProgress(int progress) { public void updateProgress(int progress) {

16
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -1,8 +1,10 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.extension.FileExtension;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.cluster.ClusterBridge; import com.fr.cluster.ClusterBridge;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
@ -367,17 +369,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private void fireVcsActionChange() { private void fireVcsActionChange() {
if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()
|| VcsHelper.getInstance().isUnSelectedTemplate() || VcsHelper.getInstance().isUnSelectedTemplate()
|| ClusterBridge.isClusterMode()) { || FineClusterConfig.getInstance().isCluster()) {
setEnabled(false); setEnabled(false);
return; return;
} }
if (WorkContext.getCurrent() != null) { if (WorkContext.getCurrent() != null) {
boolean pathSupportVcsAction = selectedOperation.getFilePath() != null && pathSupportVcsAction(selectedOperation.getFilePath());
if (!WorkContext.getCurrent().isLocal()) { if (!WorkContext.getCurrent().isLocal()) {
//当前环境为远程环境时 //当前环境为远程环境时
FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode(); FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode();
if (selectedOperation.getFilePath() != null) { if (pathSupportVcsAction) {
if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) { if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) {
setEnabled(false); setEnabled(false);
} else { } else {
@ -388,11 +391,18 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
} }
} else { } 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) { private void closeOpenedTemplate(String path, boolean isCurrentEditing) {
for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) { for (JTemplate jTemplate : HistoryTemplateListCache.getInstance().getHistoryList()) {
if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) { if (ComparatorUtils.equals(jTemplate.getEditingFILE().getPath(), path)) {

39
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.FRContext;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.extension.FileExtension;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.base.iofile.attr.DesignBanCopyAttrMark; import com.fr.base.iofile.attr.DesignBanCopyAttrMark;
import com.fr.base.iofile.attr.TemplateIdAttrMark; 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.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
import com.fr.design.actions.TableDataSourceAction; import com.fr.design.actions.TableDataSourceAction;
import com.fr.design.actions.edit.RedoAction; import com.fr.design.actions.edit.RedoAction;
import com.fr.design.actions.edit.UndoAction; import com.fr.design.actions.edit.UndoAction;
@ -27,6 +27,7 @@ import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateTreePane; import com.fr.design.file.TemplateTreePane;
import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.fun.DesignerFrameUpButtonProvider;
import com.fr.design.fun.MenuHandler; import com.fr.design.fun.MenuHandler;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PreviewProvider;
import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
@ -49,6 +50,7 @@ import com.fr.design.write.submit.DBManipulationPane;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.file.MemFILE; import com.fr.file.MemFILE;
import com.fr.file.filter.ChooseFileFilter;
import com.fr.form.ui.NoneWidget; import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -575,6 +577,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
String oldName = this.getPath(); String oldName = this.getPath();
// alex:如果是SaveAs的话需要让用户来选择路径了 // alex:如果是SaveAs的话需要让用户来选择路径了
FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc); FILEChooserPane fileChooser = getFILEChooserPane(isShowLoc);
addChooseFILEFilter(fileChooser);
fileChooser.setFileNameTextField(fileName, this.suffix()); fileChooser.setFileNameTextField(fileName, this.suffix());
int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix()); int chooseResult = fileChooser.showSaveDialog(DesignerContext.getDesignerFrame(), this.suffix());
@ -625,6 +628,22 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
} }
private void addChooseFILEFilter(FILEChooserPane fileChooser){
String appName = ProductConstants.APP_NAME;
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){
}
// 保存新模板时会进入此方法(新建模板直接保存,或者另存为) // 保存新模板时会进入此方法(新建模板直接保存,或者另存为)
protected boolean saveNewFile(FILE editingFILE, String oldName) { protected boolean saveNewFile(FILE editingFILE, String oldName) {
String originID = StringUtils.EMPTY; String originID = StringUtils.EMPTY;
@ -635,13 +654,25 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
initForCollect(); initForCollect();
this.editingFILE = editingFILE; this.editingFILE = editingFILE;
boolean result = this.saveFile(); boolean result = this.saveToNewFile(oldName);
if (result) { if (result) {
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refresh();
collectInfo(originID); collectInfo(originID);
} }
//更换最近打开 return result;
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); }
protected boolean saveToNewFile(String oldName){
boolean result = false;
Set<ReportSupportedFileUIProvider> 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())){
result = result || this.saveFile();
//更换最近打开
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath());
}
return result; return result;
} }

3
designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.vcs.common; package com.fr.design.mainframe.vcs.common;
import com.fr.cluster.ClusterBridge; import com.fr.cluster.ClusterBridge;
import com.fr.cluster.engine.base.FineClusterConfig;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -173,7 +174,7 @@ public class VcsHelper implements JTemplateActionListener {
public void templateSaved(JTemplate<?, ?> jt) { public void templateSaved(JTemplate<?, ?> jt) {
if (needInit() if (needInit()
&& DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()
&& !ClusterBridge.isClusterMode()) { && !FineClusterConfig.getInstance().isCluster()) {
fireVcs(jt); fireVcs(jt);
} }
} }

11
designer-base/src/main/java/com/fr/design/os/impl/RestartAction.java

@ -10,10 +10,19 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class RestartAction implements OSBasedAction { public class RestartAction implements OSBasedAction {
private static String installHome;
public RestartAction() {
installHome = StableUtils.getInstallHome();
}
@Override @Override
public void execute(Object... objects) { public void execute(Object... objects) {
String[] filesToBeDelete = (String[])objects; String[] filesToBeDelete = (String[])objects;
String installHome = StableUtils.getInstallHome(); if (installHome == null) {
installHome = StableUtils.getInstallHome();
}
try{ try{
if (OperatingSystem.isMacos()) { if (OperatingSystem.isMacos()) {
restartInMacOS(installHome, filesToBeDelete); restartInMacOS(installHome, filesToBeDelete);

4
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.backup.Recover;
import com.fr.decision.update.data.UpdateConstants; import com.fr.decision.update.data.UpdateConstants;
import com.fr.decision.update.exception.UpdateException; import com.fr.decision.update.exception.UpdateException;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.CommonIOUtils; import com.fr.general.CommonIOUtils;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
@ -46,8 +47,9 @@ public class RecoverForDesigner implements Recover {
CommonUtils.mkdirs(file); CommonUtils.mkdirs(file);
IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME), IOUtils.copyFilesInDirByPath(StableUtils.pathJoin(installHome,ProjectConstants.LIB_NAME),
StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH)); StableUtils.pathJoin(installHome, UpdateConstants.DESIGNERBACKUPPATH));
DesignerContext.getDesignerFrame().prepareForExit();
return true; return true;
}catch (IOException e) { } catch (IOException e) {
UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage()); UpdateException exception = new UpdateException("Backup Exception for designer" + e.getMessage());
FineLoggerFactory.getLogger().error(exception.getMessage(),exception); FineLoggerFactory.getLogger().error(exception.getMessage(),exception);
return false; return false;

11
designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java

@ -47,10 +47,8 @@ import java.io.*;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static java.nio.charset.StandardCharsets.*; import static java.nio.charset.StandardCharsets.*;
@ -594,19 +592,22 @@ public class UpdateMainDialog extends UIDialog {
UpdateCallBack callBack = new UpdateProgressCallBack(progressBar); UpdateCallBack callBack = new UpdateProgressCallBack(progressBar);
updateButton.setEnabled(false); updateButton.setEnabled(false);
updateLabel.setVisible(false); updateLabel.setVisible(false);
RestoreResultDialog.deletePreviousPropertyFile();
final JFrame frame = DesignerContext.getDesignerFrame();
final RestartHelper helper = new RestartHelper();
new FileProcess(callBack) { new FileProcess(callBack) {
@Override @Override
public void onDownloadSuccess() { public void onDownloadSuccess() {
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate(); deleteForDesignerUpdate();
RestartHelper.restart(); helper.restartForUpdate(frame);
} }
@Override @Override
public void onDownloadFailed() { public void onDownloadFailed() {
progressBar.setVisible(false); progressBar.setVisible(false);
deleteForDesignerUpdate(); deleteForDesignerUpdate();
JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message")); JOptionPane.showMessageDialog(getParent(), Toolkit.i18nText("Fine-Design_Update_Info_Failed_Message"));
RestartHelper.restart(); helper.restartForUpdate(frame);
} }
}.execute(); }.execute();
} }

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

@ -725,11 +725,9 @@ public class FILEChooserPane extends BasicPane {
// ben:filefilter设置初值为cpt过滤 // ben:filefilter设置初值为cpt过滤
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.CPT, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); 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 改成三个字 // richer:form文件 daniel 改成三个字
this.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File"))); 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 { } else {
if (type == JFileChooser.OPEN_DIALOG) { if (type == JFileChooser.OPEN_DIALOG) {
this.addChooseFILEFilter(new ChooseFileFilter(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source"))); this.addChooseFILEFilter(new ChooseFileFilter(EnumSet.of(FileExtension.XLS, FileExtension.XLSX), Toolkit.i18nText("Fine-Design_Basic_Import_Excel_Source")));
@ -782,12 +780,7 @@ public class FILEChooserPane extends BasicPane {
} }
} }
//jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑 //jerry 26216 只保留.cpt .frm有用的格式,并且不可编辑
if (type == JFileChooser.OPEN_DIALOG) { postfixComboBox.setEnabled(true);
postfixComboBox.setEnabled(true);
} else {
postfixComboBox.setEnabled(false);
}
//只有一个类型时不可下拉 //只有一个类型时不可下拉
if (filterList.size() == 1) { if (filterList.size() == 1) {
postfixComboBox.setEnabled(false); postfixComboBox.setEnabled(false);
@ -841,14 +834,7 @@ public class FILEChooserPane extends BasicPane {
private void saveDialog() { private void saveDialog() {
String filename = fileNameTextField.getText(); String filename = fileNameTextField.getText();
if (!filename.endsWith(suffix)) { fileNameTextField.setText(calFileNameText(filename, (ChooseFileFilter) (postfixComboBox.getSelectedItem())));
ChooseFileFilter chooseFileFilter = (ChooseFileFilter) (postfixComboBox.getSelectedItem());
if (chooseFileFilter != null && StringUtils.isNotEmpty(chooseFileFilter.getExtensionString())) {
fileNameTextField.setText(filename + chooseFileFilter.getExtensionString());
} else {
fileNameTextField.setText(filename + this.suffix);
}
}
option = OK_OPTION; option = OK_OPTION;
FILE selectedFile = this.getSelectedFILE(); FILE selectedFile = this.getSelectedFILE();
@ -874,6 +860,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) { private boolean access(FILE selectedFile) {
boolean access = false; boolean access = false;
try { try {

60
designer-base/src/test/java/com/fr/design/gui/itree/filetree/FileNodeConstantsTest.java

@ -1,51 +1,63 @@
package com.fr.design.gui.itree.filetree; package com.fr.design.gui.itree.filetree;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.io.BaseBook;
import com.fr.design.ExtraDesignClassManager; import com.fr.design.ExtraDesignClassManager;
import com.fr.design.mainframe.AbstractAppProvider; import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.mainframe.App; import com.fr.design.fun.impl.AbstractReportSupportedFileUIProvider;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; 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.HashSet;
import java.util.Set; import java.util.Set;
/** /**
* Created by alex sung on 2019/7/25. * Created by alex sung on 2019/7/25.
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest(ExtraDesignClassManager.class)
public class FileNodeConstantsTest { public class FileNodeConstantsTest {
@Test @Test
public void supportFileTypesTest(){ public void supportFileTypesTest() {
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.getFileExtensions()[0]);
}
@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); ExtraDesignClassManager extra = EasyMock.mock(ExtraDesignClassManager.class);
Set<Mutable> apps = new HashSet<Mutable>(){{add(new MockCptxApp());}}; Set<Mutable> options = new HashSet<Mutable>() {{
EasyMock.expect(extra.getArray(App.MARK_STRING)).andReturn(apps).anyTimes(); add(new MockNewTemplateFileOption());
}};
EasyMock.expect(extra.getArray(ReportSupportedFileUIProvider.XML_TAG)).andReturn(options).anyTimes();
EasyMock.replay(extra); EasyMock.replay(extra);
return extra;
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{ private class MockNewTemplateFileOption extends AbstractReportSupportedFileUIProvider {
@Override
public String[] defaultExtensions() {
return new String[] {FileExtension.CPTX.getExtension()};
}
@Override @Override
public JTemplate openTemplate(FILE tplFile) { public FileExtension[] getFileExtensions() {
return null; return new FileExtension[]{FileExtension.CPTX
};
} }
@Override
public BaseBook asIOFile(FILE tplFile) {
return null;
}
} }
} }

38
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);
}
}

14
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.BaseUtils;
import com.fr.base.PaperSize; import com.fr.base.PaperSize;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.extension.FileExtension;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.actions.FormMobileAttrAction; 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.imenu.UIMenuItem;
import com.fr.design.gui.xpane.FormHyperlinkGroupPane; import com.fr.design.gui.xpane.FormHyperlinkGroupPane;
import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop; import com.fr.design.gui.xpane.FormHyperlinkGroupPaneNoPop;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider; 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.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.gui.LayoutUtils; import com.fr.design.utils.gui.LayoutUtils;
import com.fr.file.FILE; 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.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider; import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form; 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.report.worksheet.FormElementCase;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.ProductConstants;
import com.fr.stable.bridge.StableFactory; import com.fr.stable.bridge.StableFactory;
import com.fr.web.controller.ViewRequestConstants; import com.fr.web.controller.ViewRequestConstants;
@ -949,4 +954,13 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
public String route() { public String route() {
return ViewRequestConstants.FORM_VIEW_PATH; return ViewRequestConstants.FORM_VIEW_PATH;
} }
protected void addChooseFILEFilter(FILEChooserPane fileChooser){
String appName = ProductConstants.APP_NAME;
if (FileExtension.FRM.matchExtension(this.suffix())) {
// richer:form文件 daniel 改成三个字
fileChooser.addChooseFILEFilter(new ChooseFileFilter(FileExtension.FRM, appName + Toolkit.i18nText("Fine-Design_Report_Template_File")));
}
}
} }

2
designer-realize/src/main/java/com/fr/design/actions/cell/CellAttributeAction.java

@ -17,7 +17,7 @@ public class CellAttributeAction extends CellAttributeTableAction {
@Override @Override
protected String getID() { 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");
} }
} }

7
designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java

@ -3,6 +3,7 @@
*/ */
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.file.FILEChooserPane;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.poly.PolyWorkSheet; import com.fr.report.poly.PolyWorkSheet;
@ -44,4 +45,8 @@ public class JPolyWorkBook extends JWorkBook {
public void refreshEastPropertiesPane() { public void refreshEastPropertiesPane() {
EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.POLY); EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.POLY);
} }
}
protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser) {
}
}

15
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.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fun.ReportSupportedFileUIProvider;
import com.fr.design.fun.PreviewProvider; import com.fr.design.fun.PreviewProvider;
import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
@ -65,6 +66,7 @@ import com.fr.design.write.submit.DBManipulationPane;
import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane; import com.fr.design.write.submit.SmartInsertDBManipulationInWidgetEventPane;
import com.fr.design.write.submit.SmartInsertDBManipulationPane; import com.fr.design.write.submit.SmartInsertDBManipulationPane;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FILEChooserPane;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
@ -669,11 +671,13 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
// Export - MenuDef // Export - MenuDef
MenuDef exportMenuDef = new MenuDef(KeySetUtils.EXPORT.getMenuName()); MenuDef exportMenuDef = new MenuDef(KeySetUtils.EXPORT.getMenuName());
exportMenuDef.setIconPath("/com/fr/design/images/m_file/export.png"); 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), exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this),
new CSVExportAction(this), new TextExportAction(this), new EmbeddedExportExportAction(this)); new CSVExportAction(this), new TextExportAction(this), new EmbeddedExportExportAction(this));
return exportMenuDef;
} }
/** /**
@ -1166,4 +1170,11 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
public String route() { public String route() {
return ViewRequestConstants.REPORT_VIEW_PATH; return ViewRequestConstants.REPORT_VIEW_PATH;
} }
protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser){
Set<ReportSupportedFileUIProvider> providers = ExtraDesignClassManager.getInstance().getArray(ReportSupportedFileUIProvider.XML_TAG);
for (ReportSupportedFileUIProvider provider : providers) {
provider.addChooseFileFilter(fileChooser, this.suffix());
}
}
} }

Loading…
Cancel
Save