Browse Source

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

feature/10.0
Yuan.Wang 3 years ago
parent
commit
2146d43f03
  1. 92
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 116
      designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java
  3. 12
      designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java
  4. 251
      designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java
  5. 2
      designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java
  6. 15
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  7. 453
      designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java
  8. 4
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptActionPane.java
  9. 14
      designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java
  10. 3
      designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java
  11. 30
      designer-base/src/main/java/com/fr/env/HelpLink.java
  12. 36
      designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java
  13. 48
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  14. 16
      designer-base/src/main/java/com/fr/env/handler/Handler.java
  15. 28
      designer-base/src/main/java/com/fr/env/handler/RefWrapper.java
  16. 90
      designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java
  17. 30
      designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java
  18. 22
      designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java
  19. 52
      designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java
  20. 23
      designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java
  21. 26
      designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java
  22. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties
  23. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties
  24. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties
  25. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties
  26. 3
      designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties
  27. 21
      designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java
  28. 10
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java
  29. 4
      designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java
  30. 7
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  31. 3
      designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java
  32. 65
      designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java
  33. 22
      designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java
  34. 2
      designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java
  35. 948
      designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java
  36. 16
      designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java
  37. 10
      designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java
  38. 13
      designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java
  39. 14
      designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

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

