Browse Source

Merge remote-tracking branch 'origin/release/10.0' into release/10.0

final/10.0
alex.sung 6 years ago
parent
commit
203e228c79
  1. 6
      designer-base/pom.xml
  2. 44
      designer-base/src/main/java/com/fr/design/DesignerEnvManager.java
  3. 173
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 4
      designer-base/src/main/java/com/fr/design/RestartHelper.java
  5. 6
      designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java
  6. 74
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  7. 2
      designer-base/src/main/java/com/fr/design/actions/help/FeedBackPane.java
  8. 86
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java
  9. 121
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  10. 6
      designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java
  11. 2
      designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java
  12. 2
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  13. 2
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  14. 4
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java
  15. 4
      designer-base/src/main/java/com/fr/design/data/tabledata/ResponseDataSourceChange.java
  16. 2
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  17. 2
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java
  18. 2
      designer-base/src/main/java/com/fr/design/dialog/UIDialog.java
  19. 4
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java
  20. 7
      designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java
  21. 12
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  22. 33
      designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java
  23. 4
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  24. 2
      designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java
  25. 2
      designer-base/src/main/java/com/fr/design/extra/PluginUtils.java
  26. 6
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  27. 2
      designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java
  28. 2
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  29. 2
      designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java
  30. 2
      designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java
  31. 2
      designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java
  32. 63
      designer-base/src/main/java/com/fr/design/file/FileOperations.java
  33. 295
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  34. 443
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java
  35. 460
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  36. 225
      designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java
  37. 359
      designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java
  38. 3
      designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java
  39. 128
      designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java
  40. 29
      designer-base/src/main/java/com/fr/design/hyperlink/WebHyperlinkPane.java
  41. 43
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  42. 700
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  43. 28
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  44. 22
      designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java
  45. 341
      designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java
  46. 71
      designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java
  47. 6
      designer-base/src/main/java/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java
  48. 22
      designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java
  49. 68
      designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java
  50. 4555
      designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/EncodingDetect.java
  51. 21
      designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java
  52. 77
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java
  53. 4
      designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java
  54. 20
      designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java
  55. 275
      designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java
  56. 100
      designer-base/src/main/java/com/fr/design/roleAuthority/RoleSourceOP.java
  57. 57
      designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java
  58. 39
      designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java
  59. 2
      designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java
  60. 10
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  61. 185
      designer-base/src/main/java/com/fr/env/RemoteEnvPane2.java
  62. 167
      designer-base/src/main/java/com/fr/env/RemoteEnvUtils.java
  63. 51
      designer-base/src/main/java/com/fr/file/FILE.java
  64. 799
      designer-base/src/main/java/com/fr/file/FILEChooserPane.java
  65. 4
      designer-base/src/main/java/com/fr/file/FILEFactory.java
  66. 48
      designer-base/src/main/java/com/fr/file/FileFILE.java
  67. 102
      designer-base/src/main/java/com/fr/file/FileNodeFILE.java
  68. 7
      designer-base/src/main/java/com/fr/file/MemFILE.java
  69. 12
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  70. 26
      designer-base/src/main/java/com/fr/start/ServerStarter.java
  71. 4
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java
  72. 90
      designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java
  73. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/bbs.png
  74. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/bug.png
  75. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/center.png
  76. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/demand.png
  77. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/help.png
  78. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/need.png
  79. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/question.png
  80. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/sign.png
  81. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/solution.png
  82. BIN
      designer-base/src/main/resources/com/fr/design/images/bbs/video.png
  83. BIN
      designer-base/src/main/resources/com/fr/design/images/icon_NewFolderIcon_normal.png
  84. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart-Map.png
  85. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Column.png
  86. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Comb_Chart.png
  87. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Donut.png
  88. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Funnel.png
  89. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gantt.png
  90. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gis.png
  91. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Meter.png
  92. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Pie.png
  93. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Radar.png
  94. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Range_Chart.png
  95. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Stock.png
  96. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-XYScatter.png
  97. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart_BubbleChart.png
  98. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/FR-Chart-Bit_Map.png
  99. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Area.png
  100. BIN
      designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Bar.png
  101. Some files were not shown because too many files have changed in this diff Show More

6
designer-base/pom.xml

@ -8,6 +8,9 @@
<artifactId>design</artifactId>
<version>10.0</version>
</parent>
<groupId>com.fr.report</groupId>
<artifactId>designer-base</artifactId>
<version>10.0</version>
<dependencies>
<dependency>
<groupId>io.socket</groupId>
@ -15,7 +18,4 @@
<version>0.7.0</version>
</dependency>
</dependencies>
<groupId>com.fr.report</groupId>
<artifactId>designer-base</artifactId>
<version>10.0</version>
</project>

44
designer-base/src/main/java/com/fr/design/DesignerEnvManager.java

@ -26,6 +26,7 @@ import com.fr.general.xml.GeneralXMLTools;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CommonUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreConstants;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.ListMap;
import com.fr.stable.ProductConstants;
@ -38,12 +39,14 @@ import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import javax.swing.*;
import javax.swing.SwingWorker;
import javax.swing.SwingWorker.StateValue;
import java.awt.*;
import java.awt.Color;
import java.awt.Rectangle;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
@ -57,6 +60,7 @@ import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
@ -622,7 +626,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
fout.flush();
fout.close();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
}
@ -848,10 +852,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param filePath 文件路径
*/
public void addRecentOpenedFilePath(String filePath) {
filePath = FilenameUtils.standard(filePath);
// 先删除.
if (getRecentOpenedFilePathList().contains(filePath)) {
getRecentOpenedFilePathList().remove(filePath);
}
getRecentOpenedFilePathList().add(0, filePath);
checkRecentOpenedFileNum();
@ -860,18 +863,38 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
/**
* 替换近期打开的文件路径
*
* @param oldPath 旧的路径
* @param newPath 新的路径
* @param oldPath path 使用 unix 分隔符
* @param newPath path 使用 unix 分隔符
*/
public void replaceRecentOpenedFilePath(String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList();
if (list.contains(oldPath)) {
int index = getRecentOpenedFilePathList().indexOf(oldPath);
int index = list.indexOf(oldPath);
list.remove(oldPath);
list.add(index, newPath);
}
}
/**
* 替换近期打开的文件路径
*
* @param type 文件类型,文件夹true,文件false
* @param oldPath path 使用 unix 分隔符
* @param newPath path 使用 unix 分隔符
*/
public void replaceRecentOpenedFilePath(boolean type, String oldPath, String newPath) {
List<String> list = getRecentOpenedFilePathList();
ListIterator<String> iterator = list.listIterator();
while (iterator.hasNext()) {
String s = FilenameUtils.standard(iterator.next());
if (type ? s.contains(oldPath + CoreConstants.SEPARATOR) : s.equals(oldPath)) {
s = s.replace(oldPath, newPath);
iterator.set(s);
}
}
}
private void checkRecentOpenedFileNum() {
List<String> list = getRecentOpenedFilePathList();
if (list == null) {
@ -888,10 +911,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
* @param filePath 文件路径
*/
public void removeRecentOpenedFilePath(String filePath) {
if (getRecentOpenedFilePathList().contains(filePath)) {
filePath = FilenameUtils.standard(filePath);
getRecentOpenedFilePathList().remove(filePath);
}
}
/**
@ -1609,7 +1631,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter {
if (reader.isChildNode()) {
String n = reader.getTagName();
if ("Path".equals(n)) {
String path = reader.getElementValue();
String path = FilenameUtils.standard(reader.getElementValue());
if (StringUtils.isNotEmpty(path)) {
recentOpenedFileList.add(path);
}

173
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -0,0 +1,173 @@
package com.fr.design;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.DesignUtils;
import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.util.HashMap;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
public class EnvChangeEntrance {
private String currentEnvName = "";
public static EnvChangeEntrance getInstance() {
return HOLDER.singleton;
}
private static class HOLDER {
private static EnvChangeEntrance singleton = new EnvChangeEntrance();
}
private EnvChangeEntrance() {
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName();
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName();
}
});
}
private boolean envListOkAction(EnvListPane envListPane) {
final String selectedName = envListPane.updateEnvManager();
return switch2Env(selectedName);
}
/**
* 切换到新环境
*
* @param envName 新工作环境名称
* @return 是否成功
*/
public boolean switch2Env(final String envName) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame();
JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
DesignTableDataManager.fireDSChanged(new HashMap<String, String>());
}
});
} catch (AuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
return false;
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
UIManager.getString("OptionPane.messageDialogTitle"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
return false;
}
TemplateTreePane.getInstance().refreshDockingView();
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter();
if (model != null) {
model.envChanged();
}
return true;
}
/**
* 编辑items
*
* @see EnvChangeEntrance#chooseEnv()
* @deprecated use {@link EnvChangeEntrance#chooseEnv()}
*/
@Deprecated
public void editItems() {
chooseEnv();
}
/**
* 出现对话框选择使用的工作环境
*/
public void chooseEnv() {
final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(currentEnvName);
envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
envListDialog.dispose();
envListOkAction(envListPane);
}
@Override
public void doCancel() {
envListDialog.dispose();
}
});
envListDialog.setVisible(true);
}
/**
* 处理异常
*/
public void dealEvnExceptionWhenStartDesigner() {
final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(currentEnvName);
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
if (!envListOkAction(envListPane)) {
System.exit(0);
}
}
@Override
public void doCancel() {
System.exit(0);
}
});
envListDialog.setVisible(true);
}
}

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

@ -166,7 +166,7 @@ public class RestartHelper {
FineLoggerFactory.getLogger().error("restart lock null!");
}
}catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (OperatingSystem.isMacOS()) {
restartInMacOS(installHome, filesToBeDelete);
@ -174,7 +174,7 @@ public class RestartHelper {
restartInWindows(installHome, filesToBeDelete);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} finally {
DesignerContext.getDesignerFrame().exit();
}

6
designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java

@ -1,12 +1,11 @@
package com.fr.design.actions.file;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.actions.UpdateAction;
import com.fr.design.mainframe.TemplatePane;
import java.awt.event.ActionEvent;
public class EditEnvAction extends UpdateAction {
@ -16,7 +15,6 @@ public class EditEnvAction extends UpdateAction {
@Override
public void actionPerformed(ActionEvent e) {
TemplatePane.getInstance().editItems();
EnvChangeEntrance.getInstance().chooseEnv();
}
}

74
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -2,31 +2,15 @@ package com.fr.design.actions.file;
import com.fr.base.BaseUtils;
import com.fr.design.DesignerEnvManager;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.actions.UpdateAction;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef;
import com.fr.design.utils.DesignUtils;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class SwitchExistEnv extends MenuDef {
@ -38,7 +22,6 @@ public class SwitchExistEnv extends MenuDef {
}
private void initMenuDef() {
// ButtonGroup group = new ButtonGroup();
Iterator<String> nameIt = DesignerEnvManager.getEnvManager().getEnvNameIterator();
while (nameIt.hasNext()) {
String name = nameIt.next();
@ -49,7 +32,8 @@ public class SwitchExistEnv extends MenuDef {
this.addShortCut(new EditEnvAction());
}
public static class GetExistEnvAction extends UpdateAction implements ResponseDataSourceChange {
public static class GetExistEnvAction extends UpdateAction {
public GetExistEnvAction() {
}
@ -68,64 +52,14 @@ public class SwitchExistEnv extends MenuDef {
}
}
/**
* 响应数据集改变
*/
public void fireDSChanged() {
fireDSChanged(new HashMap<String, String>());
}
/**
* 响应数据集改变
*
* @param map 数据集
*/
public void fireDSChanged(Map<String, String> map) {
DesignTableDataManager.fireDSChanged(map);
}
/**
* 动作
*
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
final String envName = getName();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
Workspace workspace;
try {
workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace == null ? false : selectedEnv.checkValid();
if (!checkValid) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
return;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
fireDSChanged();
if (WorkContext.getCurrent().isLocal()) {
//初始化一下serverTray
ServerTray.init();
}
}
});
} catch (AuthException exception) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
} catch (RegistEditionException exception) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
EnvChangeEntrance.getInstance().switch2Env(envName);
}
}
}

2
designer-base/src/main/java/com/fr/design/actions/help/FeedBackPane.java

@ -279,7 +279,7 @@ public class FeedBackPane extends BasicPane {
try {
return DesignUtils.sendFeedBack(feedBackInfo);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}

86
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java

@ -18,11 +18,11 @@ public class AlphaFineConfigManager implements XMLable {
/**
* 是否开启alphafine
*/
private boolean isEnabled = true;
private boolean enabled = true;
/**
* 是否联网搜索
*/
private boolean isSearchOnLine = true;
private boolean searchOnLine = true;
/**
* 搜索范围
@ -34,27 +34,35 @@ public class AlphaFineConfigManager implements XMLable {
/**
* 猜您需要
*/
private boolean isContainRecommend = true;
private boolean containRecommend = true;
/**
* 设置
*/
private boolean isContainAction = true;
private boolean containAction = true;
/**
* 帮助文档
*/
private boolean isContainDocument = true;
private boolean containDocument = true;
/**
* 模板
*/
private boolean isContainTemplate = true;
private boolean containTemplate = true;
/**
* 模板内容
*/
private boolean isContainFileContent;
private boolean containFileContent;
/**
* 应用中心
*/
private boolean isContainPlugin = true;
private boolean containPlugin = true;
/**
* 分词搜索
*/
private boolean needSegmentationCheckbox = true;
/**
* 智能客服
*/
private boolean needIntelligentCustomerService = true;
/**
* 快捷键
*/
@ -62,7 +70,7 @@ public class AlphaFineConfigManager implements XMLable {
/**
* 是否提醒
*/
private boolean isNeedRemind = true;
private boolean needRemind = true;
/**
* 直接操作菜单次数
*/
@ -94,6 +102,8 @@ public class AlphaFineConfigManager implements XMLable {
this.setContainAction(reader.getAttrAsBoolean("isContainAction", true));
this.setContainTemplate(reader.getAttrAsBoolean("isContainTemplate", true));
this.setContainFileContent(reader.getAttrAsBoolean("isContainFileContent", false));
this.setNeedSegmentationCheckbox(reader.getAttrAsBoolean("needSegmentationCheckbox", true));
this.setNeedIntelligentCustomerService(reader.getAttrAsBoolean("needIntelligentCustomerService", true));
this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts()));
this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true));
this.setOperateCount(reader.getAttrAsInt("operateCount", 0));
@ -115,16 +125,18 @@ public class AlphaFineConfigManager implements XMLable {
.attr("isContainPlugin", this.isContainPlugin())
.attr("isContainFileContent", this.isContainFileContent())
.attr("isNeedRemind", this.isNeedRemind())
.attr("operateCount", this.getOperateCount());
.attr("operateCount", this.getOperateCount())
.attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox())
.attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService());
writer.end();
}
public boolean isSearchOnLine() {
return isSearchOnLine;
return searchOnLine;
}
public void setSearchOnLine(boolean searchOnLine) {
isSearchOnLine = searchOnLine;
this.searchOnLine = searchOnLine;
}
public String getShortcuts() {
@ -149,51 +161,51 @@ public class AlphaFineConfigManager implements XMLable {
}
public boolean isContainAction() {
return isContainAction;
return containAction;
}
public void setContainAction(boolean containAction) {
this.isContainAction = containAction;
this.containAction = containAction;
}
public boolean isContainDocument() {
return isContainDocument;
return containDocument;
}
public void setContainDocument(boolean containDocument) {
this.isContainDocument = containDocument;
this.containDocument = containDocument;
}
public boolean isContainTemplate() {
return isContainTemplate;
return containTemplate;
}
public void setContainTemplate(boolean containTemplate) {
this.isContainTemplate = containTemplate;
this.containTemplate = containTemplate;
}
public boolean isContainPlugin() {
return isContainPlugin;
return containPlugin;
}
public void setContainPlugin(boolean containPlugin) {
this.isContainPlugin = containPlugin;
this.containPlugin = containPlugin;
}
public boolean isContainRecommend() {
return isContainRecommend;
return containRecommend;
}
public void setContainRecommend(boolean containConclude) {
isContainRecommend = containConclude;
this.containRecommend = containConclude;
}
public boolean isEnabled() {
return isEnabled;
return enabled;
}
public void setEnabled(boolean isEnabled) {
this.isEnabled = isEnabled;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public KeyStroke getShortCutKeyStore() {
@ -212,19 +224,35 @@ public class AlphaFineConfigManager implements XMLable {
}
public boolean isContainFileContent() {
return isContainFileContent;
return containFileContent;
}
public void setContainFileContent(boolean containFileContent) {
isContainFileContent = containFileContent;
this.containFileContent = containFileContent;
}
public boolean isNeedRemind() {
return isNeedRemind;
return needRemind;
}
public void setNeedRemind(boolean needRemind) {
isNeedRemind = needRemind;
this.needRemind = needRemind;
}
public boolean isNeedSegmentationCheckbox() {
return needSegmentationCheckbox;
}
public void setNeedSegmentationCheckbox(boolean needSegmentationCheckbox) {
this.needSegmentationCheckbox = needSegmentationCheckbox;
}
public boolean isNeedIntelligentCustomerService() {
return needIntelligentCustomerService;
}
public void setNeedIntelligentCustomerService(boolean needIntelligentCustomerService) {
this.needIntelligentCustomerService = needIntelligentCustomerService;
}
public int getOperateCount() {

121
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -8,7 +8,6 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.log.FineLoggerFactory;
import javax.swing.*;
@ -56,7 +55,7 @@ public class AlphaFineConfigPane extends BasicPane {
private static final double COLUMN_GAP = 180;
private static final double ROW_GAP = 25;
private KeyStroke shortCutKeyStore = null;
private UICheckBox isEnabledCheckbox, isSearchOnlineCheckbox, isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox, isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox;
private UICheckBox enabledCheckbox, searchOnlineCheckbox, needSegmentationCheckbox, needIntelligentCustomerService, containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox, containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox;
private UITextField shortcutsField;
public AlphaFineConfigPane() {
@ -76,24 +75,33 @@ public class AlphaFineConfigPane extends BasicPane {
private Component[][] initSearchRangeComponents() {
Component[][] components = new Component[][]{
new Component[]{isContainRecommendCheckbox, isContainActionCheckbox, isContainDocumentCheckbox},
new Component[]{isContainTemplateCheckbox, isContainPluginCheckbox, isContainFileContentCheckbox}
new Component[]{containRecommendCheckbox, containActionCheckbox, containDocumentCheckbox},
new Component[]{containTemplateCheckbox, containPluginCheckbox, containFileContentCheckbox},
new Component[]{needIntelligentCustomerService, null, null}
};
return components;
}
private Component[][] initOnlineComponents() {
Component[][] components = new Component[][]{
new Component[]{searchOnlineCheckbox, needSegmentationCheckbox, null}
};
return components;
}
private void createSearchConfigPane(JPanel contentPane) {
double[] rowSize = {ROW_GAP, ROW_GAP};
double[] rowSize = {ROW_GAP, ROW_GAP, ROW_GAP};
double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP};
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range"));
isContainRecommendCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Recommend"));
isContainActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"));
isContainPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"));
isContainDocumentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"));
isContainTemplateCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates"));
isContainFileContentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
containRecommendCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Recommend"));
containActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set"));
containPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"));
containDocumentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"));
containTemplateCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Templates"));
containFileContentCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
needIntelligentCustomerService = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Intelligent_Customer_Service"));
JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initSearchRangeComponents(), rowSize, columnSize);
northPane.add(searchConfigPane);
contentPane.add(northPane);
@ -138,33 +146,40 @@ public class AlphaFineConfigPane extends BasicPane {
}
private void createOnlinePane(JPanel contentPane) {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet"));
isSearchOnlineCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet_Search"));
isSearchOnlineCheckbox.addActionListener(new ActionListener() {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Type"));
searchOnlineCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Internet_Search"));
needSegmentationCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_Segmentation"));
searchOnlineCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isSearchOnlineCheckbox.isSelected()) {
isContainRecommendCheckbox.setEnabled(false);
isContainPluginCheckbox.setEnabled(false);
isContainDocumentCheckbox.setEnabled(false);
isContainRecommendCheckbox.setSelected(false);
isContainPluginCheckbox.setSelected(false);
isContainDocumentCheckbox.setSelected(false);
if (!searchOnlineCheckbox.isSelected()) {
containRecommendCheckbox.setEnabled(false);
containPluginCheckbox.setEnabled(false);
containDocumentCheckbox.setEnabled(false);
needIntelligentCustomerService.setEnabled(false);
containRecommendCheckbox.setSelected(false);
containPluginCheckbox.setSelected(false);
containDocumentCheckbox.setSelected(false);
needIntelligentCustomerService.setSelected(false);
} else {
isContainRecommendCheckbox.setEnabled(true);
isContainPluginCheckbox.setEnabled(true);
isContainDocumentCheckbox.setEnabled(true);
containRecommendCheckbox.setEnabled(true);
containPluginCheckbox.setEnabled(true);
containDocumentCheckbox.setEnabled(true);
needIntelligentCustomerService.setEnabled(true);
}
}
});
northPane.add(isSearchOnlineCheckbox);
double[] rowSize = {ROW_GAP};
double[] columnSize = {COLUMN_GAP, COLUMN_GAP, COLUMN_GAP};
JPanel onlinePane = TableLayoutHelper.createTableLayoutPane(initOnlineComponents(), rowSize, columnSize);
northPane.add(onlinePane);
contentPane.add(northPane);
}
private void createOpenPane(JPanel contentPane) {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable"));
isEnabledCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_AlphaFine"));
northPane.add(isEnabledCheckbox);
enabledCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Enable_AlphaFine"));
northPane.add(enabledCheckbox);
contentPane.add(northPane);
}
@ -174,40 +189,46 @@ public class AlphaFineConfigPane extends BasicPane {
}
public void populate(AlphaFineConfigManager alphaFineConfigManager) {
this.isEnabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
this.isSearchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
this.isSearchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine());
this.isContainActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.isContainTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.isContainFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.isContainDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine());
this.isContainDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.isContainPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine());
this.isContainPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.isContainRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine());
this.isContainRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.enabledCheckbox.setSelected(alphaFineConfigManager.isEnabled());
this.searchOnlineCheckbox.setEnabled(FRContext.isChineseEnv());
this.searchOnlineCheckbox.setSelected(alphaFineConfigManager.isSearchOnLine());
this.containActionCheckbox.setSelected(alphaFineConfigManager.isContainAction());
this.containTemplateCheckbox.setSelected(alphaFineConfigManager.isContainTemplate());
this.containFileContentCheckbox.setSelected(alphaFineConfigManager.isContainFileContent());
this.containDocumentCheckbox.setSelected(alphaFineConfigManager.isContainDocument() && alphaFineConfigManager.isSearchOnLine());
this.containDocumentCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.containPluginCheckbox.setSelected(alphaFineConfigManager.isContainPlugin() && alphaFineConfigManager.isSearchOnLine());
this.containPluginCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.containRecommendCheckbox.setSelected(alphaFineConfigManager.isContainRecommend() && alphaFineConfigManager.isSearchOnLine());
this.containRecommendCheckbox.setEnabled(alphaFineConfigManager.isSearchOnLine());
this.shortcutsField.setText(getDisplayShortCut(alphaFineConfigManager.getShortcuts()));
this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox());
this.needIntelligentCustomerService.setSelected(alphaFineConfigManager.isNeedIntelligentCustomerService() && alphaFineConfigManager.isSearchOnLine());
this.needIntelligentCustomerService.setEnabled(alphaFineConfigManager.isSearchOnLine());
shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts());
}
public void update() {
DesignerEnvManager designerEnvManager = DesignerEnvManager.getEnvManager();
AlphaFineConfigManager alphaFineConfigManager = designerEnvManager.getAlphaFineConfigManager();
alphaFineConfigManager.setContainPlugin(this.isContainPluginCheckbox.isSelected());
alphaFineConfigManager.setContainAction(this.isContainActionCheckbox.isSelected());
alphaFineConfigManager.setContainDocument(this.isContainDocumentCheckbox.isSelected());
alphaFineConfigManager.setContainRecommend(this.isContainRecommendCheckbox.isSelected());
alphaFineConfigManager.setEnabled(this.isEnabledCheckbox.isSelected());
alphaFineConfigManager.setSearchOnLine(this.isSearchOnlineCheckbox.isSelected());
alphaFineConfigManager.setContainTemplate(this.isContainTemplateCheckbox.isSelected());
alphaFineConfigManager.setContainFileContent(this.isContainFileContentCheckbox.isSelected());
alphaFineConfigManager.setContainPlugin(this.containPluginCheckbox.isSelected());
alphaFineConfigManager.setContainAction(this.containActionCheckbox.isSelected());
alphaFineConfigManager.setContainDocument(this.containDocumentCheckbox.isSelected());
alphaFineConfigManager.setContainRecommend(this.containRecommendCheckbox.isSelected());
alphaFineConfigManager.setEnabled(this.enabledCheckbox.isSelected());
alphaFineConfigManager.setSearchOnLine(this.searchOnlineCheckbox.isSelected());
alphaFineConfigManager.setContainTemplate(this.containTemplateCheckbox.isSelected());
alphaFineConfigManager.setContainFileContent(this.containFileContentCheckbox.isSelected());
alphaFineConfigManager.setNeedSegmentationCheckbox(this.needSegmentationCheckbox.isSelected());
alphaFineConfigManager.setNeedIntelligentCustomerService(this.needIntelligentCustomerService.isSelected());
alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText());
designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager);
try {
DesignerEnvManager.loadLogSetting();
DesignerEnvManager.getEnvManager().saveXMLFile();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
@ -234,10 +255,10 @@ public class AlphaFineConfigPane extends BasicPane {
}
public UICheckBox getIsContainFileContentCheckbox() {
return isContainFileContentCheckbox;
return containFileContentCheckbox;
}
public void setIsContainFileContentCheckbox(UICheckBox isContainFileContentCheckbox) {
this.isContainFileContentCheckbox = isContainFileContentCheckbox;
this.containFileContentCheckbox = isContainFileContentCheckbox;
}
}

