diff --git a/designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java b/designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java index 1efa613abc..a3135c15fa 100644 --- a/designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java +++ b/designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java @@ -7,5 +7,12 @@ public interface JSExecutor { String CALLBACK_FUNCTION_NAME = "action"; + JSExecutor DEFAULT = new JSExecutor() { + @Override + public void executor(String newValue) { + // do nothing + } + }; + void executor(String newValue); } diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIExpandDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIExpandDialog.java new file mode 100644 index 0000000000..60ee096c3d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dialog/UIExpandDialog.java @@ -0,0 +1,328 @@ +package com.fr.design.dialog; + +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.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.UIManager; +import java.awt.BorderLayout; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * 可展开对话框 + * + *
+ * UIExpandDialog.Builder() + * .owner(jf) + * .title("title") + * .messageType(UIExpandDialog.WARNING_MESSAGE) + * .message("message text") + * .detail("detail") + * .expand(false) + * .modal(false) + * .dialogActionListener(new DialogActionAdapter(){ + * public void doOk() { + * System.out.println("OK"); + * } + * }).build().setVisible(true); + *+ * + * @author vito + * @version 10.0 + * Created by vito on 2021/5/19 + */ +public class UIExpandDialog extends UIDialog { + public static final int MARGIN = 10; + public static final int TEXT_AREA_ROW = 5; + public static final int GAP = 5; + + public static final int ERROR_MESSAGE = 0; + public static final int INFORMATION_MESSAGE = 1; + public static final int WARNING_MESSAGE = 2; + public static final int QUESTION_MESSAGE = 3; + + public static final String HTML_TAG_1 = ""; + public static final String HTML_TAG_2 = ""; + + private final JPanel foldBar = new JPanel(); + private final JPanel expandableContentPane = new JPanel(); + private final UILabel narrow = new UILabel(); + private final UILabel narrowHit = new UILabel(); + private final UIButton buttonOK; + private final UIButton buttonCancel; + private JLabel msg; + private final UITextArea textArea = new UITextArea(); + + public UIExpandDialog(Frame owner, String title, boolean isModal, + int messageType, String message, String detail, + String okText, String cancelText, boolean isExpand) { + super(owner); + buttonOK = new UIButton(okText); + buttonCancel = new UIButton(cancelText); + setTitle(title); + setModal(isModal); + initComponents(messageType, message, detail, isModal, isExpand, null); + } + + public UIExpandDialog(Builder builder) { + super(builder.owner); + buttonOK = new UIButton(builder.okText); + buttonCancel = new UIButton(builder.cancelText); + setTitle(builder.title); + setModal(builder.modal); + initComponents(builder.messageType, builder.message, builder.detail, + builder.modal, builder.expand, builder.dialogActionListener); + } + + public void initComponents(int messageType, String message, String detail, + boolean isModal, boolean isExpand, DialogActionListener l) { + + setLayout(new BorderLayout(GAP, GAP)); + setResizable(false); + setModal(isModal); + getRootPane().setDefaultButton(buttonOK); + + // 标题面板 + UILabel icon = new UILabel(getIconForType(messageType)); + msg = new JLabel(HTML_TAG_1 + message + HTML_TAG_2); + msg.setPreferredSize(new Dimension(300, 50)); + JPanel mainMsg = new JPanel(); + mainMsg.setLayout(new FlowLayout(FlowLayout.LEFT, MARGIN, MARGIN)); + mainMsg.setPreferredSize(new Dimension(380, 60)); + mainMsg.add(icon); + mainMsg.add(msg); + add(mainMsg, BorderLayout.NORTH); + + // 内容面板 + JPanel contentPanel = new JPanel(); + contentPanel.setLayout(new BorderLayout(GAP, GAP)); + foldBar.setLayout(new FlowLayout(FlowLayout.LEFT, MARGIN, 0)); + foldBar.add(narrow); + foldBar.add(narrowHit); + contentPanel.add(foldBar, BorderLayout.NORTH); + + textArea.setEditable(false); + textArea.setRows(TEXT_AREA_ROW); + textArea.setMargin(new Insets(GAP, GAP, GAP, GAP)); + textArea.setEditable(false); + textArea.setText(detail); + UIScrollPane scrollPane = new UIScrollPane(textArea); + expandableContentPane.setLayout(new BorderLayout()); + expandableContentPane.setBorder(BorderFactory.createEmptyBorder(0, MARGIN, 0, MARGIN)); + expandableContentPane.add(scrollPane, BorderLayout.CENTER); + changeExpand(isExpand); + contentPanel.add(expandableContentPane, BorderLayout.CENTER); + add(contentPanel, BorderLayout.CENTER); + + + // 操作面板 + JPanel actionPanel = new JPanel(); + actionPanel.setLayout(new FlowLayout(FlowLayout.CENTER, MARGIN, MARGIN)); + actionPanel.add(buttonCancel); + actionPanel.add(buttonOK); + add(actionPanel, BorderLayout.SOUTH); + + initListener(); + if (l != null) { + addDialogActionListener(l); + } + pack(); + if (getOwner() != null) { + GUICoreUtils.setWindowCenter(getOwner(), this); + } + + } + + private void changeExpand(boolean isExpand) { + if (isExpand) { + expandableContentPane.setVisible(true); + narrow.setIcon(UIManager.getIcon("OptionPane.narrow.down")); + narrowHit.setText(Toolkit.i18nText("Fine_Designer_Hide_Detail")); + } else { + expandableContentPane.setVisible(false); + narrow.setIcon(UIManager.getIcon("OptionPane.narrow.right")); + narrowHit.setText(Toolkit.i18nText("Fine_Designer_Look_Detail")); + } + } + + private void initListener() { + + foldBar.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + changeExpand(!expandableContentPane.isShowing()); + pack(); + } + + @Override + public void mouseEntered(MouseEvent e) { + foldBar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + + @Override + public void mouseExited(MouseEvent e) { + foldBar.setCursor(Cursor.getDefaultCursor()); + } + }); + buttonOK.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doOK(); + } + }); + + buttonCancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doCancel(); + } + }); + } + + protected Icon getIconForType(int messageType) { + if (messageType < 0 || messageType > 3) + return null; + String propertyName; + switch (messageType) { + case 0: + propertyName = "OptionPane.errorIcon"; + break; + case 1: + default: + propertyName = "OptionPane.informationIcon"; + break; + case 2: + propertyName = "OptionPane.warningIcon"; + break; + case 3: + propertyName = "OptionPane.questionIcon"; + break; + } + return UIManager.getIcon(propertyName); + } + + /** + * 设置对话框主消息 + * + * @param message 消息内容 + */ + public void setMessage(String message) { + msg.setText(HTML_TAG_1 + message + HTML_TAG_2); + } + + /** + * 设置对话框消息详情 + * + * @param detail 消息详情 + */ + public void setDetail(String detail) { + textArea.setText(detail); + } + + /** + * 设置详情面板展开关闭 + * + * @param expand 展开或关闭 + */ + public void setExpand(boolean expand) { + changeExpand(expand); + } + + @Override + public void setVisible(boolean b) { + super.setVisible(b); + } + + public static Builder Builder() { + return new UIExpandDialog.Builder(); + } + + public static final class Builder { + + public int messageType = ERROR_MESSAGE; + public String title; + public String message; + public String detail; + public String okText = Toolkit.i18nText("Fine-Design_Report_OK"); + public String cancelText = Toolkit.i18nText("Fine-Design_Basic_Cancel"); + public boolean modal = true; + public boolean expand = true; + public Frame owner = null; + public DialogActionListener dialogActionListener = null; + + private Builder() { + } + + public UIExpandDialog build() { + return new UIExpandDialog(this); + } + + public Builder owner(Frame owner) { + this.owner = owner; + return this; + } + + public Builder messageType(int messageType) { + this.messageType = messageType; + return this; + } + + public Builder title(String title) { + this.title = title; + return this; + } + + public Builder message(String message) { + this.message = message; + return this; + } + + public Builder detail(String detail) { + this.detail = detail; + return this; + } + + public Builder okText(String okText) { + this.okText = okText; + return this; + } + + public Builder cancelText(String cancelText) { + this.cancelText = cancelText; + return this; + } + + public Builder modal(boolean modal) { + this.modal = modal; + return this; + } + + public Builder expand(boolean expand) { + this.expand = expand; + return this; + } + + public Builder dialogActionListener(DialogActionListener dialogActionListener) { + this.dialogActionListener = dialogActionListener; + return this; + } + } + + @Override + public void checkValid() throws Exception { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 4c94a9f42c..0b1eb33fb9 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.bridge.exec.JSExecutor; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; import com.fr.design.i18n.Toolkit; @@ -17,17 +18,22 @@ import com.fr.plugin.manage.control.PluginTaskResult; * Created by ibm on 2017/5/26. */ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { - protected JSCallback jsCallback; + protected JSCallback jsCallback = new JSCallback(JSExecutor.DEFAULT); + private static int HUNDRED_PERCENT = 100; - public InstallOnlineCallback(PluginTask pluginTask, JSCallback jsCallback){ + public InstallOnlineCallback(PluginTask pluginTask) { + super(pluginTask); + } + + public InstallOnlineCallback(PluginTask pluginTask, JSCallback jsCallback) { super(pluginTask); this.jsCallback = jsCallback; } @Override public void updateProgress(String description, double aProgress) { - jsCallback.execute(String.valueOf(aProgress * HUNDRED_PERCENT + "%")); + jsCallback.execute(aProgress * HUNDRED_PERCENT + "%"); } @@ -37,10 +43,10 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { if (result.isSuccess()) { String switchedInfo = PluginOperateUtils.getSwitchedInfo(result); jsCallback.execute("success"); - String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo; + String successInfo = pluginInfo + Toolkit.i18nText("Fine-Design_Basic_Plugin_Install_Success") + switchedInfo; FineLoggerFactory.getLogger().info(successInfo); FineJOptionPane.showMessageDialog(null, successInfo); - } else if(result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall){ + } else if (result.errorCode() == PluginErrorCode.HasLowerPluginWhenInstall) { int rv = FineJOptionPane.showConfirmDialog( null, Toolkit.i18nText("Fine-Design_Basic_Plugin_Has_Install_Lower"), @@ -51,8 +57,7 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { if (rv == FineJOptionPane.OK_OPTION) { PluginMarker pluginMarker = result.getCurrentTask().getMarker(); PluginOperateUtils.updatePluginOnline(pluginMarker, jsCallback); - } - else { + } else { jsCallback.execute("success"); } } else { @@ -63,5 +68,4 @@ public class InstallOnlineCallback extends AbstractDealPreTaskCallback { } - } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java index 78e338f8c1..434be685db 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java @@ -1,6 +1,7 @@ package com.fr.design.extra.exe.callback; import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.bridge.exec.JSExecutor; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginOperateUtils; import com.fr.design.i18n.Toolkit; @@ -15,14 +16,20 @@ import javax.swing.JOptionPane; /** * Created by ibm on 2017/5/27. */ -public class ModifyStatusCallback implements PluginTaskCallback{ +public class ModifyStatusCallback implements PluginTaskCallback { private boolean isActive; - private JSCallback jsCallback; + private JSCallback jsCallback = new JSCallback(JSExecutor.DEFAULT); + ; - public ModifyStatusCallback (boolean isActive, JSCallback jsCallback){ + public ModifyStatusCallback(boolean isActive) { + this.isActive = isActive; + } + + public ModifyStatusCallback(boolean isActive, JSCallback jsCallback) { this.isActive = isActive; this.jsCallback = jsCallback; } + @Override public void done(PluginTaskResult result) { String pluginInfo = PluginOperateUtils.getSuccessInfo(result); diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index bfe0320c45..9fa676f94e 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -967,7 +967,7 @@ public class MutilTempalteTabPane extends JComponent { //如果在权限编辑情况下,不允许切换到表单类型的工作簿 if (DesignerMode.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()) { DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); - FineJOptionPane.showMessageDialog(MutilTempalteTabPane.this, Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Form_Authority_Edited_Cannot_Be_Supported") + "!", Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); MutilTempalteTabPane.this.repaint(); return; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/ComponentReuseNotifyUtil.java b/designer-base/src/main/java/com/fr/design/mainframe/ComponentReuseNotifyUtil.java index abad05eb19..4ab10194ce 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/ComponentReuseNotifyUtil.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/ComponentReuseNotifyUtil.java @@ -18,7 +18,7 @@ public class ComponentReuseNotifyUtil { } - public static void enterWidgetLibExtraAction() { + public static void enterWidgetLibExtraAction(boolean needValidRead) { if (ComponentReuseNotificationInfo.getInstance().isClickedWidgetLib()) { return; } @@ -28,11 +28,12 @@ public class ComponentReuseNotifyUtil { return COMPONENT_SNAP_CHAT_KEY; } }); - if (snapChat.hasRead()) { + if (snapChat.hasRead() && needValidRead) { DesignerToastMsgUtil.toastPrompt(Toolkit.i18nText("Fine-Design_Component_Reuse_Merge_Prompt")); } ComponentReuseNotificationInfo.getInstance().setClickedWidgetLib(true); DesignerEnvManager.getEnvManager().saveXMLFile(); } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 94d79b2d10..1bffe08428 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -313,7 +313,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - ComponentReuseNotifyUtil.enterWidgetLibExtraAction(); + ComponentReuseNotifyUtil.enterWidgetLibExtraAction(true); } }); // 权限编辑 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 8d526971cb..6c64e1eb60 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1465,10 +1465,8 @@ public abstract class JTemplate