@ -6,7 +6,6 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
@ -21,14 +20,11 @@ import com.fr.design.notification.NotificationCenter;
import com.fr.design.utils.DesignUtils;
import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.EnvListPane;
import com.fr.env.RemoteWorkspaceURL;
import com.fr.env.TestConnectionResult;
import com.fr.env.handler.RemoteDesignExceptionHandler;
import com.fr.exit.DesignerExiter;
import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import com.fr.json.JSONArray;
import com.fr.license.exception.RegistEditionException;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.process.ProcessEventPipe;
@ -46,8 +42,6 @@ import com.fr.workspace.base.WorkspaceAPI;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.base.FineObjectPool;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import com.fr.workspace.engine.exception.WorkspaceConnectionException;
import com.fr.workspace.engine.rpc.WorkspaceProxyPool;
@ -66,7 +60,6 @@ import java.util.List;
import java.util.Set;
import java.util.HashSet;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance {
@ -79,6 +72,8 @@ public class EnvChangeEntrance {
private static EnvChangeEntrance singleton = new EnvChangeEntrance();
}
private BasicDialog dialog;
private EnvChangeEntrance() {
@ -116,13 +111,6 @@ public class EnvChangeEntrance {
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
boolean checkValid = workspace != null && selectedEnv.checkValid();
if (!checkValid) {
strategy.showTip(new PopTip() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
}
@ -149,34 +137,9 @@ public class EnvChangeEntrance {
template.refreshToolArea();
}
pluginErrorRemind();
} catch (WorkspaceAuthException | 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");
strategy.showTip(new PopTip() {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
});
return false;
} catch (WorkspaceCheckException e) {
handleWorkspaceCheckException(e, strategy, connectionInfo);
return false;
} catch (Exception exception) {
if (exception.getCause() instanceof WorkspaceCheckException) {
handleWorkspaceCheckException((WorkspaceCheckException) exception.getCause(), strategy, connectionInfo);
} else {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
// 失败的处理
RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv);
return false;
}
TemplateTreePane.getInstance().refreshDockingView();
@ -188,29 +151,6 @@ public class EnvChangeEntrance {
return true;
}
public void handleWorkspaceCheckException(WorkspaceCheckException e, PopTipStrategy strategy, WorkspaceConnectionInfo info) {
TestConnectionResult result = TestConnectionResult.parseByException(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (ComparatorUtils.equals(result, TestConnectionResult.AUTH_FAILED)) {
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
} else {
if (result.isVerifyResult()) {
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
}
strategy.showTip(() -> FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
result.isVerifyResult()
? new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), info.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH)
: result.getText(),
Toolkit.i18nText("Fine-Design_Basic_Error"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")));
}
}
/**
* 这个功能留着可能会加回来先做注释处理
* 切换远程环境之前进行版本检测当版本不一致的时候提示
@ -440,7 +380,7 @@ public class EnvChangeEntrance {
public void chooseEnv(final String envName) {
final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(DesignerContext.getDesignerFrame());
dialog = envListDialog;
envListPane.populateEnvManager(envName);
envListDialog.addDialogActionListener(new DialogActionAdapter() {
@ -450,13 +390,14 @@ public class EnvChangeEntrance {
// 切换完成后清理密码
updateNotRememberPwdEnv();
if (changeResult) {
VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager());
VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName());
}
}
@Override
public void doCancel() {
envListDialog.dispose();
dialog = null;
// todo 断开了但是没选择新的环境,那么尝试重连旧环境,等接口
}
});
@ -474,6 +415,7 @@ public class EnvChangeEntrance {
final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
dialog = envListDialog;
envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
@ -483,12 +425,13 @@ public class EnvChangeEntrance {
DesignerExiter.getInstance().execute();
} else {
updateNotRememberPwdEnv();
VersionCheckUtils.showVersionCheckDialog(envListPane.updateEnvManager());
VersionCheckUtils.showVersionCheckDialog(envListPane.getSelectedName());
}
}
@Override
public void doCancel() {
dialog = null;
DesignerExiter.getInstance().execute();
}
});
@ -523,6 +466,9 @@ public class EnvChangeEntrance {
return false;
}
public BasicDialog getDialog() {
return dialog;
}
/**
* 提示显示策略
@ -559,14 +505,4 @@ public class EnvChangeEntrance {
interface PopTip {
void show();
}
private static class SuccessPopTip implements PopTip {
@Override
public void show() {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Success"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
FineJOptionPane.INFORMATION_MESSAGE);
}
}
}

116
designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java

@ -6,7 +6,11 @@ import com.fr.design.gui.itable.TableSorter;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
@ -40,27 +44,104 @@ public class CopyableJTable extends SortableJTable {
int commandKeyCode = 157;
//选中单元格的背景色
Color selectBackGround = new Color(54, 133, 242, 63);
Color headerBackGround = new Color(229, 229, 229);
boolean mouseDrag = false;
boolean headerSelect = false;
DefaultTableCellRenderer tableHeaderCellRenderer = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isChoose(row, column)) {
comp.setBackground(selectBackGround);
} else {
comp.setBackground(headerBackGround);
}
return comp;
}
};
public CopyableJTable(TableSorter tableModel) {
super(tableModel);
initListener();
this.getTableHeader().setDefaultRenderer(tableHeaderCellRenderer);
}
private void initListener() {
CopyableJTable self = this;
this.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
if (mouseDrag) {
headerSelect = true;
int column = getColumn(e);
self.updateEndPoint(-1, column);
self.getTableHeader().repaint();
}
}
@Override
public void mouseExited(MouseEvent e) {
if (mouseDrag) {
headerSelect = false;
}
}
@Override
public void mouseClicked(MouseEvent e) {
headerSelect = true;
int column = getColumn(e);
if (column != -1) {
self.clearPoint();
self.addPoint(-1, column);
self.updateStartPoint(-1, column);
self.updateEndPoint(-1, column);
self.refreshTable();
}
}
private int getColumn(MouseEvent e) {
JTableHeader h = (JTableHeader) e.getSource();
TableColumnModel columnModel = h.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
return viewColumn;
}
});
this.getTableHeader().addMouseMotionListener(new MouseAdapter() {
@Override
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
@Override
public void mouseDragged(MouseEvent e) {
self.clearPoint();
self.updateStartPoint(-1, -1);
self.updateEndPoint(-1, -1);
self.refreshTable();
}
});
this.addMouseMotionListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseDragged(MouseEvent evt) {
mouseDrag = true;
int row = self.rowAtPoint(evt.getPoint());
int col = self.columnAtPoint(evt.getPoint());
if (self.updateEndPoint(row, col)) {
self.repaint();
self.refreshTable();
}
}
public void mouseMoved(MouseEvent e) {
mouseDrag = false;
}
});
this.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
headerSelect = false;
int row = self.rowAtPoint(e.getPoint());
int col = self.columnAtPoint(e.getPoint());
if (!self.isControlDown) {
@ -74,7 +155,7 @@ public class CopyableJTable extends SortableJTable {
self.addPoint(row, col);
self.updateEndPoint(row, col);
self.repaint();
self.refreshTable();
}
});
@ -129,6 +210,8 @@ public class CopyableJTable extends SortableJTable {
private boolean updateEndPoint(int row, int col) {
if (headerSelect && row != -1)
return false;
if (endRow != row || endCol != col) {
endRow = row;
endCol = col;
@ -157,13 +240,12 @@ public class CopyableJTable extends SortableJTable {
private void copy() {
FineLoggerFactory.getLogger().info("copy cell value");
java.util.List<java.util.List<Object>> table = new ArrayList<>();
if ((startRow != endRow || startCol != endCol) &&
Math.min(startRow, endRow) > -1 && Math.min(startCol, endCol) > -1) {
if ((startRow != endRow || startCol != endCol) && Math.min(startCol, endCol) > -1) {
for (int i = Math.min(startRow, endRow); i <= Math.max(startRow, endRow); i++) {
table.add(new ArrayList<>());
for (int j = Math.min(startCol, endCol); j <= Math.max(startCol, endCol); j++) {
Object text = this.getValueAt(i, j);
table.get(i - Math.min(startRow, endRow)).add(text);
Object text = this.getTableValue(i, j);
table.get(table.size() - 1).add(text);
}
}
} else if (pointList.size() > 0) {
@ -176,8 +258,8 @@ public class CopyableJTable extends SortableJTable {
table.add(new ArrayList<>());
currentRow++;
}
Object text = this.getValueAt(point.x, point.y);
table.get(currentRow - startRow).add(text);
Object text = this.getTableValue(point.x, point.y);
table.get(table.size() - 1).add(text);
}
}
@ -186,6 +268,24 @@ public class CopyableJTable extends SortableJTable {
clip.setContents(tText, null);
}
private Object getTableValue(int row, int col) {
Object value = null;
if (col > -1) {
if (row > -1) {
value = this.getValueAt(row, col);
} else if (row == -1) {
col = columnModel.getColumn(col).getModelIndex();
value = this.getModel().getColumnName(col);
}
}
return value;
}
private void refreshTable() {
this.repaint();
this.getTableHeader().repaint();
}
private boolean isChoose(int row, int col) {
if (row >= Math.min(startRow, endRow) && row <= Math.max(startRow, endRow)) {
if (col >= Math.min(startCol, endCol) && col <= Math.max(startCol, endCol)) {

12
designer-base/src/main/java/com/fr/design/dialog/NotificationDialog.java

@ -3,6 +3,7 @@ package com.fr.design.dialog;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
@ -10,6 +11,7 @@ import com.fr.design.notification.Notification;
import com.fr.design.notification.NotificationCenter;
import com.fr.module.ModuleContext;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -40,9 +42,17 @@ public class NotificationDialog extends JDialog {
private UILabel messageText;
private NotificationDialogAction notificationDialogAction;
private ScheduledExecutorService TIMER;
private Dimension dialogSize = new Dimension(230, 95);
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action) {
this(owner, title, isModal, messageType, message, action, null);
}
public NotificationDialog(Frame owner, String title, boolean isModal, int messageType, String message, NotificationDialogAction action, Dimension dimension) {
super(owner);
if (dimension != null) {
this.dialogSize = dimension;
}
setTitle(title);
initComponents(StringUtils.EMPTY, messageType, message, isModal, action);
}
@ -77,7 +87,7 @@ public class NotificationDialog extends JDialog {
JScrollPane jScrollPane = new JScrollPane(messageText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPane.setBorder(BorderFactory.createEmptyBorder());
centerPanel.add(jScrollPane, BorderLayout.CENTER);
centerPanel.setPreferredSize(new Dimension(230, 95));
centerPanel.setPreferredSize(dialogSize);
body.add(centerPanel, BorderLayout.CENTER);
//查看详情

251
designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java

@ -0,0 +1,251 @@
package com.fr.design.dialog;
import com.fr.base.GraphHelper;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
/**
* 带链接的错误详情弹窗
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/2
*/
public class UIDetailErrorLinkDialog extends UIDialog {
private static final Color LINK_COLOR = new Color(51, 152, 253);
private static final int GAP_5 = 5;
private static final int GAP_10 = 10;
private static final String TAG_A_START = "<a>";
private static final String TAG_A_END = "</a>";
private static final double SCALE = 1.2;
private final Dimension dimension = new Dimension(300, 180);
public static Builder newBuilder() {
return new Builder();
}
private UIDetailErrorLinkDialog(Frame parent, Builder builder) {
super(parent);
init(builder);
}
private UIDetailErrorLinkDialog(Dialog parent, Builder builder) {
super(parent);
init(builder);
}
private void init(Builder builder) {
this.setTitle(builder.title);
// 顶部 图标和提示
UILabel errorIcon = new UILabel(IOUtils.readIcon("com/fr/design/images/lookandfeel/Information_Icon_Error_32x32.png"));
UILabel errorInfo= new UILabel(builder.reason);
JPanel topPane = new JPanel(new FlowLayout(FlowLayout.LEFT, GAP_10, GAP_5));
topPane.add(errorIcon);
topPane.add(errorInfo);
// 中部 详细内容
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBorder(BorderFactory.createEmptyBorder(0, GAP_5,0,0));
UILabel errorCodeLabel = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Error_Code", builder.errorCode));
UILabel link = new UILabel(Toolkit.i18nText("Fine_Design_Basic_Show_Error_Stack"));
link.setForeground(LINK_COLOR);
link.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
StringWriter stackTraceWriter = new StringWriter();
builder.throwable.printStackTrace(new PrintWriter(stackTraceWriter));
StackPane stackPane = new StackPane(stackTraceWriter.toString());
BasicDialog dialog = stackPane.showLargeWindow(UIDetailErrorLinkDialog.this, null);
dialog.setVisible(true);
}
});
contentPane.add(errorCodeLabel, BorderLayout.NORTH);
contentPane.add(createComponent(builder), BorderLayout.CENTER);
contentPane.add(link, BorderLayout.SOUTH);
// 确定 + 取消
JPanel actionPane = new JPanel(new FlowLayout(FlowLayout.RIGHT, GAP_10, GAP_10));
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Report_OK")));
actionPane.add(createButton(Toolkit.i18nText("Fine-Design_Basic_Cancel")));
this.getContentPane().add(topPane, BorderLayout.NORTH);
this.getContentPane().add(contentPane, BorderLayout.CENTER);
this.getContentPane().add(actionPane, BorderLayout.SOUTH);
this.setSize(dimension);
this.setResizable(false);
this.setModal(true);
GUICoreUtils.centerWindow(this);
}
private UIButton createButton(String content) {
UIButton button = new UIButton(content);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
UIDetailErrorLinkDialog.this.dispose();
}
});
return button;
}
private JComponent createComponent(Builder builder) {
JPanel panel = new JPanel(new BorderLayout());
boolean existDetailReason = StringUtils.isNotEmpty(builder.detailReason);
int maxWidth = dimension.width;
if (existDetailReason) {
String message = Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.detailReason);
UILabel label = new UILabel(message);
maxWidth = Math.max(maxWidth, GraphHelper.getWidth(message, label.getFont()));
panel.add(label, BorderLayout.NORTH);
}
String solution = existDetailReason ? builder.solution : Toolkit.i18nText("Fine_Design_Basic_Detail_Error_Info", builder.solution);
if (builder.solution.contains(TAG_A_START)) {
String[] solutionP1 = solution.split(TAG_A_START);
String[] solutionP2 = solutionP1[1].split(TAG_A_END);
MessageWithLink messageWithLink;
if (solutionP2.length == 2) {
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link, solutionP2[1]);
} else {
messageWithLink = new MessageWithLink(solutionP1[0], solutionP2[0], builder.link);
}
panel.add(messageWithLink, BorderLayout.CENTER);
} else {
UILabel solutionLabel = new UILabel(solution);
panel.add(solutionLabel, BorderLayout.CENTER);
}
dimension.width = getMaxDimensionWidth(maxWidth, solution);
return panel;
}
private int getMaxDimensionWidth(int width, String solution) {
int maxWidth = GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont());
if (maxWidth >= width) {
maxWidth = (int) (SCALE * maxWidth);
} else {
maxWidth = width;
}
return maxWidth;
}
@Override
public void checkValid() throws Exception {
// do nothing
}
class StackPane extends BasicPane {
public StackPane(String stack) {
setLayout(new BorderLayout());
UITextArea textArea = new UITextArea();
textArea.setEditable(false);
textArea.setText(stack);
UIScrollPane scrollPane = new UIScrollPane(textArea);
add(scrollPane);
// 滚动条默认在顶部
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
scrollPane.getViewport().setViewPosition(new Point(0, 0));
}
});
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine_Design_Basic_Error_Stack");
}
}
public static class Builder {
private Window window;
private String title;
private String reason;
private String errorCode;
private String detailReason;
private String solution;
private String link;
private Throwable throwable;
private Builder() {
}
public Builder setTitle(String title) {
this.title = title;
return this;
}
public Builder setReason(String reason) {
this.reason = reason;
return this;
}
public Builder setErrorCode(String errorCode) {
this.errorCode = errorCode;
return this;
}
public Builder setSolution(String solution) {
this.solution = solution;
return this;
}
public Builder setDetailReason(String detailReason) {
this.detailReason = detailReason;
return this;
}
public Builder setThrowable(Throwable throwable) {
this.throwable = throwable;
return this;
}
public Builder setWindow(Window window) {
this.window = window;
return this;
}
public Builder setLink(String link) {
this.link = link;
return this;
}
public UIDetailErrorLinkDialog build() {
if (this.window instanceof Frame) {
return new UIDetailErrorLinkDialog((Frame) window, this);
} else {
return new UIDetailErrorLinkDialog((Dialog) window, this);
}
}
}
}

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