6
designer-base/src/main/java/com/fr/design/bbs/BBSLoginUtils.java

@ -32,7 +32,7 @@ public class BBSLoginUtils {
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@ -58,7 +58,7 @@ public class BBSLoginUtils {
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@ -71,7 +71,7 @@ public class BBSLoginUtils {
try {
MarketConfig.getInstance().setBBsAttr(bbsAttr);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

2
designer-base/src/main/java/com/fr/design/condition/LiteConditionPane.java

@ -966,7 +966,7 @@ public abstract class LiteConditionPane<T extends Condition> extends BasicBeanPa
try{
newCondition = (Condition)joinCondition.getCondition().clone();
}catch (CloneNotSupportedException e){
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return newCondition;
}

2
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -488,7 +488,7 @@ public abstract class DesignTableDataManager {
}
rs.release();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
}

2
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -278,7 +278,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
schemaBox.setSelectedIndex(index);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
schemaBox.setRefreshingModel(false);
schemaBox.removePopupMenuListener(listener);

4
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePaneSupportFormula.java

@ -113,7 +113,7 @@ public class ChoosePaneSupportFormula extends ChoosePane {
selectedDSName = Utils.objectToString(ca.eval(BaseFormula.createFormulaBuilder().build(item)));
// selectedDSName = ParameterHelper.analyzeCurrentContextTableData4Templatee(item, parameters);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
} else {
selectedDSName = item;
@ -156,7 +156,7 @@ public class ChoosePaneSupportFormula extends ChoosePane {
dsName = dsItem.startsWith("=") ? Utils.objectToString(ca.eval(BaseFormula.createFormulaBuilder().build(dsItem))) : dsItem;
tableName = tableItem.startsWith("=") ? Utils.objectToString(ca.eval(BaseFormula.createFormulaBuilder().build(tableItem))) : tableItem;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
ori_ds_name = dsName;
ori_table_name = tableName;

4
designer-base/src/main/java/com/fr/design/data/tabledata/ResponseDataSourceChange.java

@ -14,12 +14,12 @@ public interface ResponseDataSourceChange {
/**
* 响应数据集改变
*/
public void fireDSChanged();
void fireDSChanged();
/**
* 响应数据集改变
*/
public void fireDSChanged(Map<String, String> map);
void fireDSChanged(Map<String, String> map);
}

2
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -146,7 +146,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
}
return true;
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
return false;
}

2
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java

@ -77,7 +77,7 @@ public final class StoreProcedureNameWrapper implements TableDataWrapper {
try {
procedureDataModel = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar)[0];
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
}

2
designer-base/src/main/java/com/fr/design/dialog/UIDialog.java

@ -166,7 +166,7 @@ public abstract class UIDialog extends JDialog {
l.doOk();
} catch (RuntimeException e) {
isDoOKSucceed = false;
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
}
if (isDoOKSucceed) {

4
designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java vendored

@ -1,7 +1,7 @@
package com.fr.design.env;
import com.fr.stable.xml.XMLable;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
public interface DesignerWorkspaceInfo extends XMLable {
DesignerWorkspaceType getType();
@ -10,7 +10,7 @@ public interface DesignerWorkspaceInfo extends XMLable {
String getPath();
WorkspaceConnection getConnection();
WorkspaceConnectionInfo getConnection();
boolean checkValid();
}

7
designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java vendored

@ -1,13 +1,10 @@
package com.fr.design.env;
import com.fr.base.EnvException;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import java.io.File;
@ -47,7 +44,7 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
}
@Override
public WorkspaceConnection getConnection() {
public WorkspaceConnectionInfo getConnection() {
return null;
}

12
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -5,15 +5,15 @@ import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
private String name;
private WorkspaceConnection connection;
private WorkspaceConnectionInfo connection;
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnection connection) {
public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) {
RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo();
info.connection = connection;
return info;
@ -38,7 +38,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
}
@Override
public WorkspaceConnection getConnection() {
public WorkspaceConnectionInfo getConnection() {
return connection;
}
@ -58,7 +58,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n"));
String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY);
String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY);
this.connection = new WorkspaceConnection(url, username, password, certPath, certSecretKey);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey);
}
}
}
@ -83,7 +83,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
RemoteDesignerWorkspaceInfo object = (RemoteDesignerWorkspaceInfo) super.clone();
object.connection = (WorkspaceConnection) StableUtils.cloneObject(this.connection);
object.connection = (WorkspaceConnectionInfo) StableUtils.cloneObject(this.connection);
return object;
}

33
designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java vendored

@ -6,6 +6,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.server.authority.decision.DecisionOperator;
/**
@ -18,9 +19,11 @@ public class RemoteWorkspace implements Workspace {
private final String address;
private final WorkspaceConnection connection;
private final WorkspaceConnectionInfo connection;
RemoteWorkspace(WorkspaceClient client, WorkspaceConnection connection) {
private volatile Boolean isRoot = null;
RemoteWorkspace(WorkspaceClient client, WorkspaceConnectionInfo connection) {
this.client = client;
this.address = connection.getUrl();
@ -53,12 +56,22 @@ public class RemoteWorkspace implements Workspace {
@Override
public boolean isRoot() {
try {
return WorkContext.getCurrent().get(DecisionOperator.class).isRoot(WorkContext.getConnector().currentUser());
} catch (Exception e) {
return false;
if (isRoot == null) {
synchronized (this) {
if (isRoot == null) {
isRoot = WorkContext.getCurrent().get(DecisionOperator.class).isRoot(getConnection().getUserName());
}
}
}
return isRoot;
}
@Override
public WorkspaceConnection getConnection() {
return client.getConnection();
}
@Override
public <T> T get(Class<T> type) {
@ -66,6 +79,12 @@ public class RemoteWorkspace implements Workspace {
return client.getPool().get(type);
}
@Override
public void close() {
client.close();
}
@Override
public int hashCode() {
@ -75,6 +94,6 @@ public class RemoteWorkspace implements Workspace {
@Override
public boolean equals(Object obj) {
return obj != null && obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection);
return obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection);
}
}

4
designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java

@ -150,7 +150,7 @@ public class LoginWebBridge {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
}
@ -306,7 +306,7 @@ public class LoginWebBridge {
}
}
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
}

2
designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java

@ -116,7 +116,7 @@ public class PluginOperateUtils {
JSONArray jsonArray = new JSONArray(result);
resultArray = PluginUtils.filterPluginsFromVersion(jsonArray);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return resultArray.toString();
}

2
designer-base/src/main/java/com/fr/design/extra/PluginUtils.java

@ -59,7 +59,7 @@ public class PluginUtils {
httpClient.asGet();
result = httpClient.getResponseText();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} else {
result = PluginConstants.CONNECTION_404;

6
designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java

@ -350,7 +350,7 @@ public class PluginWebBridge {
Task<Void> task = new PluginTask<>(webEngine, callback, new GetPluginFromStoreExecutor(new JSONObject(info)));
threadPoolExecutor.submit(task);
} catch (JSONException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
@ -486,10 +486,10 @@ public class PluginWebBridge {
}
} catch (NullPointerException e) {
//此为uri为空时抛出异常
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IOException e) {
//此为无法获取系统默认浏览器
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

2
designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java

@ -149,7 +149,7 @@ public class QQLoginWebPane extends JFXPanel {
}
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}

2
designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java

@ -123,7 +123,7 @@ public class WebViewDlgHelper {
try {
CommonIOUtils.copy(new File(mainJsPath), new File(installHome));
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}

2
designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java

@ -72,7 +72,7 @@ public class GetPluginFromStoreExecutor implements Executor {
JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(resultArr);
result = resultJSONArray.toString();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} else {
result = PluginConstants.CONNECTION_404;

2
designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java

@ -42,7 +42,7 @@ public class ReadUpdateOnlineExecutor implements Executor {
}
result = jsonArray.toString();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

2
designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java

@ -50,7 +50,7 @@ public class SearchOnlineExecutor implements Executor {
JSONArray resultJSONArray = PluginUtils.filterPluginsFromVersion(jsonArray);
result = resultJSONArray.toString();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}

63
designer-base/src/main/java/com/fr/design/file/FileOperations.java

@ -1,45 +1,88 @@
package com.fr.design.file;
import com.fr.file.FILE;
import com.fr.file.filetree.FileNode;
public interface FileOperations {
/**
* 新建文件夹
*
* @param name 文件夹名称
* @return 是否成功
*/
boolean mkdir(String name);
/**
*打开选中的报表文件
* 打开报表文件
*/
public void openSelectedReport();
void openFile();
/**
* 打开文件夹
*/
public void openContainerFolder();
void showInExplorer();
/**
* 刷新
*/
public void refresh();
void refresh();
/**
* 删除文件
*/
public void deleteFile();
void deleteFile();
/**
* 加上文件锁
*/
public void lockFile();
void lockFile();
/**
* 文件解锁
*/
public void unLockFile();
void unlockFile();
/**
* 选中的模板路径
*
* @return 选中的模板路径
*/
String getFilePath();
/**
* 选中的文件节点
*
* @return 文件节点
*/
FileNode getFileNode();
/**
* 是否有完整权限
*
* @return 是否有完整权限
*/
boolean access();
/**
* 重命名
*
* @param tplFile 旧文件
* @param to 新文件名
* @param from 旧文件名
* @return 是否成功
*/
boolean rename(FILE tplFile, String from, String to);
public String getSelectedTemplatePath();
/**
* 文件名是否存在
*
* @param newName 原名
* @param oldName 新的文件名
* @param suffix 后缀名
* @return 是否存在
*/
public boolean isNameAlreadyExist(String newName, String oldName, String suffix);
boolean duplicated(String newName, String suffix);
}

295
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -0,0 +1,295 @@
package com.fr.design.file;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
/**
* 历史模板缓存
*
* @see HistoryTemplateListPane
*/
public class HistoryTemplateListCache implements CallbackEvent {
//最大保存内存中面板数,为0时关闭优化内存
private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private static volatile HistoryTemplateListCache THIS;
public static HistoryTemplateListCache getInstance() {
if (THIS == null) {
synchronized (HistoryTemplateListCache.class) {
if (THIS == null) {
THIS = new HistoryTemplateListCache();
}
}
}
return THIS;
}
private HistoryTemplateListCache() {
historyList = new ArrayList<>();
}
/**
* 关闭选择的文件
*
* @param selected 选择的
*/
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
historyList.remove(contains(selected));
selected.getEditingFILE().closeTemplate();
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName()));
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 临时关闭选择的文件
*
* @param selected 选择的
*/
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
selected.getEditingFILE().closeTemplate();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
public JTemplate<?, ?> getCurrentEditingTemplate() {
return this.editingTemplate;
}
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt;
//如果当前历史面板中没有
if (contains(jt) == -1) {
addHistory();
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
//设置tab栏为当前选中的那一栏
if (editingTemplate != null) {
MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt));
}
}
/**
* 添加历史记录
*/
public void addHistory() {
if (editingTemplate == null) {
return;
}
DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getPath());
historyList.add(editingTemplate);
closeOverLineTemplate();
}
public List<JTemplate<?, ?>> getHistoryList() {
return historyList;
}
/**
* 清空历史记录
*/
public void removeAllHistory() {
historyList.clear();
this.editingTemplate = null;
}
public int getHistoryCount() {
return historyList.size();
}
public JTemplate<?, ?> get(int index) {
if (index > historyList.size() - 1 || index < 0) {
return null;
}
Collections.reverse(historyList);
JTemplate<?, ?> select = historyList.get(index);
Collections.reverse(historyList);
return select;
}
public JTemplate<?, ?> getTemplate(int index) {
return historyList.get(index);
}
/**
* 获取模板的index
*
* @param jt 模板
* @return 位置
*/
public int contains(JTemplate<?, ?> jt) {
for (int i = 0; i < historyList.size(); i++) {
if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) {
return i;
}
}
return -1;
}
/**
* 判断是否打开过该模板
*
* @param filename 文件名
* @return 文件位置
*/
public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath();
//文件路径和历史路径都是 reportlets/xxx/xxx/xxx/xx.suffix
if (filename.equals(historyPath)) {
return i;
}
}
return -1;
}
/**
* 是否是当前编辑的文件
*
* @param filename 文件名
* @return 是则返回TRUE
*/
public boolean isCurrentEditingFile(String filename) {
String editingFileName = editingTemplate.getPath();
return ComparatorUtils.equals(filename, editingFileName);
}
@Override
public void callback() {
getCurrentEditingTemplate().repaint();
}
/**
* 打开new模板的同时关闭old模板,优先关已保存的先打开的
*/
public void closeOverLineTemplate() {
int size = historyList.size();
int vCount = size - DEAD_LINE;
if (DEAD_LINE == 0 || vCount <= 0) {
return;
}
for (int i = 0; i < vCount; i++) {
JTemplate overTemplate = historyList.get(i);
if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) {
closeVirtualSelectedReport(overTemplate);
historyList.set(i, new JVirtualTemplate(overTemplate.getEditingFILE()));
}
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
}
public void deleteFile(FileNodeFILE file) {
boolean isDir = file.isDirectory();
String suffix = isDir ? CoreConstants.SEPARATOR : StringUtils.EMPTY;
// path like reportlets/xx/xxx/xxx
String path = file.getPath() + suffix;
ListIterator<JTemplate<?, ?>> iterator = historyList.listIterator();
while (iterator.hasNext()) {
JTemplate<?, ?> template = iterator.next();
String tPath = template.getPath();
if (isDir ? tPath.startsWith(path) : tPath.equals(path)) {
iterator.remove();
int index = iterator.nextIndex();
int size = getHistoryCount();
if (size == index + 1 && index > 0) {
//如果删除的是后一个Tab,则定位到前一个
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);
JTemplate selectedFile = MutilTempalteTabPane.getInstance().getSelectedFile();
if (!isCurrentEditingFile(selectedFile.getPath())) {
//如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样
DesignerContext.getDesignerFrame().activateJTemplate(selectedFile);
}
}
}
}
//如果打开过,则删除,实时刷新多tab面板
int openFileCount = getHistoryCount();
if (openFileCount == 0) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
}
MutilTempalteTabPane.getInstance().repaint();
}
public boolean rename(FILE tplFile, String from, String to) {
boolean isDir = tplFile.isDirectory();
JTemplate<?, ?> template;
template = this.getCurrentEditingTemplate();
if (template != null) {
String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath());
if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to));
}
}
for (int i = 0; i < this.getHistoryCount(); i++) {
template = this.get(i);
String editingPath = FilenameUtils.standard(template.getEditingFILE().getPath());
if (isDir ? editingPath.contains(from + CoreConstants.SEPARATOR) : editingPath.equals(from)) {
FILE renameFile = template.getEditingFILE();
renameFile.setPath(editingPath.replace(from, to));
}
}
return true;
}
}

443
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListPane.java

