From f3f07ad21a232f5af88771e8b1c8dd3561973093 Mon Sep 17 00:00:00 2001 From: "Joe.Jiang" Date: Thu, 5 Dec 2019 19:06:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-20516=20=E8=AF=AD=E8=A8=80=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E8=87=B3=E8=8B=B1=E6=96=87=EF=BC=8C=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E5=B1=9E=E6=80=A7=E3=80=81=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=EF=BC=8C=E7=82=B9=E5=87=BB=E5=88=A0=E9=99=A4?= =?UTF-8?q?=EF=BC=8C=E5=AF=B9=E8=AF=9D=E6=A1=86=E7=9A=84=E2=80=9C=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E2=80=9D=E5=92=8C=E2=80=9C=E5=8F=96=E6=B6=88=E2=80=9D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=BA=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/dialog/FineJOptionPane.java | 111 +++++++++++++++++- .../itableeditorpane/UITableModelAdapter.java | 2 +- .../PlotSeries/MapGroupExtensionPane.java | 7 +- .../VanChartCustomPlotSelectPane.java | 3 +- .../designer/creator/XWidgetCreator.java | 3 +- .../cell/editor/DSColumnCellEditor.java | 5 +- .../fr/design/mainframe/SheetNameTabPane.java | 2 +- .../com/fr/design/report/ReportStylePane.java | 5 +- .../java/com/fr/design/style/StylePane.java | 3 +- .../com/fr/design/webattr/ToolBarPane.java | 3 +- .../grid/dnd/ElementCasePaneDropTarget.java | 9 +- .../start/CollectUserInformationDialog.java | 5 +- .../src/main/java/com/fr/start/Designer.java | 3 +- 13 files changed, 139 insertions(+), 22 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java b/designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java index f92f6bc0d..933f2c49b 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/FineJOptionPane.java @@ -1,6 +1,9 @@ package com.fr.design.dialog; +import com.fr.invoke.Reflect; + import javax.swing.Icon; +import javax.swing.JDialog; import javax.swing.JOptionPane; import java.awt.Component; import java.awt.HeadlessException; @@ -35,6 +38,7 @@ public class FineJOptionPane extends JOptionPane { private final static String MESSAGE_DIALOG_TITLE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Message"); private final static String CONFIRM_DIALOG_TITLE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"); + private final static String INPUT_DIALOG_TITLE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"); /** * 使用默认 标题 和 消息类型 的消息提示弹出框 @@ -79,7 +83,7 @@ public class FineJOptionPane extends JOptionPane { } /** - * 完全自定义的消息提示弹出框 + * 自定义的消息提示弹出框 * @param parentComponent 父容器 * @param message 具体的提示消息 * @param title 标题 @@ -159,7 +163,7 @@ public class FineJOptionPane extends JOptionPane { } /** - * 完全自定义的确认弹出框 + * 自定义的确认弹出框 * @param parentComponent 父容器 * @param message 具体的提示消息 * @param title 标题 @@ -178,5 +182,108 @@ public class FineJOptionPane extends JOptionPane { messageType, icon, options, initialValue); } + /** + * 指定消息内容的输入弹出框 + * @param message 消息内容 + * @return + * @throws HeadlessException + */ + public static String showInputDialog(Object message) + throws HeadlessException { + return showInputDialog(null, message); + } + + /** + * 使用默认 标题 和 消息类型 的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息内容 + * @return + * @throws HeadlessException + */ + public static String showInputDialog(Component parentComponent, + Object message) throws HeadlessException { + return showInputDialog(parentComponent, message, INPUT_DIALOG_TITLE, QUESTION_MESSAGE); + } + + /** + * 使用默认 标题、消息类型、Icon 和 选项 的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息类型 + * @param initialSelectionValue 初始选项 + * @return + */ + public static String showInputDialog(Component parentComponent, Object message, + Object initialSelectionValue) { + return (String)showInputDialog(parentComponent, message, + INPUT_DIALOG_TITLE, QUESTION_MESSAGE, null, null, + initialSelectionValue); + } + + /** + * 使用默认 父容器、消息内容 和 初始选项 的输入弹出框 + * @param message 消息内容 + * @param initialSelectionValue 初始选项 + * @return + */ + public static String showInputDialog(Object message, Object initialSelectionValue) { + return showInputDialog(null, message, initialSelectionValue); + } + + /** + * 使用默认 Icon、选项 和 初始选项 的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息内容 + * @param title 标题 + * @param messageType 消息类型 + * @return + * @throws HeadlessException + */ + public static String showInputDialog(Component parentComponent, + Object message, String title, int messageType) + throws HeadlessException { + return (String)showInputDialog(parentComponent, message, title, + messageType, null, null, null); + } + + /** + * 自定义的输入弹出框 + * @param parentComponent 父容器 + * @param message 消息内容 + * @param title 标题 + * @param messageType 消息类型 + * @param icon 图标 + * @param selectionValues 选项 + * @param initialSelectionValue 初始选项 + * @return + * @throws HeadlessException + */ + public static Object showInputDialog(Component parentComponent, + Object message, String title, int messageType, Icon icon, + Object[] selectionValues, Object initialSelectionValue) + throws HeadlessException { + JOptionPane pane = new JOptionPane(message, messageType, + OK_CANCEL_OPTION, icon, + OPTION_OK_CANCEL, null); + + pane.setWantsInput(true); + pane.setSelectionValues(selectionValues); + pane.setInitialSelectionValue(initialSelectionValue); + pane.setComponentOrientation(((parentComponent == null) ? + getRootFrame() : parentComponent).getComponentOrientation()); + + int style = Reflect.on(JOptionPane.class).call("styleFromMessageType", messageType).get(); + JDialog dialog = Reflect.on(pane).call("createDialog", parentComponent, title, style).get(); + + pane.selectInitialValue(); + dialog.show(); + dialog.dispose(); + + Object value = pane.getInputValue(); + + if (value == UNINITIALIZED_VALUE) { + return null; + } + return value; + } } diff --git a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java index 19b53ae14..fc219a30b 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java @@ -208,7 +208,7 @@ public abstract class UITableModelAdapter extends AbstractTabl public void actionPerformed(ActionEvent e) { final int selectedRow = table.getSelectedRow(); if (selectedRow > table.getRowCount() - 1 || selectedRow < 0) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No-Alternatives")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No-Alternatives")); return; } stopCellEditing(); diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index 2148257a4..d6134e0ce 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java @@ -13,6 +13,7 @@ import com.fr.design.constants.UIConstants; 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.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; @@ -327,15 +328,15 @@ public class MapGroupExtensionPane extends BasicPane implements UIObserver { } private void showRenameWaring(String newName){ - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Has_Been_Existed") - + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alert"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Has_Been_Existed") + + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), + String newName = FineJOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java index 133cba525..8f7b9557d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotSelectPane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.custom.component; import com.fr.chart.chartattr.Chart; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; @@ -115,7 +116,7 @@ public class VanChartCustomPlotSelectPane extends BasicBeanPane { customTypeList.get(index).getCheckBox().setSelected(true); //彈出警告框 - JOptionPane.showMessageDialog(new JPanel(), MASSAGE,"", JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(new JPanel(), MASSAGE,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.WARNING_MESSAGE); } //点击后更新已选顺序 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java index 4835ec16b..590aea339 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWidgetCreator.java @@ -4,6 +4,7 @@ package com.fr.design.designer.creator; import com.fr.base.BaseUtils; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.FormDesigner; @@ -183,7 +184,7 @@ public abstract class XWidgetCreator extends XCreator { */ public void ChangeCreatorName(FormDesigner designer, XCreator creator) { String oldName = creator.toData().getWidgetName(); - String value = JOptionPane.showInputDialog(designer, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Change_Widget_Name_Discription"), oldName); + String value = FineJOptionPane.showInputDialog(designer, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Change_Widget_Name_Discription"), oldName); if (value != null) { designer.renameCreator(creator, value); } diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java index 5f3ae97f1..a7fb154e0 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java @@ -3,6 +3,7 @@ package com.fr.design.cell.editor; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionListener; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dscolumn.DSColumnPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.grid.Grid; @@ -71,8 +72,8 @@ public class DSColumnCellEditor extends AbstractCellEditor implements DialogActi try { this.dsColumnPane.populate(DesignTableDataManager.getEditingTableDataSource(), cellElement); } catch (Exception exp) { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(grid), exp.getMessage(), - ProductConstants.APP_NAME, JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(grid), exp.getMessage(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); FineLoggerFactory.getLogger().error(exp.getMessage(), exp); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java index 5b211dda5..747789cdb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java @@ -929,7 +929,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse return; } - String newName = JOptionPane.showInputDialog(reportComposite, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Rename") + ":", reportComposite.getEditingWorkBook().getReportName(selectedIndex)); + String newName = FineJOptionPane.showInputDialog(reportComposite, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Rename") + ":", reportComposite.getEditingWorkBook().getReportName(selectedIndex)); if (newName != null) { // marks:判断是否重名 boolean isExisted = false; diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java index 2ee1d5781..558cf4291 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java @@ -1,6 +1,7 @@ package com.fr.design.report; import com.fr.config.ServerPreferenceConfig; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.style.StylePane; import com.fr.design.utils.gui.GUICoreUtils; @@ -31,14 +32,14 @@ public class ReportStylePane extends StylePane { popupMenu.add(menuItem); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - String name = JOptionPane.showInputDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Input_The_Name_Of_Gloabel_Style")); + String name = FineJOptionPane.showInputDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Input_The_Name_Of_Gloabel_Style")); if (ComparatorUtils.equals(name, "")) { return; } if (ServerPreferenceConfig.getInstance().getStyle(name) == null) { ServerPreferenceConfig.getInstance().putStyle(name, ReportStylePane.this.updateBean()); } else { - JOptionPane.showMessageDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_This_Name_Has_Exsit") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Warning"), JOptionPane.WARNING_MESSAGE); + FineJOptionPane.showMessageDialog(getParent(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_This_Name_Has_Exsit") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Warning"), JOptionPane.WARNING_MESSAGE); } } }); diff --git a/designer-realize/src/main/java/com/fr/design/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/style/StylePane.java index 7fd8db07d..fc5337647 100644 --- a/designer-realize/src/main/java/com/fr/design/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/style/StylePane.java @@ -9,6 +9,7 @@ import com.fr.base.ScreenResolution; import com.fr.base.Style; import com.fr.base.core.StyleUtils; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.ElementCasePane; @@ -358,7 +359,7 @@ public class StylePane extends BasicBeanPane