@ -15,5 +15,5 @@ public interface DesignerWorkspaceInfo extends XMLable {
WorkspaceConnectionInfo getConnection();
boolean checkValid();
boolean checkValid() throws Exception;
}

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

@ -168,8 +168,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
@Override
public boolean checkValid() {
boolean result = false;
public boolean checkValid() throws Exception {
String newPort = Integer.toString(DesignerEnvManager.getEnvManager().getEmbedServerPort());
if (!ComparatorUtils.equals(port, newPort)) {
// 使用过程中 更改了内置服务器端口 重新初始化下
@ -177,15 +176,9 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
}
if (FILTER_SET.contains(connection.getUrl())) {
FineLoggerFactory.getLogger().error("url is same with local designer");
return result;
return false;
}
try {
WorkContext.getConnector().validateVT(connection);
result = true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return result;
}
return result;
WorkContext.getConnector().validateVT(connection);
return true;
}
}

453
designer-base/src/main/java/com/fr/design/javascript/ExportJavaScriptPane.java

@ -0,0 +1,453 @@
package com.fr.design.javascript;
import com.fr.base.BaseFormula;
import com.fr.base.Parameter;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.editor.editor.FormulaEditor;
import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itree.filetree.TemplateFileTree;
import com.fr.design.hyperlink.AbstractHyperLinkPane;
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.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.file.filetree.IOFileNodeFilter;
import com.fr.general.GeneralUtils;
import com.fr.js.ExportJavaScript;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
public class ExportJavaScriptPane extends AbstractHyperLinkPane<ExportJavaScript> {
private ExportRadioGroup templateRadioGroup;
private UIRadioButton currentTemplateRadio;
private UIRadioButton otherTemplateRadio;
private UITextField reportPathTextField;
private UIButton browserButton;
private UIComboBox exportTypeComboBox;
private ExportRadioGroup fileNameRadioGroup;
private UIRadioButton defaultNameRadio;
private UIRadioButton customNameRadio;
private FormulaEditor fileNameFormulaEditor;
private UICheckBox extendParametersCheckBox;
private ReportletParameterViewPane parameterViewPane;
private static final double p = TableLayout.PREFERRED;
private static final Map<String, String> EXPORT_TYPES_MAP = new HashMap<>();
private static final String CURRENT_TEMPLATE = "current";
private static final String DEFAULT_FILENAME = "default";
static {
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_PDF, Toolkit.i18nText("Fine-Design_Basic_Export_JS_PDF"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_PAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Page"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SIMPLE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Simple"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_EXCEL_SHEET, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Excel_Sheet"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_WORD, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Word"));
EXPORT_TYPES_MAP.put(ExportJavaScript.EXPORT_IMAGE, Toolkit.i18nText("Fine-Design_Basic_Export_JS_Image"));
}
public ExportJavaScriptPane() {
initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Export_JS_Setting")));
//导出模板+导出方式+导出文件名
JPanel northPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
//导出模板
JPanel chooseTemplatePane = initChooseTemplatePane();
northPane.add(chooseTemplatePane, BorderLayout.NORTH);
//导出方式
JPanel exportTypePane = initExportTypePane();
northPane.add(exportTypePane, BorderLayout.CENTER);
//导出文件名
JPanel fileNamePane = initFileNamePane();
northPane.add(fileNamePane, BorderLayout.SOUTH);
//参数
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel paramsPane = initParamsPane();
centerPane.add(paramsPane);
this.add(northPane, BorderLayout.NORTH);
this.add(centerPane, BorderLayout.CENTER);
}
private JPanel initParamsPane() {
extendParametersCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Extends_Report_Parameters"));
parameterViewPane = new ReportletParameterViewPane(getChartParaType(), getValueEditorPane(), getValueEditorPane());
parameterViewPane.addTableEditorListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) {
List<ParameterProvider> list = parameterViewPane.update();
HashSet<String> tempSet = new HashSet<>();
for (int i = 0; i < list.size(); i++) {
if (StringUtils.isEmpty(list.get(i).getName())) {
continue;
}
if (tempSet.contains(list.get(i).toString())) {
list.remove(i);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!");
return;
}
tempSet.add(list.get(i).toString());
}
}
});
extendParametersCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
parameterViewPane.setVisible(e.getStateChange() == ItemEvent.DESELECTED);
}
});
JPanel paramsPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
paramsPane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), Toolkit.i18nText("Fine-Design_Basic_Parameters")));
paramsPane.add(extendParametersCheckBox, BorderLayout.NORTH);
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
dynamicPaneWrapper.add(parameterViewPane);
paramsPane.add(dynamicPaneWrapper, BorderLayout.CENTER);
return paramsPane;
}
private JPanel initFileNamePane() {
UILabel nameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ":");
fileNameRadioGroup = new ExportRadioGroup();
defaultNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Default"));
defaultNameRadio.setSelected(true);
customNameRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename_Custom"));
addRadioToGroup(fileNameRadioGroup, defaultNameRadio, customNameRadio);
fileNameFormulaEditor = new FormulaEditor(Toolkit.i18nText("Fine-Design_Report_Parameter_Formula"));
fileNameRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (defaultNameRadio.isSelected()) {
fileNameFormulaEditor.setEnabled(false);
} else {
fileNameFormulaEditor.setEnabled(true);
}
}
});
Component[][] components = new Component[][]{{nameLabel, defaultNameRadio, customNameRadio, fileNameFormulaEditor}};
JPanel fileNameRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p, p});
JPanel fileNameTipPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
UILabel fileNameTipLabel = new UILabel("<html><body style=\"color:red\">" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Front") + "\\/:*?\"<>|" + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Title_Tip_Back") + "</html>");
fileNameTipPane.add(fileNameTipLabel);
JPanel fileNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
fileNamePane.add(fileNameRadioPane, BorderLayout.NORTH);
fileNamePane.add(fileNameTipPane, BorderLayout.CENTER);
fileNameTipPane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
fileNamePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return fileNamePane;
}
private JPanel initExportTypePane() {
UILabel typeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Type") + ":");
exportTypeComboBox = new UIComboBox(new DefaultComboBoxModel<String>());
DefaultComboBoxModel<String> comboBoxModel = (DefaultComboBoxModel<String>) exportTypeComboBox.getModel();
String[] allExportTypes = new String[]{ExportJavaScript.EXPORT_PDF, ExportJavaScript.EXPORT_EXCEL_PAGE, ExportJavaScript.EXPORT_EXCEL_SIMPLE, ExportJavaScript.EXPORT_EXCEL_SHEET, ExportJavaScript.EXPORT_WORD, ExportJavaScript.EXPORT_IMAGE};
for (int i = 0; i < allExportTypes.length; i++) {
comboBoxModel.addElement(allExportTypes[i]);
}
this.exportTypeComboBox.setRenderer(new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof String) {
this.setText(EXPORT_TYPES_MAP.get(value));
}
return this;
}
});
Component[][] components = new Component[][]{{typeLabel, exportTypeComboBox}};
JPanel exportTypePane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p});
exportTypePane.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
return exportTypePane;
}
private JPanel initChooseTemplatePane() {
UILabel templateLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template") + ":");
templateRadioGroup = new ExportRadioGroup();
currentTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"));
currentTemplateRadio.setSelected(true);
otherTemplateRadio = new UIRadioButton(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"));
addRadioToGroup(templateRadioGroup, currentTemplateRadio, otherTemplateRadio);
templateRadioGroup.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (currentTemplateRadio.isSelected()) {
reportPathTextField.setEnabled(false);
browserButton.setEnabled(false);
} else {
reportPathTextField.setEnabled(true);
browserButton.setEnabled(true);
}
}
});
Component[][] components = new Component[][]{{templateLabel, currentTemplateRadio, otherTemplateRadio}};
JPanel reportletRadioPane = TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{p, p, p});
JPanel reportletNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 路径输入框
reportPathTextField = new UITextField(20);
reportletNamePane.add(reportPathTextField, BorderLayout.CENTER);
// 选择路径按钮
browserButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Select"));
browserButton.setPreferredSize(new Dimension(browserButton.getPreferredSize().width, 20));
reportletNamePane.add(browserButton, BorderLayout.EAST);
browserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
final ReportletPane reportletPane = new ReportletPane();
reportletPane.setSelectedReportletPath(reportPathTextField.getText());
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(ExportJavaScriptPane.this));
reportletDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
reportPathTextField.setText(reportletPane.getSelectedReportletPath());
}
});
reportletDialog.setVisible(true);
}
});
JPanel chooseTemplatePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
chooseTemplatePane.add(reportletRadioPane, BorderLayout.NORTH);
chooseTemplatePane.add(reportletNamePane, BorderLayout.CENTER);
chooseTemplatePane.setBorder(BorderFactory.createEmptyBorder(0,2,5,2));
return chooseTemplatePane;
}
@Override
public void populateBean(ExportJavaScript ob) {
if (ob == null) {
ob = new ExportJavaScript();
}
this.templateRadioGroup.selectIndexButton(ob.isCurrentTemplate() ? 0 : 1);
if (ob.isCurrentTemplate()) {
this.reportPathTextField.setEnabled(false);
this.browserButton.setEnabled(false);
} else {
this.reportPathTextField.setEnabled(true);
this.browserButton.setEnabled(true);
this.reportPathTextField.setText(ob.getTemplatePath());
}
this.exportTypeComboBox.setSelectedItem(ob.getExportType());
this.fileNameRadioGroup.selectIndexButton(ob.isDefaultFileName() ? 0 : 1);
if (ob.isDefaultFileName()) {
this.fileNameFormulaEditor.setEnabled(false);
} else {
this.fileNameFormulaEditor.setEnabled(true);
this.fileNameFormulaEditor.setValue(BaseFormula.createFormulaBuilder().build(ob.getFileName()));
}
if (ob.isExtendParameters()) {
this.extendParametersCheckBox.setSelected(true);
} else {
this.extendParametersCheckBox.setSelected(false);
List<ParameterProvider> parameterList = this.parameterViewPane.update();
parameterList.clear();
ParameterProvider[] parameters = ob.getParameters();
this.parameterViewPane.populate(parameters);
}
}
@Override
public ExportJavaScript updateBean() {
ExportJavaScript exportJavaScript = new ExportJavaScript();
updateBean(exportJavaScript);
return exportJavaScript;
}
@Override
public void updateBean(ExportJavaScript exportJavaScript) {
exportJavaScript.setCurrentTemplate(this.currentTemplateRadio.isSelected());
exportJavaScript.setTemplatePath(getTemplatePath());
exportJavaScript.setExportType(GeneralUtils.objectToString(this.exportTypeComboBox.getSelectedItem()));
exportJavaScript.setDefaultFileName(this.defaultNameRadio.isSelected());
exportJavaScript.setFileName(getFileName());
exportJavaScript.setExtendParameters(this.extendParametersCheckBox.isSelected());
if (extendParametersCheckBox.isSelected()) {
exportJavaScript.setParameters(null);
} else {
List<ParameterProvider> parameterList = this.parameterViewPane.update();
if (!parameterList.isEmpty()) {
Parameter[] parameters = new Parameter[parameterList.size()];
parameterList.toArray(parameters);
exportJavaScript.setParameters(parameters);
}
}
}
private String getTemplatePath() {
return currentTemplateRadio.isSelected() ? CURRENT_TEMPLATE : reportPathTextField.getText();
}
private String getFileName() {
return defaultNameRadio.isSelected() ? DEFAULT_FILENAME : fileNameFormulaEditor.getUITextField().getText();
}
@Override
public boolean accept(Object ob) {
return ob instanceof ExportJavaScript;
}
@Override
public void reset() {
populateBean(null);
}
@Override
public java.lang.String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
}
private void addRadioToGroup(ButtonGroup buttonGroup, UIRadioButton... radios) {
for (UIRadioButton radio : radios) {
buttonGroup.add(radio);
}
}
class ExportRadioGroup extends ButtonGroup {
private List<UIRadioButton> radioButtons = new ArrayList<>();
@Override
public void add(AbstractButton button) {
super.add(button);
UIRadioButton radioButton = (UIRadioButton) button;
radioButtons.add(radioButton);
}
public void selectIndexButton(int index) {
if (index < 0 || index > radioButtons.size() - 1) {
return;
}
UIRadioButton button = radioButtons.get(index);
button.setSelected(true);
}
public void addActionListener(ActionListener actionListener) {
for (UIRadioButton radioButton : radioButtons) {
radioButton.addActionListener(actionListener);
}
}
}
class ReportletPane extends BasicPane {
private TemplateFileTree templateReportletTree;
private JScrollPane t_panel;
private JPanel cardPane;
public ReportletPane() {
this.setLayout(FRGUIPaneFactory.createM_BorderLayout());
JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(centerPane, BorderLayout.CENTER);
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
centerPane.add(cardPane, BorderLayout.CENTER);
cardPane.setLayout(new CardLayout());
templateReportletTree = new TemplateFileTree();
IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt"});
templateReportletTree.setFileNodeFilter(filter);
cardPane.add(t_panel = new JScrollPane(templateReportletTree), "TEMPLATE");
this.refreshEnv();
}
/**
* 检查是否符合规范
*
* @throws Exception 抛错
*/
@Override
public void checkValid() throws Exception {
String path = this.getSelectedReportletPath();
if (path == null) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Function_The_Selected_File_Cannot_Be_Null"));
}
}
/**
* 刷新Env
*/
public void refreshEnv() {
this.templateReportletTree.refreshEnv();
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
}
/*
* 返回选中的Reportlet的路径
*/
public String getSelectedReportletPath() {
if (t_panel.isVisible()) {
return templateReportletTree.getSelectedTemplatePath();
}
return null;
}
/*
* 选中某Reportlet
*/
public void setSelectedReportletPath(String reportletPath) {
if (reportletPath == null) {
return;
}
templateReportletTree.setSelectedTemplatePath(reportletPath);
}
}
}

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