@ -1,443 +1,16 @@
package com.fr.design.file;
import com.fr.base.FRContext;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ilist.UIList;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class HistoryTemplateListPane extends JPanel implements FileOperations, CallbackEvent {
//最大保存内存中面板数,为0时关闭优化内存
private static final int DEAD_LINE = DesignerEnvManager.getEnvManager().getCachingTemplateLimit();;
private static final int LIST_BORDER = 4;
private List<JTemplate<?, ?>> historyList;
private JTemplate<?, ?> editingTemplate;
private FileToolbarStateChangeListener toobarStateChangeListener;
private static volatile HistoryTemplateListPane THIS;
private UIList list;
public static final HistoryTemplateListPane getInstance() {
if (THIS == null) {
synchronized (HistoryTemplateListPane.class) {
if (THIS == null) {
THIS = new HistoryTemplateListPane();
}
}
}
return THIS;
}
private HistoryTemplateListPane() {
setLayout(new BorderLayout());
historyList = new ArrayList<JTemplate<?, ?>>();
list = new UIList(new HistoryListDataMode()) {
public int locationToIndex(Point location) {
int rowCount = getModel().getSize();
int height = getPreferredSize().height - 2 * LIST_BORDER;
int rowHeight = height / rowCount;
int index = (location.y - LIST_BORDER) / rowHeight;
if (location.y < LIST_BORDER || index > rowCount - 1) {
return -1;
} else {
return index;
}
}
};
ToolTipManager.sharedInstance().registerComponent(list);
list.setBackground(UIConstants.NORMAL_BACKGROUND);
list.setCellRenderer(new HistoryListCellRender());
list.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() < 2) {
return;
}
openSelectedReport();
}
});
list.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
if (toobarStateChangeListener != null) {
toobarStateChangeListener.stateChange();
}
}
});
list.setBorder(BorderFactory.createEmptyBorder(LIST_BORDER, LIST_BORDER, LIST_BORDER, LIST_BORDER));
UIScrollPane scrollPane = new UIScrollPane(list);
scrollPane.setBorder(null);
this.add(scrollPane, BorderLayout.CENTER);
}
/**
* 关闭选择的文件
* 历史模板缓存
*
* @param selected 选择的
*/
public void closeSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
historyList.remove(contains(selected));
selected.getEditingFILE().closeTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Closed_Warn_Text", selected.getEditingFILE().getName()));
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 临时关闭选择的文件
*
* @param selected 选择的
*/
public void closeVirtualSelectedReport(JTemplate<?, ?> selected) {
DesignModuleFactory.clearChartPropertyPane();
DesignTableDataManager.closeTemplate(selected);
if (contains(selected) == -1) {
return;
}
selected.fireJTemplateClosed();
selected.stopEditing();
try {
selected.getEditingFILE().closeTemplate();
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
/**
* 关闭选择的文件
*/
public void selectedReportToVirtual(int i) {
closeOverLineTemplate();
}
public JTemplate<?, ?> getCurrentEditingTemplate() {
return this.editingTemplate;
}
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt;
//如果当前历史面板中没有
if (contains(jt) == -1) {
addHistory();
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
//设置tab栏为当前选中的那一栏
if (editingTemplate != null) {
MutilTempalteTabPane.getInstance().setSelectedIndex(contains(jt));
}
}
/**
* 添加历史记录
*/
public void addHistory() {
if (editingTemplate == null) {
return;
}
DesignerEnvManager.getEnvManager().addRecentOpenedFilePath(editingTemplate.getPath());
((HistoryListDataMode) list.getModel()).add(editingTemplate);
}
public List<JTemplate<?, ?>> getHistoryList() {
return historyList;
}
/**
* 清空历史记录
*/
public void removeAllHistory() {
historyList.clear();
this.editingTemplate = null;
}
public int getHistoryCount() {
return list.getModel().getSize();
}
public UIList getList() {
return list;
}
public JTemplate<?, ?> get(int index) {
return (JTemplate<?, ?>) list.getModel().getElementAt(index);
}
public JTemplate<?, ?> getTemplate(int index) {
return historyList.get(index);
}
/**
* 获取模板的index
*
* @param jt 模板
* @return 位置
*/
public int contains(JTemplate<?, ?> jt) {
for (int i = 0; i < historyList.size(); i++) {
if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) {
return i;
}
}
return -1;
}
/**
* 判断是否打开过该模板
* 为可能存在的插件做兼容处理
*
* @param filename 文件名
* @return 文件位置
* @see HistoryTemplateListCache
* @deprecated use HistoryTemplateListCache instead
*/
public int contains(String filename) {
for (int i = 0; i < historyList.size(); i++) {
String historyPath = historyList.get(i).getPath().replaceAll("/", "\\\\");
//文件路径是全路径,历史路径是reportlets/模板名
if (filename.endsWith(historyPath)) {
return i;
}
}
return -1;
}
/**
* 是否是当前编辑的文件
*
* @param filename 文件名
* @return 是则返回TRUE
*/
public boolean isCurrentEditingFile(String filename) {
String editingFileName = editingTemplate.getPath();
return ComparatorUtils.equals(filename, editingFileName);
}
@Override
public void callback() {
getCurrentEditingTemplate().repaint();
}
private class HistoryListCellRender extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
JTemplate<?, ?> jt = (JTemplate<?, ?>) value;
UILabel nameLabel = new UILabel(jt.getEditingFILE().getName());
final int nameWidth = nameLabel.getPreferredSize().width;
UILabel uiLabel = new UILabel() {
public void paint(Graphics g) {
GUIPaintUtils.fillPaint((Graphics2D) g, 18, 0, nameWidth + 2, getHeight(), true, Constants.NULL, isSelected ? UIConstants.FLESH_BLUE : UIConstants.NORMAL_BACKGROUND, UIConstants.ARC);
super.paint(g);
}
};
uiLabel.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0));
uiLabel.setIcon(jt.getIcon());
uiLabel.setText(jt.getEditingFILE().getName());
return uiLabel;
}
}
private class HistoryListDataMode extends AbstractListModel {
@Override
public int getSize() {
return historyList.size();
}
@Override
public JTemplate<?, ?> getElementAt(int index) {
if (index > getSize() - 1 || index < 0) {
return null;
}
Collections.reverse(historyList);
JTemplate<?, ?> select = historyList.get(index);
Collections.reverse(historyList);
return select;
}
public void remove(int index) {
boolean outofindex = index >= historyList.size() || index < 0;
if (historyList.isEmpty() || outofindex) {
return;
}
historyList.remove(index);
}
public void add(JTemplate<?, ?> jt) {
historyList.add(jt);
closeOverLineTemplate();
refresh();
}
}
/**
* 打开new模板的同时关闭old模板,优先关已保存的先打开的
*/
public void closeOverLineTemplate() {
int size = historyList.size();
int vCount = size - DEAD_LINE;
if (DEAD_LINE == 0 || vCount <= 0) {
return;
}
for (int i = 0; i < vCount; i++) {
JTemplate overTemplate = historyList.get(i);
if (overTemplate.getEditingFILE().exists() && overTemplate.isALLSaved() && overTemplate != editingTemplate) {
historyList.get(i).closeOverLineTemplate(i);
}
}
MutilTempalteTabPane.getInstance().refreshOpenedTemplate(historyList);
}
/**
* 刷新
*/
public void refresh() {
list.removeAll();
list.setModel(new HistoryListDataMode());
list.setSelectedIndex(list.getSelectedIndex());
}
/**
* 打开选择的文件
*/
public void openSelectedReport() {
DesignerContext.getDesignerFrame().addAndActivateJTemplate((JTemplate<?, ?>) list.getSelectedValue());
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
refresh();
}
/**
* 打开文件所在文件夹
*/
public void openContainerFolder() {
FileNode fileNode = new FileNode(((JTemplate<?, ?>) list.getSelectedValue()).getEditingFILE().getPath(), false);
if (WorkContext.getCurrent().isLocal()) {
IOUtils.openWindowsFolder(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fileNode.getEnvPath()));
}
}
/**
* 删除文件
*/
public void deleteFile() {
// TODO Auto-generated method stub
}
/***
* 琐文件
*/
public void lockFile() {
// TODO Auto-generated method stub
}
/**
* 解锁
*/
public void unLockFile() {
// TODO Auto-generated method stub
}
/**
* 路径
*
* @return 路径
*/
public String getSelectedTemplatePath() {
if (list.getSelectedIndex() < 0 || list.getSelectedIndex() > list.getModel().getSize() - 1) {
return null;
}
;
String path = ((HistoryListDataMode) list.getModel()).getElementAt(list.getSelectedIndex()).getEditingFILE().getPath();
if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return path.substring(ProjectConstants.REPORTLETS_NAME.length());
}
return path;
}
public void setToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.toobarStateChangeListener = toobarStateChangeListener;
}
/**
* 文件是否存在
*
* @param newName 文件名
* @param oldName 原名
* @param suffix 后缀名
* @return 文件是否存在
*/
public boolean isNameAlreadyExist(String newName, String oldName, String suffix) {
boolean isNameAreadyExist = false;
for (int i = 0; i < getHistoryCount(); i++) {
JTemplate<?, ?> jt = ((HistoryListDataMode) list.getModel()).getElementAt(i);
if (ComparatorUtils.equals(jt.getEditingFILE().getName(), newName + suffix)) {
isNameAreadyExist = true;
break;
}
}
if (ComparatorUtils.equals(newName, oldName)) {
isNameAreadyExist = false;
}
return isNameAreadyExist;
@Deprecated
public class HistoryTemplateListPane {
public static HistoryTemplateListCache getInstance() {
return HistoryTemplateListCache.getInstance();
}
}

460
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -7,23 +7,40 @@ import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.gui.imenu.UIScrollPopUpMenu;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.ProductConstants;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.BorderFactory;
import javax.swing.ButtonModel;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.plaf.basic.BasicMenuItemUI;
import java.awt.*;
import java.awt.AWTEvent;
import java.awt.AlphaComposite;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.AWTEventListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -35,14 +52,15 @@ import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.awt.geom.RoundRectangle2D;
import java.io.File;
import java.util.List;
/**
* Author : daisy
* Date: 13-8-5
* Time: 下午6:12
*/
public class MutilTempalteTabPane extends JComponent implements MouseListener, MouseMotionListener, Action {
public class MutilTempalteTabPane extends JComponent {
private static Icon LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_normal.png");
private static Icon MOUSE_OVER_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png");
private static Icon MOUSE_PRESS_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png");
@ -50,13 +68,11 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
private static Icon MOUSE_OVER_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png");
private static Icon MOUSE_PRESS_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png");
private static final String ELLIPSIS = "...";
private static final int GAP_BEFORE_CLOSE = 10;
private static final int GAP = 5;
private static final int SMALLGAP = 3;
private static final int LIST_BUTTON_WIDTH = 34;
private static final int HEIGHT = 26;
private static final int LIST_DOWN_HEIGHT = 25;
private static final double FOR_CAL_BYTES = 0.5;
private static final double CORNOR_RADIUS = 0.0;
//选了30度和60度的特殊角度的x,y作为经过的两个点的坐标
private static final double SPECIAL_LOCATION_1 = 2.5;
@ -86,19 +102,11 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
private int minPaintIndex = 0;
private int maxPaintIndex = 0;
/**
* 鼠标按下时的坐标数组鼠标放开时的坐标数组
*/
private int[] xyPressedCoordinate = {0, 0};
//每个关闭图标的起始位置
private int[] startX;
private boolean[] isNeedToolTips;
private Graphics2D g2d;
//记录关闭按钮的状态
private int closeIconIndex = -1;
private boolean isCloseCurrent = false;
@ -112,7 +120,28 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
private JTemplate<?, ?> temTemplate = null;
private AWTEventListener awt = new AWTEventListener() {
public static MutilTempalteTabPane getInstance() {
if (THIS == null) {
THIS = new MutilTempalteTabPane();
}
return THIS;
}
/**
* 多工作簿面板
*/
public MutilTempalteTabPane() {
this.setLayout(new BorderLayout(0, 0));
this.addMouseListener(new MultiTemplateTabMouseListener());
this.addMouseMotionListener(new MultiTemplateTabMouseMotionListener());
this.setBorder(null);
this.setForeground(new Color(58, 56, 58));
this.setFont(new Font(Toolkit.i18nText("Fine-Design_Basic_Song_TypeFace"), 0, 12));
openedTemplate = HistoryTemplateListCache.getInstance().getHistoryList();
selectedIndex = openedTemplate.size() - 1;
AWTEventListener awt = new AWTEventListener() {
@Override
public void eventDispatched(AWTEvent event) {
if (event instanceof MouseEvent) {
MouseEvent mv = (MouseEvent) event;
@ -123,13 +152,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
};
public static final MutilTempalteTabPane getInstance() {
if (THIS == null) {
THIS = new MutilTempalteTabPane();
}
return THIS;
java.awt.Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
}
public JTemplate getSelectedFile() {
@ -152,31 +175,18 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
@Override
public Dimension getPreferredSize() {
Dimension dimension = super.getPreferredSize();
dimension.height = HEIGHT;
return dimension;
}
/**
* 多工作簿面板
*/
public MutilTempalteTabPane() {
this.setLayout(new BorderLayout(0, 0));
this.addMouseListener(this);
this.addMouseMotionListener(this);
this.setBorder(null);
this.setForeground(new Color(58, 56, 58));
this.setFont(new Font(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Song_TypeFace"), 0, 12));
openedTemplate = HistoryTemplateListPane.getInstance().getHistoryList();
selectedIndex = openedTemplate.size() - 1;
Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK);
}
private UIMenuItem initCloseOther() {
UIMenuItem closeOther = new UIMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Close_Other_Templates"));
UIMenuItem closeOther = new UIMenuItem(Toolkit.i18nText("Fine-Design_Basic_FS_Close_Other_Templates"));
setListDownItemPreferredSize(closeOther);
closeOther.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (openedTemplate.size() == 1) {
return;
@ -190,20 +200,21 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
for (int i = 0; i < panes.length; i++) {
if (i != selectedIndex) {
JTemplate<?, ?> jTemplate = panes[i];
//判断关闭的模板是不是格式刷的被参照的模板
openedTemplate.remove(panes[i]);
closeFormat(panes[i]);
HistoryTemplateListPane.getInstance().closeSelectedReport(panes[i]);
openedTemplate.remove(jTemplate);
closeFormat(jTemplate);
HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(jTemplate.getPath());
}
}
JTemplate<?, ?> currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
HistoryTemplateListPane.getInstance().removeAllHistory();
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
HistoryTemplateListCache.getInstance().removeAllHistory();
DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate);
THIS.repaint();
}
//如果取消保存了,则不关闭其他模板
}
});
if (openedTemplate.size() == 1) {
@ -227,6 +238,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
templates[i].setBackground(UIConstants.SHADOW_CENTER);
}
templates[i].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectedIndex = index;
tem.activeNewJTemplate();
@ -256,7 +268,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
*
* @param history 模板
*/
public void refreshOpenedTemplate(java.util.List<JTemplate<?, ?>> history) {
public void refreshOpenedTemplate(List<JTemplate<?, ?>> history) {
openedTemplate = history;
}
@ -271,6 +283,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0));
menu.add(initCloseOther());
JSeparator separator = new JSeparator() {
@Override
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
d.height = 1;
@ -278,6 +291,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
};
menu.add(new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
d.height = 1;
@ -287,6 +301,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
separator.setForeground(UIConstants.LINE_COLOR);
menu.add(separator);
menu.add(new JPanel() {
@Override
public Dimension getPreferredSize() {
Dimension d = super.getPreferredSize();
d.height = 1;
@ -306,14 +321,16 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
double maxWidth = getWidth() - LIST_BUTTON_WIDTH; //最大宽度
g2d = (Graphics2D) g;
Graphics2D g2d = (Graphics2D) g;
paintBackgroundAndLine(g2d, maxWidth);
}
@Override
public void paint(Graphics g) {
//不可见时,按钮.4f透明
AlphaComposite composite = DesignerMode.isVcsMode()
@ -354,7 +371,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
isNeedToolTips[i - minPaintIndex] = false;
}
Icon selectedIcon = null;
Icon selectedIcon;
if (i == closeIconIndex) {
selectedIcon = clodeMode;
} else {
@ -642,72 +659,6 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
generalPath.closePath();
}
/**
* 点击
*
* @param e 鼠标事件
*/
public void mouseClicked(MouseEvent e) {
}
/**
* 按下
*
* @param e 鼠标事件
*/
public void mousePressed(MouseEvent e) {
//如果在版本管理情况下,不允许切换tab
if (DesignerMode.isVcsMode()) {
return;
}
int evtX = e.getX();
int evtY = e.getY();
this.setPressedXY(evtX, evtY);
//是否点击关闭按钮 如果点击了关闭按钮,则将点击的模板关闭,不需要切换,如果没有点击关闭按钮,则切换到点击的模板处
boolean isOverCloseIcon = isOverCloseIcon(evtX);
if (isOverListDown(evtX)) {
listDownMode = isOverListDown(evtX) ? MOUSE_PRESS_LIST_DOWN : LIST_DOWN;
if (!isShowList) {
showListDown();
}
isShowList = !isShowList;
} else if (isOverCloseIcon) {
//关闭按钮的图标变化
closeIconIndex = getTemplateIndex(evtX);
clodeMode = MOUSE_PRESS_CLOSE;
//关闭close图标所在的模板{
closeFormat(openedTemplate.get(closeIconIndex));
closeSpecifiedTemplate(openedTemplate.get(closeIconIndex));
DesignerContext.getDesignerFrame().getContentFrame().repaint();
isShowList = false;
} else {
//没有点击关闭和ListDown按钮,则切换到点击的模板处
closeIconIndex = -1;
clodeMode = CLOSE;
int tempSelectedIndex = selectedIndex;
if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) {
openedTemplate.get(selectedIndex).stopEditing();
selectedIndex = getTemplateIndex(evtX);
//如果在权限编辑情况下,不允许切换到表单类型的工作簿
if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex));
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported")
+ "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE);
this.repaint();
return;
}
JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX));
evtXTemplate.activeNewJTemplate();
}
isShowList = false;
}
this.repaint();
}
public void setIsCloseCurrent(boolean isCloseCurrent) {
this.isCloseCurrent = isCloseCurrent;
@ -725,24 +676,33 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
//当前激活的模板
String filename = openedTemplate.get(selectedIndex).getEditingFILE().getPath();
if (filename.startsWith(ProjectConstants.REPORTLETS_NAME)) {
filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename;
}
String filename = openedTemplate.get(selectedIndex).getPath();
filename = OperatingSystem.isWindows() ? filename.replaceAll("/", "\\\\") : filename.replaceAll("\\\\", "/");
filename = FilenameUtils.standard(filename);
if (!specifiedTemplate.isALLSaved() && !DesignerMode.isVcsMode()) {
specifiedTemplate.stopEditing();
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Would_You_Like_To_Save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?",
ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) {
if (returnVal == JOptionPane.YES_OPTION) {
specifiedTemplate.saveTemplate();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
}
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath());
activeTemplate(filename);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
}
HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate);
} else {
HistoryTemplateListCache.getInstance().closeSelectedReport(specifiedTemplate);
// release lock
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(specifiedTemplate.getPath());
activeTemplate(filename);
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_Already_Saved", specifiedTemplate.getEditingFILE().getName()));
}
}
/**
@ -767,15 +727,15 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
/**
* 关闭掉一个模板之后该激活的Tab
*
* @param fileName
* @param fileName 关闭掉一个模板之后该激活的Tab的文件名绝对路径
*/
private void activeTemplate(String fileName) {
if (openedTemplate.isEmpty()) {
//新建并激活模板
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
selectedIndex = 0;
//此时刚自动新建的模板在HistoryTemplateListPane的editingTemplate
temTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
//此时刚自动新建的模板在HistoryTemplateListCache的editingTemplate
temTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
} else {
//如果关闭的模板是当前选中的模板,则重新激活
@ -794,30 +754,13 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
} else {
//如果关闭的模板不是当前选中的模板,则激活的模板不变
selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName);
selectedIndex = HistoryTemplateListCache.getInstance().contains(fileName);
}
//如果是已后台关闭的模板,则重新打开文件
openedTemplate.get(selectedIndex).activeOldJTemplate();
}
}
/**
* 鼠标释放
*
* @param e 鼠标事件
*/
public void mouseReleased(MouseEvent e) {
}
/**
* 鼠标进入
*
* @param e 鼠标事件
*/
public void mouseEntered(MouseEvent e) {
}
private boolean isOverCloseIcon(int evtX) {
boolean isOverCloseIcon = false;
@ -849,76 +792,6 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
return -1;
}
/**
* 鼠标离开
*
* @param e 鼠标事件
*/
public void mouseExited(MouseEvent e) {
listDownMode = LIST_DOWN;
closeIconIndex = -1;
mouseOveredIndex = -1;
this.repaint();
}
/**
* 鼠标拖拽
*
* @param e 鼠标事件
*/
public void mouseDragged(MouseEvent e) {
}
/**
* 鼠标移动
*
* @param e 鼠标事件
*/
public void mouseMoved(MouseEvent e) {
int evtX = e.getX();
mouseOveredIndex = getTemplateIndex(evtX);
//看是否需要显示toolTip
if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) {
setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName());
} else {
setToolTipText(null);
}
listDownMode = isOverListDown(evtX) ? MOUSE_OVER_LIST_DOWN : LIST_DOWN;
boolean isOverCloseIcon = isOverCloseIcon(evtX);
clodeMode = isOverCloseIcon ? MOUSE_OVER_CLOSE : CLOSE;
closeIconIndex = isOverCloseIcon ? mouseOveredIndex : -1;
this.repaint();
}
private void setPressedXY(int x, int y) {
this.xyPressedCoordinate[0] = x;
this.xyPressedCoordinate[1] = y;
}
public Object getValue(String key) {
return null;
}
/**
* 加入值
*
* @param key
* @param value
*/
public void putValue(String key, Object value) {
}
/**
* 动作
*
* @param e 事件
*/
public void actionPerformed(ActionEvent e) {
}
/**
* 处理自动新建的模板 在切换时的处理
@ -926,7 +799,7 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
public void doWithtemTemplate() {
//temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板
//没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭
if (temTemplate == null || temTemplate == HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()) {
if (temTemplate == null || temTemplate == HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()) {
return;
}
@ -936,9 +809,9 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
//自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘
if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) {
HistoryTemplateListPane.getInstance().closeSelectedReport(temTemplate);
HistoryTemplateListCache.getInstance().closeSelectedReport(temTemplate);
temTemplate = null;
setSelectedIndex(HistoryTemplateListPane.getInstance().contains(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()));
setSelectedIndex(HistoryTemplateListCache.getInstance().contains(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()));
}
}
@ -970,5 +843,146 @@ public class MutilTempalteTabPane extends JComponent implements MouseListener, M
}
}
private class MultiTemplateTabMouseListener implements MouseListener {
/**
* 鼠标进入
*
* @param e 鼠标事件
*/
@Override
public void mouseEntered(MouseEvent e) {
}
/**
* 鼠标离开
*
* @param e 鼠标事件
*/
@Override
public void mouseExited(MouseEvent e) {
listDownMode = LIST_DOWN;
closeIconIndex = -1;
mouseOveredIndex = -1;
MutilTempalteTabPane.this.repaint();
}
/**
* 鼠标释放
*
* @param e 鼠标事件
*/
@Override
public void mouseReleased(MouseEvent e) {
}
/**
* 点击
*
* @param e 鼠标事件
*/
@Override
public void mouseClicked(MouseEvent e) {
}
/**
* 按下
*
* @param e 鼠标事件
*/
@Override
public void mousePressed(MouseEvent e) {
//如果在版本管理情况下,不允许切换tab
if (DesignerMode.isVcsMode()) {
return;
}
int evtX = e.getX();
//是否点击关闭按钮 如果点击了关闭按钮,则将点击的模板关闭,不需要切换,如果没有点击关闭按钮,则切换到点击的模板处
boolean isOverCloseIcon = isOverCloseIcon(evtX);
if (isOverListDown(evtX)) {
listDownMode = isOverListDown(evtX) ? MOUSE_PRESS_LIST_DOWN : LIST_DOWN;
if (!isShowList) {
showListDown();
}
isShowList = !isShowList;
} else if (isOverCloseIcon) {
//关闭按钮的图标变化
closeIconIndex = getTemplateIndex(evtX);
clodeMode = MOUSE_PRESS_CLOSE;
//关闭close图标所在的模板{
closeFormat(openedTemplate.get(closeIconIndex));
closeSpecifiedTemplate(openedTemplate.get(closeIconIndex));
DesignerContext.getDesignerFrame().getContentFrame().repaint();
isShowList = false;
} else {
//没有点击关闭和ListDown按钮,则切换到点击的模板处
closeIconIndex = -1;
clodeMode = CLOSE;
int tempSelectedIndex = selectedIndex;
if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) {
openedTemplate.get(selectedIndex).stopEditing();
selectedIndex = getTemplateIndex(evtX);
//如果在权限编辑情况下,不允许切换到表单类型的工作簿
if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex));
JOptionPane.showMessageDialog(MutilTempalteTabPane.this, Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported")
+ "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE);
MutilTempalteTabPane.this.repaint();
return;
}
JTemplate evtXTemplate = openedTemplate.get(getTemplateIndex(evtX));
evtXTemplate.activeNewJTemplate();
}
isShowList = false;
}
MutilTempalteTabPane.this.repaint();
}
}
private class MultiTemplateTabMouseMotionListener implements MouseMotionListener {
/**
* 鼠标拖拽
*
* @param e 鼠标事件
*/
@Override
public void mouseDragged(MouseEvent e) {
}
/**
* 鼠标移动
*
* @param e 鼠标事件
*/
@Override
public void mouseMoved(MouseEvent e) {
int evtX = e.getX();
mouseOveredIndex = getTemplateIndex(evtX);
//看是否需要显示toolTip
if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) {
setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName());
} else {
setToolTipText(null);
}
listDownMode = isOverListDown(evtX) ? MOUSE_OVER_LIST_DOWN : LIST_DOWN;
boolean isOverCloseIcon = isOverCloseIcon(evtX);
clodeMode = isOverCloseIcon ? MOUSE_OVER_CLOSE : CLOSE;
closeIconIndex = isOverCloseIcon ? mouseOveredIndex : -1;
MutilTempalteTabPane.this.repaint();
}
}
}

225
designer-base/src/main/java/com/fr/design/file/NodeAuthProcessor.java

@ -0,0 +1,225 @@
package com.fr.design.file;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.stable.CoreConstants;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.AuthorityOperator;
import java.util.ArrayList;
public class NodeAuthProcessor {
public static NodeAuthProcessor getInstance() {
return NodeAuthProcessor.HOLDER.singleton;
}
private static class HOLDER {
private static NodeAuthProcessor singleton = new NodeAuthProcessor();
}
/**
* 远程设计拥有全部权限的文件夹路径
*/
private ArrayList<String> authPaths = new ArrayList<>();
private NodeAuthProcessor() {
}
public void refresh() {
authPaths.clear();
if (!WorkContext.getCurrent().isLocal()) {
try {
String username = WorkContext.getCurrent().getConnection().getUserName();
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
DesignAuthority authority = null;
if (authorities != null) {
for (DesignAuthority designAuthority : authorities) {
if (ComparatorUtils.equals(designAuthority.getUsername(), username)) {
authority = designAuthority;
}
}
}
if (authority != null) {
for (DesignAuthority.Item item : authority.getItems()) {
if (item.getType()) {
authPaths.add(item.getPath());
}
}
}
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
}
public void clear() {
authPaths.clear();
}
/**
* 生成带权限信息的文件节点供另存对话框使用
*
* @param fileNodes file nodes
* @return 带权限信息的文件节点
*/
public FILE[] parser2FILEArray(FileNode[] fileNodes, String envPath) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
FILE[] res = new FILE[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
if (fn.isDirectory()) {
if (isLocal || isRoot) {
res[i] = new FileNodeFILE(fileNodes[i], envPath);
} else {
boolean hasFullAuthority = isContained(fn);
res[i] = new FileNodeFILE(fileNodes[i], envPath, hasFullAuthority);
}
} else {
res[i] = new FileNodeFILE(fileNodes[i], envPath);
}
}
return res;
}
/**
* 生成带权限信息的文件节点供另存对话框使用
*
* @param fileNode file nodes
* @return 带权限信息的文件节点
*/
public FILE fixFILENodeAuth(FileNode fileNode) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
if (fileNode.isDirectory()) {
if (isLocal || isRoot) {
return new FileNodeFILE(fileNode);
} else {
boolean hasFullAuthority = isContained(fileNode);
return new FileNodeFILE(fileNode, hasFullAuthority);
}
} else {
return new FileNodeFILE(fileNode);
}
}
/**
* 生成带权限信息的文件节点供另存对话框使用
*
* @param fileNode file nodes
* @return 带权限信息的文件节点
*/
public boolean fixFileNodeAuth(FileNode fileNode) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
if (fileNode.isDirectory()) {
if (isLocal || isRoot) {
return true;
} else {
return isContained(fileNode);
}
} else {
return true;
}
}
/**
* 生成带权限信息的目录树节点
* 提供给目录树使用
*
* @param fileNodes file nodes
* @return 带权限信息的目录树节点
*/
public ExpandMutableTreeNode[] parser2TreeNodeArray(FileNode[] fileNodes) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode());
if (isLocal || isRoot) {
res[i].setFullAuthority(true);
} else {
boolean hasFullAuthority = isContained(fn);
res[i].setFullAuthority(hasFullAuthority);
}
}
}
return res;
}
public void fixTreeNodeAuth(ExpandMutableTreeNode treeNode) {
if (treeNode == null) {
return;
}
Object object = treeNode.getUserObject();
if (object instanceof FileNode) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
if (((FileNode) object).isDirectory()) {
if (isLocal || isRoot) {
treeNode.setFullAuthority(true);
} else {
boolean hasFullAuthority = isContained((FileNode) object);
treeNode.setFullAuthority(hasFullAuthority);
}
}
}
}
private boolean isContained(FileNode fileNode) {
for (String auPath : authPaths) {
if (isContained(auPath, fileNode)) {
return true;
}
}
return false;
}
private boolean isContained(String auPath, FileNode fileNode) {
auPath = ProjectConstants.REPORTLETS_NAME + CoreConstants.SEPARATOR + auPath;
String fileName = fileNode.getEnvPath();
String[] auPaths = auPath.split(CoreConstants.SEPARATOR);
String[] nodePaths = fileName.split(CoreConstants.SEPARATOR);
// 待判断目录是有权限目录或者有权限目录的子目录,全部权限
if (auPaths.length <= nodePaths.length) {
for (int i = 0; i < auPaths.length; i++) {
if (!auPaths[i].equals(nodePaths[i])) {
return false;
}
}
return fileNode.isDirectory();
}
// 其他情况半权限
else {
return false;
}
}
}

359
designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java

