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 c644550795..4e0b4e520d 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 @@ -8,6 +8,7 @@ import javax.swing.JDialog; import javax.swing.JOptionPane; import java.awt.Component; import java.awt.HeadlessException; +import java.awt.event.ActionListener; import java.util.HashMap; import java.util.Map; @@ -184,6 +185,29 @@ public class FineJOptionPane extends JOptionPane { messageType, icon, options, initialValue); } + /** + * 带确认+取消按钮的弹出框,并绑定确认事件 + * + * @param parentComponent 父容器 + * @param message 具体的提示消息 + * @param title 标题 + * @param icon 图标 + * @param initialValue 初始选项 + * @throws HeadlessException + */ + public static int showConfirmDialogWithOkListener(Component parentComponent, Object message, + String title, Icon icon, Object initialValue, ActionListener listener) + throws HeadlessException { + int val = showOptionDialog(parentComponent, message, title, JOptionPane.DEFAULT_OPTION, + FineJOptionPane.WARNING_MESSAGE, icon, OPTION_OK_CANCEL, initialValue); + if (val == JOptionPane.OK_OPTION && listener!=null) { + listener.actionPerformed(null); + } + return val; + } + + + /** * 指定消息内容的输入弹出框 * @param message 消息内容 diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java index f9e790103d..4656d8d393 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/ReadUpdateOnlineExecutor.java @@ -4,6 +4,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginsReaderFromStore; import com.fr.design.extra.Process; import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.DesignUtils; import com.fr.general.SiteBlockedException; import com.fr.json.JSONArray; import com.fr.json.JSONObject; @@ -12,6 +13,8 @@ import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; import javax.swing.JOptionPane; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.List; import static com.fr.design.dialog.FineJOptionPane.OPTION_OK_CANCEL; @@ -48,10 +51,18 @@ public class ReadUpdateOnlineExecutor implements Executor { } result = jsonArray.toString(); } catch (SiteBlockedException e1) { - FineJOptionPane.showConfirmDialog(null, + FineJOptionPane.showConfirmDialogWithOkListener(null, e1.getMessage(), - Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, - FineJOptionPane.WARNING_MESSAGE, null, OPTION_OK_CANCEL, null); + Toolkit.i18nText("Fine-Design_Basic_Alert"), null, null, + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignUtils.visitEnvServerByParameters( + "#management/system/normal", + null, + null); + } + }); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index b770290d3c..deda005c36 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -24,6 +24,7 @@ import com.fr.design.update.ui.widget.UpdateInfoTable; import com.fr.design.update.ui.widget.UpdateInfoTableCellRender; import com.fr.design.update.ui.widget.UpdateInfoTableModel; import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender; +import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.*; import com.fr.general.http.HttpToolbox; @@ -356,10 +357,18 @@ public class UpdateMainDialog extends UIDialog { return new JSONObject(HttpToolbox.get(url)); } catch (SiteBlockedException e) { stopLoading(); - FineJOptionPane.showConfirmDialog(null, + FineJOptionPane.showConfirmDialogWithOkListener(null, e.getMessage(), - Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, - FineJOptionPane.WARNING_MESSAGE, null, OPTION_OK_CANCEL, null); + Toolkit.i18nText("Fine-Design_Basic_Alert"), null, null, + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignUtils.visitEnvServerByParameters( + "#management/system/normal", + null, + null); + } + }); } return null; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java index 7fc8e7e5ad..a2e43df3eb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java +++ b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java @@ -6,6 +6,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.DesignUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.CloudCenter; import com.fr.general.IOUtils; @@ -22,6 +23,8 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; @@ -76,10 +79,18 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { try { httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind(siteKind)); } catch (SiteBlockedException e) { - FineJOptionPane.showConfirmDialog(null, + FineJOptionPane.showConfirmDialogWithOkListener(null, e.getMessage(), - Toolkit.i18nText("Fine-Design_Basic_Alert"), JOptionPane.DEFAULT_OPTION, - FineJOptionPane.WARNING_MESSAGE, null, OPTION_OK_CANCEL, null); + Toolkit.i18nText("Fine-Design_Basic_Alert"), null, null, + new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + DesignUtils.visitEnvServerByParameters( + "#management/system/normal", + null, + null); + } + }); return; } if (httpClient.getResponseCode() != HttpURLConnection.HTTP_OK) {