@ -47,6 +47,10 @@ public abstract class JavaScriptActionPane extends UIComboBoxPane<JavaScript> {
contentDBManiPane.add(createDBManipulationPane());
paneList.add(new Commit2DBJavaScriptPane(this, contentDBManiPane));
paneList.add(initEmaiPane());
boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
if (workbook) {
paneList.add(new ExportJavaScriptPane());
}
Set<JavaScriptActionProvider> javaScriptActionProviders = ExtraDesignClassManager.getInstance().getArray(JavaScriptActionProvider.XML_TAG);
if (javaScriptActionProviders != null) {
for (JavaScriptActionProvider jsp : javaScriptActionProviders) {

14
designer-base/src/main/java/com/fr/design/mainframe/reuse/ComponentReuseNotificationInfo.java

@ -25,6 +25,8 @@ public class ComponentReuseNotificationInfo implements XMLable {
private long lastGuidePopUpTime = 0;
private String historyCreatedReuses = "[]";
public long getLastNotifyTime() {
return lastNotifyTime;
}
@ -62,12 +64,21 @@ public class ComponentReuseNotificationInfo implements XMLable {
DesignerEnvManager.getEnvManager().saveXMLFile();
}
public String getHistoryCreatedReuses() {
return historyCreatedReuses;
}
public void setHistoryCreatedReuses(String historyCreatedReuses) {
this.historyCreatedReuses = historyCreatedReuses;
}
@Override
public void readXML(XMLableReader reader) {
this.setLastNotifyTime(reader.getAttrAsLong("lastNotifyTime", 0L));
this.setNotifiedNumber(reader.getAttrAsInt("notifiedNumber", 0));
this.setClickedWidgetLib(reader.getAttrAsBoolean("clickedWidgetLib", false));
this.setLastGuidePopUpTime(reader.getAttrAsLong("lastGuidePopUpTime", 0L));
this.setHistoryCreatedReuses(reader.getAttrAsString("historyCreatedReuses", "[]"));
}
@Override
@ -76,7 +87,8 @@ public class ComponentReuseNotificationInfo implements XMLable {
writer.attr("lastNotifyTime", this.lastNotifyTime)
.attr("notifiedNumber", this.notifiedNumber)
.attr("clickedWidgetLib", this.clickedWidgetLib)
.attr("lastGuidePopUpTime", this.lastGuidePopUpTime);
.attr("lastGuidePopUpTime", this.lastGuidePopUpTime)
.attr("historyCreatedReuses", this.historyCreatedReuses);;
writer.end();
}

3
designer-base/src/main/java/com/fr/design/versioncheck/VersionCheckUtils.java

@ -7,6 +7,7 @@ import com.fr.design.dialog.NotificationDialogAction;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteWorkspace;
import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.env.CheckServiceDialog;
@ -107,7 +108,7 @@ public class VersionCheckUtils {
CheckServiceDialog checkServiceDialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), GeneralUtils.readFullBuildNO(), getRemoteBranch(envName), getNoExistServiceDescription(envName));
checkServiceDialog.setVisible(true);
}
});
},DesignSizeI18nManager.getInstance().i18nDimension("com.fr.design.version.check.dialog"));
notificationDialog.setVisible(true);
}