@ -4,29 +4,32 @@
package com.fr.design.file;
import com.fr.base.FRContext;
import com.fr.base.io.FileAssistUtilsOperator;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Dimension;
@ -37,6 +40,12 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
import static javax.swing.JOptionPane.YES_NO_OPTION;
public class TemplateTreePane extends JPanel implements FileOperations {
@ -49,7 +58,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
private TemplateFileTree reportletsTree;
private FileToolbarStateChangeListener toobarStateChangeListener;
private FileToolbarStateChangeListener toolBarStateChangeListener;
private TemplateTreePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
@ -71,14 +80,14 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override
public void mousePressed(MouseEvent evt) {
if (evt.getClickCount() == 2) {
openSelectedReport();
openFile();
}
}
@Override
public void mouseReleased(MouseEvent e) {
if (toobarStateChangeListener != null) {
toobarStateChangeListener.stateChange();
if (toolBarStateChangeListener != null) {
toolBarStateChangeListener.stateChange();
}
}
};
@ -89,24 +98,24 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
openSelectedReport();
openFile();
}
}
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
openSelectedReport();
openFile();
}
if (toobarStateChangeListener != null) {
toobarStateChangeListener.stateChange();
if (toolBarStateChangeListener != null) {
toolBarStateChangeListener.stateChange();
}
}
@Override
public void keyTyped(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
openSelectedReport();
openFile();
}
}
});
@ -116,6 +125,49 @@ public class TemplateTreePane extends JPanel implements FileOperations {
return this.reportletsTree;
}
/**
* 选中的路径数
*
* @return 选中的路径数
*/
public int countSelectedPath() {
TreePath[] treePaths = reportletsTree.getSelectionPaths();
if (treePaths == null) {
return 0;
}
return treePaths.length;
}
/**
* 选中的文件夹个数
*
* @return 选中的文件夹个数
*/
public int countSelectedFolder() {
if (reportletsTree.getSelectedFolderPaths() == null) {
return 0;
}
return reportletsTree.getSelectedFolderPaths().length;
}
/**
* 选中的文件个数
*
* @return 选中的文件
*/
public int countSelectedFile() {
if (reportletsTree.getSelectionPaths() == null) {
return 0;
}
return reportletsTree.getSelectedTemplatePaths().length;
}
/**
* 刷新
*/
@ -125,11 +177,27 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
@Override
public boolean mkdir(String path) {
return WorkContext.getWorkResource().createDirectory(path);
}
/**
* 打开选中的报表文件
*/
@Override
public void openSelectedReport() {
public void openFile() {
// 判断是否是远程设计的锁定文件
if (!WorkContext.getCurrent().isLocal()) {
FileNode node = reportletsTree.getSelectedFileNode();
if (node == null) {
return;
}
String lock = node.getLock();
if (lock != null && !lock.equals(node.getUserID())) {
return;
}
}
String reportPath = reportletsTree.getSelectedTemplatePath();
final String selectedFilePath = StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath);
DesignerContext.getDesignerFrame().openTemplate(new FileNodeFILE(new FileNode(selectedFilePath, false)));
@ -139,7 +207,7 @@ public class TemplateTreePane extends JPanel implements FileOperations {
* 打开文件夹
*/
@Override
public void openContainerFolder() {
public void showInExplorer() {
FileNode fn = TemplateTreePane.this.reportletsTree.getSelectedFileNode();
String filePath = StableUtils.pathJoin(WorkContext.getCurrent().getPath(), fn.getEnvPath());
filePath = filePath.substring(0, filePath.lastIndexOf(CoreConstants.SEPARATOR));
@ -156,43 +224,139 @@ public class TemplateTreePane extends JPanel implements FileOperations {
@Override
public void refresh() {
reportletsTree.refresh();
FineLoggerFactory.getLogger().info(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!");
FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!");
}
/**
* 删除文件
* 文件夹和文件均可删除
* <p>
* 当文件被锁时不能删除
* 当文件夹中包含被锁文件时不能删除
*/
@Override
public void deleteFile() {
String[] reportPaths = reportletsTree.getSelectedTemplatePaths();
if (reportPaths.length == 0) {
return;
ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes();
// 筛选可以删除的文件
ArrayList<ExpandMutableTreeNode> deletableNodes = new ArrayList<>();
ArrayList<ExpandMutableTreeNode> lockedNodes = new ArrayList<>();
for (ExpandMutableTreeNode treeNode : treeNodes) {
checkFreeOrLock(treeNode, deletableNodes, lockedNodes);
}
if (lockedNodes.isEmpty()) {
String tipContent =
countSelectedFolder() > 0
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Folder")
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File");
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
tipContent,
UIManager.getString("OptionPane.messageDialogTitle"),
YES_NO_OPTION)
== JOptionPane.YES_OPTION) {
// 删除所有选中的即可
if (!deleteNodes(Arrays.asList(treeNodes))) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
}
if (JOptionPane.showConfirmDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_File")) != JOptionPane.OK_OPTION) {
} else {
String tipContent =
countSelectedFolder() > 0
? Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File_And_Folder")
: Toolkit.i18nText("Fine-Design_Basic_Confirm_Delete_Unlock_File");
if (deletableNodes.isEmpty()) {
// 提醒被锁定模板无法删除
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Unable_Delete_Locked_File"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
for (String reportPath : reportPaths) {
FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
if (nodeFile.isLocked()) {
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FileLocked_Undeleted"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.YES_OPTION, JOptionPane.ERROR_MESSAGE) == JOptionPane.YES_OPTION) {
refreshDockingView();
if (JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
tipContent,
UIManager.getString("OptionPane.messageDialogTitle"),
YES_NO_OPTION)
== JOptionPane.YES_OPTION) {
// 删除其他
if (!deleteNodes(deletableNodes)) {
JOptionPane.showConfirmDialog(null,
Toolkit.i18nText("Fine-Design_Basic_Delete_Failure"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
}
break;
}
if (nodeFile.exists()) {
String path = StableUtils.pathJoin(nodeFile.getEnvPath(), nodeFile.getPath());
FileAssistUtilsOperator fileAssistUtils = WorkContext.getCurrent().get(FileAssistUtilsOperator.class);
fileAssistUtils.moveToTrash(nodeFile.getPath());
deleteHistory(path.replaceAll("/", "\\\\"));
reportletsTree.refresh();
}
private boolean deleteNodes(Collection<ExpandMutableTreeNode> nodes) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean success = true;
for (ExpandMutableTreeNode treeNode : nodes) {
Object node = treeNode.getUserObject();
if (node instanceof FileNode) {
FileNodeFILE nodeFILE = new FileNodeFILE((FileNode) node);
if (nodeFILE.exists()) {
if (WorkContext.getCurrent().get(TplOperator.class).delete(nodeFILE.getPath())) {
HistoryTemplateListCache.getInstance().deleteFile(nodeFILE);
} else {
JOptionPane.showMessageDialog(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Warning_Template_Do_Not_Exsit"), ProductConstants.PRODUCT_NAME,
JOptionPane.INFORMATION_MESSAGE);
success = false;
}
}
reportletsTree.refresh();
}
}
return success;
}
private boolean checkFreeOrLock(ExpandMutableTreeNode node, ArrayList<ExpandMutableTreeNode> dNodes, ArrayList<ExpandMutableTreeNode> lNodes) {
// 自己没锁
boolean selfEmptyLock = false;
Object userObj = node.getUserObject();
if (userObj instanceof FileNode) {
String lock = ((FileNode) userObj).getLock();
selfEmptyLock = lock == null || ((FileNode) userObj).getUserID().equals(lock);
}
if (node.isLeaf()) {
if (selfEmptyLock) {
dNodes.add(node);
} else {
lNodes.add(node);
}
return selfEmptyLock;
}
ExpandMutableTreeNode[] children = reportletsTree.loadChildTreeNodes(node);
boolean childrenEmptyLock = true;
for (ExpandMutableTreeNode child : children) {
childrenEmptyLock = checkFreeOrLock(child, dNodes, lNodes) && childrenEmptyLock;
}
boolean emptyLock = childrenEmptyLock && selfEmptyLock;
if (emptyLock) {
dNodes.add(node);
} else {
lNodes.add(node);
}
return emptyLock;
}
@Override
public void lockFile() {
@ -200,90 +364,103 @@ public class TemplateTreePane extends JPanel implements FileOperations {
}
@Override
public void unLockFile() {
public void unlockFile() {
throw new UnsupportedOperationException("unsupport now");
}
private void deleteHistory(String fileName) {
int index = HistoryTemplateListPane.getInstance().contains(fileName);
int size = HistoryTemplateListPane.getInstance().getHistoryCount();
if (index == -1) {
return;
@Override
public String getFilePath() {
return reportletsTree.getSelectedTemplatePath();
}
//如果打开过,则删除,实时刷新多tab面板
HistoryTemplateListPane.getInstance().getHistoryList().remove(index);
int openfileCount = HistoryTemplateListPane.getInstance().getHistoryCount();
if (openfileCount == 0) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate();
@Override
public boolean access() {
TreePath[] selectedTreePaths = reportletsTree.getSelectionPaths();
if (selectedTreePaths == null || selectedTreePaths.length != 1) {
return false;
}
MutilTempalteTabPane.getInstance().repaint();
if (size == index + 1 && index != 0) {
//如果删除的是最后一个Tab,则定位到前一个
MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1);
// 选中的是文件夹
TreePath treePath = selectedTreePaths[0];
ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treePath.getLastPathComponent();
ExpandMutableTreeNode parentTreeNode = (ExpandMutableTreeNode) currentTreeNode.getParent();
return parentTreeNode != null && parentTreeNode.hasFullAuthority();
}
JTemplate selectedfile = MutilTempalteTabPane.getInstance().getSelectedFile();
if (!HistoryTemplateListPane.getInstance().isCurrentEditingFile(selectedfile.getPath())) {
//如果此时面板上的实时刷新的selectedIndex得到的和历史的不一样
DesignerContext.getDesignerFrame().activateJTemplate(selectedfile);
@Override
public boolean rename(FILE tplFile, String from, String to) {
// 多人协作时判断是否有锁定的文件
ExpandMutableTreeNode[] treeNodes = reportletsTree.getSelectedTreeNodes();
// 筛选可以重命名的文件
ArrayList<ExpandMutableTreeNode> unlockedNodes = new ArrayList<>();
ArrayList<ExpandMutableTreeNode> lockedNodes = new ArrayList<>();
for (ExpandMutableTreeNode treeNode : treeNodes) {
checkFreeOrLock(treeNode, unlockedNodes, lockedNodes);
}
MutilTempalteTabPane.getInstance().repaint();
if (!lockedNodes.isEmpty()) {
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Warn_Rename_Lock_File"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE);
return true;
}
try {
// 接收的是WEB-INF下的路径
return WorkContext.getCurrent().get(TplOperator.class).rename(from, to);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;
}
}
@Override
public String getSelectedTemplatePath() {
return reportletsTree.getSelectedTemplatePath();
public FileNode getFileNode() {
return reportletsTree.getSelectedFileNode();
}
public void setToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.toobarStateChangeListener = toobarStateChangeListener;
public void setToolbarStateChangeListener(FileToolbarStateChangeListener listener) {
this.toolBarStateChangeListener = listener;
}
/**
* 文件名是否存在
* 仅支持在拥有完整权限的文件夹下进行新建和重命名操作那么是可以看到改文件夹下所有文件的
*
* @param newName 原名
* @param oldName 新的文件名
* @param suffix 后缀名
* @return 是否存在
* @return 是否有重名的
*/
@Override
public boolean isNameAlreadyExist(String newName, String oldName, String suffix) {
boolean isNameAlreadyExist = false;
TemplateFileTree tt = reportletsTree;
DefaultMutableTreeNode gen = (DefaultMutableTreeNode) tt.getModel().getRoot();
ArrayList<String> al = new ArrayList<String>();
findFiles(gen, al);
public boolean duplicated(String newName, String suffix) {
for (int i = 0; i < al.size(); i++) {
if (ComparatorUtils.equals(al.get(i), newName + suffix)) {
isNameAlreadyExist = true;
break;
}
// 选中的节点
TreePath treePath = reportletsTree.getSelectionPath();
if (treePath == null) {
return false;
}
DefaultMutableTreeNode currentTreeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
TreeNode parentTreeNode = currentTreeNode.getParent();
if (ComparatorUtils.equals(newName, oldName)) {
isNameAlreadyExist = false;
}
Enumeration children = parentTreeNode.children();
return isNameAlreadyExist;
while (children.hasMoreElements()) {
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) children.nextElement();
Object object = childNode.getUserObject();
if (object instanceof FileNode) {
if (ComparatorUtils.equals(((FileNode) object).getName(), newName + suffix)) {
return true;
}
private void findFiles(DefaultMutableTreeNode node, ArrayList<String> al) {
String[] str = new String[node.getChildCount()];
for (int j = 0; j < node.getChildCount(); j++) {
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) node.getChildAt(j);
if (childNode.getChildCount() > 0) {
findFiles(childNode, al);
} else {
str[j] = node.getChildAt(j).toString();
if (str[j].contains(".")) {
al.add(str[j]);
}
return false;
}
}
return false;
}
}

3
designer-base/src/main/java/com/fr/design/gui/iprogressbar/ProgressDialog.java

@ -77,4 +77,7 @@ public class ProgressDialog extends UIDialog {
centerDialog.dispose();
super.dispose();
}
public void updateLoadingText(String text) {
this.text.setText(text);
}
}

128
designer-base/src/main/java/com/fr/design/gui/itree/filetree/TemplateFileTree.java

@ -2,17 +2,13 @@ package com.fr.design.gui.itree.filetree;
import com.fr.base.FRContext;
import com.fr.base.extension.FileExtension;
import com.fr.design.file.NodeAuthProcessor;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.AuthorityOperator;
import javax.swing.text.Position;
import javax.swing.tree.DefaultTreeModel;
@ -26,12 +22,6 @@ import java.util.List;
*/
public class TemplateFileTree extends EnvFileTree {
/**
* 远程设计拥有全部权限的文件夹路径
*/
private ArrayList<String> paths = new ArrayList<>();
public TemplateFileTree() {
super(ProjectConstants.REPORTLETS_NAME, null, null);
}
@ -79,10 +69,32 @@ public class TemplateFileTree extends EnvFileTree {
}
}
return selectedPathList.toArray(new String[0]);
}
public String[] getSelectedFolderPaths() {
TreePath[] selectedTreePaths = this.getSelectionPaths();
if (ArrayUtils.isEmpty(selectedTreePaths)) {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
List<String> selectedPathList = new ArrayList<String>();
for (TreePath treepath : selectedTreePaths) {
ExpandMutableTreeNode currentTreeNode = (ExpandMutableTreeNode) treepath.getLastPathComponent();
Object userObject = currentTreeNode.getUserObject();
if (userObject instanceof FileNode) {
FileNode fn = (FileNode) userObject;
if (fn.isDirectory()) {
String envPath = fn.getEnvPath();
if (envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
selectedPathList.add(envPath.substring(ProjectConstants.REPORTLETS_NAME.length()));
}
}
}
}
return selectedPathList.toArray(new String[0]);
}
@Override
public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) {
@ -122,37 +134,11 @@ public class TemplateFileTree extends EnvFileTree {
*/
@Override
public void refreshEnv() {
paths.clear();
if (!WorkContext.getCurrent().isLocal()) {
try {
String username = WorkContext.getConnector().currentUser();
// 远程设计获取全部设计成员的权限列表
DesignAuthority[] authorities = WorkContext.getCurrent().get(AuthorityOperator.class).getAuthorities();
DesignAuthority authority = null;
if (authorities != null) {
for (DesignAuthority designAuthority : authorities) {
if (ComparatorUtils.equals(designAuthority.getUsername(), username)) {
authority = designAuthority;
}
}
}
if (authority != null) {
for (DesignAuthority.Item item : authority.getItems()) {
if (item.getType()) {
paths.add(item.getPath());
}
}
}
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
NodeAuthProcessor.getInstance().refresh();
DefaultTreeModel defaultTreeModel = (DefaultTreeModel) this.getModel();
ExpandMutableTreeNode rootTreeNode = (ExpandMutableTreeNode) defaultTreeModel.getRoot();
NodeAuthProcessor.getInstance().fixTreeNodeAuth(rootTreeNode);
rootTreeNode.removeAllChildren();
FileNode[] fns;
@ -178,64 +164,34 @@ public class TemplateFileTree extends EnvFileTree {
}
@Override
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) {
public ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode treeNode) {
FileNode[] fnArray = listFileNodes(treeNode);
return fileNodeArray2TreeNodeArray(fnArray);
}
/*
* 把FileNode[]转成ExpandMutableTreeNode[]
*/
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
boolean isLocal = WorkContext.getCurrent().isLocal();
boolean isRoot = WorkContext.getCurrent().isRoot();
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[fileNodes.length];
for (int i = 0; i < res.length; i++) {
FileNode fn = fileNodes[i];
res[i] = new ExpandMutableTreeNode(fn);
if (fn.isDirectory()) {
res[i].add(new ExpandMutableTreeNode());
if (isLocal || isRoot) {
res[i].setFullAuthority(true);
} else {
boolean hasFullAuthority = isContained(fn);
res[i].setFullAuthority(hasFullAuthority);
}
}
}
return res;
}
private boolean isContained(FileNode fileNode) {
public ExpandMutableTreeNode[] getSelectedTreeNodes() {
TreePath[] paths = this.getSelectionPaths();
for (String auPath : paths) {
if (isContained(auPath, fileNode)) {
return true;
}
}
return false;
if (paths == null) {
return new ExpandMutableTreeNode[0];
}
private boolean isContained(String auPath, FileNode fileNode) {
auPath = ProjectConstants.REPORTLETS_NAME + CoreConstants.SEPARATOR + auPath;
String fileName = fileNode.getEnvPath();
String[] auPaths = auPath.split(CoreConstants.SEPARATOR);
String[] nodePaths = fileName.split(CoreConstants.SEPARATOR);
// 待判断目录是有权限目录或者有权限目录的子目录,全部权限
if (auPaths.length <= nodePaths.length) {
for (int i = 0; i < auPaths.length; i++) {
if (!auPaths[i].equals(nodePaths[i])) {
return false;
}
}
return fileNode.isDirectory();
ArrayList<ExpandMutableTreeNode> res = new ArrayList<>();
for (TreePath path : paths) {
res.add((ExpandMutableTreeNode) path.getLastPathComponent());
}
// 其他情况半权限
else {
return false;
return res.toArray(new ExpandMutableTreeNode[res.size()]);
}
/*
* 把FileNode[]转成ExpandMutableTreeNode[]
*/
private ExpandMutableTreeNode[] fileNodeArray2TreeNodeArray(FileNode[] fileNodes) {
return NodeAuthProcessor.getInstance().parser2TreeNodeArray(fileNodes);
}
@ -284,6 +240,4 @@ public class TemplateFileTree extends EnvFileTree {
return new FileNode[0];
}
}

29
designer-base/src/main/java/com/fr/design/hyperlink/WebHyperlinkPane.java

@ -4,14 +4,16 @@ import com.fr.base.Parameter;
import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.itableeditorpane.ParameterTableModel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.WebHyperlink;
import com.fr.stable.ParameterProvider;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
import java.util.HashMap;
import java.util.List;
@ -19,8 +21,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane<WebHyperlink> {
private static final int BORDER_WIDTH = 4;
private WebHyperNorthPane northPane;
private UICheckBox useCJKCheckBox;
private UICheckBox extendParametersCheckBox;
public WebHyperlinkPane() {
@ -42,16 +42,15 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane<WebHyperlink> {
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane());
this.add(parameterViewPane, BorderLayout.CENTER);
parameterViewPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters"), null));
parameterViewPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Parameters"), null));
useCJKCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Use_CJK_To_Encode_Parameter"));
extendParametersCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
this.add(GUICoreUtils.createFlowPane(new Component[]{useCJKCheckBox, extendParametersCheckBox}, FlowLayout.LEFT), BorderLayout.SOUTH);
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
this.add(GUICoreUtils.createFlowPane(new Component[]{extendParametersCheckBox}, FlowLayout.LEFT), BorderLayout.SOUTH);
}
@Override
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Web_Link");
return Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Web_Link");
}
@Override
@ -63,7 +62,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane<WebHyperlink> {
ParameterProvider[] parameters = ob.getParameters();
parameterViewPane.populate(parameters);
useCJKCheckBox.setSelected(ob.isUseCJK());
extendParametersCheckBox.setSelected(ob.isExtendParameters());
}
@ -88,7 +86,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane<WebHyperlink> {
} else {
webHyperlink.setParameters(null);
}
webHyperlink.setUseCJK(this.useCJKCheckBox.isSelected());
webHyperlink.setExtendParameters(this.extendParametersCheckBox.isSelected());
}
@ -110,14 +107,6 @@ public class WebHyperlinkPane extends AbstractHyperLinkPane<WebHyperlink> {
this.northPane = northPane;
}
public UICheckBox getUseCJKCheckBox() {
return useCJKCheckBox;
}
public void setUseCJKCheckBox(UICheckBox useCJKCheckBox) {
this.useCJKCheckBox = useCJKCheckBox;
}
public UICheckBox getExtendParametersCheckBox() {
return extendParametersCheckBox;
}

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

@ -42,7 +42,6 @@ import com.fr.file.FILEFactory;
import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.injectable.PluginModule;
@ -57,7 +56,7 @@ import com.fr.stable.image4j.codec.ico.ICODecoder;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import javax.swing.Icon;
import javax.swing.JComponent;
@ -747,7 +746,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
String username = null;
if (info != null) {
WorkspaceConnection connection = info.getConnection();
WorkspaceConnectionInfo connection = info.getConnection();
username = connection == null ? StringUtils.EMPTY : connection.getUserName();
}
defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]");
@ -758,7 +757,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} else if (path.startsWith(ProjectConstants.REPORTLETS_NAME)) {
path = workspace.getPath() + File.separator + path;
}
defaultTitleSB.append(" " + path);
defaultTitleSB.append(" ").append(path);
}
setTitle(defaultTitleSB.toString());
@ -1070,8 +1069,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
EastRegionContainerPane.getInstance().getContainerWidth());
DesignerEnvManager.getEnvManager().saveXMLFile();
WorkContext.switchTo(null);
//关闭当前环境
WorkContext.getCurrent().close();
this.setVisible(false);
this.dispose();
@ -1153,4 +1152,36 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
return progressDialog;
}
public void showProgressDialog() {
progressDialog.setVisible(true);
}
/**
* 隐藏进度框
*/
public void hideProgressDialog() {
progressDialog.setVisible(false);
}
/**
* 更新进度框进度
*
* @param progress
*/
public void updateProgress(int progress) {
progressDialog.setProgressValue(progress);
}
/**
* 释放进度框
*/
public void disposeProgressDialog() {
progressDialog.dispose();
}
}

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

@ -1,7 +1,6 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
@ -13,74 +12,77 @@ import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.file.FileOperations;
import com.fr.design.file.FileToolbarStateChangeListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.file.SaveSomeTemplatePane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIMenuHighLight;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.io.utils.ResourceIOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils;
import com.fr.workspace.WorkContext;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static javax.swing.JOptionPane.WARNING_MESSAGE;
public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange {
private static final String FILE = "file";
private static volatile DesignerFrameFileDealerPane THIS;
private CardLayout card;
private JPanel cardPane;
private java.util.List<FileToolbarStateChangeListener> otherToobarStateChangeListeners = new ArrayList<>();
private List<FileToolbarStateChangeListener> otherToolbarStateChangeListeners = new ArrayList<>();
private FileOperations selectedOperation;
private UIToolbar toolBar;
private OpenReportAction openReportAction = new OpenReportAction();
private NewFolderAction newFolderAction = new NewFolderAction();
private RefreshTreeAction refreshTreeAction = new RefreshTreeAction();
private OpenFolderAction openFolderAction = new OpenFolderAction();
private ShowInExplorerAction showInExplorerAction = new ShowInExplorerAction();
private RenameAction renameAction = new RenameAction();
@ -91,11 +93,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
* 刷新
*/
public void refresh() {
selectedOperation.refresh();
}
public static final DesignerFrameFileDealerPane getInstance() {
public static DesignerFrameFileDealerPane getInstance() {
if (THIS == null) {
synchronized (DesignerFrameFileDealerPane.class) {
@ -121,13 +122,14 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
tooBarPane.add(new UIMenuHighLight(), BorderLayout.SOUTH);
add(tooBarPane, BorderLayout.NORTH);
cardPane = new JPanel(card = new CardLayout());
CardLayout card;
JPanel cardPane = new JPanel(card = new CardLayout());
cardPane.add(TemplateTreePane.getInstance(), FILE);
selectedOperation = TemplateTreePane.getInstance();
card.show(cardPane, FILE);
TemplateTreePane.getInstance().setToobarStateChangeListener(this);
TemplateTreePane.getInstance().setToolbarStateChangeListener(this);
add(cardPane, BorderLayout.CENTER);
stateChange();
@ -136,7 +138,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public final void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
DesignModelAdapter.setCurrentModelAdapter(jt == null ? null : jt.getModel());
DesignModelAdapter.setCurrentModelAdapter(jt.getModel());
fireDSChanged();
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter());
HistoryTemplateListPane.getInstance().setCurrentEditingTemplate(jt);
@ -152,7 +154,9 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
jt.requestFocus();
jt.revert();
FRContext.getLogger().info("\"" + jt.getEditingFILE().getName() + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_LOG_Has_Been_Openned") + "!");
FineLoggerFactory.getLogger().info(
"\"" + jt.getEditingFILE().getName() + "\""
+ Toolkit.i18nText("Fine-Design_Basic_LOG_Has_Been_Openned") + "!");
}
/**
@ -161,27 +165,26 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public void refreshDockingView() {
ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(openReportAction, refreshTreeAction);
toolbarDef.addShortCut(newFolderAction, refreshTreeAction);
if (WorkContext.getCurrent().isLocal()) {
toolbarDef.addShortCut(openFolderAction, renameAction);
toolbarDef.addShortCut(showInExplorerAction);
}
toolbarDef.addShortCut(delFileAction);
toolbarDef.addShortCut(renameAction, delFileAction);
Set<ShortCut> extraShortCuts = ExtraDesignClassManager.getInstance().getExtraShortCuts();
for (ShortCut shortCut : extraShortCuts) {
toolbarDef.addShortCut(shortCut);
}
toolbarDef.updateToolBar(toolBar);
refreshActions();
resetActionStatus();
refresh();
}
private void refreshActions() {
private void resetActionStatus() {
openReportAction.setEnabled(false);
newFolderAction.setEnabled(false);
refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false);
showInExplorerAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
this.repaint();
@ -206,28 +209,53 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
public void addToolbarStateChangeListener(FileToolbarStateChangeListener listener) {
this.otherToolbarStateChangeListeners.add(listener);
}
public void removeToolbarStateChangeListener(FileToolbarStateChangeListener listener) {
this.otherToolbarStateChangeListeners.remove(listener);
}
private void otherStateChange() {
for (FileToolbarStateChangeListener listener : otherToolbarStateChangeListeners) {
listener.stateChange();
}
}
/*
* Open Report Action
* 新建文件夹
*/
private class OpenReportAction extends UpdateAction {
private class NewFolderAction extends UpdateAction {
public OpenReportAction() {
public NewFolderAction() {
this.setName(KeySetUtils.OPEN_TEMPLATE.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/open.png"));
this.setName(KeySetUtils.NEW_FOLDER.getMenuKeySetName());
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/icon_NewFolderIcon_normal.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.openSelectedReport();
if (!selectedOperation.access()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
new MkdirDialog();
}
}
private class OpenFolderAction extends UpdateAction {
/**
* 在系统资源管理器中打开
*/
private class ShowInExplorerAction extends UpdateAction {
public OpenFolderAction() {
public ShowInExplorerAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Show_In_Containing_Folder"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/view_folder.png"));
@ -236,7 +264,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
@Override
public void actionPerformed(ActionEvent evt) {
selectedOperation.openContainerFolder();
selectedOperation.showInExplorer();
}
}
@ -247,7 +275,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public RefreshTreeAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Refresh"));
this.setSmallIcon(UIConstants.REFRESH_ICON);
}
@ -260,20 +288,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
}
}
public void addToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.otherToobarStateChangeListeners.add(toobarStateChangeListener);
}
public void removeToobarStateChangeListener(FileToolbarStateChangeListener toobarStateChangeListener) {
this.otherToobarStateChangeListeners.remove(toobarStateChangeListener);
}
private void otherStateChange() {
for (FileToolbarStateChangeListener toobarStateChangeListener : otherToobarStateChangeListeners) {
toobarStateChangeListener.stateChange();
}
}
/*
* 重命名文件
*/
@ -281,14 +295,32 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public RenameAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Rename"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Rename"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/rename.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
if (!selectedOperation.access()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
FileNode node = selectedOperation.getFileNode();
String lock = node.getLock();
if (lock != null && !lock.equals(node.getUserID())) {
// 提醒被锁定模板无法重命名
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Unable_Rename_Locked_File"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
new RenameDialog();
new FileRenameDialog(node);
MutilTempalteTabPane.getInstance().repaint();
}
@ -301,13 +333,21 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
public DelFileAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remove"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Remove"));
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/data/source/delete.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
if (!selectedOperation.access()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
WARNING_MESSAGE);
return;
}
selectedOperation.deleteFile();
}
}
@ -318,295 +358,431 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
@Override
public void stateChange() {
if (selectedOperation.getSelectedTemplatePath() != null) {
openReportAction.setEnabled(true);
renameAction.setEnabled(true);
delFileAction.setEnabled(true);
} else {
openReportAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(false);
}
openFolderAction.setEnabled(containsFolderNums() + seletedTemplateNums() != 0);
int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath();
// 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用
boolean singleSelected = selectedPathNum == 1;
newFolderAction.setEnabled(singleSelected);
renameAction.setEnabled(singleSelected);
showInExplorerAction.setEnabled(singleSelected);
// 删除操作在至少选中一个时可用
boolean selected = selectedPathNum > 0;
delFileAction.setEnabled(selected);
// 刷新操作始终可用
refreshTreeAction.setEnabled(true);
if (containsFolderNums() > 0 && (containsFolderNums() + seletedTemplateNums() > 1)) {
refreshActions();
} else if (containsFolderNums() == 0 && seletedTemplateNums() > 1) {
openReportAction.setEnabled(false);
refreshTreeAction.setEnabled(true);
openFolderAction.setEnabled(false);
renameAction.setEnabled(false);
delFileAction.setEnabled(true);
}
// 其他状态
otherStateChange();
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}
/**
* 是否包含文件夹
*
* @return
* 重命名对话框
* 支持快捷键EnterESC
*/
private class FileRenameDialog extends JDialog {
private int containsFolderNums() {
private UITextField nameField;
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
private UILabel warnLabel;
//选择的包含文件和文件夹的数目
if (fileTree.getSelectionPaths().length == 0) {
return 0;
}
//所有的num减去模板的num,得到文件夹的num
return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length;
}
private UIButton confirmButton;
/**
* 是否选择了多个模板
*
* @return
* 操作的节点
*/
private int seletedTemplateNums() {
private FileNodeFILE fnf;
TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree();
if (fileTree.getSelectionPaths() == null) {
return 0;
}
return fileTree.getSelectedTemplatePaths().length;
private FileRenameDialog(FileNode node) {
if (node == null) {
return;
}
fnf = new FileNodeFILE(node);
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY);
// js: 重命名对话框,模仿Eclipse的重命名,支持快捷键F2,Enter,ESC
private class RenameDialog {
private UITextField jt;
private String userInput;
this.setLayout(new BorderLayout());
this.setModal(true);
private String oldName;
private UILabel hintsLabel;
private UIButton confirmButton;
// 输入框前提示
UILabel newNameLabel = new UILabel(Toolkit.i18nText(
fnf.isDirectory() ?
"Fine-Design_Basic_Enter_New_Folder_Name" : "Fine-Design_Basic_Enter_New_File_Name")
);
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
newNameLabel.setPreferredSize(new Dimension(118, 15));
private JDialog jd;
// 重命名输入框
nameField = new UITextField(oldName);
nameField.getDocument().addDocumentListener(new DocumentListener() {
private String suffix;
public void changedUpdate(DocumentEvent e) {
validInput();
}
public RenameDialog() {
public void insertUpdate(DocumentEvent e) {
validInput();
}
final String reportPath = selectedOperation.getSelectedTemplatePath();
if (reportPath == null) {
return;
public void removeUpdate(DocumentEvent e) {
validInput();
}
});
nameField.selectAll();
nameField.setPreferredSize(new Dimension(180, 20));
final FileNodeFILE nodeFile = new FileNodeFILE(new FileNode(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, reportPath), false));
final String path = nodeFile.getPath();
oldName = nodeFile.getName();
suffix = oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, "");
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
topPanel.add(newNameLabel);
topPanel.add(nameField);
jd = new JDialog();
jd.setLayout(new GridLayout(2, 2));
jd.setModal(true);
UILabel newNameLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Enter_New_File_Name"));
newNameLabel.setMinimumSize(new Dimension(150, 27));
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
jt = new UITextField(oldName);
jt.getDocument().addDocumentListener(getdoDocumentListener());
jt.selectAll();
jt.setPreferredSize(new Dimension(150, 20));
JPanel newNamePanel = new JPanel();
newNamePanel.setLayout(new BoxLayout(newNamePanel, BoxLayout.X_AXIS));
newNamePanel.add(Box.createHorizontalGlue());
newNamePanel.add(newNameLabel);
newNamePanel.add(Box.createHorizontalStrut(5));
jd.add(newNamePanel);
JPanel jtPanel = new JPanel();
jtPanel.setLayout(new BoxLayout(jtPanel, BoxLayout.Y_AXIS));
JPanel containJt = new JPanel(new BorderLayout());
containJt.add(jt, BorderLayout.WEST);
containJt.setMaximumSize(new Dimension(200, 20));
jtPanel.add(Box.createVerticalGlue());
jtPanel.add(containJt);
jtPanel.add(Box.createVerticalGlue());
jd.add(jtPanel);
addUITextFieldListener(nodeFile, path);
hintsLabel = new UILabel();
hintsLabel.setBounds(20, 50, 250, 30);
hintsLabel.setMaximumSize(new Dimension(200, 30));
hintsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
hintsLabel.setForeground(Color.RED);
hintsLabel.setVisible(false);
confirmButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"));
confirmButton.setPreferredSize(new Dimension(80, 25));
confirmButton.setMinimumSize(new Dimension(80, 25));
confirmButton.setMaximumSize(new Dimension(80, 25));
// 增加enter以及esc快捷键的支持
nameField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
dispose();
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) {
confirmClose();
}
}
}
});
// 重名提示
warnLabel = new UILabel();
warnLabel.setPreferredSize(new Dimension(300, 30));
warnLabel.setHorizontalAlignment(SwingConstants.LEFT);
warnLabel.setForeground(Color.RED);
warnLabel.setVisible(false);
JPanel midPanel = new JPanel(new BorderLayout());
midPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
midPanel.add(warnLabel, BorderLayout.WEST);
// 确认按钮
confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm"));
confirmButton.setPreferredSize(new Dimension(60, 25));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
confirmClose(nodeFile, path);
confirmClose();
}
});
UIButton cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
cancelButton.setPreferredSize(new Dimension(80, 25));
cancelButton.setMinimumSize(new Dimension(80, 25));
cancelButton.setMaximumSize(new Dimension(80, 25));
// 取消按钮
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
cancelButton.setPreferredSize(new Dimension(60, 25));
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jd.dispose();
dispose();
}
});
JPanel hintsPanel = new JPanel();
hintsPanel.setLayout(new BorderLayout());
hintsPanel.add(hintsLabel, BorderLayout.EAST);
jd.add(hintsLabel);
JPanel btPanel = new JPanel(new BorderLayout());
btPanel.setLayout(new BoxLayout(btPanel, BoxLayout.X_AXIS));
btPanel.add(Box.createHorizontalGlue());
btPanel.add(confirmButton);
btPanel.add(Box.createHorizontalStrut(5));
btPanel.add(cancelButton);
btPanel.add(Box.createHorizontalStrut(20));
jd.add(btPanel);
jd.setSize(380, 200);
jd.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Rename"));
jd.setResizable(false);
jd.setAlwaysOnTop(true);
jd.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
jd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
GUICoreUtils.centerWindow(jd);
jd.setVisible(true);
}
public void confirmClose(FileNodeFILE nodeFile, String path) {
userInput = userInput == null ? oldName : userInput;
String oldPath = path.replaceAll("/", "\\\\");
String newPath = path.replace(nodeFile.getName(), userInput + suffix);
renameTemplateInMemory(nodeFile, userInput + suffix, oldName + suffix);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldPath, newPath.replaceAll("/", "\\\\"));
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
bottomPanel.add(confirmButton);
bottomPanel.add(cancelButton);
this.add(
TableLayoutHelper.createTableLayoutPane(
new Component[][]{
new Component[]{topPanel},
new Component[]{midPanel},
new Component[]{bottomPanel}
},
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
new double[]{TableLayout.FILL}
),
BorderLayout.CENTER);
this.setSize(340, 180);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Rename"));
this.setResizable(false);
this.setAlwaysOnTop(true);
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
GUICoreUtils.centerWindow(this);
this.setVisible(true);
}
private void confirmClose() {
String userInput = nameField.getText().trim();
// 处理不合法的文件夹名称
userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY);
String path = FilenameUtils.standard(fnf.getPath());
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY);
// 输入为空或者没有修改
if (ComparatorUtils.equals(userInput, oldName)) {
this.dispose();
return;
}
String parentPath = FilenameUtils.standard(fnf.getParent().getPath());
// 简单执行old new 替换是不可行的,例如 /abc/abc/abc/abc/
String newPath = parentPath + CoreConstants.SEPARATOR + userInput + suffix;
this.dispose();
//模版重命名
ResourceIOUtils.renameTo(path, newPath);
boolean success = false;
// 提醒保存文件
SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true);
// 只有一个文件未保存时
if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) {
int choose = saveSomeTempaltePane.saveLastOneTemplate();
if (choose != JOptionPane.CANCEL_OPTION) {
success = selectedOperation.rename(fnf, path, newPath);
}
} else {
if (saveSomeTempaltePane.showSavePane()) {
success = selectedOperation.rename(fnf, path, newPath);
}
}
if (success) {
HistoryTemplateListCache.getInstance().rename(fnf, path, newPath);
DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(fnf.isDirectory(), path, newPath);
selectedOperation.refresh();
DesignerContext.getDesignerFrame().setTitle();
jd.dispose();
} else {
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Rename_Failure"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
}
private void renameTemplateInMemory(FILE tplFile, String newName, String oldName) {
JTemplate<?, ?> dPane = getSpecialTemplateByFILE(tplFile);
if (dPane == null) {
private void validInput() {
String userInput = nameField.getText().trim();
String oldName = fnf.getName();
String suffix = fnf.isDirectory() ? StringUtils.EMPTY : oldName.substring(oldName.lastIndexOf(CoreConstants.DOT), oldName.length());
oldName = oldName.replaceAll(suffix, StringUtils.EMPTY);
if (StringUtils.isEmpty(userInput)) {
confirmButton.setEnabled(false);
return;
}
FILE renameFile = dPane.getEditingFILE();
renameFile.setPath(renameFile.getPath().replace(oldName, newName));
if (ComparatorUtils.equals(userInput, oldName)) {
warnLabel.setVisible(false);
confirmButton.setEnabled(true);
return;
}
// 增加enter以及esc快捷键的支持
public void addUITextFieldListener(final FileNodeFILE nodeFile, final String path) {
if (selectedOperation.duplicated(userInput, suffix)) {
nameField.selectAll();
// 如果文件名已存在,则灰掉确认按钮
warnLabel.setText(
Toolkit.i18nText(fnf.isDirectory() ?
"Fine-Design_Basic_Folder_Name_Duplicate" :
"Fine-Design_Basic_Template_File_Name_Duplicate",
userInput));
warnLabel.setVisible(true);
confirmButton.setEnabled(false);
} else {
warnLabel.setVisible(false);
confirmButton.setEnabled(true);
}
}
}
jt.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
/**
* 新建文件夹对话框
* 支持快捷键EnterESC
*/
private class MkdirDialog extends JDialog {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
jd.dispose();
private UITextField nameField;
private UILabel warnLabel;
private UIButton confirmButton;
private MkdirDialog() {
this.setLayout(new BorderLayout());
this.setModal(true);
// 输入框前提示
UILabel newNameLabel = new UILabel(Toolkit.i18nText(
"Fine-Design_Basic_Enter_New_Folder_Name")
);
newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
newNameLabel.setPreferredSize(new Dimension(118, 15));
// 文件名输入框
nameField = new UITextField();
nameField.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
validInput();
}
public void insertUpdate(DocumentEvent e) {
validInput();
}
public void removeUpdate(DocumentEvent e) {
validInput();
}
});
nameField.selectAll();
nameField.setPreferredSize(new Dimension(180, 20));
jt.addKeyListener(new KeyAdapter() {
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 5));
topPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
topPanel.add(newNameLabel);
topPanel.add(nameField);
// 增加enter以及esc快捷键的支持
nameField.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
dispose();
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if (confirmButton.isEnabled()) {
confirmClose(nodeFile, path);
confirmClose();
}
}
}
});
// 重名提示
warnLabel = new UILabel();
warnLabel.setPreferredSize(new Dimension(300, 30));
warnLabel.setHorizontalAlignment(SwingConstants.LEFT);
warnLabel.setForeground(Color.RED);
warnLabel.setVisible(false);
JPanel midPanel = new JPanel(new BorderLayout());
midPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
midPanel.add(warnLabel, BorderLayout.WEST);
// 确认按钮
confirmButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Confirm"));
confirmButton.setPreferredSize(new Dimension(60, 25));
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
confirmClose();
}
});
confirmButton.setEnabled(false);
// UITextField的输入监听
public DocumentListener getdoDocumentListener() {
DocumentListener dl = new DocumentListener() {
// 取消按钮
UIButton cancelButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
cancelButton.setPreferredSize(new Dimension(60, 25));
public void changedUpdate(DocumentEvent e) {
cancelButton.addActionListener(new ActionListener() {
isNameAlreadyExist();
public void actionPerformed(ActionEvent e) {
dispose();
}
});
public void insertUpdate(DocumentEvent e) {
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 15));
bottomPanel.add(confirmButton);
bottomPanel.add(cancelButton);
this.add(
TableLayoutHelper.createTableLayoutPane(
new Component[][]{
new Component[]{topPanel},
new Component[]{midPanel},
new Component[]{bottomPanel}
},
new double[]{TableLayout.FILL, TableLayout.FILL, TableLayout.FILL},
new double[]{TableLayout.FILL}
),
BorderLayout.CENTER);
this.setSize(340, 180);
this.setTitle(Toolkit.i18nText("Fine-Design_Basic_Mkdir"));
this.setResizable(false);
this.setAlwaysOnTop(true);
this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png"));
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
GUICoreUtils.setWindowCenter(DesignerContext.getDesignerFrame(), this);
this.setVisible(true);
}
private void confirmClose() {
String userInput = nameField.getText().trim();
// 处理不合法的文件夹名称
userInput = userInput.replaceAll("[\\\\/:*?\"<>|]", StringUtils.EMPTY);
if (StringUtils.isEmpty(userInput)) {
return;
}
isNameAlreadyExist();
//新建文件夹
boolean success = selectedOperation.mkdir(
FilenameUtils.standard(selectedOperation.getFileNode().getParent() + CoreConstants.SEPARATOR + userInput)
);
selectedOperation.refresh();
this.dispose();
if (!success) {
JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Make_Failure"),
UIManager.getString("OptionPane.messageDialogTitle"),
JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE);
}
}
public void removeUpdate(DocumentEvent e) {
isNameAlreadyExist();
}
};
private void validInput() {
String userInput = nameField.getText().trim();
return dl;
}
private void isNameAlreadyExist() {
if (StringUtils.isEmpty(userInput)) {
confirmButton.setEnabled(false);
return;
}
userInput = jt.getText().trim();
if (selectedOperation.isNameAlreadyExist(userInput, oldName, suffix)) {
jt.selectAll();
if (selectedOperation.duplicated(userInput, StringUtils.EMPTY)) {
nameField.selectAll();
// 如果文件名已存在,则灰掉确认按钮
hintsLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Template_File_Name_Duplicate", userInput));
hintsLabel.setVisible(true);
warnLabel.setText(
Toolkit.i18nText(
"Fine-Design_Basic_Folder_Name_Duplicate",
userInput));
warnLabel.setVisible(true);
confirmButton.setEnabled(false);
} else {
hintsLabel.setVisible(false);
warnLabel.setVisible(false);
confirmButton.setEnabled(true);
}
}
}
/**
* @param tplFile
* @return 内存中的template重命名一下
*/
private JTemplate<?, ?> getSpecialTemplateByFILE(FILE tplFile) {
HistoryTemplateListPane historyHandle = HistoryTemplateListPane.getInstance();
if (ComparatorUtils.equals(historyHandle.getCurrentEditingTemplate().getEditingFILE(), tplFile)) {
return historyHandle.getCurrentEditingTemplate();
}
for (int i = 0; i < historyHandle.getHistoryCount(); i++) {
if (ComparatorUtils.equals(historyHandle.get(i).getEditingFILE(), tplFile)) {
return historyHandle.get(i);
}
}
return null;
}
public FileOperations getSelectedOperation() {
return selectedOperation;
}
}