30
designer-base/src/main/java/com/fr/env/HelpLink.java vendored

@ -0,0 +1,30 @@
package com.fr.env;
import com.fr.general.locale.LocaleCenter;
import com.fr.general.locale.LocaleMark;
import com.fr.locale.InterProviderFactory;
import com.fr.stable.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 错误提示中的跳转链接管理
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/9
*/
public class HelpLink {
public static String getLink(String solution) {
Map<String, String> map = new HashMap<>();
LocaleMark<String> linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class);
String link = linkMark.getValue();
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), StringUtils.EMPTY);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Cert_Error_Solution"), link);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Connection_Unknown_Error_Solution"), link);
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_NetWork_Connection_Error_Solution"), link);
return map.get(solution);
}
}

36
designer-base/src/main/java/com/fr/env/RemoteDesignLocaleMark.java vendored

@ -0,0 +1,36 @@
package com.fr.env;
import com.fr.general.CloudCenter;
import com.fr.general.GeneralContext;
import com.fr.general.locale.LocaleMark;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/9
*/
public class RemoteDesignLocaleMark implements LocaleMark<String> {
private Map<Locale, String> map = new HashMap<>();
private static final String REMOTE_DESIGN_CN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.zh_CN", "https://help.fanruan.com/finereport/doc-view-3925.html");
private static final String REMOTE_DESIGN_EN = CloudCenter.getInstance().acquireUrlByKind("help.remote.design.en_US", "https://help.fanruan.com/finereport-en/doc-view-3862.html");
public RemoteDesignLocaleMark() {
map.put(Locale.CHINA, REMOTE_DESIGN_CN);
map.put(Locale.KOREA, REMOTE_DESIGN_EN);
map.put(Locale.JAPAN, REMOTE_DESIGN_EN);
map.put(Locale.US, REMOTE_DESIGN_EN);
map.put(Locale.TAIWAN, REMOTE_DESIGN_CN);
}
@Override
public String getValue() {
String result = map.get(GeneralContext.getLocale());
return result == null ? REMOTE_DESIGN_CN : result;
}
}

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

@ -4,8 +4,6 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.fun.DesignerEnvProcessor;
import com.fr.design.gui.ibutton.UIButton;
@ -22,17 +20,12 @@ import com.fr.design.i18n.DesignSizeI18nManager;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.env.handler.RemoteDesignExceptionHandler;
import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Strings;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
@ -66,9 +59,7 @@ import java.io.File;
import static com.fr.design.layout.TableLayout.FILL;
import static com.fr.design.layout.TableLayout.PREFERRED;
import static com.fr.env.TestConnectionResult.AUTH_FAILED;
import static com.fr.third.guava.base.Optional.fromNullable;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
/**
* @author yaohwu
@ -573,8 +564,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
fileChooserButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().
fileSelectionMode(FileSelectionMode.FILE).build();
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder().fileSelectionMode(FileSelectionMode.FILE).build();
int saveValue = fileChooserProvider.showDialog(SwingUtilities.getWindowAncestor(RemoteEnvPane.this));
if (saveValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = fileChooserProvider.getSelectedFile();
@ -589,42 +579,24 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<TestConnectionResult, Void> worker = new SwingWorker<TestConnectionResult, Void>() {
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override
protected TestConnectionResult doInBackground() throws Exception {
try {
return TestConnectionResult.parse(WorkContext.getConnector().testConnection(connection), connection);
} catch (WorkspaceAuthException ignored) {
return AUTH_FAILED;
} catch (RegistEditionException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
throw e;
} catch (WorkspaceCheckException e) {
return TestConnectionResult.parseByException(e);
}
protected Boolean doInBackground() throws Exception {
return WorkContext.getConnector().testConnection(connection);
}
@Override
protected void done() {
okButton.setEnabled(true);
try {
TestConnectionResult result = get();
if (result.isVerifyResult()) {
dialog.dispose();
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
FineJOptionPane.showMessageDialog(RemoteEnvPane.this,
new MessageWithLink(result.getText(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"), connection.getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH),
Toolkit.i18nText("Fine-Design_Basic_Dialog_Message_Title"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
if (get()) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
}
message.setText(result.getText());
uiLabel.setIcon(result.getIcon());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
dialog.dispose();
RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv);
}
dialogDownPane.remove(cancelButton);
dialogDownPane.revalidate();

16
designer-base/src/main/java/com/fr/env/handler/Handler.java vendored

@ -0,0 +1,16 @@
package com.fr.env.handler;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public interface Handler<T, R> {
/**
* @param t
* @return 是否需要继续处理
*/
R handle(T t);
}

28
designer-base/src/main/java/com/fr/env/handler/RefWrapper.java vendored

@ -0,0 +1,28 @@
package com.fr.env.handler;
/**
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/11
*/
public class RefWrapper {
private final Throwable throwable;
private final String link;
public RefWrapper(Throwable throwable, String link) {
this.throwable = throwable;
this.link = link;
}
public Throwable getThrowable() {
return throwable;
}
public String getLink() {
return link;
}
}

90
designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java vendored

@ -0,0 +1,90 @@
package com.fr.env.handler;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.i18n.Toolkit;
import com.fr.env.RemoteWorkspaceURL;
import com.fr.env.handler.impl.CancelHandler;
import com.fr.env.handler.impl.CommonHandler;
import com.fr.env.handler.impl.ExecutionHandler;
import com.fr.env.handler.impl.UnexpectedHandler;
import com.fr.log.FineLoggerFactory;
import java.util.ArrayList;
import java.util.List;
import javax.swing.UIManager;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class RemoteDesignExceptionHandler {
private static final RemoteDesignExceptionHandler INSTANCE = new RemoteDesignExceptionHandler();
public static RemoteDesignExceptionHandler getInstance() {
return INSTANCE;
}
private final List<Handler<RefWrapper, ResultWrapper>> testList = new ArrayList<>();
private final List<Handler<RefWrapper, ResultWrapper>> switchList = new ArrayList<>();
private RemoteDesignExceptionHandler() {
// 要保证顺序
testList.add(new CancelHandler());
testList.add(new ExecutionHandler());
testList.add(new UnexpectedHandler());
testList.add(new CommonHandler(false));
switchList.add(new CancelHandler());
switchList.add(new ExecutionHandler());
switchList.add(new UnexpectedHandler());
switchList.add(new CommonHandler(true));
}
public void handle(Throwable e, List<Handler<RefWrapper, ResultWrapper>> list, DesignerWorkspaceInfo workspaceInfo) {
Throwable throwable = e;
ResultWrapper wrapper;
String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH;
for (Handler<RefWrapper, ResultWrapper> handler : list) {
wrapper = handler.handle(new RefWrapper(throwable, link));
throwable = wrapper.getThrowable();
if (!wrapper.isNext()) {
break;
}
}
FineLoggerFactory.getLogger().error(throwable.getMessage(), throwable);
}
public void handleInSwitch(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(EnvChangeEntrance.getInstance().getDialog(),
Toolkit.i18nText("Fine-Design_Basic_Switch_Workspace_Failed"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
return;
}
handle(e, switchList, workspaceInfo);
}
public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
if (workspaceInfo == null || workspaceInfo.getType() == DesignerWorkspaceType.Local) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return;
}
handle(e, testList, workspaceInfo);
}
public void handleInTest(Throwable e, DesignerWorkspaceInfo workspaceInfo) {
handle(e, testList, workspaceInfo);
}
}

30
designer-base/src/main/java/com/fr/env/handler/ResultWrapper.java vendored

@ -0,0 +1,30 @@
package com.fr.env.handler;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class ResultWrapper {
private final boolean next;
private final Throwable throwable;
public ResultWrapper(Throwable throwable) {
this(true, throwable);
}
public ResultWrapper(boolean next, Throwable e) {
this.next = next;
this.throwable = e;
}
public boolean isNext() {
return next;
}
public Throwable getThrowable() {
return throwable;
}
}

22
designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java vendored

@ -0,0 +1,22 @@
package com.fr.env.handler.impl;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import java.util.concurrent.CancellationException;
/**
* 取消测试连接时的处理器
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class CancelHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
return new ResultWrapper(!(e instanceof CancellationException), e);
}
}

52
designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java vendored

@ -0,0 +1,52 @@
package com.fr.env.handler.impl;
import com.fr.base.exception.ExceptionDescriptor;
import com.fr.design.EnvChangeEntrance;
import com.fr.design.dialog.UIDetailErrorLinkDialog;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.env.HelpLink;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import com.fr.stable.StringUtils;
import javax.swing.SwingUtilities;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class CommonHandler implements Handler<RefWrapper, ResultWrapper> {
private final boolean onSwitch;
public CommonHandler(boolean onSwitch) {
this.onSwitch = onSwitch;
}
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (e instanceof ExceptionDescriptor) {
ExceptionDescriptor exceptionDescriptor = (ExceptionDescriptor) e;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
String link = HelpLink.getLink(exceptionDescriptor.solution());
UIDetailErrorLinkDialog detailErrorLinkDialog = UIDetailErrorLinkDialog.newBuilder().
setWindow(onSwitch ? DesignerContext.getDesignerFrame() : EnvChangeEntrance.getInstance().getDialog()).
setErrorCode(exceptionDescriptor.errorCode()).
setReason(exceptionDescriptor.reason()).
setSolution(exceptionDescriptor.solution()).
setDetailReason(exceptionDescriptor.detailReason()).
setTitle(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")).
setLink(StringUtils.isEmpty(link) ? wrapper.getLink() : link).
setThrowable(e).build();
detailErrorLinkDialog.setVisible(true);
}
});
}
return new ResultWrapper(e);
}
}

23
designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java vendored

@ -0,0 +1,23 @@
package com.fr.env.handler.impl;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import java.util.concurrent.ExecutionException;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class ExecutionHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (e instanceof ExecutionException) {
return new ResultWrapper(e.getCause());
}
return new ResultWrapper(e);
}
}

26
designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java vendored

@ -0,0 +1,26 @@
package com.fr.env.handler.impl;
import com.fr.base.exception.ExceptionDescriptor;
import com.fr.env.handler.Handler;
import com.fr.env.handler.RefWrapper;
import com.fr.env.handler.ResultWrapper;
import com.fr.workspace.engine.convert.ExceptionConverter;
/**
* 出现预料之外的情况异常处理器
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/5
*/
public class UnexpectedHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
if (!(e instanceof ExceptionDescriptor)) {
return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ;
}
return new ResultWrapper(e);
}
}

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_en.properties