28
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -17,7 +17,6 @@ import com.fr.design.actions.edit.UndoAction;
import com.fr.design.actions.file.SaveAsTemplateAction;
import com.fr.design.actions.file.SaveTemplateAction;
import com.fr.design.actions.file.WebPreviewUtils;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.TargetComponent;
import com.fr.design.dialog.InformationWarnPane;
import com.fr.design.file.HistoryTemplateListPane;
@ -47,7 +46,6 @@ import com.fr.file.MemFILE;
import com.fr.form.ui.NoneWidget;
import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.cell.Elem;
import com.fr.report.cell.cellattr.CellImage;
@ -56,10 +54,13 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.core.UUID;
import javax.swing.*;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager;
import java.awt.*;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
@ -180,7 +181,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
* 有条件取消格式刷
*/
public void doConditionCancelFormat() {
return;
}
@Override
@ -193,7 +193,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
*/
@Override
public void cancelFormat() {
return;
}
//因为报表的tab从0开始,所以表单默认为-1吧
@ -462,8 +461,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// 子类实现
}
;
/**
* 是否保存
*
@ -522,7 +519,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
// return false;
// }
// } catch (Exception e) {
// FineLoggerFactory.getLogger().error(e.getMessage());
// FineLoggerFactory.getLogger().error(e.getMessage(), e);
// }
@ -565,6 +562,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
/**
* 保存
*
* @param isShowLoc 是否显示报表运行环境外的路径(C盘D盘等)
* @param fileName 保存文件名
* @return
@ -592,7 +590,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return false;
}
editingFILE = fileChooser.getSelectedFILE();
mkNewFile(editingFILE);
}
return saveNewFile(editingFILE, oldName);
@ -942,17 +939,6 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
DesignerContext.getDesignerFrame().addAndActivateJTemplate(this);
}
/**
* 后台关闭template
*/
public void closeOverLineTemplate(int index) {
JTemplate overTemplate = HistoryTemplateListPane.getInstance().getHistoryList().get(index);
HistoryTemplateListPane.getInstance().closeVirtualSelectedReport(overTemplate);
HistoryTemplateListPane.getInstance().getHistoryList().set(index, new JVirtualTemplate(overTemplate.getEditingFILE()));
}
;
/**
* 返回当前支持的超链界面pane

22
designer-base/src/main/java/com/fr/design/mainframe/JVirtualTemplate.java

@ -11,15 +11,11 @@ import com.fr.design.mainframe.templateinfo.TemplateProcessInfo;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.io.File;
import java.util.List;
/**
@ -30,20 +26,10 @@ import java.util.List;
*/
public class JVirtualTemplate extends JTemplate {
private FILE editingFILE = null;
private FILE editingFILE;
public JVirtualTemplate(FILE editingFILE) {
setEditingFILE(editingFILE);
}
@Override
public String getPath() {
String editingFileName = getEditingFILE().getPath();
if (editingFileName.startsWith(ProjectConstants.REPORTLETS_NAME)) {
editingFileName = ((FileNodeFILE) getEditingFILE()).getEnvPath() + File.separator + editingFileName;
}
editingFileName = OperatingSystem.isWindows() ? editingFileName.replaceAll("/", "\\\\") : editingFileName.replaceAll("\\\\", "/");
return editingFileName;
this.editingFILE = editingFILE;
}
/**
@ -237,10 +223,6 @@ public class JVirtualTemplate extends JTemplate {
DesignerContext.getDesignerFrame().openTemplate(this.getEditingFILE());
}
@Override
public void closeOverLineTemplate(int index) {
}
@Override
public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) {
return null;

341
designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java

@ -1,344 +1,19 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignerEnvManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.DesignUtils;
import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
//TODO: august TemplatePane和TemplateTreePane最好合并成一个类
public class TemplatePane extends JPanel implements MouseListener {
private static final long NUM = 1L;
private static int NUM200 = 200;
public static TemplatePane getInstance() {
return HOLDER.singleton;
}
private static class HOLDER {
private static TemplatePane singleton = new TemplatePane();
}
private static final long serialVersionUID = 2108412478281713143L;
public static final int HEIGHT = 23;// 最好和日志的高度统一 用同一个变量
private static javax.swing.Icon leftIcon = BaseUtils.readIcon("/com/fr/design/images/docking/left.png");
private static javax.swing.Icon rightIcon = BaseUtils.readIcon("/com/fr/design/images/docking/right.png");
private boolean isExpanded = false;
private UIButton editButton;
private UILabel envLabel;
private TemplatePane() {
super();
this.initComponents();
this.setFocusable(true);
this.addMouseListener(this);
isExpanded = DesignerEnvManager.getEnvManager().isTemplateTreePaneExpanded();
TemplateTreePane.getInstance().setVisible(isExpanded);
TemplateTreePane.getInstance().setVisible(true);
}
private void initComponents() {
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
public void envChanged() {
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
}
});
this.setLayout(new BorderLayout(25, 0));
editButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/control/control-center2.png")) {
private static final long serialVersionUID = NUM;
@Override
public Point getToolTipLocation(MouseEvent event) {
return new Point(25, 2);
}
};
editButton.setOpaque(false);
editButton.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 10));
editButton.setMargin(null);
editButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
editButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Env_Configure_Workspace"));
this.add(new UILabel(" "), BorderLayout.WEST);
this.add(editButton, BorderLayout.EAST);
editButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
editItems();
}
});
envLabel = new UILabel();
envLabel.setForeground(new Color(102, 102, 102));
setJLabel(DesignerEnvManager.getEnvManager().getCurEnvName());
this.add(envLabel, BorderLayout.CENTER);
}
/**
* 是否可扩展
*
* @return 同上
*/
public boolean IsExpanded() {
return this.isExpanded;
}
public void setExpand(boolean b) {
this.isExpanded = b;
this.repaint();
}
private boolean envListOkAction(EnvListPane envListPane) {
final String selectedName = envListPane.updateEnvManager();
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName);
try {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace == null ? false : selectedEnv.checkValid();
if (!checkValid) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(selectedName);
DesignUtils.refreshDesignerFrame();
}
});
JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (template != null) {
template.refreshToolArea();
}
setJLabel(selectedName);
} catch (AuthException e) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
return false;
} catch (RegistEditionException e) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
TemplateTreePane.getInstance().refreshDockingView();
DesignModelAdapter<?, ?> model = DesignModelAdapter.getCurrentModelAdapter();
if (model != null) {
model.envChanged();
}
return true;
}
import com.fr.design.EnvChangeEntrance;
/**
* 编辑items
* @see EnvChangeEntrance
* @deprecated use {@link EnvChangeEntrance}
*/
public void editItems() {
@Deprecated
public class TemplatePane {
final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(envLabel.getText());
envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
envListOkAction(envListPane);
}
public void doCancel() {
envListDialog.setVisible(false);
}
});
envListDialog.setVisible(true);
public static EnvChangeEntrance getInstance() {
return EnvChangeEntrance.getInstance();
}
private void setJLabel(String name) {
DesignerWorkspaceInfo config = DesignerEnvManager.getEnvManager().getWorkspaceInfo(name);
if (config != null) {
switch (config.getType()) {
case Remote: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/localconnect.png"));
break;
}
case Local: {
envLabel.setIcon(IOUtils.readIcon("com/fr/design/images/data/bind/distanceconnect.png"));
break;
}
}
}
envLabel.setText(name);
envLabel.repaint();
}
@Override
public Dimension getPreferredSize() {
return new Dimension(250, HEIGHT);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
paintBackgroundIcon(g);
}
private void paintBackgroundIcon(Graphics g) {
int w = this.getWidth();
int h = this.getHeight();
Graphics2D g2d = (Graphics2D) g;
Color lightColor = new Color(226, 230, 234);
Color darkColor = new Color(183, 188, 195);
GradientPaint gp = new GradientPaint(1, 1, lightColor, 1, h - 1, darkColor);
g2d.setPaint(gp);
g2d.fillRect(1, 1, w - 2, h - 1);
g2d.setColor(lightColor);
g2d.drawLine(0, 2, 0, h - 1);
g2d.setColor(darkColor);
g2d.drawLine(w - 1, 2, w - 1, h - 1);
Icon icon = !isExpanded ? leftIcon : rightIcon;
icon.paintIcon(this, g2d, 4, 4);
}
/**
* 鼠标点击
*
* @param e 事件
*/
@Override
public void mouseClicked(MouseEvent e) {
}
/**
* 鼠标按下
*
* @param e 事件
*/
@Override
public void mousePressed(MouseEvent e) {
if (e.getX() < NUM200) {
isExpanded = !isExpanded;
TemplateTreePane.getInstance().setVisible(isExpanded);
this.setExpand(isExpanded);
DesignerEnvManager.getEnvManager().setTemplateTreePaneExpanded(isExpanded);
}
}
/**
* 鼠标放开
*
* @param e 事件
*/
@Override
public void mouseReleased(MouseEvent e) {
}
/**
* 鼠标进入
*
* @param e 事件
*/
@Override
public void mouseEntered(MouseEvent e) {
}
/**
* 鼠标离开
*
* @param e 事件
*/
@Override
public void mouseExited(MouseEvent e) {
}
/**
* 处理异常
*/
public void dealEvnExceptionWhenStartDesigner() {
final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(envLabel.getText());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListDialog.addDialogActionListener(new DialogActionAdapter() {
public void doOk() {
if (!envListOkAction(envListPane)) {
System.exit(0);
}
}
public void doCancel() {
System.exit(0);
private TemplatePane() {
}
});
envListDialog.setVisible(true);
}
}

71
designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java

@ -5,20 +5,29 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.ComparatorUtils;
import com.fr.general.log.Log4jConfig;
import com.fr.log.FineLoggerFactory;
import com.fr.third.apache.log4j.Level;
import com.fr.third.apache.log4j.spi.LoggingEvent;
import com.fr.third.apache.log4j.spi.ThrowableInformation;
import javax.swing.*;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultEditorKit;
import javax.swing.text.Document;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
@ -35,31 +44,45 @@ public class DesignerLogHandler {
private static final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
protected static final int INFO_INT = Level.INFO.toInt();
protected static final int ERROR_INT = Level.ERROR.toInt();
protected static final int WARN_INT = Level.WARN.toInt();
protected static final int DEBUG_INT = Level.DEBUG.toInt();
private static final int INFO_INT = Level.INFO.toInt();
private static final int ERROR_INT = Level.ERROR.toInt();
private static final int WARN_INT = Level.WARN.toInt();
private static final int DEBUG_INT = Level.DEBUG.toInt();
private static final int GAP_X = -150;
private static final int INFO_GAP_Y = -60;
private static final int ERRO_GAP_Y = -40;
private static final int SERVER_GAP_Y = -20;
public static DesignerLogHandler getInstance() {
return HOLDER.singleton;
}
private static class HOLDER {
private static DesignerLogHandler singleton = new DesignerLogHandler();
}
// 所有的面板
private LogHandlerBar caption;
private JCheckBoxMenuItem showInfo;
private JCheckBoxMenuItem showError;
private JCheckBoxMenuItem showServer;
private LogHandlerArea logHandlerArea;
public DesignerLogHandler() {
logHandlerArea = new LogHandlerArea();
caption = new LogHandlerBar(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log"));
@ -67,6 +90,7 @@ public class DesignerLogHandler {
@Override
public void actionPerformed(ActionEvent e) {
logHandlerArea.jTextArea.setText("");
caption.clearMessage();
}
@ -75,6 +99,7 @@ public class DesignerLogHandler {
@Override
public void actionPerformed(ActionEvent e) {
logHandlerArea.jTextArea.requestFocus();
logHandlerArea.jTextArea.selectAll();
}
@ -83,6 +108,7 @@ public class DesignerLogHandler {
@Override
public void itemStateChanged(ItemEvent e) {
logHandlerArea.jTextArea.setText("");
caption.clearMessage();
}
@ -97,6 +123,7 @@ public class DesignerLogHandler {
@Override
public void actionPerformed(ActionEvent e) {
JPopupMenu jPopupMenu = new JPopupMenu();
int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt();
@ -118,27 +145,36 @@ public class DesignerLogHandler {
}
public JComponent getLogHandlerArea() {
return logHandlerArea;
}
public JComponent getCaption() {
return caption;
}
public void printRemoteLog(String message, Level level, Date date) {
logHandlerArea.printStackTrace(message, level, date);
}
private class LogHandlerArea extends JPanel {
private static final long serialVersionUID = 8215630927304621660L;
private JTextPane jTextArea;
private JPopupMenu popup;
private UIMenuItem selectAll;
private UIMenuItem copy;
private UIMenuItem clear;
private LogHandlerArea() {
jTextArea = initLogJTextArea();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UIScrollPane js = new UIScrollPane(jTextArea);
@ -169,8 +205,10 @@ public class DesignerLogHandler {
clear.setAccelerator(KeyStroke.getKeyStroke('L', DEFAULT_MODIFIER));
jTextArea.addMouseListener(new MouseAdapter() {
// check for right click
public void mousePressed(MouseEvent event) {
if (event.getButton() == MouseEvent.BUTTON3) {
popup.show(jTextArea, event.getX(), event.getY());
checkEnabled();
@ -180,6 +218,7 @@ public class DesignerLogHandler {
}
private JTextPane initLogJTextArea() {
final JTextPane resultPane = new JTextPane();
InputMap inputMap = resultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction);
@ -187,7 +226,9 @@ public class DesignerLogHandler {
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, DEFAULT_MODIFIER), "clear");
ActionMap actionMap = resultPane.getActionMap();
actionMap.put("clear", new AbstractAction() {
public void actionPerformed(ActionEvent evt) {
resultPane.setText("");
caption.clearMessage();
}
@ -196,6 +237,7 @@ public class DesignerLogHandler {
}
public void printStackTrace(LoggingEvent event) {
int intLevel = event.getLevel().toInt();
Date date = new Date(event.getTimeStamp());
ThrowableInformation information = event.getThrowableInformation();
@ -209,25 +251,25 @@ public class DesignerLogHandler {
}
public void printStackTrace(String message, Level level, Date date) {
int intLevel = level.toInt();
int logLevel = Log4jConfig.getInstance().getRootLevel().toInt();
if (intLevel == INFO_INT && showInfo.isSelected()) {
printMessage(message, intLevel, date);
} else if (intLevel == ERROR_INT && showError.isSelected()) {
printMessage(message, intLevel, date);
} else if (intLevel == WARN_INT && showServer.isSelected()) {
printMessage(message, intLevel, date);
} else if (intLevel == DEBUG_INT && logLevel == DEBUG_INT){
printMessage(message, intLevel, date);
}
}
private void printMessage(String message, int intLevel, Date date) {
printMessage(message, intLevel, date, null);
}
private void printMessage(String msg, int intLevel, Date date, Throwable e) {
this.log(LOG_SIMPLE_DATE_FORMAT.format(date) + "\n", 0);
String message = appendLocaleMark(msg, intLevel);
this.log(message, intLevel);
@ -243,6 +285,7 @@ public class DesignerLogHandler {
}
private void log(String str, int style) {
SimpleAttributeSet attrSet = new SimpleAttributeSet();
if (style == ERROR_INT) {
StyleConstants.setForeground(attrSet, new Color(247, 148, 29));
@ -261,11 +304,12 @@ public class DesignerLogHandler {
try {
doc.insertString(doc.getLength(), str, attrSet);
} catch (BadLocationException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private String appendLocaleMark(String str, int style) {
if (style == ERROR_INT) {
str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n";
} else if (style == WARN_INT) {
@ -277,6 +321,7 @@ public class DesignerLogHandler {
}
private void setMessage(String message, int level) {
LogMessageBar.getInstance().setMessage(message);
if (level == DesignerLogHandler.INFO_INT && showInfo.isSelected()) {
caption.infoAdd();
@ -288,6 +333,7 @@ public class DesignerLogHandler {
}
private void checkEnabled() {
this.selectAll.setEnabled(true);
this.copy.setEnabled(true);
this.clear.setEnabled(true);
@ -307,7 +353,9 @@ public class DesignerLogHandler {
}
ActionListener popupListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.selectAll.getText())) {
LogHandlerArea.this.jTextArea.selectAll();
} else if (ComparatorUtils.equals(evt.getActionCommand(), LogHandlerArea.this.copy.getText())) {
@ -322,6 +370,7 @@ public class DesignerLogHandler {
}
public void printLoggingEvent(LoggingEvent event) {
logHandlerArea.printStackTrace(event);
}
}

6
designer-base/src/main/java/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

@ -132,11 +132,11 @@ public class TemplateInfoCollector<T extends BaseBook> implements Serializable,
}
xmlInputStream.close();
} catch (FileNotFoundException e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
} catch (IOException e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
} catch (XMLStreamException e) {
FRContext.getLogger().error(e.getMessage());
FRContext.getLogger().error(e.getMessage(), e);
}
}

22
designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java

@ -16,7 +16,6 @@ import com.fr.design.actions.community.NeedAction;
import com.fr.design.actions.community.QuestionAction;
import com.fr.design.actions.community.SignAction;
import com.fr.design.actions.community.TechSolutionAction;
import com.fr.design.actions.community.UpAction;
import com.fr.design.actions.community.VideoAction;
import com.fr.design.actions.file.CloseCurrentTemplateAction;
import com.fr.design.actions.file.ExitDesignerAction;
@ -51,7 +50,7 @@ import com.fr.design.menu.SeparatorDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.onlineupdate.actions.SoftwareUpdateAction;
import com.fr.design.remote.action.RemoteDesignAuthorityManagerAction;
import com.fr.design.remote.action.RemoteDesignAuthManagerAction;
import com.fr.design.utils.ThemeUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
@ -426,8 +425,8 @@ public abstract class ToolBarMenuDock {
new PlatformManagerAction()
);
if (shouldShowRemotePermission()) {
menuDef.addShortCut(new RemoteDesignAuthorityManagerAction());
if (shouldShowRemoteAuth()) {
menuDef.addShortCut(new RemoteDesignAuthManagerAction());
}
if (!DesignerMode.isAuthorityEditing()) {
@ -451,7 +450,13 @@ public abstract class ToolBarMenuDock {
return processor == null ? new GlobalTableDataAction() : processor.createServerTDAction();
}
private boolean shouldShowRemotePermission() {
/**
* 判断是否应该展示远程设计权限管理
* 如果当前环境是远程环境并且登录用户为管理员那么应该展示否则不予展示
*
* @return boolean
*/
private boolean shouldShowRemoteAuth() {
return WorkContext.getCurrent() != null && !WorkContext.getCurrent().isLocal() && WorkContext.getCurrent().isRoot();
}
@ -474,9 +479,10 @@ public abstract class ToolBarMenuDock {
shortCuts.add(new TutorialAction());
}
//远程不使用更新升级
// if(WorkContext.getCurrent().isLocal()) {
// shortCuts.add(new SoftwareUpdateAction());
// }
if (WorkContext.getCurrent().isLocal()) {
shortCuts.add(new SoftwareUpdateAction());
}
if (AlphaFineConfigManager.isALPHALicAvailable()) {
shortCuts.add(new AlphaFineAction());
}

68
designer-base/src/main/java/com/fr/design/menu/KeySetUtils.java

@ -5,7 +5,7 @@
package com.fr.design.menu;
import javax.swing.*;
import javax.swing.KeyStroke;
import java.awt.event.KeyEvent;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -20,6 +20,23 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M
public class KeySetUtils {
public static final MenuKeySet NEW_FOLDER = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'I';
}
@Override
public String getMenuName() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_New_Folder");
}
@Override
public KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_I, DEFAULT_MODIFIER);
}
};
public static final MenuKeySet OPEN_TEMPLATE = new MenuKeySet() {
@Override
@ -547,7 +564,9 @@ public class KeySetUtils {
public static final MenuKeySet REPORT_WATERMARK = new MenuKeySet() {
@Override
public char getMnemonic() { return 'M'; }
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
@ -974,14 +993,6 @@ public class KeySetUtils {
};
public static final MenuKeySet INSERT_FLOAT = new MenuKeySet() {
@Override
public char getMnemonic() {
@ -1000,41 +1011,4 @@ public class KeySetUtils {
};
}

4555
designer-base/src/main/java/com/fr/design/onlineupdate/ui/dialog/EncodingDetect.java

File diff suppressed because it is too large Load Diff

21
designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthorityManagerAction.java → designer-base/src/main/java/com/fr/design/remote/action/RemoteDesignAuthManagerAction.java

@ -4,25 +4,25 @@ import com.fr.base.BaseUtils;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.remote.ui.AuthorityManagerPane;
import com.fr.workspace.server.authority.AuthorityOperator;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.authority.AuthorityOperator;
import java.awt.event.ActionEvent;
/**
* @author yaohwu
*/
public class RemoteDesignAuthorityManagerAction extends UpdateAction {
public class RemoteDesignAuthManagerAction extends UpdateAction {
public RemoteDesignAuthorityManagerAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Permission_Manager_normal@1x.png"));
public RemoteDesignAuthManagerAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager"));
this.setSmallIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_Remote_Design_Auth_Manager_normal@1x.png"));
}
@ -49,7 +49,6 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
@Override
public void doOk() {
DesignAuthority[] authorities = managerPane.update();
if (!WorkContext.getCurrent().isLocal()) {
boolean success = false;
@ -58,15 +57,9 @@ public class RemoteDesignAuthorityManagerAction extends UpdateAction {
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
FineLoggerFactory.getLogger().info("update remote design authority: " + success);
FineLoggerFactory.getLogger().debug("update remote design authority: " + success);
}
}
@Override
public void doCancel() {
super.doCancel();
}
});
dialog.setModal(true);
dialog.setVisible(true);

77
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityListControlPane.java

@ -10,6 +10,7 @@ import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.menu.ShortCut;
@ -19,7 +20,6 @@ import com.fr.design.remote.ui.list.AuthorityList;
import com.fr.design.remote.ui.list.AuthorityListCellRenderer;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.report.DesignAuthority;
import com.fr.stable.ArrayUtils;
@ -78,7 +78,7 @@ public class AuthorityListControlPane extends BasicPane {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.authorityCreators = new RemoteDesignAuthorityCreator[]{
new RemoteDesignAuthorityCreator(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"),
Toolkit.i18nText("Fine-Design_Basic_Remote_Design_User"),
BaseUtils.readIcon("com/fr/design/remote/images/icon_Member_normal@1x.png"),
DesignAuthority.class,
AuthorityEditorPane.class)
@ -247,6 +247,34 @@ public class AuthorityListControlPane extends BasicPane {
}
/**
* 添加 RemoteDesignAuthority
*
* @param authorities authority
*/
public void setAuthority(List<DesignAuthority> authorities) {
if (authorities == null || authorities.isEmpty()) {
return;
}
DefaultListModel<DesignAuthority> model = (DefaultListModel<DesignAuthority>) authorityList.getModel();
model.clear();
for (DesignAuthority authority : authorities) {
model.addElement(authority);
}
int size = model.getSize() - 1;
authorityList.setSelectedIndex(size);
authorityList.ensureIndexIsVisible(size);
authorityList.revalidate();
authorityList.repaint();
}
protected DefaultListModel<DesignAuthority> getModel() {
return (DefaultListModel<DesignAuthority>) this.authorityList.getModel();
}
@ -465,12 +493,12 @@ public class AuthorityListControlPane extends BasicPane {
}
/**
* 添加按钮
* 选择按钮
*/
private class AddItemUpdateAction extends UpdateAction {
AddItemUpdateAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Add"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Action_Choose"));
this.setMnemonic('A');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png"));
}
@ -480,29 +508,54 @@ public class AuthorityListControlPane extends BasicPane {
final UserManagerPane userManagerPane = new UserManagerPane();
BasicDialog dialog = userManagerPane.showWindow(SwingUtilities.getWindowAncestor(AuthorityListControlPane.this));
// 刷新用户管理面板展示信息
final DesignAuthority[] authorities = AuthorityListControlPane.this.update();
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
// 获取添加的用户到权限编辑面板
List<RemoteDesignMember> members = userManagerPane.update();
List<DesignAuthority> oldAuthorities = new ArrayList<>();
// 已有的未修改的
for (RemoteDesignMember member : members) {
for (DesignAuthority authority : authorities) {
if (member.getUserId().equals(authority.getUserId())) {
oldAuthorities.add(authority);
}
}
}
// 保留已有且仍选择的,删除不再选择的
setAuthority(oldAuthorities);
// 新增的
for (RemoteDesignMember member : members) {
DesignAuthority authority = new DesignAuthority();
authority.setUsername(member.getUsername());
authority.setUserId(member.getUserId());
authority.setRealName(member.getRealName());
AuthorityListControlPane.this.addAuthority(authority, getModel().getSize());
}
addAuthority(authority, getModel().getSize());
}
@Override
public void doCancel() {
super.doCancel();
}
});
dialog.setModal(true);
dialog.setVisible(true);
List<RemoteDesignMember> members = new ArrayList<>();
for (DesignAuthority authority : authorities) {
RemoteDesignMember m = new RemoteDesignMember();
m.setUsername(authority.getUsername());
m.setUserId(authority.getUserId());
m.setRealName(authority.getRealName());
m.setSelected(true);
members.add(m);
}
userManagerPane.populate(members);
dialog.setModal(true);
dialog.setVisible(true);
}
}
@ -511,7 +564,7 @@ public class AuthorityListControlPane extends BasicPane {
*/
private class RemoveItemAction extends UpdateAction {
RemoveItemAction() {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Action_Remove"));
this.setName(Toolkit.i18nText("Fine-Design_Basic_Action_Remove"));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils
.readIcon(IconPathConstants.TD_REMOVE_ICON_PATH));

4
designer-base/src/main/java/com/fr/design/remote/ui/AuthorityManagerPane.java

@ -1,7 +1,7 @@
package com.fr.design.remote.ui;
import com.fr.design.dialog.BasicPane;
import com.fr.design.i18n.Toolkit;
import com.fr.report.DesignAuthority;
import javax.swing.BorderFactory;
@ -23,7 +23,7 @@ public class AuthorityManagerPane extends BasicPane {
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager");
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Authority_Manager");
}
public void populate(DesignAuthority[] authorities) {

20
designer-base/src/main/java/com/fr/design/remote/ui/UserManagerPane.java

@ -208,10 +208,23 @@ public class UserManagerPane extends BasicPane {
BorderLayout.CENTER);
}
public void populate(List<RemoteDesignMember> addedMembers) {
// 已选信息
resetAddedMembers();
this.addedMembers.addAll(addedMembers);
// 刷新右侧面板
addToAddedMemberList();
// 刷新左侧展示信息
addToMemberList();
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Add_Member");
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Choose_Member");
}
private JPanel createLeftPanel() {
@ -355,7 +368,7 @@ public class UserManagerPane extends BasicPane {
@Override
protected List<RemoteDesignMember> doInBackground() {
addingMembers.clear();
String username = WorkContext.getConnector().currentUser();
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
Collection<RemoteDesignMember> more = WorkContext.getCurrent().get(DecisionOperator.class).getMembers(username, keyword);
pageNum = 1;
@ -382,7 +395,8 @@ public class UserManagerPane extends BasicPane {
final SwingWorker loadMoreWorker = new SwingWorker<List<RemoteDesignMember>, Void>() {
@Override
protected List<RemoteDesignMember> doInBackground() {
String username = WorkContext.getConnector().currentUser();
String username = WorkContext.getCurrent().getConnection().getUserName();
synchronized (addingMembers) {
addingMembers.remove(RemoteDesignMember.DEFAULT_MEMBER);
Collection<RemoteDesignMember> more =

275
designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java

@ -36,26 +36,17 @@ import java.util.Enumeration;
*/
public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange {
private static final int REPORT_PLATEFORM_MANAGE = 0;
private static final int FS_MANAGE = 1;
private static final int LEFT_GAP = -125;
private static boolean isSupportFS = false;
private TreePath treePath = null;
private static ReportAndFSManagePane singleton = new ReportAndFSManagePane();
private static RoleTree roleTree;
// carl:我先屏了,现在半拉子,等客户要了再好好做
// private AddAction addAction = new AddAction();
// private RemoveAction removeAction = new RemoveAction();
private RefreshAction refreshAction = new RefreshAction();
private UIHeadGroup buttonGroup;
private RoleSourceOP op;
protected String[] roleNames = new String[2];
private String roleNames;
public synchronized static ReportAndFSManagePane getInstance() {
singleton.op = new RoleSourceOP();
singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE);
singleton.setDefaultSelectedRole();
return singleton;
@ -99,29 +90,15 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo
}
protected void setTabRoleName(String roleName) {
roleNames[getMode()] = roleTree.getSelectedRoleName();
roleNames = roleTree.getSelectedRoleName();
}
};
roleTree.setEnabled(true);
roleTree.setEditable(false);
// RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField());
// treeCellEditor.addCellEditorListener(treeCellEditor);
// roleTree.setCellEditor(treeCellEditor);
roleTree.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
roleTree.setEditable(false);
// int row = roleTree.getRowForLocation(e.getX(), e.getY());
// TreePath path = roleTree.getPathForLocation(e.getX(), e.getY());
// if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) {
// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance();
// AuthenticationProvider ap = pm.getAuthenticationProvider();
// if (!(ap instanceof DaoAuthenticationProvider)) {
// roleTree.setEditable(true);
// roleTree.startEditingAtPath(path);
// treePath = path;
// }
// }
}
});
}
@ -141,7 +118,7 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo
ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent();
String selectedRole = null;
if (singleton != null) {
selectedRole = roleNames[getMode()];
selectedRole = roleNames;
}
if (selectedRole == null) {
if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) {
@ -190,13 +167,12 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo
public void tabChanged(int index) {
roleTree.setEditable(false);
if (op != null) {
op.setDataMode(getMode());
//判断是否可编辑
refreshDockingView();
}
setDefaultSelectedRole();
if (singleton != null) {
changeAlreadyEditedPaneRole(roleNames[getMode()]);
changeAlreadyEditedPaneRole(roleNames);
}
}
};
@ -204,37 +180,11 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo
buttonGroup.setNeedLeftRightOutLine(false);
}
private int getMode(){
return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE;
}
// /**
// * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑
// */
// public void checkToolButtonsEnabled() {
// if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) {
// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance();
// AuthenticationProvider ap = pm.getAuthenticationProvider();
// PrivilegeFilter pf = pm.getPrivilegeFilter();
// boolean isClickable = !(ap instanceof DaoAuthenticationProvider)
// && pf instanceof AuthorityControlFilter;
// addAction.setEnabled(isClickable);
// removeAction.setEnabled(isClickable);
// } else {
// addAction.setEnabled(false);
// removeAction.setEnabled(false);
// }
//
// }
/**
* 刷新界面
*/
public void refreshDockingView() {
populate(new RoleSourceOP());
// this.checkToolButtonsEnabled();
}
private void populate(RoleSourceOP op) {
@ -276,85 +226,6 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo
}
// private class AddAction extends UpdateAction {
// public AddAction() {
// this.setName(com.fr.design.i18n.Toolkit.i18nText("Add"));
// this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"));
// }
//
// @Override
// public void actionPerformed(ActionEvent e) {
// refreshDockingView();
//
// DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel();
// ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot();
// ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0);
// String newName = com.fr.design.i18n.Toolkit.i18nText("newNode") + (++newIndex);
// parentNode.add(new ExpandMutableTreeNode(newName));
// op.addAction(newName);
// roleTree.updateUI();
//
// try {
// synchronized (AuthorityRoleDAOManager.class) {
// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true);
//
// if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) {
// newName = com.fr.design.i18n.Toolkit.i18nText("newNode") + (++newIndex);
// roleTree.refreshTreeNode();
// expandTree(roleTree, true);
// }
//
// AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true);
//
// AuthorityRoleDAOManager.doEnd(pf);
// }
// } catch (Exception e1) {
// FRContext.getLogger().error(e1.getMessage(), e1);
// }
// }
// }
// private class RemoveAction extends UpdateAction {
//
// public RemoveAction() {
// this.setName(com.fr.design.i18n.Toolkit.i18nText("Remove"));
// this.setSmallIcon(UIConstants.CLEAR_ICON);
// }
//
// @Override
// public void actionPerformed(ActionEvent e) {
//
//
// NameObject selectedNO = roleTree.getSelectedNameObject();
//
// if (selectedNO == null) {
// return;
// }
//
// int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + ":" + selectedNO.getName() + "?",
// com.fr.design.i18n.Toolkit.i18nText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
// if (returnVal == JOptionPane.OK_OPTION) {
// op.removeAction(selectedNO.getName());
//
// try {
// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true);
//
// AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true);
// AuthorityRoleDAOManager.doEnd(pf);
// } catch (Exception e1) {
// FRContext.getLogger().error(e1.getMessage(), e1);
// }
//
// roleTree.refreshTreeNode();
// expandTree(roleTree, true);
// roleTree.updateUI();
// roleTree.requestFocus();
// roleTree.setSelectionRow(roleTree.getRowCount() - 1);
// }
// }
// }
/*
* 刷新ReportletsTree
*/
@ -373,144 +244,6 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo
}
}
// private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener {
//
// private NameObject editingNO;
// private String oldName;
// private String newName;
// private UITextField jTextField;
//
// public RoleTreeCellEditor(final UITextField textField) {
// super(textField);
// this.jTextField = textField;
// this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight()));
// }
//
// @Override
// public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
// editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject();
// oldName = editingNO.getName();
//
// delegate.setValue(oldName);
//
// editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height));
//
// return editorComponent;
// }
//
// @Override
//
// public boolean isCellEditable(EventObject anEvent) {
// NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject();
// return !(no.getName() == com.fr.design.i18n.Toolkit.i18nText("Role"));
// }
//
// @Override
// public Object getCellEditorValue() {
// newName = super.getCellEditorValue().toString();
// editingNO.setName(newName);
// return editingNO;
// }
//
//
// private boolean checkRoleNameNotEmpty() {
// refreshDockingView();
//
// String currentText = delegate.getCellEditorValue().toString();
// boolean isContained = false;
// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false);
// if (pf != null &&
// !ComparatorUtils.equals(oldName, currentText)) {
// try {
// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf);
//
// while (iterator.hasNext()) {
// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next())
// .getValue();
// Authority _authority = authorityAllocation.getAuthority();
// if(ComparatorUtils.equals(_authority.getName(), currentText)){
// isContained = true;
// break;
// }
// }
// } catch (Exception e) {
// }
// }
//
// if (currentText.isEmpty() || isContained) {
// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("RoleName_Can_Not_Be_Null") + "!");
// roleTree.refreshTreeNode();
// expandTree(roleTree, true);
// delegate.setValue(oldName);
// return false;
// }
// return true;
// }
//
// /*
// * 下面两个方法是CellEditorListener的
// */
// @Override
// public void editingCanceled(ChangeEvent e) {
// if (!checkRoleNameNotEmpty()) {
// treePath = null;
// return;
// }
// roleTree.stopEditing();
// if (treePath == null) {
// return;
// }
// changeValue();
// roleTree.refreshTreeNode();
// expandTree(roleTree, true);
// }
//
// @Override
// public void editingStopped(ChangeEvent e) {
// if (!checkRoleNameNotEmpty()) {
// treePath = null;
// return;
// }
// changeValue();
// roleTree.refreshTreeNode();
// expandTree(roleTree, true);
// roleTree.updateUI();
// }
//
// private void changeValue() {
// newName = delegate.getCellEditorValue().toString();
// if (!newName.isEmpty() && newName != oldName) {
// roleTree.setSelectedRoleName(newName);
// op.rename(oldName, newName);
//
// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false);
// if (pf != null) {
// try {
// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf);
//
// while (iterator.hasNext()) {
// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next())
// .getValue();
// Authority _authority = authorityAllocation.getAuthority();
// if (ComparatorUtils.equals(_authority.getName(), oldName)) {
// _authority.setName(newName);
// }
// }
// } catch (Exception e) {
// }
// }
//
// try {
// AuthorityRoleDAOManager.doEnd(pf);
// } catch (Exception e) {
// FRContext.getLogger().error(e.getMessage(), e);
// }
// }
// }
// }
/**
* 展开树
* @param tree

100
designer-base/src/main/java/com/fr/design/roleAuthority/RoleSourceOP.java

File diff suppressed because one or more lines are too long

57
designer-base/src/main/java/com/fr/design/roleAuthority/RoleTree.java

@ -1,23 +1,23 @@
package com.fr.design.roleAuthority;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.itree.checkboxtree.CheckBoxTree;
import com.fr.design.gui.itree.checkboxtree.CheckBoxTreeSelectionModel;
import com.fr.general.NameObject;
import com.fr.design.constants.UIConstants;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree;
import com.fr.design.mainframe.AuthorityPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.start.server.FineEmbedServer;
import javax.swing.SwingUtilities;
import javax.swing.JTree;
import javax.swing.JComponent;
import javax.swing.JTree;
import javax.swing.SwingUtilities;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
@ -54,13 +54,6 @@ public class RoleTree extends UserObjectRefreshJTree<RoleSourceOP> {
this.replaceMouseListener(this, handler, 0);
this.replaceKeyListener(this, handler, 0);
this.addTreeSelectionListener(handler);
// this.removeMouseListener(treeMouseListener);
// this.addTreeSelectionListener(new TreeSelectionListener() {
// public void valueChanged(TreeSelectionEvent e) {
// doWithValueChanged(e);
// }
// });
}
public boolean isCheckBoxVisible(TreePath path) {
@ -68,6 +61,13 @@ public class RoleTree extends UserObjectRefreshJTree<RoleSourceOP> {
}
@Override
protected ExpandMutableTreeNode[] loadChildTreeNodes(ExpandMutableTreeNode selectedTreeNode) {
// 启动平台模块加载角色列表, server内部已经做了启动状态与Workspace判断.
FineEmbedServer.start();
return super.loadChildTreeNodes(selectedTreeNode);
}
/**
* Creates the mouse listener and key listener used by RoleTree.
*
@ -100,26 +100,8 @@ public class RoleTree extends UserObjectRefreshJTree<RoleSourceOP> {
return null;
}
// if (clicksInCheckBox(e, path)) {
return path;
// } else {
// return null;
// }
}
// protected boolean clicksInCheckBox(MouseEvent e, TreePath path) {
// if (!_tree.isCheckBoxVisible(path)) {
// return false;
// } else {
// Rectangle bounds = _tree.getPathBounds(path);
// if (_tree.getComponentOrientation().isLeftToRight()) {
// return e.getX() < bounds.x + _hotspot;
// } else {
// return e.getX() > bounds.x + bounds.width - _hotspot;
// }
// }
// }
}
private TreePath preventToggleEvent(MouseEvent e) {
TreePath pathForMouseEvent = getTreePathForMouseEvent(e);
@ -220,9 +202,6 @@ public class RoleTree extends UserObjectRefreshJTree<RoleSourceOP> {
TreePath tmpTreePath = treePaths[i];
toggleSelection(tmpTreePath);
}
// for (TreePath treePath : treePaths) {
// toggleSelection(treePath);
// }
}
}
@ -366,9 +345,6 @@ public class RoleTree extends UserObjectRefreshJTree<RoleSourceOP> {
for (int i = 0, length = listeners.length; i < length; i++) {
component.removeMouseListener(listeners[i]);
}
// for (MouseListener listener : listeners) {
// component.removeMouseListener(listener);
// }
for (int i = 0; i < listeners.length; i++) {
MouseListener listener = listeners[i];
if (index == i) {
@ -399,9 +375,6 @@ public class RoleTree extends UserObjectRefreshJTree<RoleSourceOP> {
for (int i = 0, length = listeners.length; i < length; i++) {
component.removeKeyListener(listeners[i]);
}
// for (MouseListener listener : listeners) {
// component.removeMouseListener(listener);
// }
for (int i = 0; i < listeners.length; i++) {
KeyListener listener = listeners[i];
if (index == i) {

39
designer-base/src/main/java/com/fr/design/roleAuthority/RolesEditedSourceOP.java

@ -1 +1,38 @@
package com.fr.design.roleAuthority; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Map; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.mainframe.JTemplate; import com.fr.general.NameObject; import com.fr.privilege.PrivilegeEditedRoleProvider; /** * Author : daisy * Date: 13-9-25 * Time: 下午4:57 */ public class RolesEditedSourceOP extends RoleSourceOP { /** * 获取报表平台的角色 */ protected void addReportRoles(Map<String, RoleDataWrapper> report_roles) { RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager")); report_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_M_Server_Platform_Manager"), tdw); } /** * 获取数据决策系统的角色 */ protected void addFSRoles(Map<String, RoleDataWrapper> FS_roles) { RoleDataWrapper tdw = new RoleDataWrapper(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate")); FS_roles.put(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_FS_Name_Duplicate"), tdw); } /** * 生成子节点 * * @return */ @Override public ExpandMutableTreeNode[] load() { Map<String, RoleDataWrapper> report_roles = null; // Map<String, RoleDataWrapper> FS_roles = null; if (this != null) { report_roles = this.init().get(0); // FS_roles = this.init().get(1); } else { report_roles = Collections.emptyMap(); // FS_roles = Collections.emptyMap(); } List<ExpandMutableTreeNode> list = new ArrayList<ExpandMutableTreeNode>(); //所有的角色 List<ExpandMutableTreeNode> reportlist = new ArrayList<ExpandMutableTreeNode>(); //报表平台橘色 // List<ExpandMutableTreeNode> FSlist = new ArrayList<ExpandMutableTreeNode>(); //数据决策系统角色 list.add(initReportRolseNode(report_roles)); addNodeToList(report_roles, reportlist); // list.add(initFSRolseNode(FS_roles)); // addNodeToList(FS_roles, FSlist); return list.toArray(new ExpandMutableTreeNode[list.size()]); } protected ExpandMutableTreeNode initReportRolseNode(Map<String, RoleDataWrapper> report_roles) { ExpandMutableTreeNode templateNode = new ExpandMutableTreeNode(new NameObject(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Roles_Already_Authority_Edited"), 0), true); templateNode.addChildTreeNodes(getNodeArrayFromMap(report_roles)); return templateNode; } protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, RoleDataWrapper> map) { List<ExpandMutableTreeNode> roleList = new ArrayList<ExpandMutableTreeNode>(); Iterator<Map.Entry<String, RoleDataWrapper>> entryIt = map.entrySet().iterator(); while (entryIt.hasNext()) { Map.Entry<String, RoleDataWrapper> entry = entryIt.next(); String name = entry.getKey(); RoleDataWrapper t = entry.getValue(); JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget(); ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet())); for (ExpandMutableTreeNode expandMutableTreeNode : expand) { roleList.add(expandMutableTreeNode); } } return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]); } }
package com.fr.design.roleAuthority;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.mainframe.JTemplate;
import com.fr.privilege.PrivilegeEditedRoleProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Author : daisy
* Date: 13-9-25
* Time: 下午4:57
*/
public class RolesEditedSourceOP extends RoleSourceOP {
protected ExpandMutableTreeNode[] getNodeArrayFromMap(Map<String, RoleDataWrapper> map) {
List<ExpandMutableTreeNode> roleList = new ArrayList<ExpandMutableTreeNode>();
Iterator<Map.Entry<String, RoleDataWrapper>> entryIt = map.entrySet().iterator();
while (entryIt.hasNext()) {
Map.Entry<String, RoleDataWrapper> entry = entryIt.next();
RoleDataWrapper t = entry.getValue();
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
PrivilegeEditedRoleProvider pe = (PrivilegeEditedRoleProvider) jt.getTarget();
ExpandMutableTreeNode[] expand = t.load(Arrays.asList(pe.getAllEditedRoleSet()));
for (ExpandMutableTreeNode expandMutableTreeNode : expand) {
roleList.add(expandMutableTreeNode);
}
}
return roleList.toArray(new ExpandMutableTreeNode[roleList.size()]);
}
}

2
designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java

@ -73,7 +73,7 @@ public class ColorPicker extends JDialog implements ActionListener
try {
Thread.sleep(100); // 等待弹窗关闭
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage());
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
colorPickerPanel.captureScreen();
}

10
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -20,7 +20,7 @@ import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Strings;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
@ -270,7 +270,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
@Override
public void populateBean(RemoteDesignerWorkspaceInfo ob) {
WorkspaceConnection connection = ob.getConnection();
WorkspaceConnectionInfo connection = ob.getConnection();
if (connection != null) {
this.remoteWorkspaceURL = Strings.isNullOrEmpty(connection.getUrl())
? RemoteWorkspaceURL.createDefaultURL()
@ -303,7 +303,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
@Override
public RemoteDesignerWorkspaceInfo updateBean() {
WorkspaceConnection connection = new WorkspaceConnection(
WorkspaceConnectionInfo connection = new WorkspaceConnectionInfo(
this.remoteWorkspaceURL.getURL(),
this.usernameInput.getText(),
new String(this.passwordInput.getPassword()),
@ -518,7 +518,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
WorkspaceConnection connection = remoteEnv.getConnection();
WorkspaceConnectionInfo connection = remoteEnv.getConnection();
DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath());
DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey());
try {
@ -587,7 +587,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
okButton.setEnabled(false);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), Toolkit.i18nText("Fine-Design_Basic_Datasource_Test_Connection"), true);
dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane.this), UIManager.getString("OptionPane.messageDialogTitle"), true);
dialog.setSize(new Dimension(268, 118));
okButton.setEnabled(false);

185
designer-base/src/main/java/com/fr/env/RemoteEnvPane2.java vendored

@ -1,185 +0,0 @@
//package com.fr.env;
//
//import com.fr.design.beans.BasicBeanPane;
//import com.fr.design.border.UITitledBorder;
//import com.fr.design.env.DesignerWorkspaceInfo;
//import com.fr.design.env.DesignerWorkspaceType;
//import com.fr.design.gui.ibutton.UIButton;
//import com.fr.design.gui.ilable.UILabel;
//import com.fr.design.gui.ipasswordfield.UIPassWordField;
//import com.fr.design.gui.itextfield.UIIntNumberField;
//import com.fr.design.gui.itextfield.UITextField;
//import com.fr.design.layout.TableLayout;
//import com.fr.design.layout.TableLayoutHelper;
//import com.fr.design.utils.gui.GUICoreUtils;
//
//import com.fr.workspace.WorkContext;
//import com.fr.workspace.connect.WorkspaceConnection;
//
//import javax.swing.*;
//import javax.swing.border.EmptyBorder;
//import java.awt.*;
//import java.awt.event.ActionEvent;
//import java.awt.event.ActionListener;
//import java.awt.event.WindowAdapter;
//import java.awt.event.WindowEvent;
//
///**
// * 远程环境设置界面,暂时命名为2,待做完功能直接替代掉老的RemoteEnvPane
// */
//public class RemoteEnvPane2 extends BasicBeanPane<DesignerWorkspaceInfo> {
//
// private UITextField urlTextField;
// private UITextField usernameTextField;
// private UIPassWordField passwordTextField;
// private JDialog dialog;
// private UILabel message;
// private UIButton okButton;
// private UIButton cancelButton;
//
// public RemoteEnvPane2() {
// initComponents();
// }
//
// private void initComponents() {
// setLayout(new BorderLayout());
//
// JPanel contentPanel = new JPanel(new BorderLayout());
// add(contentPanel, BorderLayout.CENTER);
//
// contentPanel.setBorder(
// BorderFactory.createCompoundBorder(
// new EmptyBorder(6, 0, 0, 0),
// UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Config")))
// );
//
// double p = TableLayout.PREFERRED;
// double f = TableLayout.FILL;
// double[] rowSize = new double[]{p, p, p, p};
// double[] columnSize = new double[]{p, f};
// UIButton testConnectionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try"));
// urlTextField = new UITextField();
// urlTextField.setPlaceholder("http://192.168.100.200/webroot/decision");
// JPanel valuePane = TableLayoutHelper.createTableLayoutPane(
// new Component[][]{
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Host") + ":", SwingConstants.RIGHT), urlTextField},
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_User") + ":", SwingConstants.RIGHT), usernameTextField = new UITextField()},
// {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Password") + ":", SwingConstants.RIGHT), passwordTextField = new UIPassWordField()},
// {null, GUICoreUtils.createFlowPane(testConnectionButton, FlowLayout.LEFT)}
// },
// rowSize, columnSize
// );
// testConnectionButton.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// tryConnectRemoteEnv();
// }
// });
// contentPanel.add(valuePane, BorderLayout.CENTER);
//
// message = new UILabel();
// okButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("OK"));
// cancelButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Cancel"));
// }
//
// private void tryConnectRemoteEnv() {
// final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() {
//
// @Override
// protected Void doInBackground() throws Exception {
//
// final DesignerWorkspaceInfo remoteEnv = updateBean();
// WorkContext.getConnector().testConnection(remoteEnv.getConnection());
// return null;
// }
//
// @Override
// protected void done() {
// okButton.setEnabled(true);
// try {
// get();
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Successful"));
// } catch (Exception e) {
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Connect_Failed"));
// }
// }
// };
// worker.execute();
// initMessageDialog();
// okButton.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// dialog.dispose();
// }
// });
// cancelButton.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// dialog.dispose();
// worker.cancel(true);
// }
// });
//
// dialog.addWindowListener(new WindowAdapter() {
// public void windowClosed(WindowEvent e) {
// worker.cancel(true);
// }
// });
//
// dialog.setVisible(true);
// dialog.dispose();
// }
//
// private void initMessageDialog() {
// message.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Designer_Basic_Remote_Env_Try") + "...");
// message.setBorder(BorderFactory.createEmptyBorder(8, 5, 0, 0));
// okButton.setEnabled(false);
//
// dialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(RemoteEnvPane2.this), com.fr.design.i18n.Toolkit.i18nText("Datasource-Test_Connection"), true);
//
// dialog.setSize(new Dimension(268, 118));
// okButton.setEnabled(false);
// JPanel jp = new JPanel();
// JPanel upPane = new JPanel();
// JPanel downPane = new JPanel();
// UILabel uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
// upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
// upPane.add(uiLabel);
// upPane.add(message);
// downPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));
// downPane.add(okButton);
// downPane.add(cancelButton);
// jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
// jp.add(upPane);
// jp.add(downPane);
// dialog.add(jp);
// dialog.setResizable(false);
// dialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(RemoteEnvPane2.this));
// }
//
// @Override
// protected String title4PopupWindow() {
// return "RemoteEnv";
// }
//
// @Override
// public void populateBean(DesignerWorkspaceInfo config) {
// if (config == null) {
// return;
// }
// WorkspaceConnection connection = config.getConnection();
// if (connection != null) {
// urlTextField.setText(connection.getUrl());
// usernameTextField.setText(connection.getUserName());
// passwordTextField.setText(connection.getPassword());
// }
// }
//
// @Override
// public DesignerWorkspaceInfo updateBean() {
//
// DesignerWorkspaceInfo config = new DesignerWorkspaceInfo();
// WorkspaceConnection connection = new WorkspaceConnection(urlTextField.getText(), usernameTextField.getText(), passwordTextField.getText());
// config.setConnection(connection);
// config.setType(DesignerWorkspaceType.Remote);
// return config;
// }
//}

167
designer-base/src/main/java/com/fr/env/RemoteEnvUtils.java vendored

@ -1,167 +0,0 @@
//package com.fr.env;
//
//import com.fr.base.EnvException;
//import com.fr.base.FRContext;
//import com.fr.report.DesignAuthority;
//import com.fr.report.util.AuthorityXMLUtils;
//import com.fr.stable.EncodeConstants;
//import com.fr.third.org.apache.commons.io.IOUtils;
//import com.fr.third.org.apache.http.HttpResponse;
//import com.fr.third.org.apache.http.HttpStatus;
//import com.fr.third.org.apache.http.client.ClientProtocolException;
//import com.fr.third.org.apache.http.client.ResponseHandler;
//import com.fr.third.org.apache.http.client.methods.HttpUriRequest;
//import com.fr.third.org.apache.http.client.methods.RequestBuilder;
//import com.fr.third.org.apache.http.entity.ContentType;
//import com.fr.third.org.apache.http.entity.InputStreamEntity;
//import com.fr.third.org.apache.http.impl.client.CloseableHttpClient;
//import com.fr.third.org.apache.http.impl.client.HttpClients;
//
//import java.io.ByteArrayInputStream;
//import java.io.ByteArrayOutputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.URLEncoder;
//import java.util.Map;
//
//public class RemoteEnvUtils {
//
// private RemoteEnvUtils() {
// }
//
// private static ResponseHandler<InputStream> responseHandler = new ResponseHandler<InputStream>() {
// @Override
// public InputStream handleResponse(HttpResponse response) throws IOException {
// int statusCode = response.getStatusLine().getStatusCode();
// if (statusCode != HttpStatus.SC_OK) {
// throw new ClientProtocolException("Method failed: " + response.getStatusLine().toString());
// }
// InputStream in = response.getEntity().getContent();
// if (in == null) {
// return null;
// }
// // 读取并返回
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// IOUtils.copy(in, out);
// return new ByteArrayInputStream(out.toByteArray());
// }
// };
//
// public static InputStream simulateRPCByHttpPost(byte[] bytes, Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.post(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(bytes));
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder
// .setEntity(reqEntity)
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
// public static InputStream simulateRPCByHttpPost(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.post(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
// public static InputStream simulateRPCByHttpGet(Map<String, String> parameters, boolean isSignIn, RemoteEnv env) throws EnvException {
// String path = env.getPath();
// RequestBuilder builder = RequestBuilder.get(path);
//
// InputStream inputStream = null;
//
// for (Map.Entry<String, String> entry : parameters.entrySet()) {
// builder.addParameter(entry.getKey(), entry.getValue());
// }
// if (!isSignIn) {
// builder.addParameter("id", env.getUserID());
// }
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = builder.build();
// inputStream = httpClient.execute(request, responseHandler);
//
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
//
// public static InputStream updateAuthorities(DesignAuthority[] authorities, RemoteEnv env) {
// String path = env.getPath();
// // 远程设计临时用户id
// String userID = env.getUserID();
// InputStream inputStream = null;
//
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
// AuthorityXMLUtils.writeDesignAuthoritiesXML(authorities, outputStream);
// InputStreamEntity reqEntity = new InputStreamEntity(new ByteArrayInputStream(outputStream.toByteArray()), ContentType.TEXT_XML);
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem()) {
// HttpUriRequest request = RequestBuilder.post(path)
// .addParameter("id", userID)
// .addParameter("op", "remote_design_authority")
// .addParameter("cmd", "update_authorities")
// .setEntity(reqEntity)
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
//
// return inputStream;
//
// }
//
// public static InputStream getAuthorities(RemoteEnv env) throws EnvException {
// String path = env.getPath();
// // 远程设计临时用户id
// String userID = env.getUserID();
// InputStream inputStream = null;
//
// try (CloseableHttpClient httpClient = HttpClients.createSystem();) {
// HttpUriRequest request = RequestBuilder.get(path)
// .addParameter("id", userID)
// .addParameter("op", "remote_design_authority")
// .addParameter("cmd", "get_authorities")
// .build();
// inputStream = httpClient.execute(request, responseHandler);
// } catch (IOException e) {
// FRContext.getLogger().error(e.getMessage());
// }
// return inputStream;
// }
//
//
//}

51
designer-base/src/main/java/com/fr/file/FILE.java

@ -1,93 +1,106 @@
package com.fr.file;
import javax.swing.Icon;
import java.io.InputStream;
import java.io.OutputStream;
public interface FILE {
/**
* 后缀
* @return 后缀
* 前缀
*
* @return 前缀
*/
public String prefix();
String prefix();
/**
* 是否是目录
*
* @return 是则返回true
*/
public boolean isDirectory();
boolean isDirectory();
// Name
public String getName();
String getName();
// Icon
public Icon getIcon();
Icon getIcon();
// 当前目录的Path
public String getPath();
String getPath();
public void setPath(String path);
void setPath(String path);
// 取当前目录的上级目录
public FILE getParent();
FILE getParent();
/**
* 列出当前目录下所有的文件及文件夹
*
* @return 文件
*/
public FILE[] listFiles();
FILE[] listFiles();
/**
* 新建一个目录
*
* @param name 名字
* @return 新建目录
*/
public boolean createFolder(String name);
boolean createFolder(String name);
/**
* 新建文件
*
* @return 是否新建成功
* @throws Exception 异常
*/
public boolean mkfile() throws Exception;
boolean mkfile() throws Exception;
/**
* 是否存在
*
* @return 是否存在
*/
public boolean exists();
boolean exists();
/**
* 关闭文件
*
* @throws Exception 异常
*/
public void closeTemplate() throws Exception;
void closeTemplate() throws Exception;
/**
* 作为输入流
*
* @return 输入流
* @throws Exception 异常
*/
public java.io.InputStream asInputStream() throws Exception;
InputStream asInputStream() throws Exception;
/**
* 作为输出流
*
* @return 输出流
* @throws Exception 异常
*/
public java.io.OutputStream asOutputStream() throws Exception;
OutputStream asOutputStream() throws Exception;
public String getEnvFullName();
String getEnvFullName();
/**
* 是否是内存文件
*
* @return 是则返回true
*/
public boolean isMemFile();
boolean isMemFile();
/**
* 是否是环境文件
*
* @return 是则返回true
*/
public boolean isEnvFile();
boolean isEnvFile();
}

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

File diff suppressed because it is too large Load Diff

4
designer-base/src/main/java/com/fr/file/FILEFactory.java

@ -1,6 +1,7 @@
package com.fr.file;
import com.fr.base.FRContext;
import com.fr.design.file.NodeAuthProcessor;
import com.fr.file.filetree.FileNode;
import com.fr.workspace.WorkContext;
@ -45,7 +46,8 @@ public class FILEFactory {
} else if (path.startsWith(MEM_PREFIX)) {
return new MemFILE(path.substring(MEM_PREFIX.length()));
} else if (path.startsWith(ENV_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(ENV_PREFIX.length()), true));
return NodeAuthProcessor.getInstance().
fixFILENodeAuth(new FileNode(path.substring(ENV_PREFIX.length()), true));
} else if (path.startsWith(WEBREPORT_PREFIX)) {
return new FileNodeFILE(new FileNode(path.substring(WEBREPORT_PREFIX.length()), true),
FRContext.getCommonOperator().getWebRootPath());

48
designer-base/src/main/java/com/fr/file/FileFILE.java

@ -4,11 +4,11 @@ import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.gui.itree.filetree.FileComparator;
import com.fr.design.gui.itree.filetree.FileTreeIcon;
import com.fr.general.ComparatorUtils;
import com.fr.web.session.SessionLocalManager;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.web.session.SessionLocalManager;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.filechooser.FileSystemView;
import java.io.File;
import java.io.FileOutputStream;
@ -16,6 +16,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FileFILE implements FILE {
@ -30,9 +32,9 @@ public class FileFILE implements FILE {
}
/**
*
*
*
* @return
* @return
*/
public String prefix() {
return FILEFactory.FILE_PREFIX;
@ -44,7 +46,7 @@ public class FileFILE implements FILE {
* @returns 是则返回true
*/
public boolean isDirectory() {
return file == null ? false : file.isDirectory();
return file != null && file.isDirectory();
}
@Override
@ -118,22 +120,22 @@ public class FileFILE implements FILE {
return new FILE[]{this};
}
File[] file_array = file.listFiles();
if (file_array == null) {
File[] fileArray = file.listFiles();
if (fileArray == null) {
return new FILE[0];
}
java.util.Arrays.sort(file_array, new FileComparator());
Arrays.sort(fileArray, new FileComparator());
java.util.List<FILE> res_list = new ArrayList<FILE>(file_array.length);
List<FILE> resList = new ArrayList<FILE>(fileArray.length);
for (int i = 0; i < file_array.length; i++) {
for (int i = 0; i < fileArray.length; i++) {
// 因为有一些系统文件,比如虚拟内存等,会在listFiles的时候出现,但却not exists
if (file_array[i].exists()) {
res_list.add(new FileFILE(file_array[i]));
if (fileArray[i].exists()) {
resList.add(new FileFILE(fileArray[i]));
}
}
return res_list.toArray(new FILE[res_list.size()]);
return resList.toArray(new FILE[resList.size()]);
}
/**
@ -147,9 +149,7 @@ public class FileFILE implements FILE {
return false;
}
File new_file = new File(StableUtils.pathJoin(new String[]{
file.getAbsolutePath(), name
}));
File new_file = new File(StableUtils.pathJoin(file.getAbsolutePath(), name));
if (new_file.exists()) {
return false;
@ -164,7 +164,7 @@ public class FileFILE implements FILE {
* @return 是否存在
*/
public boolean exists() {
return file == null ? false : file.exists();
return file != null && file.exists();
}
/**
@ -192,14 +192,14 @@ public class FileFILE implements FILE {
* 作为输出流
*
* @return 输出流
* @throws Exception 异常
*/
public OutputStream asOutputStream() throws Exception {
if (file == null || !file.exists()) {
public OutputStream asOutputStream() {
if (file == null) {
return null;
}
java.io.OutputStream out = null;
OutputStream out;
try {
StableUtils.makesureFileExist(file);
out = new FileOutputStream(file);
} catch (Exception e) {
throw SessionLocalManager.createLogPackedException(e);
@ -209,10 +209,8 @@ public class FileFILE implements FILE {
/**
* 关闭文件
*
* @throws Exception 异常
*/
public void closeTemplate() throws Exception {
public void closeTemplate() {
}
@Override
@ -252,6 +250,7 @@ public class FileFILE implements FILE {
/**
* 是否是内存文件
*
* @return 是则返回true
*/
public boolean isMemFile() {
@ -260,6 +259,7 @@ public class FileFILE implements FILE {
/**
* 是否是环境文件
*
* @return 是则返回true
*/
public boolean isEnvFile() {

102
designer-base/src/main/java/com/fr/file/FileNodeFILE.java

@ -3,30 +3,38 @@ package com.fr.file;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.design.file.NodeAuthProcessor;
import com.fr.design.gui.itree.filetree.FileNodeComparator;
import com.fr.design.gui.itree.filetree.FileTreeIcon;
import com.fr.design.i18n.Toolkit;
import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils;
import com.fr.workspace.resource.WorkResourceOutputStream;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.CoreConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.project.ProjectConstants;
import com.fr.workspace.WorkContext;
import com.fr.workspace.resource.WorkResourceTempRenameStream;
import com.fr.workspace.server.lock.TplOperator;
import javax.swing.*;
import javax.swing.Icon;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
public class FileNodeFILE implements FILE {
private FileNode node;
// carl:记录下FILE对应的运行环境,每次创建都设置下当前的运行环境
//记录下FILE对应的运行环境,每次创建都设置下当前的运行环境
private String envPath;
/**
* 是否有全部权限
*/
private boolean hasFullAuth = true;
public FileNodeFILE(FileNodeFILE parent, String name, boolean isDir) {
FileNode fn = parent.node;
@ -39,31 +47,51 @@ public class FileNodeFILE implements FILE {
this.node = new FileNode(StableUtils.pathJoin(parentDir, name), isDir);
this.envPath = WorkContext.getCurrent().getPath();
this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node);
}
public FileNodeFILE(FileNode node) {
public FileNodeFILE(FileNode node) {
this.node = node;
this.envPath = WorkContext.getCurrent().getPath();
this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node);
}
public FileNodeFILE(String envPath) {
public FileNodeFILE(FileNode node, boolean hasFullAuth) {
this(node);
this.hasFullAuth = hasFullAuth;
}
public FileNodeFILE(String envPath) {
this.node = null;
this.envPath = envPath;
}
public FileNodeFILE(FileNode node, String envPath) {
this.node = node;
this.envPath = envPath;
this.hasFullAuth = NodeAuthProcessor.getInstance().fixFileNodeAuth(node);
}
public FileNodeFILE(FileNode node, String envPath, boolean hasFullAuth) {
this(node, envPath);
this.hasFullAuth = hasFullAuth;
}
/**
* @return 是否有完整权限
*/
public boolean hasFullAuth() {
return hasFullAuth;
}
/**
* prefix 后缀
*
*
* @return 返回后缀
* @return
*/
@Override
public String prefix() {
if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) {
@ -85,14 +113,16 @@ public class FileNodeFILE implements FILE {
*
* @return 是则返回true
*/
@Override
public boolean isDirectory() {
return ComparatorUtils.equals(node, null) ? true : node.isDirectory();
return ComparatorUtils.equals(node, null) || node.isDirectory();
}
/**
* @return
*/
@Override
public String getName() {
if (node == null) {
@ -100,7 +130,7 @@ public class FileNodeFILE implements FILE {
}
if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Runtime_Env");
return Toolkit.i18nText("Fine-Design_Basic_Utils_Report_Runtime_Env");
} else {
return node.getName();
}
@ -109,6 +139,7 @@ public class FileNodeFILE implements FILE {
/**
* @return
*/
@Override
public Icon getIcon() {
if (node == null) {
@ -118,6 +149,11 @@ public class FileNodeFILE implements FILE {
if (ComparatorUtils.equals(node.getEnvPath(), ProjectConstants.REPORTLETS_NAME)) {
return BaseUtils.readIcon("/com/fr/base/images/oem/logo.png");
} else {
if (!hasFullAuth) {
return FileTreeIcon.getFolderHalfImageIcon();
}
return FileTreeIcon.getIcon(node);
}
}
@ -125,6 +161,7 @@ public class FileNodeFILE implements FILE {
/**
* @return
*/
@Override
public String getPath() {
if (node == null) {
@ -137,6 +174,7 @@ public class FileNodeFILE implements FILE {
/**
* @param path
*/
@Override
public void setPath(String path) {
node.setEnvPath(path);
@ -145,6 +183,7 @@ public class FileNodeFILE implements FILE {
/**
* @return
*/
@Override
public FILE getParent() {
if (node == null) {
@ -159,33 +198,33 @@ public class FileNodeFILE implements FILE {
*
* @return 文件组
*/
@Override
public FILE[] listFiles() {
if (ComparatorUtils.equals(node, null)) {
node = new FileNode(CoreConstants.SEPARATOR, true);
//return new FILE[0];
}
if (!node.isDirectory()) {
return new FILE[]{this};
}
try {
FileNode[] node_array;
node_array = listFile(node.getEnvPath());
java.util.Arrays.sort(node_array, new FileNodeComparator());
FileNode[] nodeArray;
nodeArray = listFile(node.getEnvPath());
Arrays.sort(nodeArray, new FileNodeComparator());
FILE[] res_array = new FILE[node_array.length];
for (int i = 0; i < node_array.length; i++) {
res_array[i] = new FileNodeFILE(node_array[i], envPath);
}
return res_array;
return fileNodeArray2FILEArray(nodeArray, envPath);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return new FILE[0];
}
}
private FILE[] fileNodeArray2FILEArray(FileNode[] nodeArray, String envPath) {
return NodeAuthProcessor.getInstance().parser2FILEArray(nodeArray, envPath);
}
/**
* 根目录文件地址
*
@ -212,6 +251,7 @@ public class FileNodeFILE implements FILE {
* @param name 文件夹名字
* @return 创建成功返回true
*/
@Override
public boolean createFolder(String name) {
if (ComparatorUtils.equals(node, null) || !node.isDirectory()) {
@ -250,6 +290,7 @@ public class FileNodeFILE implements FILE {
*
* @return 文件存在返回 true
*/
@Override
public boolean exists() {
if (node == null) {
@ -283,6 +324,7 @@ public class FileNodeFILE implements FILE {
*
* @return 成功返回true
*/
@Override
public boolean mkfile() {
if (node == null) {
@ -303,6 +345,7 @@ public class FileNodeFILE implements FILE {
* @return 输入流
* @throws Exception
*/
@Override
public InputStream asInputStream() throws Exception {
if (node == null) {
@ -314,8 +357,14 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return null;
}
InputStream in = new ByteArrayInputStream(WorkContext.getWorkResource().readFully(StableUtils.pathJoin(ProjectConstants.REPORTLETS_NAME, envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1))));
InputStream in = new ByteArrayInputStream(
WorkContext.getCurrent().get(TplOperator.class).readAndLockFile(
StableUtils.pathJoin(
ProjectConstants.REPORTLETS_NAME,
envPath.substring(ProjectConstants.REPORTLETS_NAME.length() + 1)
)
)
);
return envPath.endsWith(".cpt") || envPath.endsWith(".frm")
? XMLEncryptUtils.decodeInputStream(in) : in;
@ -327,6 +376,7 @@ public class FileNodeFILE implements FILE {
* @return 返回输出流
* @throws Exception
*/
@Override
public OutputStream asOutputStream() throws Exception {
if (ComparatorUtils.equals(node, null)) {
@ -338,7 +388,7 @@ public class FileNodeFILE implements FILE {
if (!envPath.startsWith(ProjectConstants.REPORTLETS_NAME)) {
return null;
}
return new WorkResourceOutputStream(envPath);
return new WorkResourceTempRenameStream(envPath);
}
/**
@ -346,6 +396,7 @@ public class FileNodeFILE implements FILE {
*
* @throws Exception
*/
@Override
public void closeTemplate() throws Exception {
if (node == null) {
@ -367,6 +418,7 @@ public class FileNodeFILE implements FILE {
*
* @return
*/
@Override
public String getEnvFullName() {
return this.node.getEnvPath().substring(ProjectConstants.REPORTLETS_NAME.length() + 1);
@ -377,6 +429,7 @@ public class FileNodeFILE implements FILE {
*
* @return 是则返回true
*/
@Override
public boolean isMemFile() {
return false;
@ -387,6 +440,7 @@ public class FileNodeFILE implements FILE {
*
* @return 是则返回true
*/
@Override
public boolean isEnvFile() {
return true;

7
designer-base/src/main/java/com/fr/file/MemFILE.java

@ -1,10 +1,9 @@
package com.fr.file;
import javax.swing.Icon;
import java.io.InputStream;
import java.io.OutputStream;
import javax.swing.Icon;
public class MemFILE implements FILE {
private String name;
@ -103,9 +102,9 @@ public class MemFILE implements FILE {
}
/**
*
*
*
* @return
* @return
*/
public String prefix() {
return FILEFactory.MEM_PREFIX;

12
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -31,6 +31,10 @@ import java.lang.reflect.Method;
* The main class of Report Designer.
*/
public abstract class BaseDesigner extends ToolBarMenuDock {
private static final int PERCENT_TEN = 10;
private static final int PERCENT_SIXTY = 60;
private static final int PERCENT_NINTY= 90;
private static final int PERCENT_COMPLETE= 100;
private static final int LOAD_TREE_MAXNUM = 10;
@ -51,15 +55,15 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
public void show(final String[] args) {
collectUserInformation();
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(10);
DesignerContext.getDesignerFrame().updateProgress(PERCENT_TEN);
showDesignerFrame(args, DesignerContext.getDesignerFrame(), false);
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(60);
DesignerContext.getDesignerFrame().updateProgress(PERCENT_SIXTY);
DesignerContext.getDesignerFrame().refreshEnv();
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(90);
DesignerContext.getDesignerFrame().updateProgress(PERCENT_NINTY);
for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) {
TemplateTreePane.getInstance().getTemplateFileTree().refresh();
}
DesignerContext.getDesignerFrame().getProgressDialog().setProgressValue(100);
DesignerContext.getDesignerFrame().updateProgress(PERCENT_COMPLETE);
}

26
designer-base/src/main/java/com/fr/start/ServerStarter.java

@ -5,10 +5,20 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.utils.BrowseUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralContext;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils;
import com.fr.start.server.FineEmbedServer;
import com.fr.start.server.FineEmbedServerMonitor;
import com.fr.workspace.WorkContext;
import javax.swing.JOptionPane;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ServerStarter {
@ -47,9 +57,23 @@ public class ServerStarter {
*
* @param url 指定路径
*/
public static void browserURLWithLocalEnv(String url) {
public static void browserURLWithLocalEnv(final String url) {
if(!FineEmbedServerMonitor.getInstance().isComplete()){
FineEmbedServerMonitor.getInstance().monitor();
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new Runnable() {
@Override
public void run() {
FineEmbedServer.start();
BrowseUtils.browser(url);
}
});
service.shutdown();
}else{
FineEmbedServer.start();
BrowseUtils.browser(url);
}
}
}

4
designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java

@ -30,11 +30,15 @@ public class FineEmbedServerActivator extends Activator {
public synchronized void start() {
try {
FineEmbedServerMonitor.getInstance().reset();
//初始化tomcat
initTomcat();
tomcat.start();
} catch (LifecycleException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}finally {
FineEmbedServerMonitor.getInstance().setComplete();
}
}

90
designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java

@ -0,0 +1,90 @@
package com.fr.start.server;
import com.fr.design.mainframe.DesignerContext;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* 内置服务器启动监视器
* Created by zack on 2018/8/21.
*/
public class FineEmbedServerMonitor {
private int progress;
private static final int COMPLETE = 100;//启动完成
private static final int STEP = 5;//随便设置一个假的进度条
private static final int STEP_HEARTBEAT = 2000;//2秒更新进度
private static volatile FineEmbedServerMonitor monitor;
private FineEmbedServerMonitor() {
}
static {
EventDispatcher.listen(EmbedServerEvent.AfterStop, new Listener<Null>() {
@Override
public void on(Event event, Null aNull) {
getInstance().reset();
DesignerContext.getDesignerFrame().hideProgressDialog();
}
});
}
public static FineEmbedServerMonitor getInstance() {
if (monitor == null) {
synchronized (FineEmbedServerMonitor.class) {
if (monitor == null) {
monitor = new FineEmbedServerMonitor();
}
}
}
return monitor;
}
public int getProgress() {
if (progress == COMPLETE) {
return progress;
} else {
progress += STEP;
return progress;
}
}
public void setComplete() {
this.progress = COMPLETE;
}
public void reset() {
this.progress = 0;
}
public boolean isComplete() {
return this.progress == COMPLETE;
}
public void monitor() {
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(new Runnable() {
@Override
public void run() {
while (!isComplete()) {
if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) {
DesignerContext.getDesignerFrame().showProgressDialog();
DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server"));
}
DesignerContext.getDesignerFrame().updateProgress(getProgress());
try {
Thread.sleep(STEP_HEARTBEAT);
} catch (InterruptedException ignore) {
}
}
DesignerContext.getDesignerFrame().hideProgressDialog();
}
});
service.shutdown();
}
}

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/bbs.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

After

Width:  |  Height:  |  Size: 272 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/bug.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 560 B

After

Width:  |  Height:  |  Size: 352 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/center.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 B

After

Width:  |  Height:  |  Size: 199 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/demand.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 379 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/help.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 225 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/need.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

After

Width:  |  Height:  |  Size: 326 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/question.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 543 B

After

Width:  |  Height:  |  Size: 600 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/sign.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 388 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/solution.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 407 B

After

Width:  |  Height:  |  Size: 309 B

BIN
designer-base/src/main/resources/com/fr/design/images/bbs/video.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 449 B

BIN
designer-base/src/main/resources/com/fr/design/images/icon_NewFolderIcon_normal.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart-Map.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 473 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Column.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

After

Width:  |  Height:  |  Size: 143 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Comb_Chart.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 381 B

After

Width:  |  Height:  |  Size: 379 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Donut.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

After

Width:  |  Height:  |  Size: 643 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Funnel.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 314 B

After

Width:  |  Height:  |  Size: 314 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gantt.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

After

Width:  |  Height:  |  Size: 156 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Gis.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 800 B

After

Width:  |  Height:  |  Size: 638 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Meter.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 559 B

After

Width:  |  Height:  |  Size: 629 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Pie.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 424 B

After

Width:  |  Height:  |  Size: 576 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Radar.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1002 B

After

Width:  |  Height:  |  Size: 808 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Range_Chart.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 B

After

Width:  |  Height:  |  Size: 188 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-Stock.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 B

After

Width:  |  Height:  |  Size: 172 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/ChartF-XYScatter.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 405 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Chart_BubbleChart.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 581 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/FR-Chart-Bit_Map.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 523 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Area.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 439 B

After

Width:  |  Height:  |  Size: 422 B

BIN
designer-base/src/main/resources/com/fr/design/images/poly/toolbar/Fine-Engine_Chart_New_Bar.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 144 B

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save