@ -3,4 +3,5 @@ com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=630*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=630*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=630*280
com.fr.design.report.ReportColumnsPane=800*600
com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=490*95

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_ja_JP.properties

@ -2,4 +2,5 @@ com.fr.design.mainframe.check.CheckButton=280*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=610*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=610*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=610*280
com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=430*95

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_ko_KR.properties

@ -2,4 +2,5 @@ com.fr.design.mainframe.check.CheckButton=230*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=490*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=490*35
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=490*280
com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.env.RemoteEnvPane.dialog=458*132
com.fr.design.version.check.dialog=450*95

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh.properties

@ -3,4 +3,5 @@ com.fr.design.mainframe.check.CheckButton=250*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280
com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.design.version.check.dialog=230*95

3
designer-base/src/main/resources/com/fr/design/i18n/dimension_zh_TW.properties

@ -2,4 +2,5 @@ com.fr.design.mainframe.check.CheckButton=250*118
com.fr.design.mainframe.check.CheckFontInfoDialog.collapse=385*185
com.fr.design.mainframe.check.CheckFontInfoDialog.messageWithLink=385*31
com.fr.design.mainframe.check.CheckFontInfoDialog.unfold=385*280
com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.env.RemoteEnvPane.dialog=308*132
com.fr.design.version.check.dialog=230*95

21
designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java vendored

@ -4,7 +4,10 @@ import com.fr.invoke.Reflect;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLReaderHelper;
import com.fr.stable.xml.XMLableReader;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceClient;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.connect.WorkspaceConnector;
import junit.framework.TestCase;
import org.junit.Assert;
@ -18,15 +21,31 @@ import java.io.ByteArrayOutputStream;
*/
public class RemoteDesignerWorkspaceInfoTest extends TestCase {
public void testCheckValid() {
public void testCheckValid() throws Exception {
RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true));
RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true));
WorkspaceConnector connector = WorkContext.getConnector();
WorkspaceConnector workspaceConnector = new WorkspaceConnector() {
@Override
public boolean testConnection(WorkspaceConnectionInfo connection) throws Exception {
return false;
}
@Override
public WorkspaceClient connect(WorkspaceConnectionInfo connection) throws Exception {
return null;
}
};
WorkContext.setConnector(workspaceConnector);
Assert.assertFalse(workspaceInfo0.checkValid());
Assert.assertFalse(workspaceInfo1.checkValid());
Assert.assertFalse(workspaceInfo2.checkValid());
Assert.assertFalse(workspaceInfo3.checkValid());
WorkContext.setConnector(connector);
}
public void testReadXml() {

10
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java

@ -277,11 +277,11 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
*/
public Dimension getPreferredSize() {
if (designTypeButtonGroup.getSelectedIndex() == 0) {
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getBoundY());
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getPreferredMarginY());
} else {
int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getBoundY();
int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getPreferredMarginY();
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width,
extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getBoundY());
extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getPreferredMarginY());
}
}
@ -662,6 +662,10 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
return UPCONTROLPANE_WIDTH;
}
protected int getPreferredMarginY() {
return MARGIN_TOP;
}
/**
*刷新颜色选取器
* @param colorArray 颜色值

4
designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

@ -132,6 +132,10 @@ public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane {
return 10;
}
protected int getPreferredMarginY() {
return 10;
}
protected double getDescriptionWidth() {
double descriptionWidth = super.getDescriptionWidth();
if (valueFillStylePane == null) {

7
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -865,4 +865,11 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public boolean isParentAbsolute() {
return ((XCreator) this.getParent()).acceptType(XWAbsoluteLayout.class);
}
public int getLevel() {
if (this.getParent() == null) {
return 1;
}
return ((XCreator) this.getParent()).getLevel() + 1;
}
}

3
designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java

@ -318,6 +318,8 @@ public class EditingMouseListener extends MouseInputAdapter {
offsetEventPoint(e);
XCreator component = designer.getComponentAt(e);
designer.getSpacingLineDrawer().updateMouseEvent(e, true);
setCoverPaneNotDisplay(component, e, false);
if (processTopLayoutMouseMove(component, e)) {
@ -353,7 +355,6 @@ public class EditingMouseListener extends MouseInputAdapter {
return;
}
designer.getSpacingLineDrawer().updateMouseEvent(e, true);
processChartEditorMouseMove(component, e);
e.translatePoint(oldX - e.getX(), oldY - e.getY());
designer.repaint();

65
designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java

@ -835,6 +835,38 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
return null;
}
/**
* 从root里面查找层级为level的控件
*/
private XCreator xCreatorAt(int x, int y, XCreator root, int level) {
if (root == null || !root.isVisible()) {
return null;
}
x -= root.getX();
y -= root.getY();
if (root instanceof XLayoutContainer) {
XLayoutContainer rootContainer = (XLayoutContainer) root;
int count = rootContainer.getXCreatorCount();
for (int i = 0; i < count; i++) {
XCreator child = rootContainer.getXCreator(i);
XCreator dest = xCreatorAt(x, y, child, level);
if (dest != null && dest.getLevel() == level) {
return dest;
}
}
}
Rectangle rect = ComponentUtils.computeVisibleRect(root);
if (isIntersectArea(x, y, rect)) {
// 判断是否处于交叉区域
return root;
}
return null;
}
/**
* 从已选择的组件中找x,y所在的组件
*/
@ -1095,25 +1127,38 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
* */
@Override
public XCreator getComponentAt(int x, int y) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
if (container == null) {
container = rootComponent;
}
int relativeX = x + (int) (formArea.getHorizontalValue() / scale) - container.getX();
int relativeY = y + (int) (formArea.getVerticalValue() / scale) - container.getY();
XCreator result = xCreatorAt(relativeX, relativeY, container);
XLayoutContainer container = getRootContainer(y);
XCreator result = xCreatorAt(getRelativeScaleX(x) - container.getX(), getRelativeScaleY(y) - container.getY(), container);
return result == null ? getComponentAt(x, y, null) : result;
}
@Nullable
public XCreator getComponentAt(int x, int y, XCreator[] except) {
XLayoutContainer container = getRootContainer(y);
XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, except);
return comp == null ? container : comp;
}
public XCreator getComponentAt(int x, int y, int level) {
XLayoutContainer container = getRootContainer(y);
XCreator comp = xCreatorAt(getRelativeScaleX(x), getRelativeScaleY(y), container, level);
return comp == null ? container : comp;
}
private XLayoutContainer getRootContainer(int y) {
XLayoutContainer container = y < paraHeight - formArea.getVerticalValue() ? paraComponent : rootComponent;
if (container == null) {
container = rootComponent;
}
XCreator comp = xCreatorAt(x + (int)(formArea.getHorizontalValue()/scale), (int)(y + formArea.getVerticalValue()/scale), container,
except);
return comp == null ? container : comp;
return container;
}
private int getRelativeScaleX(int x) {
return x + (int)(formArea.getHorizontalValue() / scale);
}
private int getRelativeScaleY(int y) {
return y + (int)(formArea.getVerticalValue() / scale);
}
public SelectionModel getSelectionModel() {

22
designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

@ -21,7 +21,7 @@ public class FormSpacingLineDrawer {
private static final int MIN_SPACING = 10;
private FormDesigner designer;
private XCreator hoverCreator;
private XCreator hoverCreator = null;
private Rectangle selectedRec;
private boolean isMouseMoveEvent = false;
@ -30,7 +30,10 @@ public class FormSpacingLineDrawer {
}
public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) {
this.hoverCreator = designer.getComponentAt(e);
XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator();
if (creator != null) {
this.hoverCreator = designer.getComponentAt(e.getX(), e.getY(), creator.getLevel());
}
this.isMouseMoveEvent = isMouseMoveEvent;
}
@ -131,14 +134,6 @@ public class FormSpacingLineDrawer {
designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null;
}
private boolean isHoveredRootComponent() {
return designer.isRoot(hoverCreator);
}
private boolean isHoveredForm() {
return hoverCreator.getParent() == null;
}
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) {
return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]);
}
@ -147,12 +142,13 @@ public class FormSpacingLineDrawer {
return isSelectedForm() || isSelectedRootComponent();
}
private boolean isHoveredRootPane() {
return isHoveredForm() || isHoveredRootComponent();
private boolean isSelectedCreatorSameParentWithHoveredCreator() {
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent();
}
private boolean isDrawSpacingLine() {
return !isSelectedRootPane() && !isHoveredRootPane() && isMouseMoveEvent;
return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent;
}
private AbstractFormParallelLine[] getNearestHorizontalSide() {

2
designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormMultiWidgetCardPane.java

@ -32,10 +32,10 @@ public class FormMultiWidgetCardPane extends FormWidgetCardPane {
public FormMultiWidgetCardPane(FormDesigner designer) {
super(designer);
arrangement = new MultiSelectionArrangement(designer);
}
public void initPropertyPane() {
arrangement = new MultiSelectionArrangement(designer);
content.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
content.add(createArrangementLayoutPane(), BorderLayout.CENTER);
}

948
designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java

File diff suppressed because it is too large Load Diff

16
designer-realize/src/main/java/com/fr/design/javascript/ListenerEditPane.java

@ -27,6 +27,7 @@ import java.awt.FlowLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
@ -41,6 +42,7 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
private static final String DBCOMMIT = Toolkit.i18nText("Fine-Design_Basic_JavaScript_Commit_To_Database");
private static final String CUSTOMACTION = Toolkit.i18nText("Fine-Design_Report_Submit_Type_Custom");
private static final String EMAIL = Toolkit.i18nText("Fine-Design_Report_Email_Sent_Email");
private static final String EXPORT = Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event");
private Listener listener;
@ -66,8 +68,12 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
nameText = new UITextField(8);
nameText.setEditable(false);
namePane.add(nameText, BorderLayout.WEST);
final String[] style = {JS, DBCOMMIT, CUSTOMACTION, EMAIL};
styleBox = new UIComboBox(style);
final List<String> style = new ArrayList<>(Arrays.asList(JS, DBCOMMIT, CUSTOMACTION, EMAIL));
boolean workbook = DesignerContext.getDesignerFrame().getSelectedJTemplate().isJWorkBook();
if (workbook) {
style.add(EXPORT);
}
styleBox = new UIComboBox(style.toArray());
namePane.add(styleBox);
namePane = GUICoreUtils.createFlowPane(new Component[]{
new UILabel(" " + Toolkit.i18nText("Fine-Design_Report_Event_Name") + ":"),
@ -95,6 +101,12 @@ public class ListenerEditPane extends BasicBeanPane<Listener> {
// 发送邮件
EmailPane emailPane = new EmailPane();
hyperlinkPane.add(EMAIL, emailPane);
// 导出事件
if (workbook) {
ExportJavaScriptPane exportJavaScriptPane = new ExportJavaScriptPane();
hyperlinkPane.add(EXPORT, exportJavaScriptPane);
cards.add(exportJavaScriptPane);
}
cards.add(javaScriptPane);
cards.add(commit2DBJavaScriptPane);
cards.add(customActionPane);

10
designer-realize/src/main/java/com/fr/design/mainframe/AuthorityToolBarPane.java

@ -185,7 +185,7 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
*/
private void checkToolBarPaneEnable() {
List<ToolBarButton> toolBarButtons = toolBarPane.getToolBarButtons();
boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role"))&& !WorkContext.getCurrent().isRoot();
boolean isnotEnable = ComparatorUtils.equals(title.getText(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Server_Toolbar_Choose_Role")) && !WorkContext.getCurrent().isRoot();
for (ToolBarButton button : toolBarButtons) {
button.setEnabled(!isnotEnable);
}
@ -296,9 +296,15 @@ public class AuthorityToolBarPane<T extends WebContent> extends BasicBeanPane<Re
if (toolBarManager.length == 0) {
return;
}
ToolBar resultToolbar = new ToolBar();
for (int i = 0; i < toolBarManager.length; i++) {
toolBarPane.populateBean(toolBarManager[i].getToolBar());
ToolBar toolBar = toolBarManager[i].getToolBar();
for (int j = 0; j < toolBar.getWidgetSize(); j++) {
Widget widget = toolBar.getWidget(j);
resultToolbar.addWidget(widget);
}
}
toolBarPane.populateBean(resultToolbar);
}

13
designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java

@ -20,6 +20,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.login.DesignerLoginHelper;
import com.fr.design.login.DesignerLoginSource;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo;
import com.fr.design.mainframe.share.constants.ComponentType;
import com.fr.design.mainframe.share.constants.ComponentTypes;
import com.fr.design.mainframe.share.constants.DisplayDevice;
@ -36,6 +37,9 @@ import com.fr.form.share.bean.StyleThemeBean;
import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.form.share.group.DefaultShareGroupManager;
import com.fr.form.share.Group;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.manage.PluginFilter;
import com.fr.plugin.manage.PluginManager;
@ -622,6 +626,15 @@ public class ShareMainPane extends JPanel {
provider.setDesignerVersion(ProductConstants.VERSION);
provider.setVendor(loginLabel.getText());
provider.setFileName(provider.getNameWithID());
provider.setVendorUid(DesignerEnvManager.getEnvManager().getDesignerLoginUid());
provider.setCreateTime(System.currentTimeMillis());
JSONArray historyCreatedReuses = JSONFactory.createJSON(
JSON.ARRAY,
ComponentReuseNotificationInfo.getInstance().getHistoryCreatedReuses()
);
historyCreatedReuses.add(uuid);
ComponentReuseNotificationInfo.getInstance().setHistoryCreatedReuses(historyCreatedReuses.toString());
DesignerEnvManager.getEnvManager().saveXMLFile();
if (upload) {
provider.setSummary(content.getText());

14
designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java

@ -8,9 +8,8 @@ import com.fr.design.editlock.ServerTableDataLockChangeChecker;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.LocalDesignerWorkspaceInfo;
import com.fr.design.i18n.Toolkit;
import com.fr.design.versioncheck.VersionCheckUtils;
import com.fr.env.TestConnectionResult;
import com.fr.env.handler.RemoteDesignExceptionHandler;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
@ -21,7 +20,6 @@ import com.fr.stable.StringUtils;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.engine.exception.WorkspaceCheckException;
import org.jetbrains.annotations.NotNull;
@ -78,15 +76,7 @@ public class DesignerWorkspaceProvider extends Activator {
});
}
} catch (Throwable e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (e.getCause() instanceof WorkspaceCheckException) {
WorkspaceCheckException exception = (WorkspaceCheckException) e.getCause();
// 输出标准详情
TestConnectionResult result = TestConnectionResult.parseByException(exception);
if (result.isVerifyResult()) {
FineLoggerFactory.getLogger().error(result.getText().replaceAll(TestConnectionResult.WRAP, StringUtils.EMPTY) + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Modify_PassWord"));
}
}
RemoteDesignExceptionHandler.getInstance().handleInStart(e, workspaceInfo);
EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner();
}
}

Loading…
Cancel
Save