diff --git a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java index 1c441a83f..4fabbd6da 100644 --- a/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/community/VideoAction.java @@ -6,6 +6,7 @@ import com.fr.design.menu.MenuKeySet; import com.fr.design.utils.BrowseUtils; import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.event.ActionEvent; @@ -19,7 +20,7 @@ public class VideoAction extends UpdateAction this.setMenuKeySet(VIDEO); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/video.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/video.png")); } @@ -27,12 +28,10 @@ public class VideoAction extends UpdateAction public void actionPerformed(ActionEvent arg0) { String url; - if (Locale.US.equals(GeneralContext.getLocale())) { + if (GeneralContext.getLocale().equals(Locale.US)) { url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); - } else if (Locale.TAIWAN.equals(GeneralContext.getLocale())) { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw"); } else { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); + url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); } BrowseUtils.browser(url); diff --git a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java index de223e2cc..f3bfe5622 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/WebPreviewUtils.java @@ -1,7 +1,8 @@ package com.fr.design.actions.file; -import com.fr.base.vcs.DesignerMode; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.fun.PreviewProvider; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; @@ -10,41 +11,56 @@ import com.fr.file.FileNodeFILE; import com.fr.general.GeneralUtils; import com.fr.general.web.ParameterConstants; import com.fr.stable.project.ProjectConstants; +import com.fr.web.referrer.DesignSessionReferrer; -import javax.swing.JOptionPane; -import java.util.Collections; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import static javax.swing.JOptionPane.OK_CANCEL_OPTION; +import static javax.swing.JOptionPane.OK_OPTION; +import static javax.swing.JOptionPane.WARNING_MESSAGE; +import static javax.swing.JOptionPane.showConfirmDialog; + public final class WebPreviewUtils { public static void preview(JTemplate jt) { preview(jt, jt.getPreviewType()); } - @SuppressWarnings("unchecked") public static void preview(JTemplate jt, PreviewProvider provider) { String baseRoute = jt.route(); - if (provider == null) { - actionPerformed(jt, baseRoute, Collections.EMPTY_MAP, ParameterConstants.VIEWLET); - } else { - actionPerformed(jt, baseRoute, provider.parametersForPreview(), provider.getActionType()); + + String previewType = ParameterConstants.VIEWLET; + Map paraMap = new HashMap<>(getExtraPara()); + + if (provider != null) { + Map providerParaMap = provider.parametersForPreview(); + if (providerParaMap != null) { + paraMap.putAll(providerParaMap); + } + previewType = provider.getActionType(); } + actionPerformed(jt, baseRoute, paraMap, previewType); + } + + private static Map getExtraPara() { + Map extraPara = new HashMap<>(); + if (DesignModeContext.isVcsMode()) { + extraPara.put("mode", DesignModeContext.getMode().toString()); + + } + extraPara.putAll(new DesignSessionReferrer.Builder().referrerMap()); + + return extraPara; } private static void actionPerformed(JTemplate jt, String baseRoute, Map map, String actionType) { if (jt == null) { return; } - - if (map == null || map == Collections.EMPTY_MAP) { - map = new HashMap<>(); - } - if (DesignerMode.isVcsMode()) { - map.put("mode", DesignerMode.getMode().toString()); - } DesignerContext.getDesignerFrame().refreshToolbar(); - jt.stopEditing(); /* * alex:如果没有保存,先保存到Env @@ -54,17 +70,20 @@ public final class WebPreviewUtils { if (!jt.isSaved() && !jt.saveTemplate2Env()) { return; } - FILE currentTemplate = jt.getEditingFILE(); // carl:是否是保存在运行环境下的模板,不是就不能被预览 if (currentTemplate instanceof FileNodeFILE) { browseUrl(currentTemplate, baseRoute, map, actionType, jt); } else { // 说明模板没有保存在报表运行环境下面,提示用户 - int selVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); + int selVal = showConfirmDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), + Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), + OK_CANCEL_OPTION, + WARNING_MESSAGE); - if (JOptionPane.OK_OPTION == selVal) { + if (OK_OPTION == selVal) { if (!jt.saveAsTemplate2Env()) { return; } @@ -74,7 +93,10 @@ public final class WebPreviewUtils { } } - private static void browseUrl(FILE currentTemplate, String baseRoute, Map map, String actionType, JTemplate jt) { + private static void browseUrl(FILE currentTemplate, + String baseRoute, + Map map, + String actionType, JTemplate jt) { if (!(currentTemplate instanceof FileNodeFILE)) { return; } @@ -85,8 +107,8 @@ public final class WebPreviewUtils { path = path.substring(ProjectConstants.REPORTLETS_NAME.length() + 1); } - java.util.List parameterNameList = new java.util.ArrayList(); - java.util.List parameterValueList = new java.util.ArrayList(); + List parameterNameList = new ArrayList<>(); + List parameterValueList = new ArrayList<>(); parameterNameList.add(actionType); parameterValueList.add(path); @@ -96,14 +118,21 @@ public final class WebPreviewUtils { parameterValueList.add(GeneralUtils.objectToString(map.get(key))); } } - DesignUtils.visitEnvServerByParameters(baseRoute, parameterNameList.toArray(new String[parameterNameList.size()]), parameterValueList.toArray(new String[parameterValueList.size()])); + DesignUtils.visitEnvServerByParameters( + baseRoute, + parameterNameList.toArray(new String[0]), + parameterValueList.toArray(new String[0]) + ); } else { - int selVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE); - if (JOptionPane.OK_OPTION == selVal) { - if (!jt.saveAsTemplate()) { - return; - } + int selVal = showConfirmDialog( + DesignerContext.getDesignerFrame(), + Toolkit.i18nText("Fine-Design_Basic_Web_Preview_Message"), + Toolkit.i18nText("Fine-Design_Basic_Preview_Tool_Tips"), + OK_CANCEL_OPTION, + WARNING_MESSAGE + ); + if (OK_OPTION == selVal) { + jt.saveAsTemplate(); } } } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java index f5dc26f10..5de31eb31 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java @@ -1,10 +1,10 @@ package com.fr.design.actions.help; -import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; import com.fr.design.menu.MenuKeySet; import com.fr.general.CloudCenter; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; import com.fr.general.http.HttpToolbox; import com.fr.log.FineLoggerFactory; import com.fr.stable.CommonUtils; @@ -22,11 +22,13 @@ import java.net.URI; public class TutorialAction extends UpdateAction { + private static final String URL_FOR_TEST_NETWORK = "https://www.baidu.com"; + public TutorialAction() { this.setMenuKeySet(HELP_TUTORIAL); this.setName(getMenuKeySet().getMenuName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/bbs/help.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/help.png")); this.setAccelerator(getMenuKeySet().getKeyStroke()); } @@ -34,9 +36,11 @@ public class TutorialAction extends UpdateAction { * 动作 * @param evt 事件 */ + @Override public void actionPerformed(ActionEvent evt) { String helpURL = CloudCenter.getInstance().acquireUrlByKind(createDocKey()); - if (isServerOnline(helpURL)) { + // 用第三方网址去判断是否处在离线状态 + if (isServerOnline(URL_FOR_TEST_NETWORK)) { try { Desktop.getDesktop().browse(new URI(helpURL)); return; diff --git a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java index 89f2ac3c3..76b11b2ff 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/ConnectionListAction.java @@ -1,6 +1,7 @@ package com.fr.design.actions.server; +import com.fr.config.ServerPreferenceConfig; import com.fr.data.impl.Connection; import com.fr.design.actions.UpdateAction; import com.fr.design.data.datapane.connect.ConnectionManagerPane; @@ -12,6 +13,7 @@ import com.fr.design.gui.NameInspector; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; +import com.fr.design.dcm.UniversalDatabaseOpener; import com.fr.file.ConnectionConfig; import com.fr.general.IOUtils; import com.fr.transaction.CallBackAdaptor; @@ -58,6 +60,14 @@ public class ConnectionListAction extends UpdateAction { * @param evt 事件 */ public void actionPerformed(ActionEvent evt) { + if (ServerPreferenceConfig.getInstance().isUseUniverseDBM()) { + UniversalDatabaseOpener.showUniverseDatabaseDialog(); + } else { + openDesignDatabaseManager(); + } + } + + private void openDesignDatabaseManager() { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); final ConnectionConfig datasourceManager = ConnectionConfig.getInstance(); final ConnectionManagerPane databaseManagerPane = new ConnectionManagerPane() { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 9ec67adb6..413a0f00d 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -32,6 +32,7 @@ import com.fr.design.mainframe.DesignerFrame; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.file.ConnectionConfig; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; @@ -331,7 +332,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha DBUtils.refreshDatabase(); String schema = StringUtils.isEmpty(schemaBox.getSelectedItem()) ? null : schemaBox.getSelectedItem(); DataCoreUtils.refreshTables(getConnection(), TableProcedure.TABLE, schema); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Successfully") + "!", com.fr.design.i18n.Toolkit.i18nText("FR-Designer_Refresh_Database"), + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Successfully") + "!", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh_Database"), JOptionPane.INFORMATION_MESSAGE); } @@ -343,7 +344,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Object userObj = node.getUserObject(); if (userObj instanceof String) { - this.setIcon(BaseUtils.readIcon("com/fr/design/images/m_insert/expandCell.gif")); + this.setIcon(IOUtils.readIcon("com/fr/design/images/m_insert/expandCell.gif")); } else if (userObj instanceof TableProcedure) { this.setText(((TableProcedure) userObj).getName()); } diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseComponent.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseComponent.java new file mode 100644 index 000000000..3410af044 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseComponent.java @@ -0,0 +1,39 @@ +package com.fr.design.dcm; + +import com.fr.web.struct.AssembleComponent; +import com.fr.web.struct.Atom; +import com.fr.web.struct.browser.RequestClient; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; +import com.fr.web.struct.impl.FineUI; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-05-16 + */ +public class UniversalDatabaseComponent extends AssembleComponent { + + public static final UniversalDatabaseComponent KEY = new UniversalDatabaseComponent(); + + private UniversalDatabaseComponent() { + + } + + @Override + public ScriptPath script(RequestClient req) { + return ScriptPath.build("/com/fr/design/dcm/index.js"); + } + + @Override + public StylePath style(RequestClient req) { + return StylePath.build("/com/fr/design/dcm/style.css"); + } + + @Override + public Atom[] refer() { + return new Atom[]{ + FineUI.KEY + }; + } +} diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java new file mode 100644 index 000000000..1a01a8641 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseDialog.java @@ -0,0 +1,32 @@ +package com.fr.design.dcm; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.UIDialog; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-05-16 + */ +public class UniversalDatabaseDialog extends UIDialog { + + public UniversalDatabaseDialog(Frame frame, BasicPane pane) { + super(frame); + setUndecorated(true); + JPanel panel = (JPanel) getContentPane(); + panel.setLayout(new BorderLayout()); + add(pane, BorderLayout.CENTER); + setSize(new Dimension(1000, 600)); + GUICoreUtils.centerWindow(this); + setResizable(false); + } + + @Override + public void checkValid() throws Exception { + + } +} diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseOpener.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseOpener.java new file mode 100644 index 000000000..9239b9d4d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabaseOpener.java @@ -0,0 +1,36 @@ +package com.fr.design.dcm; + +import com.fr.design.dialog.UIDialog; +import com.fr.design.mainframe.DesignerContext; + +import javax.swing.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-05-16 + */ +public class UniversalDatabaseOpener { + + private static UIDialog dialog = null; + + public static UIDialog getDialog() { + return dialog; + } + + public static void showUniverseDatabaseDialog() { + UniversalDatabasePane upmPane = new UniversalDatabasePane(); + if (dialog == null) { + dialog = new UniversalDatabaseDialog(DesignerContext.getDesignerFrame(), upmPane); + } + dialog.setVisible(true); + } + + public static void closeWindow() { + if (dialog != null) { + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + dialog.setVisible(false); + dialog = null; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java new file mode 100644 index 000000000..e29a9f669 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDatabasePane.java @@ -0,0 +1,39 @@ +package com.fr.design.dcm; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.ui.ModernUIPane; +import com.teamdev.jxbrowser.chromium.JSValue; +import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; +import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; + +import java.awt.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-05-16 + */ +public class UniversalDatabasePane extends BasicPane { + + private ModernUIPane modernUIPane; + + @Override + protected String title4PopupWindow() { + return "Database"; + } + + public UniversalDatabasePane() { + setLayout(new BorderLayout()); + modernUIPane = new ModernUIPane.Builder<>() + .withComponent(UniversalDatabaseComponent.KEY) + .prepare(new ScriptContextAdapter() { + @Override + public void onScriptContextCreated(ScriptContextEvent event) { + JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); + window.asObject().setProperty("DcmHelper", UniversalDcmBridge.getBridge(event.getBrowser())); + } + }) + .build(); + add(modernUIPane, BorderLayout.CENTER); + } +} diff --git a/designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java b/designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java new file mode 100644 index 000000000..577acada9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/dcm/UniversalDcmBridge.java @@ -0,0 +1,34 @@ +package com.fr.design.dcm; + +import com.fr.decision.webservice.bean.BaseBean; +import com.fr.design.bridge.exec.JSBridge; +import com.teamdev.jxbrowser.chromium.Browser; +import com.teamdev.jxbrowser.chromium.JSObject; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-05-17 + * 桥接Java和JavaScript的类 + */ +public class UniversalDcmBridge { + + public static UniversalDcmBridge getBridge(Browser browser) { + return new UniversalDcmBridge(browser); + } + + private JSObject window; + + private UniversalDcmBridge(Browser browser) { + this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); + } + + /** + * 获取所有的数据连接 + * @return 数据连接集合 + */ + @JSBridge + public BaseBean getConnections() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java index c01daff70..4809e536c 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java +++ b/designer-base/src/main/java/com/fr/design/dialog/BasicPane.java @@ -40,21 +40,7 @@ public abstract class BasicPane extends JPanel { * @return 对话框 */ public BasicDialog showWindow(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - - dg.setBasicDialogSize(BasicDialog.DEFAULT); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; + return showWindowWithCustomSize(window, l, BasicDialog.DEFAULT); } /** @@ -100,21 +86,7 @@ public abstract class BasicPane extends JPanel { * @return 对话框 */ public BasicDialog showWindow4ChartType(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - - dg.setBasicDialogSize(BasicDialog.CHART); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; + return showWindowWithCustomSize(window, l, BasicDialog.CHART); } /** @@ -125,20 +97,7 @@ public abstract class BasicPane extends JPanel { * @return 对话框 */ public BasicDialog showSmallWindow(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - dg.setBasicDialogSize(BasicDialog.SMALL); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; + return showWindowWithCustomSize(window, l, BasicDialog.SMALL); } /** @@ -149,20 +108,7 @@ public abstract class BasicPane extends JPanel { * @return 对话框 */ public BasicDialog showMediumWindow(Window window, DialogActionListener l) { - BasicDialog dg; - if (window instanceof Frame) { - dg = new DIALOG((Frame) window); - } else { - dg = new DIALOG((Dialog) window); - } - - if (l != null) { - dg.addDialogActionListener(l); - } - dg.setBasicDialogSize(BasicDialog.MEDIUM); - GUICoreUtils.centerWindow(dg); - dg.setResizable(false); - return dg; + return showWindowWithCustomSize(window, l, BasicDialog.MEDIUM); } /** @@ -173,6 +119,17 @@ public abstract class BasicPane extends JPanel { * @return 对话框 */ public BasicDialog showLargeWindow(Window window, DialogActionListener l) { + return showWindowWithCustomSize(window, l, BasicDialog.LARGE); + } + + /** + * 以自定义的宽高显示窗口 + * @param window 窗口 + * @param l 对话框监听器 + * @param dimension 自定义尺寸 + * @return 对话框 + */ + protected BasicDialog showWindowWithCustomSize(Window window, DialogActionListener l, Dimension dimension) { BasicDialog dg; if (window instanceof Frame) { dg = new DIALOG((Frame) window); @@ -183,7 +140,7 @@ public abstract class BasicPane extends JPanel { if (l != null) { dg.addDialogActionListener(l); } - dg.setBasicDialogSize(BasicDialog.LARGE); + dg.setBasicDialogSize(dimension); GUICoreUtils.centerWindow(dg); dg.setResizable(false); return dg; @@ -350,6 +307,7 @@ public abstract class BasicPane extends JPanel { } } + @Override public void setVisible(boolean isVisible) { this.nameTextField.setVisible(isVisible); this.Name.setVisible(isVisible); @@ -377,6 +335,7 @@ public abstract class BasicPane extends JPanel { * * @throws Exception 异常 */ + @Override public void checkValid() throws Exception { super.checkValid(); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/ImgChooseWrapper.java b/designer-base/src/main/java/com/fr/design/gui/frpane/ImgChooseWrapper.java index 36183f107..19823d8b4 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/ImgChooseWrapper.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/ImgChooseWrapper.java @@ -7,7 +7,6 @@ import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImagePreviewer; import com.fr.design.utils.ImageUtils; import com.fr.general.ImageWithSuffix; - import com.fr.stable.CoreGraphHelper; import com.fr.stable.StringUtils; @@ -16,6 +15,7 @@ import javax.swing.SwingWorker; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.Image; +import java.awt.image.BufferedImage; import java.io.File; /** @@ -103,7 +103,7 @@ public class ImgChooseWrapper { if (imageFileChooser.isCheckSelected()) { imageWithSuffix = ImageUtils.defaultImageCompWithSuff(selectedFile); } else { - Image image = BaseUtils.readImage(selectedFile.getPath()); + BufferedImage image = BaseUtils.readImage(selectedFile.getPath()); String type = ImageUtils.getImageType(selectedFile); imageWithSuffix = new ImageWithSuffix(image, type); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java index 7f794b708..afa6fc907 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImageBackgroundQuickPane.java @@ -114,7 +114,7 @@ public class ImageBackgroundQuickPane extends BackgroundQuickPane { @Override public Background updateBean() { - ImageFileBackground imageBackground = new ImageFileBackground(previewPane.getImage(), suffix); + ImageFileBackground imageBackground = new ImageFileBackground(previewPane.getImageWithSuffix()); imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(imageLayoutPane.getSelectedItem()); imageBackground.setLayout(imageStyle.getImageLayout()); return imageBackground; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java index 6b9882397..24b3ebfc4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/backgroundpane/ImagePreviewPane.java @@ -304,7 +304,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre @Override public void setImage(Image image) { - setImageWithSuffix(image == null ? null : new ImageWithSuffix(image)); + setImageWithSuffix(ImageWithSuffix.build(image)); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java index 35abeb82c..79e94d399 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogHandler.java @@ -44,14 +44,6 @@ public class DesignerLogHandler { private static final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - private static final int INFO_INT = Level.INFO.toInt(); - - private static final int ERROR_INT = Level.ERROR.toInt(); - - private static final int WARN_INT = Level.WARN.toInt(); - - private static final int DEBUG_INT = Level.DEBUG.toInt(); - private static final int GAP_X = -150; private static final int INFO_GAP_Y = -60; @@ -127,12 +119,12 @@ public class DesignerLogHandler { JPopupMenu jPopupMenu = new JPopupMenu(); int logLevelInt = Log4jConfig.getInstance().getRootLevel().toInt(); - if (logLevelInt <= INFO_INT) { + if (logLevelInt <= DesignerLogger.INFO_INT) { jPopupMenu.add(showInfo); jPopupMenu.add(showError); jPopupMenu.add(showServer); jPopupMenu.show(caption, caption.getWidth() + GAP_X, INFO_GAP_Y); - } else if (logLevelInt == ERROR_INT) { + } else if (logLevelInt == DesignerLogger.ERROR_INT) { jPopupMenu.add(showError); jPopupMenu.add(showServer); jPopupMenu.show(caption, caption.getWidth() + GAP_X, ERRO_GAP_Y); @@ -241,11 +233,11 @@ public class DesignerLogHandler { int intLevel = event.getLevel().toInt(); Date date = new Date(event.getTimeStamp()); ThrowableInformation information = event.getThrowableInformation(); - if (intLevel == INFO_INT && showInfo.isSelected()) { + if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); - } else if (intLevel == ERROR_INT && showError.isSelected()) { + } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); - } else if (intLevel == WARN_INT && showServer.isSelected()) { + } else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) { printMessage(event.getRenderedMessage(), intLevel, date, information == null ? null : information.getThrowable()); } } @@ -253,11 +245,11 @@ public class DesignerLogHandler { public void printStackTrace(String message, Level level, Date date) { int intLevel = level.toInt(); - if (intLevel == INFO_INT && showInfo.isSelected()) { + if (intLevel == DesignerLogger.INFO_INT && showInfo.isSelected()) { printMessage(message, intLevel, date); - } else if (intLevel == ERROR_INT && showError.isSelected()) { + } else if (intLevel == DesignerLogger.ERROR_INT && showError.isSelected()) { printMessage(message, intLevel, date); - } else if (intLevel == WARN_INT && showServer.isSelected()) { + } else if (intLevel == DesignerLogger.WARN_INT && showServer.isSelected()) { printMessage(message, intLevel, date); } @@ -287,13 +279,13 @@ public class DesignerLogHandler { private void log(String str, int style) { SimpleAttributeSet attrSet = new SimpleAttributeSet(); - if (style == ERROR_INT) { + if (style == DesignerLogger.ERROR_INT) { StyleConstants.setForeground(attrSet, new Color(247, 148, 29)); StyleConstants.setBold(attrSet, true); - } else if (style == WARN_INT) { + } else if (style == DesignerLogger.WARN_INT) { StyleConstants.setForeground(attrSet, Color.red); StyleConstants.setBold(attrSet, true); - } else if (style == INFO_INT) { + } else if (style == DesignerLogger.INFO_INT) { StyleConstants.setForeground(attrSet, Color.black); StyleConstants.setBold(attrSet, false); } else { @@ -310,9 +302,9 @@ public class DesignerLogHandler { private String appendLocaleMark(String str, int style) { - if (style == ERROR_INT) { + if (style == DesignerLogger.ERROR_INT) { str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n"; - } else if (style == WARN_INT) { + } else if (style == DesignerLogger.WARN_INT) { str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":" + str + "\n"; } else { str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":" + str + "\n"; @@ -323,11 +315,11 @@ public class DesignerLogHandler { private void setMessage(String message, int level) { LogMessageBar.getInstance().setMessage(message); - if (level == DesignerLogHandler.INFO_INT && showInfo.isSelected()) { + if (level == DesignerLogger.INFO_INT && showInfo.isSelected()) { caption.infoAdd(); - } else if (level == DesignerLogHandler.ERROR_INT && showError.isSelected()) { + } else if (level == DesignerLogger.ERROR_INT && showError.isSelected()) { caption.errorAdd(); - } else if (level == DesignerLogHandler.WARN_INT && showServer.isSelected()) { + } else if (level == DesignerLogger.WARN_INT && showServer.isSelected()) { caption.serverAdd(); } } @@ -368,9 +360,4 @@ public class DesignerLogHandler { }; } - - public void printLoggingEvent(LoggingEvent event) { - - logHandlerArea.printStackTrace(event); - } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java new file mode 100644 index 000000000..b2b35da1c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/DesignerLogger.java @@ -0,0 +1,82 @@ +package com.fr.design.mainframe.loghandler; + +import com.fr.log.FineLoggerFactory; +import com.fr.third.apache.log4j.Level; +import com.fr.third.apache.log4j.spi.LoggingEvent; +import com.fr.third.apache.log4j.spi.ThrowableInformation; + +/** + * 设计器日志记录 + */ +public class DesignerLogger { + public static final int INFO_INT = Level.INFO.toInt(); + + public static final int ERROR_INT = Level.ERROR.toInt(); + + public static final int WARN_INT = Level.WARN.toInt(); + + /** + * 记录LoggingEvent对象 + * + * @param event + */ + public static void log(LoggingEvent event) { + if (event == null) { + return; + } + LogParser.parse(event).log(event); + } + + public enum LogParser { + DEFAULT(-1) { + @Override + public void log(LoggingEvent event) { + + } + }, + INFO(Level.INFO.toInt()) { + @Override + public void log(LoggingEvent event) { + FineLoggerFactory.getLogger().info(event.getRenderedMessage()); + } + }, + WARN(Level.WARN.toInt()) { + @Override + public void log(LoggingEvent event) { + ThrowableInformation information = event.getThrowableInformation(); + FineLoggerFactory.getLogger().warn(event.getRenderedMessage(), information == null ? null : information.getThrowable()); + } + }, + + ERROR(Level.ERROR.toInt()) { + @Override + public void log(LoggingEvent event) { + ThrowableInformation information = event.getThrowableInformation(); + FineLoggerFactory.getLogger().error(event.getRenderedMessage(), information == null ? null : information.getThrowable()); + } + }; + private int level; + + LogParser(int level) { + this.level = level; + } + + public int getLevel() { + return level; + } + + public static LogParser parse(LoggingEvent event) { + int intLevel = event.getLevel().toInt(); + for (LogParser logParser : values()) { + if (logParser.getLevel() == intLevel) { + return logParser; + } + } + return DEFAULT; + + } + + public void log(LoggingEvent event) { + } + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/background/image/ImagePreviewPane.java b/designer-base/src/main/java/com/fr/design/style/background/image/ImagePreviewPane.java index 0e5cbe463..bc4f3f41c 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/image/ImagePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/image/ImagePreviewPane.java @@ -63,7 +63,7 @@ public class ImagePreviewPane extends JComponent implements Scrollable, ImagePre @Override public void setImage(Image image) { - setImageWithSuffix(image == null ? null : new ImageWithSuffix(image)); + setImageWithSuffix(ImageWithSuffix.build(image)); } diff --git a/designer-base/src/main/java/com/fr/design/ui/Assistant.java b/designer-base/src/main/java/com/fr/design/ui/Assistant.java index 7a51c188c..3962692c7 100644 --- a/designer-base/src/main/java/com/fr/design/ui/Assistant.java +++ b/designer-base/src/main/java/com/fr/design/ui/Assistant.java @@ -6,8 +6,14 @@ import com.teamdev.jxbrowser.chromium.BrowserContext; import com.teamdev.jxbrowser.chromium.ProtocolService; import com.teamdev.jxbrowser.chromium.URLResponse; +import javax.activation.MimetypesFileTypeMap; import java.io.DataInputStream; +import java.io.File; +import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; /** * @author richie @@ -41,7 +47,15 @@ public class Assistant { if (path.endsWith(".js")) { return "text/javascript"; } - return "text/html"; + if (path.endsWith(".svg")) { + return "image/svg+xml"; + } + Path file = new File(path).toPath(); + try { + return Files.probeContentType(file); + } catch (IOException e) { + return "text/html"; + } } public static void setEmbProtocolHandler(Browser browser, EmbProtocolHandler handler) { @@ -49,6 +63,6 @@ public class Assistant { ProtocolService protocolService = browserContext.getProtocolService(); // 支持读取jar包中文件的自定义协议————emb:/com/fr/design/images/bbs.png protocolService.setProtocolHandler("emb", handler); - //protocolService.setProtocolHandler("file", handler); + protocolService.setProtocolHandler("file", handler); } } diff --git a/designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java b/designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java index 94456df97..04d2f0f85 100644 --- a/designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java +++ b/designer-base/src/main/java/com/fr/design/ui/EmbProtocolHandler.java @@ -2,6 +2,8 @@ package com.fr.design.ui; import com.fr.base.TemplateUtils; import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.EncodeConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.codec.net.URLCodec; import com.fr.third.org.apache.commons.io.FileUtils; @@ -15,11 +17,14 @@ import com.teamdev.jxbrowser.chromium.ProtocolHandler; import com.teamdev.jxbrowser.chromium.URLRequest; import com.teamdev.jxbrowser.chromium.URLResponse; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.io.StringReader; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.Map; /** @@ -51,21 +56,20 @@ public class EmbProtocolHandler implements ProtocolHandler { @Override public URLResponse onRequest(URLRequest req) { + InputStream inputStream = null; try { String path = req.getURL(); if (path.startsWith("file:")) { String url = new URLCodec().decode(path); String filePath = TemplateUtils.renderParameter4Tpl(url, map); File file = new File(URI.create(filePath).getPath()); - InputStream inputStream = new FileInputStream(file); - if (path.endsWith(".svg")) { - System.out.println(path); - } - return Assistant.inputStream2Response(inputStream, "file:///" + file.getAbsolutePath()); - } - else if (path.startsWith("emb:dynamic")) { + inputStream = IOUtils.readResource(file.getAbsolutePath()); + String text = IOUtils.inputStream2String(inputStream, EncodeConstants.ENCODING_UTF_8); + text = TemplateUtils.renderParameter4Tpl(text, map); + return Assistant.inputStream2Response(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), path); + } else if (path.startsWith("emb:dynamic")) { URLResponse response = new URLResponse(); - response.setData(htmlText().getBytes()); + response.setData(htmlText(map).getBytes()); response.getHeaders().setHeader("Content-Type", "text/html"); return response; } else { @@ -75,16 +79,24 @@ public class EmbProtocolHandler implements ProtocolHandler { } else { path = path.substring(4); } - InputStream inputStream = IOUtils.readResource(path); + inputStream = IOUtils.readResource(path); return Assistant.inputStream2Response(inputStream, path); } - } catch (Exception ignore) { - ignore.printStackTrace(); + } catch (Exception e) { + FineLoggerFactory.getLogger().info(e.getMessage()); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } } return null; } - private String htmlText() { + private String htmlText(Map map) { PathGroup pathGroup = AtomBuilder.create().buildAssembleFilePath(ModernRequestClient.KEY, component); StylePath[] stylePaths = pathGroup.toStylePathGroup(); StringBuilder styleText = new StringBuilder(); @@ -106,6 +118,13 @@ public class EmbProtocolHandler implements ProtocolHandler { } } result = result.replaceAll("##script##", scriptText.toString()); + if (map != null) { + for (Map.Entry entry : map.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + result = result.replaceAll("\\$\\{" + key + "}", value); + } + } return result; } } diff --git a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java index 99a4fe97c..4a92d3715 100644 --- a/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java +++ b/designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java @@ -52,6 +52,8 @@ public class ModernUIPane extends BasicPane { toolbar.add(openDebugButton); UIButton reloadButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Reload")); toolbar.add(reloadButton); + UIButton closeButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Close_Window")); + toolbar.add(closeButton); openDebugButton.addActionListener(new ActionListener() { @Override @@ -66,6 +68,13 @@ public class ModernUIPane extends BasicPane { browser.reloadIgnoringCache(); } }); + + closeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + SwingUtilities.getWindowAncestor(ModernUIPane.this).setVisible(false); + } + }); BrowserPreferences.setChromiumSwitches("--remote-debugging-port=9222"); initializeBrowser(); add(new BrowserView(browser), BorderLayout.CENTER); @@ -107,6 +116,16 @@ public class ModernUIPane extends BasicPane { browser.loadURL(url); } + /** + * 转向一个新的地址,相当于重新加载 + * @param url 新的地址 + * @param map 初始化参数 + */ + public void redirect(String url, Map map) { + Assistant.setEmbProtocolHandler(browser, new EmbProtocolHandler(map)); + browser.loadURL(url); + } + @Override protected String title4PopupWindow() { return "Modern"; diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java index 3d0f28613..6a4b752fd 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java @@ -2,6 +2,7 @@ package com.fr.design.upm; import com.fr.base.passport.FinePassportManager; import com.fr.config.MarketConfig; +import com.fr.config.ServerPreferenceConfig; import com.fr.decision.webservice.v10.plugin.helper.category.impl.UpmResourceLoader; import com.fr.design.bridge.exec.JSBridge; import com.fr.design.bridge.exec.JSCallback; @@ -10,6 +11,7 @@ import com.fr.design.extra.PluginUtils; import com.fr.design.extra.exe.GetInstalledPluginsExecutor; import com.fr.design.extra.exe.GetPluginCategoriesExecutor; import com.fr.design.extra.exe.GetPluginFromStoreExecutor; +import com.fr.design.extra.exe.GetPluginPrefixExecutor; import com.fr.design.extra.exe.PluginLoginExecutor; import com.fr.design.extra.exe.ReadUpdateOnlineExecutor; import com.fr.design.extra.exe.SearchOnlineExecutor; @@ -60,12 +62,34 @@ public class UpmBridge { this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); } - public void startDownload(final JSFunction callback) { + /** + * 更新插件管理中心资源文件,这个方法仅仅是为了语义上的作用(更新) + * @param callback 安装完成后的回调函数 + */ + @JSBridge + public void update(final JSFunction callback) { + callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); + try { + UpmResourceLoader.INSTANCE.download(); + UpmResourceLoader.INSTANCE.install(); + callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success")); + EventDispatcher.fire(DownloadEvent.UPDATE, "success"); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); + } + } + /** + * 下载并安装插件管理中心的资源文件 + * @param callback 安装完成后的回调函数 + */ + @JSBridge + public void startDownload(final JSFunction callback) { + callback.invoke(window, "start", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); new SwingWorker(){ @Override protected Void doInBackground() throws Exception { - callback.invoke(window, Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Start")); UpmResourceLoader.INSTANCE.download(); UpmResourceLoader.INSTANCE.install(); return null; @@ -75,10 +99,10 @@ public class UpmBridge { protected void done() { try { get(); - callback.invoke(window, Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success")); + callback.invoke(window, "success", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Success")); EventDispatcher.fire(DownloadEvent.SUCCESS, "success"); } catch (Exception e) { - callback.invoke(window, Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); + callback.invoke(window, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); FineLoggerFactory.getLogger().error(e.getMessage(), e); EventDispatcher.fire(DownloadEvent.ERROR, "error"); } @@ -86,6 +110,15 @@ public class UpmBridge { }.execute(); } + /** + * 获取upm的版本信息 + * @return 版本信息 + */ + @JSBridge + public String getVersion() { + return ServerPreferenceConfig.getInstance().getOptimizedUPMVersion(); + } + @JSBridge public String i18nText(String key) { return Toolkit.i18nText(key); @@ -107,6 +140,12 @@ public class UpmBridge { callback.invoke(window, StringUtils.EMPTY); } + @JSBridge + public void getPluginPrefix(final JSFunction callback) { + UpmTaskWorker task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginPrefixExecutor()); + task.execute(); + } + /** * 在线获取插件分类 * @@ -403,4 +442,27 @@ public class UpmBridge { FineLoggerFactory.getLogger().info(e.getMessage()); } } + + /** + * 使用系统浏览器打开网页 + * @param url 要打开的网页 + */ + @JSBridge + public void openShopUrlAtWebBrowser(String url) { + if (Desktop.isDesktopSupported()) { + try { + //创建一个URI实例,注意不是URL + URI uri = URI.create(url); + //获取当前系统桌面扩展 + Desktop desktop = Desktop.getDesktop(); + //判断系统桌面是否支持要执行的功能 + if (desktop.isSupported(Desktop.Action.BROWSE)) { + //获取系统默认浏览器打开链接 + desktop.browse(uri); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } } diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java index e64e5f02e..57b225920 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java @@ -38,8 +38,14 @@ public class UpmShowPane extends BasicPane { window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); } }) - .withURL(UpmFinder.getMainResourcePath()) + .withURL(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()) .build(); + EventDispatcher.listen(DownloadEvent.UPDATE, new Listener() { + @Override + public void on(Event event, String param) { + modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); + } + }); } else { modernUIPane = new ModernUIPane.Builder<>() .withComponent(WarnComponent.KEY) @@ -53,7 +59,7 @@ public class UpmShowPane extends BasicPane { EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener() { @Override public void on(Event event, String param) { - modernUIPane.redirect(UpmFinder.getMainResourcePath()); + modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); } }); } diff --git a/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java b/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java index a74f0f616..d27b6721a 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java @@ -1,7 +1,14 @@ package com.fr.design.upm; +import com.fr.common.annotations.Negative; +import com.fr.config.ServerPreferenceConfig; +import com.fr.general.CloudCenter; +import com.fr.stable.StringUtils; + import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author richie @@ -18,4 +25,20 @@ public class UpmUtils { } return list.toArray(new String[0]); } + + @Negative(until = "2019-08-30") + public static Map renderMap() { + Map map4Tpl = new HashMap<>(); + map4Tpl.put("version", ServerPreferenceConfig.getInstance().getOptimizedUPMVersion()); + map4Tpl.put("new_version", fetchLatestVersion()); + return map4Tpl; + } + + private static String fetchLatestVersion() { + String version = CloudCenter.getInstance().acquireUrlByKind("upm.script.version"); + if (StringUtils.isBlank(version)) { + version = "1.0"; + } + return version; + } } diff --git a/designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java b/designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java index e07156b83..25b4f0a9e 100644 --- a/designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java +++ b/designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java @@ -9,5 +9,5 @@ import com.fr.event.Event; */ public enum DownloadEvent implements Event { - SUCCESS, ERROR + SUCCESS, ERROR, UPDATE } diff --git a/designer-base/src/main/java/com/fr/design/upm/loader/UpmDesignResourceLoader.java b/designer-base/src/main/java/com/fr/design/upm/loader/UpmDesignResourceLoader.java deleted file mode 100644 index 93857dc8b..000000000 --- a/designer-base/src/main/java/com/fr/design/upm/loader/UpmDesignResourceLoader.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.fr.design.upm.loader; - -import com.fr.decision.webservice.bean.plugin.store.ProjectInfoBean; -import com.fr.decision.webservice.v10.plugin.helper.category.impl.BaseResourceLoader; - -/** - * @author richie - * @version 10.0 - * Created by richie on 2019-04-18 - */ -public class UpmDesignResourceLoader extends BaseResourceLoader { - - @Override - public String getPluginPath() { - return "upm/plugin_design.html"; - } - - @Override - public void checkResourceExist(ProjectInfoBean projectInfoBean) throws Exception { - - } - - @Override - public String getDownloadPath() throws Exception { - return "http://fanruan-market.oss-cn-shanghai.aliyuncs.com/upm/1.0/upm-10.0.zip"; - } -} diff --git a/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java b/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java index 33f928a46..389b9981e 100644 --- a/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/ImageUtils.java @@ -1,6 +1,7 @@ package com.fr.design.utils; import com.fr.base.BaseUtils; +import com.fr.base.frpx.util.ImageIOHelper; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.ImageWithSuffix; @@ -70,7 +71,7 @@ public class ImageUtils { return null; } BufferedImage srcImg = BaseUtils.readImage(imageFile.getPath()); - Image desImg = srcImg; + BufferedImage desImg = srcImg; try { if (canbeCompressedToJPEG(imageFile)) { @@ -186,11 +187,23 @@ public class ImageUtils { /** * 获取图片类型 + * 先根据ImageReader获取,ImageReader获取不到就拿后缀 * * @param imageFile 图片文件 * @return 图片类型(JPEG, PNG, GIF) */ public static String getImageType(File imageFile) { + String imageType = getImageTypeByImageReader(imageFile); + return StringUtils.EMPTY.equals(imageType) ? ImageIOHelper.getSuffix(imageFile) : imageType; + } + + /** + * 根据ImageReader获取图片类型 + * + * @param imageFile 图片文件 + * @return 图片类型(JPEG, PNG, GIF) + */ + public static String getImageTypeByImageReader(File imageFile) { try { ImageInputStream iis = ImageIO.createImageInputStream(imageFile); Iterator iter = ImageIO.getImageReaders(iis); @@ -226,7 +239,7 @@ public class ImageUtils { * @param scale 缩放比例。比例大于1时为放大,小于1大于0为缩小 * @param opacityCompatible 是否处理背景透明 */ - public static Image scale(BufferedImage srcImg, float scale, boolean opacityCompatible) { + public static BufferedImage scale(BufferedImage srcImg, float scale, boolean opacityCompatible) { if (scale < 0) { // 自动修正负数 scale = -scale; @@ -234,7 +247,7 @@ public class ImageUtils { int width = mul(Integer.toString(srcImg.getWidth(null)), Float.toString(scale)).intValue(); // 得到源图宽 int height = mul(Integer.toString(srcImg.getHeight(null)), Float.toString(scale)).intValue(); // 得到源图长 - return scale(srcImg, width, height, opacityCompatible); + return CoreGraphHelper.toBufferedImage(scale(srcImg, width, height, opacityCompatible)); } private static BigDecimal mul(String v1, String v2) { diff --git a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java index 78accb96b..42bcfae0a 100644 --- a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java +++ b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java @@ -9,13 +9,15 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.NumberEditor; - import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -23,6 +25,7 @@ import java.awt.event.ActionListener; * Created by kerry on 2017/9/10. */ public class NumberEditorValidatePane extends JPanel { + private UICheckBox allowDecimalsCheckBox; private UICheckBox allowNegativeCheckBox; private UICheckBox setMaxValueCheckBox; @@ -104,6 +107,7 @@ public class NumberEditorValidatePane extends JPanel { private void initListeners() { allowDecimalsListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (allowDecimalsCheckBox.isSelected()) { limitNumberPane.setVisible(true); @@ -129,8 +133,8 @@ public class NumberEditorValidatePane extends JPanel { if (!setMinValueCheckBox.isSelected()) { maxValueSpinner.getTextField().setMinValue(0.0); } - Double minValue = Double.parseDouble("" + minValueSpinner.getValue()); - Double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); + double minValue = Double.parseDouble("" + minValueSpinner.getValue()); + double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); if (minValue < 0.0) { minValueSpinner.setValue(0.0); } @@ -143,10 +147,11 @@ public class NumberEditorValidatePane extends JPanel { setMaxListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (setMaxValueCheckBox.isSelected()) { maxValueSpinner.setEnabled(true); - Double value = new Double(0); + Double value = (double) 0; if (setMinValueCheckBox.isSelected()) { Double minValue = Double.parseDouble("" + minValueSpinner.getValue()); if (minValue > value) { @@ -163,10 +168,11 @@ public class NumberEditorValidatePane extends JPanel { setMinListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (setMinValueCheckBox.isSelected()) { minValueSpinner.setEnabled(true); - Double value = new Double(0); + Double value = (double) 0; if (setMaxValueCheckBox.isSelected()) { Double maxValue = Double.parseDouble("" + maxValueSpinner.getValue()); if (maxValue < value) { @@ -177,7 +183,7 @@ public class NumberEditorValidatePane extends JPanel { maxValueSpinner.getTextField().setMinValue(value); } else { minValueSpinner.setEnabled(false); - maxValueSpinner.getTextField().setMinValue(allowNegativeCheckBox.isSelected() ? (-Double.MAX_VALUE) : new Double(0)); + maxValueSpinner.getTextField().setMinValue(allowNegativeCheckBox.isSelected() ? (-Double.MAX_VALUE) : (double) 0); } } }; @@ -222,28 +228,28 @@ public class NumberEditorValidatePane extends JPanel { allowNegativeCheckBox.setSelected(e.isAllowNegative()); if (e.getMaxValue() == Double.MAX_VALUE) { setMaxValueCheckBox.setSelected(false); - maxValueSpinner.setValue(new Double(Double.MAX_VALUE)); + maxValueSpinner.setValue(Double.MAX_VALUE); maxValueSpinner.setEnabled(false); } else { setMaxValueCheckBox.setSelected(true); maxValueSpinner.setEnabled(true); - maxValueSpinner.setValue(new Double(e.getMaxValue())); + maxValueSpinner.setValue(e.getMaxValue()); } if (e.getMinValue() == -Double.MAX_VALUE) { setMinValueCheckBox.setSelected(false); - minValueSpinner.setValue(new Double(-Double.MAX_VALUE)); + minValueSpinner.setValue(-Double.MAX_VALUE); minValueSpinner.setEnabled(false); } else { setMinValueCheckBox.setSelected(true); minValueSpinner.setEnabled(true); - minValueSpinner.setValue(new Double(e.getMinValue())); + minValueSpinner.setValue(e.getMinValue()); } - if(setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()){ + if (setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()) { errorMsgTextFieldPane.setVisible(true); errorMsgTextField.setText(e.getRegErrorMessage()); - }else{ + } else { errorMsgTextFieldPane.setVisible(false); errorMsgTextField.setText(StringUtils.EMPTY); } @@ -259,15 +265,19 @@ public class NumberEditorValidatePane extends JPanel { if (setMinValueCheckBox.isSelected()) { ob.setMinValue(minValueSpinner.getValue()); + } else { + ob.setMinValue(-Double.MAX_VALUE); } if (setMaxValueCheckBox.isSelected()) { ob.setMaxValue(maxValueSpinner.getValue()); + } else { + ob.setMaxValue(Double.MAX_VALUE); } - if(setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()){ + if (setMinValueCheckBox.isSelected() || setMaxValueCheckBox.isSelected()) { errorMsgTextFieldPane.setVisible(true); - }else{ + } else { errorMsgTextFieldPane.setVisible(false); errorMsgTextField.setText(StringUtils.EMPTY); } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 0d4839d6d..9b97c4359 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -3,9 +3,11 @@ package com.fr.env; import com.fr.base.FRContext; import com.fr.base.ServerConfig; 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.env.RemoteDesignerWorkspaceInfo; +import com.fr.design.fun.DesignerEnvProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; @@ -303,10 +305,17 @@ public class RemoteEnvPane extends BasicBeanPane { @Override public RemoteDesignerWorkspaceInfo updateBean() { + String url = this.remoteWorkspaceURL.getURL(); + String username = this.usernameInput.getText(); + String password = new String(this.passwordInput.getPassword()); + DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG); + if (envProcessor != null) { + url = envProcessor.changeEnvPathBeforeConnect(username, password, url); + } WorkspaceConnectionInfo connection = new WorkspaceConnectionInfo( - this.remoteWorkspaceURL.getURL(), - this.usernameInput.getText(), - new String(this.passwordInput.getPassword()), + url, + username, + password, this.certPathInput.getText(), new String(this.certSecretKeyInput.getPassword())); diff --git a/designer-base/src/main/resources/com/fr/design/dcm/index.js b/designer-base/src/main/resources/com/fr/design/dcm/index.js new file mode 100644 index 000000000..5f6220c74 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/dcm/index.js @@ -0,0 +1,2 @@ +!function(e){var t={};function i(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=e,i.c=t,i.d=function(e,t,s){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(s,o,function(t){return e[t]}.bind(null,o));return s},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=0)}([function(e,t,i){BI.DOM.ready(()=>{const e=i(5).default;BI.createWidget({type:e,element:"body"})})},function(e,t,i){},function(e,t){const i=BI.Constants.getConstant("dec.constant.database.conf.connect.form.redis.value"),s=BI.inherit(BI.Widget,{render:()=>({type:"bi.vertical",cls:"bi-plugin-redis",bgap:10,items:[{type:"bi.left",height:30,items:[{type:"bi.label",text:"数据库地址:",height:24,width:115,textAlign:"left"},{type:"bi.label",text:i.url,height:24}]},{type:"bi.left",height:30,items:[{type:"bi.label",text:"端口:",height:24,width:115,textAlign:"left"},{type:"bi.label",text:i.port,height:24}]},{type:"bi.left",height:30,items:[{type:"bi.label",text:"密码:",height:24,width:115,textAlign:"left"},{type:"bi.label",text:"********",height:24}]}]})});BI.shortcut("fr.plugin.redis.preview",s),BI.constant("dec.constant.database.conf.connect.form.redis.preview","fr.plugin.redis.preview")},function(e,t){const i=BI.inherit(BI.Widget,{render(){const{maxActive:e,maxIdle:t,numActive:i,numIdle:s}=this.options;return{type:"bi.left",items:[{type:"bi.left",cls:"right-status-item",items:[{type:"bi.vertical",cls:"right-status-board",items:[{type:"bi.vertical",cls:"right-status-board-item",items:[{type:"bi.label",cls:"right-status-text",extraCls:"card-font1",text:i},{type:"bi.label",cls:"right-status-text",text:"/"},{type:"bi.label",cls:"right-status-text",text:e}]},{type:"bi.label",text:"Redis连接数"}]}]}]}}});BI.shortcut("fr.plugin.redis.pool",i),BI.constant("dec.constant.database.conf.connect.form.redis.pool","fr.plugin.redis.pool")},function(e,t,i){},function(e,t,i){"use strict";i.r(t);const s="bi.icon_label",o="bi.label",r="bi.button",n="bi.editor",l="bi.vtape",a="bi.htape",c="bi.layout",d="bi.vertical",h="bi.left",p=[],m={childContext:["tab","linkList","linkSelected","linkUpdate","moreLinkSelected","statusSelected","connectionNameErr"],state:()=>({tab:"数据连接管理",linkList:p,linkSelected:{},linkUpdate:{},moreLinkSelected:"",statusSelected:"",connectionNameErr:""}),computed:{},actions:{setLinkList(e){this.model.linkList=e}}};BI.model("fr.model.main",BI.inherit(Fix.Model,m));const b=BI.inherit(Fix.Model,{context:["tab"],actions:{setTab(e){this.model.tab=e}}});BI.model("fr.model.title.item",b);function u(e,t){return e===t?{color:"#3685f2","border-bottom":"solid 2px #3685f2"}:{color:"#3d4d66","border-bottom":"none"}}const g=BI.inherit(BI.Widget,{props:{text:""},_store:()=>BI.Models.getModel("fr.model.title.item"),watch:{tab(e){const{text:t}=this.options;this.element.css(u(t,e))}},render(){const{text:e}=this.options;return{type:o,cls:"title-item",text:e}},mounted(){const{text:e}=this.options;this.element.css(u("数据连接管理",e)),this.element.on("click",()=>{this.store.setTab(e)})}});BI.shortcut("fr.title.item",g);const y={data:[{connectionId:"8c1c52f1-3d0a-429e-b35f-ee1e085a8b72",database:"",connectionName:"FRDemo",driver:"org.sqlite.JDBC",url:"jdbc:sqlite://${ENV_HOME}/../help/FRDemo.db",user:"",password:"",queryType:"",newCharsetName:"null",originalCharsetName:"",validationQuery:"",schema:"",testOnBorrow:!0,maxActive:50,options:"null",port:0,authType:"",creator:"designer",principal:"",keyPath:"",databaseType:"designer",privilegeDetailBeanList:"null"}]},f=window.parent.Dec,v=window.PluginHelper;const x=["数据连接管理","连接池状态"],I={render(){return{type:h,cls:"title",items:[...BI.map(x,(e,t)=>({type:"fr.title.item",text:t})),{type:"bi.icon_button",cls:"close-button",handler(){!function(){if(v)return v.closeWindow();console.log("关闭窗口")}()},invisible:!0,ref:e=>{this.CloseButton=e}}]}},mounted(){v&&v.isDesigner()&&this.CloseButton.setVisible(!0)}};BI.shortcut("fr.title",BI.inherit(BI.Widget,I));const k="dec.constant.database.conf.connect.list",B=["APACHE KYLIN","DERBY","HP Vertica","IBM DB2","INFORMIX","Microsoft SQL Server","MySQL","Oracle","Privotal Greenplum Database","Postgresql","GaussDB 200"];BI.constant(k,[]);var E=k;const w=[{text:"APACHE KYLIN",databaseType:"apache-kylin",driver:"org.apache.kylin.jdbc.Driver",url:"jdbc:kylin://:/"},{text:"DERBY",databaseType:"derby",driver:"org.apache.derby.jdbc.ClientDriver",url:"jdbc:derby://localhost:1527/"},{text:"HP Vertica",databaseType:"hp-vertica",driver:"com.vertica.jdbc.Driver",url:"jdbc:vertica://ip:port/databaseName"},{text:"IBM DB2",databaseType:"ibm-db2",driver:"com.ibm.db2.jcc.DB2Driver",url:"jdbc:db2://hostname:port/dbname"},{text:"INFORMIX",databaseType:"informix",driver:"com.informix.jdbc.IfxDriver",url:"jdbc:informix-sqli://{host}:{port}/{database}:INFORMIXSERVER={server}"},{text:"Microsoft SQL Server",databaseType:"sql-server",driver:"com.microsoft.sqlserver.jdbc.SQLServerDriver",url:"jdbc:sqlserver://localhost:1433;databaseName="},{text:"Oracle",databaseType:"oracle",driver:"oracle.jdbc.driver.OracleDriver",url:"jdbc:oracle:thin:@localhost:1521:databaseName"},{text:"Privotal Greenplum Database",databaseType:"pivotal-greenplum-database",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"Postgresql",databaseType:"postgresql",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"GaussDB 200",databaseType:"hw-libr-a",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"MySQL",databaseType:"mysql",driver:"com.mysql.jdbc.Driver",drivers:["com.mysql.jdbc.Driver","org.gjt.mm.mysql.Driver"],url:"jdbc:mysql://localhost/dbname"},{text:"其他",databaseType:"other",driver:"org.h2.Driver",drivers:["org.h2.Driver","com.fr.third.org.hsqldb.jdbcDriver","org.sqlite.JDBC"],url:"jdbc:h2://${ENV_HOME}/../databaseName"},{text:"ADS",databaseType:"ads",driver:"com.mysql.jdbc.Driver",url:"jdbc:mysql://hostname:port/my_ads_db"},{text:"Amazon Redshift",databaseType:"amazon-redshift",driver:"com.amazon.redshift.jdbc4.Driver",drivers:["com.amazon.redshift.jdbc4.Driver","com.amazon.redshift.jdbc41.Driver"],url:"jdbc:redshift://endpoint:port/database"},{text:"APACHE IMPALA",databaseType:"apache-impala",driver:"com.cloudera.impala.jdbc41.Driver",url:"jdbc:impala://hostname:port/_impala_builtins"},{text:"APACHE KYLIN",databaseType:"apache-kylin",driver:"org.apache.kylin.jdbc.Driver",url:"jdbc:kylin://:/"},{text:"APACHE Phoenix",databaseType:"apache-phoenix",driver:"org.apache.phoenix.jdbc.PhoenixDriver",url:"jdbc:phoenix:hostname:port/dbname"},{text:"DERBY",databaseType:"derby",driver:"org.apache.derby.jdbc.ClientDriver",url:"jdbc:derby://localhost:1527/"},{text:"Gbase 8A",databaseType:"gbase-8a",driver:"com.gbase.jdbc.Driver",url:"jdbc:gbase://hostname:port/dbname"},{text:"Gbase 8S",databaseType:"gbase-8s",driver:"com.gbasedbt.jdbc.IfxDriver",url:"jdbc:gbasedbt-sqli://{host}:{port}/{database}"},{text:"Gbase 8T",databaseType:"gbase-8t",driver:"com.informix.jdbc.IfxDriver",url:"jdbc:informix-sqli://{host}:{port}/{database}:INFORMIXSERVER={server}"},{text:"H2",databaseType:"h2",driver:"org.h2.Driver",url:"jdbc:h2://${ENV_HOME}/../databaseName"},{text:"华为云DWS",databaseType:"hw-dws",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"FusionInsight elk",databaseType:"hw-elk",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"FusionInsight HD",databaseType:"hw-fusioninsight-hd",driver:"org.apache.hive.jdbc.HiveDriver",url:"jdbc:hive2://10.135.0.110:24002,10.135.0.67:24002,10.135.0.66:24002/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;sasl.qop=auth-conf;auth=KERBEROS;zk.principal=zookeeper/hadoop;principal=hive/hadoop.hadoop.com@HADOOP.COM;"},{text:"GaussDB 200",databaseType:"hw-libr-a",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"Hadoop Hive",databaseType:"hadoop-hive",driver:"org.apache.hive.jdbc.HiveDriver",url:"jdbc:hive2://hostname:port/databasename"},{text:"Hbase",databaseType:"hbase",driver:"org.apache.phoenix.jdbc.PhoenixDriver",url:"jdbc:phoenix:hostname:port/dbname"},{text:"HP Vertica",databaseType:"hp-vertica",driver:"com.vertica.jdbc.Driver",url:"jdbc:vertica://ip:port/databaseName"},{text:"Hsql",databaseType:"hsql",driver:"com.fr.third.org.hsqldb.jdbcDriver",url:"jdbc:hsqldb:file:[PATH_TO_DB_FILES]"},{text:"IBM DB2",databaseType:"ibm-db2",driver:"com.ibm.db2.jcc.DB2Driver",url:"jdbc:db2://hostname:port/dbname"},{text:"INFORMIX",databaseType:"informix",driver:"com.informix.jdbc.IfxDriver",url:"jdbc:informix-sqli://{host}:{port}/{database}:INFORMIXSERVER={server}"},{text:"KINGBASE",databaseType:"kingbase",driver:"com.kingbase.Driver",url:"jdbc:kingbase://hostname:port"},{text:"Microsoft SQL Server",databaseType:"sql-server",driver:"com.microsoft.sqlserver.jdbc.SQLServerDriver",url:"jdbc:sqlserver://localhost:1433;databaseName="},{text:"MySQL",databaseType:"mysql",driver:"com.mysql.jdbc.Driver",drivers:["com.mysql.jdbc.Driver","org.gjt.mm.mysql.Driver"],url:"jdbc:mysql://localhost/dbname"},{text:"Oracle",databaseType:"oracle",driver:"oracle.jdbc.driver.OracleDriver",url:"jdbc:oracle:thin:@localhost:1521:databaseName"},{text:"Pivotal Greenplum Database",databaseType:"pivotal-greenplum-database",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"Postgresql",databaseType:"postgresql",driver:"org.postgresql.Driver",url:"jdbc:postgresql://hostname:port/dbname"},{text:"Presto",databaseType:"presto",driver:"com.facebook.presto.jdbc.PrestoDriver",url:"jdbc:presto://host:port/catalog"},{text:"SAP HANA",databaseType:"sap-hana",driver:"com.sap.db.jdbc.Driver",url:"jdbc:sap://hostname:port?reconnect=true"},{text:"SAP Sybase",databaseType:"sap-sybase",driver:"com.sybase.jdbc4.jdbc.SybDriver",url:"jdbc:sybase:Tds:hostname:2638/databasename"},{text:"SPARK",databaseType:"spark",driver:"org.apache.hive.jdbc.HiveDriver",url:"jdbc:hive2://hostname:port/databasename"},{text:"Sqlite",databaseType:"sqlite",driver:"org.sqlite.JDBC",url:"jdbc:sqlite:[PATH_TO_DB_FILES]"},{text:"TeraData",databaseType:"teradata",driver:"com.ncr.teradata.TeraDriver",url:"jdbc:teradata://localhost/CLIENT_CHARSET=EUC_CN,TMODE=TERA,CHARSET=ASCII,LOB_SUPPORT"},{text:"TRANSWARP INCEPTOR",databaseType:"transwarp-inceptor",driver:"org.apache.hive.jdbc.HiveDriver",url:"jdbc:hive2://hostname:port/databasename"}],N=(e,t)=>{const i=BI.Constants.getConstant(E);let s=0;const o=t.replace(/[0-9]/g,""),r=BI.some(i,(e,t)=>t===o)?o:"数据连接";return e.forEach(e=>{if(e.isSelected=!1,e.connectionName.startsWith(r)){const t=e.connectionName.replace(r,"0"),i=parseInt(t,10)+1;i>s&&(s=i)}}),`${r}${s>0?s:""}`};var T=new class{confirm(e,t){const i=BI.UUID();return BI.Popovers.create(i,{type:"bi.bar_popover",size:"normal",header:"提示",width:450,height:220,body:{type:"bi.left",cls:"comfirm-content",items:[{type:"bi.layout",cls:"comfirm-icon",width:50,height:50},{type:"bi.label",text:e}]},listeners:[{eventName:"EVENT_CONFIRM",action(){t&&t(!0)}},{eventName:"EVENT_CANCEL",action(){t&&t(!1)}}]}).open(i),i}loading(e){const t={type:"bi.center_adapt",cls:"show-content",items:[{type:d,items:[{type:"bi.layout",cls:"loading-icon",width:100,height:100},{type:o,text:e}]}]};return this.show(t)}success(e){const t={type:"bi.center_adapt",cls:"show-content",items:[{type:d,items:[{type:"bi.layout",cls:"success-icon",width:100,height:100},{type:o,text:e}]}]};return this.show(t,1e3)}error(e){const t={type:"bi.center_adapt",cls:"show-content",items:[{type:d,items:[{type:"bi.layout",cls:"error-icon",width:100,height:100},{type:o,text:e}]}]};return this.show(t,2e3)}linkFail(e,t,i){let s=null,n=null;const l=BI.UUID(),a=this,p={type:d,items:[{type:"bi.center_adapt",cls:"show-content",tgap:10,items:[{type:d,items:[{type:c,cls:"error-icon",width:100,height:100},{type:o,text:e},{type:h,cls:"buttons",items:[{type:r,text:"详细信息",level:"ignore",handler(){const e="详细信息"===this.getText();s.element.css({height:e?"290":"220"}),n.setVisible(e),this.setText(e?"收起信息":"详细信息")}},{type:r,text:"返回",level:"ignore",handler(){a.close(l)}},{type:r,text:"重新连接",handler(){a.close(l),i&&i()}}]}]}]},{type:o,cls:"show-more",text:t,invisible:!0,ref(e){n=e}}]};return BI.Popovers.create(l,{type:"bi.popover",cls:"popover-notitle",extraCls:"bi-custom-show",size:"normal",width:450,height:220,body:p,ref(e){s=e}}).open(l),l}close(e){BI.Popovers.close(e)}show(e,t=0){const i=BI.UUID();return BI.Popovers.create(i,{type:"bi.popover",cls:"popover-notitle",extraCls:"bi-custom-show",size:"normal",width:450,height:220,body:e}).open(i),t>0&&setTimeout(()=>{this.close(i)},t),i}};function C(e){return e.connectionId?new Promise((t,i)=>{try{!function(e,t){console.log("%cdata: ","color: MidnightBlue; background: Aquamarine;",e),f?f.reqPost("/v10/config/connection",e,e=>{t(e.data)}):t("success")}(e,e=>{t(e)})}catch(e){i(e)}}):new Promise((t,i)=>{try{!function(e,t){console.log("%cdata: ","color: MidnightBlue; background: Aquamarine;",e),f?f.reqPut("/v10/config/connection",e,e=>{t(e.data)}):t("success")}(e,e=>{t(e)})}catch(e){i(e)}})}const S={context:["tab","linkList","linkSelected","linkUpdate","connectionNameErr"],actions:{setLinkSelected(e){this.noSaveConfirm(()=>{this._setLinkSelected(e)})},_setLinkSelected(e){this.model.linkList.forEach(t=>{t.isSelected=t.connectionName===e,t.connectionName===e&&(this.model.linkSelected=Object.assign({},t,{isSelected:!1}))}),this.model.linkList=[...this.model.linkList],this.model.linkUpdate=this.model.linkSelected},onIconClick(e,t){switch(e){case"删除":!function(e,t){console.log("%cid: ","color: MidnightBlue; background: Aquamarine;",e),f?f.reqDeleta(`/v10/config/connection/${e}`,e=>{t(e.data)}):t("success")}(t,()=>{this.model.linkList=[...this.model.linkList.filter(e=>e.connectionId!==t)],this.model.linkSelected={},this.model.linkUpdate={}});break;case"测试连接":this._textLink(t);break;case"复制":this.noSaveConfirm(()=>{this.copyLink(t)})}},_textLink(e){const t=T.loading("正在测试连接,请稍候..."),i=this.model.linkList.find(t=>t.connectionId===e);var s,o;s=i,o=(s=>{T.close(t),s&&s.errorCode?T.linkFail(`${i.connectionName}测试连接失败`,s.errorMsg,()=>{this._textLink(e)}):T.success("连接成功")}),console.log("%cdata: ","color: MidnightBlue; background: Aquamarine;",s),f?f.reqPost("/v10/config/connection/test",s,e=>{o(e)}):setTimeout(()=>{o({errorCode:"500",errorMsg:"createConnectionThread not start!"})},2e3)},copyLink(e){const t=BI.find(this.model.linkList,(t,i)=>i.connectionId===e).connectionName,i=N(this.model.linkList,t);let s={};this.model.linkList.forEach(t=>{t.connectionId===e&&(s=t)});const o=Object.assign({},s,{isSelected:!0,connectionName:i,connectionId:""});this.model.linkList=[o,...this.model.linkList],this.model.linkSelected=Object.assign({},o),this.model.linkUpdate=Object.assign({},o)},setLinkUpdate(e){this.model.linkUpdate=e},setEdit(e){this.model.linkSelected=Object.assign({},this.model.linkSelected,{isSelected:e}),this.model.linkUpdate=this.model.linkSelected},setCancel(){const e=this.model.linkSelected,t=this.model.linkList;e.connectionId?this.setEdit(!1):(this.model.linkList=[...t.filter(e=>!!e.connectionId)],this.model.linkList.length>0?(this.model.linkList[0].isSelected=!0,this.model.linkSelected=Object.assign({},this.model.linkList[0],{isSelected:!1})):this.model.linkSelected={},this.model.linkUpdate=this.model.linkSelected)},setNewLink(e){w.some(t=>t.text===e)||BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${e.toLowerCase()}.edit`)?this.noSaveConfirm(()=>{this._setNewLink(e)}):T.error("找不到该连接的配置信息")},_setNewLink(e){const t=N(this.model.linkList,e);let i={};w.forEach(t=>{t.text===e&&(i=t)}),this.model.linkList=[Object.assign({connectionName:t,isSelected:!0},i,{text:e}),...this.model.linkList],this.model.linkSelected=Object.assign({},i,{connectionName:t,isSelected:!0,text:e}),this.model.linkUpdate=Object.assign({},i,{connectionName:t,text:e})},setConnectionNameErr(e){this.model.connectionNameErr=e},noSaveConfirm(e){this.model.linkSelected&&this.model.linkSelected.isSelected?T.confirm("当前设置尚未保存,是否保存?",t=>{t?this.saveLink():this.setCancel(),e()}):e()},saveLink(){const e=this.model.linkUpdate.text?BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${this.model.linkUpdate.text.toLowerCase()}.value`):{};C(Object.assign({},this.model.linkUpdate,e)).then(()=>{this.setEdit(!1)})}}};BI.model("fr.model.linkset",BI.inherit(Fix.Model,S));var j="fr.model.linkset";const _={_store:()=>BI.Models.getModel(j),render(){const{cls:e,title:t,id:i}=this.options,o=this;let r=null,n=null;return"删除"===t?{type:"bi.bubble_combo",direction:"bottom",ref(){n=this},el:{type:s,cls:e,extraCls:"action-icon",height:24,width:26,title:t,ref(e){r=e}},popup:{type:"bi.text_bubble_bar_popup_view",text:"确定删除该数据连接?",listeners:[{eventName:BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,action(e){n.hideView(),e&&o.store.onIconClick(t,i)}}]},listeners:[{eventName:BI.BubbleCombo.EVENT_EXPAND,action(){r.element.css({visibility:"visible"})}},{eventName:BI.BubbleCombo.EVENT_AFTER_HIDEVIEW,action(){r.element.css({visibility:"hidden"})}}]}:{type:s,cls:e,extraCls:"action-icon",height:24,width:26,title:t}},mounted(){const{title:e,id:t}=this.options;"删除"!==e?this.element.on("click",i=>{i.stopPropagation(),this.store.onIconClick(e,t)}):this.element.on("click",e=>{e.stopPropagation()})}};BI.shortcut("fr.component.linkSet.left.item.icon",BI.inherit(BI.Widget,_));const L={props:{title:"",id:"",creator:""},_store:()=>BI.Models.getModel(j),render(){const{title:e,extraCls:t,creator:i,text:r,id:n}=this.options;return{type:h,cls:"left-item",extraCls:t,items:[{type:s,cls:"link-font",height:24,width:26,text:"连接",title:e},{type:o,cls:"link-title",textAlign:"left",text:e,title:e},{type:h,cls:"icons",items:[{type:"fr.component.linkSet.left.item.icon",cls:"link-text-font",title:"测试连接",id:n},{type:"fr.component.linkSet.left.item.icon",cls:"copy-font",title:"复制",id:n},{type:"fr.component.linkSet.left.item.icon",cls:"info-font",title:`类型:${"DESIGNER"===r?"其他":r} \r\n创建者:${i}`,id:n},{type:"fr.component.linkSet.left.item.icon",cls:"delete-font",title:"删除",id:n}]}]}},mounted(){const{title:e}=this.options;this.element.on("click",()=>{this.store.setLinkSelected(e)})}};BI.shortcut("fr.component.linkSet.left.item",BI.inherit(BI.Widget,L));let D=null;const A={_store:()=>BI.Models.getModel(j),watch:{linkList(e){D.populate(BI.createItems((e=>{const t=[];return e.forEach(e=>{t.push({type:"fr.component.linkSet.left.item",extraCls:e.isSelected?"left-item-selected":"",title:e.connectionName,id:e.connectionId,creator:e.creator,text:e.text?e.text:"默认"})}),t})(e)))}},render:()=>({type:d,ref(e){D=e}})};BI.shortcut("fr.component.linkset.left",BI.inherit(BI.Widget,A));const M={render(){const{text:e,name:t,selected:i}=this.options;return{type:d,cls:"link-item",width:120,height:117,items:[{type:"bi.img",width:120,height:90,src:`./img/${t}.jpg`},{type:c,cls:"selected",invisible:!i,width:30,height:30},{type:o,cls:"text",text:e}]}},mounted(){const{text:e}=this.options;this.element.on("click",()=>{this.fireEvent("EVENT_SELECT",e)})}};BI.shortcut("fr.component.linkSet.morelink.item",BI.inherit(BI.Widget,M));let O=null;const U={render:()=>({type:l,cls:"more-link",items:[{el:{type:d,items:[{type:"bi.search_editor",width:300,watermark:"搜索"}]},height:30},{type:h,cls:"more-link-item",ref(e){O=e}}]}),mounted(){this._renderItems()},_renderItems(e=""){const t=w.slice(12,45),i=[],s=this;t.forEach(t=>{i.push({type:"fr.component.linkSet.morelink.item",text:t.text,name:t.databaseType,selected:e===t.text,listeners:[{eventName:"EVENT_SELECT",action(e){s._renderItems(e),s.fireEvent("EVENT_SELECT",e)}}]})}),O.populate(BI.createItems(i))}};BI.shortcut("fr.component.linkSet.morelink",BI.inherit(BI.Widget,U));let q=null,V="";const P={_store:()=>BI.Models.getModel(j),render(){let e=null;return{type:"bi.combo",cls:"select",trigger:"click",adjustYOffset:4,el:{type:"bi.button",text:"新建数据连接",height:24},popup:{el:{type:"bi.button_group",cls:"database-link-items",items:[...BI.map([...B,...BI.Constants.getConstant(E)],(e,t)=>({type:"bi.text_item",height:24,width:152,text:t,title:t,value:t})),{type:"bi.text_item",cls:"link-item",height:24,width:152,text:"更多数据连接...",title:"更多数据连接...",value:"more"},{type:"bi.text_item",cls:"link-item",height:24,width:152,text:"其他",title:"其他",value:"其他"}],layouts:[{type:d}]},maxHeight:400},listeners:[{eventName:"EVENT_CHANGE",action:t=>{"more"===t?(e=>{const t=BI.UUID();let i=null;BI.Popovers.create(t,{type:"bi.bar_popover",size:"normal",header:"更多数据连接",width:550,height:500,body:{type:"fr.component.linkSet.morelink",listeners:[{eventName:"EVENT_SELECT",action(e){V=e,q.setEnable(!0)}}]},footer:{type:"bi.right_vertical_adapt",lgap:10,items:[{type:"bi.button",text:"取消",value:1,level:"ignore",handler(e){i.close(e)}},{type:"bi.button",text:"确定",disabled:!0,value:0,ref(e){q=e},handler(t){i.close(t),e&&e(V)}}]},ref(e){i=e}}).open(t)})(e=>{this.store.setNewLink(e)}):this.store.setNewLink(t),e.hideView()}}],ref(){e=this}}}};BI.shortcut("fr.linkset.select",BI.inherit(BI.Widget,P));const H={render:()=>({type:"bi.center_adapt",items:[{type:d,width:260,height:180,items:[{type:c,cls:"data-connection-background",width:260,height:130},{type:o,cls:"bi-tips",height:20,text:"请选择左侧数据连接或点击新建数据连接"},{type:o,cls:"bi-tips",height:20,text:"平台仅支持使用JDBC的数据连接的管理"}]}]})};BI.shortcut("fr.component.right.nothing",BI.inherit(BI.Widget,H));const R={_store:()=>BI.Models.getModel(j),render(){const e=this.model.linkSelected,t=this.model.linkList,i=this,{isEdit:s}=this.options;return{type:h,height:40,cls:"right-title",items:[{type:o,cls:"right-title-text",text:`数据连接(${e.text?e.text:"默认"})`},{type:r,cls:"right-title-button",invisible:s,text:"编辑",handler(){i.store.setEdit(!0)}},{type:r,cls:"right-title-button",invisible:!s,text:"保存",handler(){BI.find(t,(e,t)=>i.model.linkUpdate.connectionName===t.connectionName&&t.connectionId!==i.model.linkUpdate.connectionId)?i.store.setConnectionNameErr("数据连接名已存在"):i.store.saveLink()}},{type:r,cls:"right-title-button",invisible:!s,level:"ignore",text:"取消",handler(){i.store.setCancel()}}]}}};BI.shortcut("fr.component.right.title",BI.inherit(BI.Widget,R));const G="fr.shared.component.both.side",W={render(){const{leftText:e,rightText:t}=this.options;return{type:a,cls:"both-side",height:24,items:[{el:{type:o,cls:"left",textAlign:"left",text:e},width:115},{type:o,textAlign:"left",text:t}]}}};BI.shortcut(G,BI.inherit(BI.Widget,W));var F=G;const $={render(){const{text:e}=this.options;return{type:o,cls:"shared-component-title",textAlign:"left",text:e}}};BI.shortcut("fr.shared.component.title",BI.inherit(BI.Widget,$));const Q={_store:()=>BI.Models.getModel(j),render(){const e=this.model.linkSelected;return{type:d,cls:"right-show",items:[{type:F,leftText:"数据连接名",rightText:e.connectionName},{type:F,leftText:"驱动器",rightText:e.driver},{type:F,leftText:"URL",rightText:e.url},{type:F,leftText:"编码",rightText:""===e.originalCharsetName?"自动":e.originalCharsetName},{type:F,leftText:"用户名",rightText:e.user},{type:F,leftText:"密码",rightText:e.password},{type:"fr.shared.component.title",text:"连接池属性"},{type:F,leftText:"SQL验证查询",rightText:e.validationQuery},{type:F,leftText:"获取连接前校验",rightText:e.testOnBorrow?"是":"否"},{type:F,leftText:"最大连接数量",rightText:e.maxActive}]}}};BI.shortcut("fr.component.right.show",BI.inherit(BI.Widget,Q));BI.constant("bi.constant.database.conf.charset.list",[{text:"自动",value:""},{text:"GBK",value:"GBK"},{text:"BIG5",value:"BIG5"},{text:"ISO-8859-1",value:"ISO-8859-1"},{text:"UTF-8",value:"UTF-8"},{text:"UTF-16",value:"UTF-16"},{text:"EUC_JP",value:"EUC_JP"},{text:"EUC_KR",value:"EUC_KR"},{text:"CP850",value:"CP850"}]);const z={render(){const{text:e,form:t,hint:i,height:s}=this.options;return{type:a,cls:"both-side",height:s||24,items:[{el:{type:o,cls:"left",textAlign:"left",text:e},width:115},t,{type:o,cls:"hint",textAlign:"left",text:i}]}}};BI.shortcut("fr.shared.component.form.item",BI.inherit(BI.Widget,z));var K="fr.shared.component.form.item";function X(e){const t=[];return e.drivers&&e.drivers.length>0?e.drivers.forEach(e=>{t.push({text:e,value:e})}):t.push({text:e.driver,value:e.driver}),t}let Y=null;const J={_store:()=>BI.Models.getModel(j),watch:{connectionNameErr(e){e?BI.Bubbles.show("singleBubble",e,Y,{level:"error"}):BI.Bubbles.hide("singleBubble")}},render(){const e=this.model.linkSelected,t=this;return{type:d,cls:"right-show",items:[{type:K,text:"数据连接名",hint:"*修改数据连接名会影响相关数据表和仪表板",form:{type:n,cls:"bi-border",width:300,value:e.connectionName,ref(e){Y=e},listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{connectionName:this.getValue()}))}},{eventName:BI.Editor.EVENT_FOCUS,action(){t.store.setConnectionNameErr("")}}]}},{type:K,text:"第一步",height:400,form:{type:d,cls:"right-form",items:[{type:K,text:"驱动器",form:{type:"bi.text_value_combo",cls:"bi-border",width:300,text:e.driver,items:X(e),listeners:[{eventName:BI.TextValueCombo.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{driver:this.getValue()[0]}))}}]}},{type:K,text:"URL",form:{type:n,cls:"bi-border",watermark:"请输入",width:300,value:e.url,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{url:this.getValue()}))}}]}},{type:K,text:"编码",form:{type:"bi.text_value_combo",cls:"bi-border",width:300,text:""===e.originalCharsetName?"自动":e.originalCharsetName,items:BI.Constants.getConstant("bi.constant.database.conf.charset.list"),listeners:[{eventName:BI.TextValueCombo.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{originalCharsetName:this.getValue()[0]}))}}]}},{type:K,text:"用户名",form:{type:n,cls:"bi-border",allowBlank:!0,watermark:"请输入",width:300,value:e.user,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{user:this.getValue()}))}}]}},{type:K,text:"密码",form:{type:n,cls:"bi-border",inputType:"password",allowBlank:!0,watermark:"请输入",width:300,value:e.password,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{password:this.getValue()}))}}]}},{type:"fr.shared.component.title",text:"连接池属性"},{type:K,text:"SQL验证查询",height:100,form:{type:"bi.textarea_editor",cls:"bi-border",allowBlank:!0,watermark:"请输入",width:300,height:100,value:e.validationQuery,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{validationQuery:this.getValue()}))}}]}},{type:K,text:"获取连接前校验",form:{type:"bi.multi_select_item",text:"是",selected:e.testOnBorrow,width:60,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{testOnBorrow:this.isSelected()}))}}]}},{type:K,text:"最大活动连接数",form:{type:n,cls:"bi-border",allowBlank:!0,watermark:"请输入",width:60,value:e.maxActive,errorText:"请输入有效的正整数",validationChecker:e=>!!/^\+?[1-9][0-9]*$/.test(e),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{maxActive:this.getValue()}))}}]}}]}},{type:K,text:"第二步",form:{type:r,text:"测试连接",level:"ignore"}},{type:K,text:"第三步",form:{type:K,text:"模式",form:{type:n,cls:"bi-border",width:300,disabled:!0}}}]}}};BI.shortcut("fr.component.right.edit",BI.inherit(BI.Widget,J));const Z={_store:()=>BI.Models.getModel(j),render(){const e=this.model.linkSelected,t=this;return{type:d,cls:"right-show",items:[{type:K,text:"数据连接名",hint:"*修改数据连接名会影响相关数据表和仪表板",form:{type:n,cls:"bi-border",width:300,value:e.connectionName,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{connectionName:this.getValue()}))}}]}},{type:K,text:"驱动器",form:{type:"bi.text_value_combo",cls:"bi-border",width:300,text:e.driver,items:X(e),listeners:[{eventName:BI.TextValueCombo.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{driver:this.getValue()[0]}))}}]}},{type:K,text:"URL",form:{type:n,cls:"bi-border",watermark:"请输入",width:300,value:e.url,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{url:this.getValue()}))}}]}},{type:K,text:"编码",form:{type:"bi.text_value_combo",cls:"bi-border",width:300,text:""===e.originalCharsetName?"自动":e.originalCharsetName,items:BI.Constants.getConstant("bi.constant.database.conf.charset.list"),listeners:[{eventName:BI.TextValueCombo.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{originalCharsetName:this.getValue()[0]}))}}]}},{type:K,text:"用户名",form:{type:n,cls:"bi-border",allowBlank:!0,watermark:"请输入",width:300,value:e.user,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{user:this.getValue()}))}}]}},{type:K,text:"密码",form:{type:n,cls:"bi-border",inputType:"password",allowBlank:!0,watermark:"请输入",width:300,value:e.password,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{password:this.getValue()}))}}]}},{type:"fr.shared.component.title",text:"连接池属性"},{type:K,text:"SQL验证查询",height:100,form:{type:"bi.textarea_editor",cls:"bi-border",allowBlank:!0,watermark:"请输入",width:300,height:100,value:e.validationQuery,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{validationQuery:this.getValue()}))}}]}},{type:K,text:"获取连接前校验",form:{type:"bi.multi_select_item",text:"是",selected:e.testOnBorrow,width:60,listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{testOnBorrow:this.isSelected()}))}}]}},{type:K,text:"最大活动连接数",form:{type:n,cls:"bi-border",allowBlank:!0,watermark:"请输入",width:60,value:e.maxActive,errorText:"请输入有效的正整数",validationChecker:e=>!!/^\+?[1-9][0-9]*$/.test(e),listeners:[{eventName:BI.Editor.EVENT_CHANGE,action(){t.store.setLinkUpdate(Object.assign({},t.model.linkUpdate,{maxActive:this.getValue()}))}}]}},{type:K,text:"测试连接",form:{type:r,text:"测试连接",level:"ignore"}}]}}};BI.shortcut("fr.component.right.edit.mysql",BI.inherit(BI.Widget,Z));let ee=null;const te=e=>{const t=BI.Constants.getConstant(E),i=BI.some(t,(t,i)=>i===e.text);let s="mysql"===e.databaseType?"fr.component.right.edit.mysql":"fr.component.right.edit";i&&(s=BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${e.text.toLowerCase()}.edit`));const o=i?BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${e.text.toLowerCase()}.preview`):"fr.component.right.show";ee.populate(BI.createItems([{type:"fr.component.right.title",isEdit:e.isSelected,linkSelected:e},{type:e.isSelected?s:o,linkSelected:e}]))},ie={_store:()=>BI.Models.getModel(j),watch:{linkSelected(e){te(e)}},render:()=>({type:d,cls:"right-content",ref(e){ee=e}}),mounted(){const e=this.model.linkSelected;te(e)}};BI.shortcut("fr.component.right.detail",BI.inherit(BI.Widget,ie));let se=null;const oe={_store:()=>BI.Models.getModel(j),watch:{linkSelected(e){se.populate(BI.createItems([{type:e&&e.connectionName?"fr.component.right.detail":"fr.component.right.nothing"}]))}},render:()=>({type:d,cls:"database-right",ref(e){se=e}}),mounted(){se.populate(BI.createItems([{type:"fr.component.right.nothing"}]))}};BI.shortcut("fr.component.right",BI.inherit(BI.Widget,oe));const re={_store:()=>BI.Models.getModel(j),watch:{tab(e){this.setVisible("数据连接管理"===e)}},render:()=>({type:a,cls:"linkset",items:[{el:{type:l,cls:"database-left",items:[{el:{type:h,cls:"select-group",items:[{type:"fr.linkset.select"}]},height:40},{type:"fr.component.linkset.left",cls:"left-list"}]},width:280},{type:"fr.component.right"}]})};BI.shortcut("fr.linkset",BI.inherit(BI.Widget,re));BI.model("fr.model.linkstatus",BI.inherit(Fix.Model,{context:["tab","linkList"],actions:{}}));const ne={context:["tab","linkList","statusSelected"],state:()=>({selected:""}),actions:{setStatusSelected(e){this.model.statusSelected=e}}};BI.model("fr.model.linkstatus.left",BI.inherit(Fix.Model,ne));const le={props:{title:"",id:"",creator:""},_store:()=>BI.Models.getModel("fr.model.linkstatus.left"),render(){const{title:e,extraCls:t,creator:i,text:s,id:r}=this.options;return{type:h,cls:"left-item",extraCls:t,items:[{type:o,cls:"link-title",textAlign:"left",text:e,title:e}]}},mounted(){const{title:e}=this.options;this.element.on("click",()=>{this.store.setStatusSelected(e)})}};BI.shortcut("fr.component.linkStatus.left.item",BI.inherit(BI.Widget,le));let ae=null;const ce={_store:()=>BI.Models.getModel("fr.model.linkstatus.left"),watch:{linkList(e){const t=e.length>0?e[0].connectionName:"";this.store.setStatusSelected(t)},statusSelected(e){const t=this.model.linkList;ae.populate(BI.createItems(((e,t="")=>{const i=[];return e.forEach(e=>{i.push({type:"fr.component.linkStatus.left.item",extraCls:e.connectionName===t?"left-item-selected":"",title:e.connectionName,id:e.connectionId,creator:e.creator,text:e.text?e.text:"默认"})}),i})(t,e)))}},render:()=>({type:d,ref(e){ae=e}})};BI.shortcut("fr.component.linkStatus.left",BI.inherit(BI.Widget,ce));const de={context:["linkList","statusSelected"],state:()=>({selected:""}),actions:{}};BI.model("fr.model.linkstatus.right",BI.inherit(Fix.Model,de));const he={render(){const{maxActive:e,maxIdle:t,numActive:i,numIdle:s}=this.options;return{type:h,items:[{type:h,cls:"right-status-item",items:[{type:d,cls:"right-status-board",items:[{type:d,cls:"right-status-board-item",items:[{type:o,cls:"right-status-text",extraCls:"card-font1",text:i},{type:o,cls:"right-status-text",text:"/"},{type:o,cls:"right-status-text",text:e}]},{type:o,height:20,text:"活动连接数"}]}]},{type:h,cls:"right-status-right",items:[{type:d,cls:"right-status-board",items:[{type:d,cls:"right-status-board-item",items:[{type:o,cls:"right-status-text",extraCls:"card-font2",text:s},{type:o,cls:"right-status-text",text:"/"},{type:o,cls:"right-status-text",text:t}]},{type:o,height:20,text:"空闲连接数"}]}]}]}}};BI.shortcut("fr.component.linkStatus.right.card",BI.inherit(BI.Widget,he));let pe=null,me=null;const be={_store:()=>BI.Models.getModel("fr.model.linkstatus.right"),watch:{statusSelected(e){const t=BI.find(this.model.linkList,(t,i)=>i.connectionName===e),i=BI.Constants.getConstant(E),s=t.text&&BI.some(i,(e,i)=>i===t.text)?BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${t.text.toLowerCase()}.pool`):"fr.component.linkStatus.right.card";!function(e,t){console.log("%cname: ","color: MidnightBlue; background: Aquamarine;",e),f?f.reqDeleta(`/v10/config/connection/pool/info?connectionName=${e}`,e=>{t(e.data)}):t({maxActive:50,maxIdle:10,numActive:0,numIdle:0})}(name,e=>{me.populate(BI.createItems([Object.assign({type:s},e)]))}),pe.setText(`数据连接(${e})`)}},render:()=>({type:d,cls:"database-right",items:[{type:h,height:40,cls:"right-status-title",items:[{type:o,text:"数据连接"}],ref(e){pe=e}},{type:d,cls:"right-status-body",ref(e){me=e}}]}),mounted(){}};BI.shortcut("fr.component.linkStatus.right",BI.inherit(BI.Widget,be));const ue={_store:()=>BI.Models.getModel("fr.model.linkstatus"),watch:{tab(e){this.setVisible("连接池状态"===e)}},render:()=>({type:a,cls:"linkStatus",items:[{el:{type:l,cls:"database-left",items:[{el:{type:h,cls:"select-group",items:[{type:o,cls:"status-title",text:"数据连接"}]},height:40},{type:"fr.component.linkStatus.left",cls:"left-list"}]},width:280},{type:"fr.component.linkStatus.right"}]}),mounted(){this.setVisible(!1)}};BI.shortcut("fr.linkstatus",BI.inherit(BI.Widget,ue));i(1);const ge={url:"192.168.1.22",port:6379,password:"123456"},ye=BI.inherit(BI.Widget,{render:()=>({type:"bi.vertical",cls:"bi-plugin-redis",bgap:10,items:[{type:"bi.left",height:30,items:[{type:"bi.label",text:"数据库地址:",height:24,width:115,textAlign:"left"},{type:"bi.editor",cls:"bi-border",watermark:"数据库地址",value:ge.url,allowBlank:!0,width:300,height:24}]},{type:"bi.left",height:30,items:[{type:"bi.label",text:"端口:",height:24,width:115,textAlign:"left"},{type:"bi.editor",cls:"bi-border",watermark:"端口",allowBlank:!0,width:300,height:24,value:ge.port,errorText:"请输入有效的正整数",validationChecker:e=>!!/^\+?[1-9][0-9]*$/.test(e)}]},{type:"bi.left",height:30,items:[{type:"bi.label",text:"密码:",height:24,width:115,textAlign:"left"},{type:"bi.editor",cls:"bi-border",inputType:"password",value:ge.password,allowBlank:!0,width:300,height:24}]}]})});BI.shortcut("fr.plugin.redis.edit",ye);BI.config("dec.constant.database.conf.connect.list",e=>[...e,"Redis"]),BI.constant("dec.constant.database.conf.connect.form.redis.value",ge),BI.constant("dec.constant.database.conf.connect.form.redis.edit","fr.plugin.redis.edit");i(2),i(3),i(4);const fe=BI.inherit(BI.Widget,{_store:()=>BI.Models.getModel("fr.model.main"),render:()=>({type:l,cls:"database-connection-layout",items:[{el:{type:"fr.title"},height:40},{type:"fr.linkset"},{type:"fr.linkstatus"}]}),mounted(){var e;e=(e=>{this.store.setLinkList(e)}),f?f.reqGet("/v10/config/connection/list","getInstalledPlugins",t=>{e(t.data)}):e(y.data)}});BI.shortcut("fr.main",fe);t.default="fr.main"}]); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/dcm/style.css b/designer-base/src/main/resources/com/fr/design/dcm/style.css new file mode 100644 index 000000000..5208edfa3 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/dcm/style.css @@ -0,0 +1,276 @@ +.bi-plugin-redis { + padding: 20px; } + +.database-connection-layout { + width: 100%; + height: 100%; + background-color: #f7f8fa; } + .database-connection-layout .title { + background-color: #fff; + border-bottom: 1px solid #e8eaed; } + .database-connection-layout .title .title-item { + height: 39px; + line-height: 39px; + padding-left: 15px; + padding-right: 15px; + text-align: center; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + position: relative; + flex-shrink: 0; + font-weight: 700; + cursor: pointer; } + .database-connection-layout .title .close-button { + position: absolute !important; + right: 5px; + top: 5px; + width: 30px; + height: 30px; + cursor: pointer; + background-image: url(./img/icon_close9x9_normal.png); + background-repeat: no-repeat; + background-position: center; } + .database-connection-layout .linkset { + margin: 10px; + bottom: 0px; + background-color: #ffffff; } + .database-connection-layout .linkStatus { + margin: 10px; + top: 40px; + background-color: #ffffff; } + +.database-left { + border-right: 1px solid #e8eaed; } + .database-left .select-group { + border-bottom: 1px solid #e8eaed; } + .database-left .select-group .select { + margin: 10px; } + .database-left .select-group .select .database-link-items { + padding-left: 10px; } + .database-left .select-group .select .database-link-items .link-item { + border-top: 1px solid #e8eaed; } + .database-left .select-group .status-title { + font-weight: 700; + margin-left: 12px; + margin-top: 12px; } + .database-left .left-list { + margin: 10px; } + .database-left .left-list .left-item { + height: 24px; + line-height: 24px; + cursor: pointer; } + .database-left .left-list .left-item:hover { + background-color: rgba(54, 133, 242, 0.05); } + .database-left .left-list .left-item:hover .icons .action-icon { + visibility: visible !important; } + .database-left .left-list .left-item .icons { + float: right !important; } + .database-left .left-list .left-item .icons .action-icon { + visibility: hidden; } + .database-left .left-list .left-item .icons .b-font { + font-size: 16px; } + .database-left .left-list .left-item-selected { + background-color: rgba(54, 133, 242, 0.05); } + .database-left .left-list .left-item-selected .link-title { + color: #3685f2; } + +.database-right { + min-width: 400px; + overflow: auto; } + .database-right .bi-flex-center-adapt-layout { + height: 100%; } + .database-right .bi-flex-center-adapt-layout .data-connection-background { + background: url(./img/resources.png) center center no-repeat; + background-size: contain; } + .database-right .right-status-title { + border-bottom: 1px solid #e8eaed; + color: #3d4d66; + line-height: 40px; + padding-left: 10px; + font-weight: 700; } + .database-right .right-status-body { + margin: 10px 30px 0px 30px; + height: 50%; } + .database-right .right-status-body .right-status-item { + height: 150px; + width: 50%; + top: 0; + left: 0; + position: absolute !important; } + .database-right .right-status-body .right-status-item .right-status-board { + margin-left: 25px; + position: relative !important; + left: -25px; } + .database-right .right-status-body .right-status-right { + height: 150px; + width: 50%; + top: 0; + right: 0; + position: absolute !important; } + .database-right .right-status-body .right-status-right .right-status-board { + margin-right: 25px; + position: relative !important; + left: 25px; } + .database-right .right-status-body .right-status-board { + background-color: #f7f8fa; + color: #3d4d66; + width: 100%; + height: 100%; } + .database-right .right-status-body .right-status-board .right-status-board-item { + text-align: center; + margin-top: 38px; } + .database-right .right-status-body .right-status-board .right-status-board-item .right-status-text { + display: inline-block; } + .database-right .right-status-body .right-status-board .right-status-board-item .card-font1 { + color: #13CD66; + font-size: 32px; } + .database-right .right-status-body .right-status-board .right-status-board-item .card-font2 { + color: #3685F2; + font-size: 32px; } + .database-right .right-content { + height: 100%; } + .database-right .right-content .right-title { + border-bottom: 1px solid #e8eaed; + color: #3d4d66; + line-height: 40px; + padding-left: 10px; } + .database-right .right-content .right-title .right-title-text { + font-weight: 700; } + .database-right .right-content .right-title .right-title-button { + float: right !important; + margin-right: 10px; + margin-top: 8px; } + .database-right .right-content .right-show { + margin: 10px; } + .database-right .right-content .right-show .right-form { + width: 100%; } + +.both-side { + line-height: 24px; + margin-bottom: 10px; } + .both-side .left { + white-space: nowrap; + text-overflow: ellipsis; + position: relative; + flex-shrink: 0; + font-weight: 700; } + .both-side .hint { + padding-left: 5px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + position: relative; + flex-shrink: 0; + margin-left: 5px; + color: #9ea6b2; } + +.shared-component-title { + height: 24px; + line-height: 24px; + margin-bottom: 10px; + color: #9ea6b2; + border-bottom: 1px solid #e8eaed; } + +.comfirm-content { + margin-top: 40px; + margin-left: 20px; } + .comfirm-content .comfirm-icon { + background-image: url(./img/warning.png); + background-size: contain; + margin-right: 12px; } + .comfirm-content .bi-text { + height: 50px; + line-height: 50px; + margin-left: 12px; } + +.more-link .more-link-item { + width: 538px; + overflow: hidden auto; + left: -10px !important; + right: 0px; + top: 10px; + bottom: 0px; + position: absolute; + height: 380px; } + .more-link .more-link-item .link-item { + margin-left: 10px; + margin-bottom: 10px; + cursor: pointer; + border: solid 1px #fff; } + .more-link .more-link-item .link-item:hover { + border: solid 1px #3480f2; } + .more-link .more-link-item .link-item .selected { + position: absolute !important; + right: -1px; + top: -1px; + height: 30px; + width: 30px; + background: url(./img/database-selected.png) center center no-repeat; + background-size: contain; } + .more-link .more-link-item .link-item .text { + height: 27px; + line-height: 27px; + padding-left: 2px; + padding-right: 2px; + text-align: center; + white-space: nowrap; + background: #F0F3F7; } + +.popover-notitle .bi-header-background { + display: none; } + +.popover-notitle .bi-absolute-layout { + top: 0px !important; } + +.bi-custom-show .show-content { + text-align: center; } + .bi-custom-show .show-content .loading-icon { + display: block; + background: url(./img/loading.gif) center center no-repeat; + background-size: contain; + margin: 0 auto; + margin-bottom: 18px; } + .bi-custom-show .show-content .success-icon { + display: block; + background: url(./img/success.png) center center no-repeat; + background-size: contain; + margin: 0 auto; + margin-bottom: 18px; } + .bi-custom-show .show-content .error-icon { + display: block; + background: url(./img/error.png) center center no-repeat; + background-size: contain; + margin: 0 auto; + margin-bottom: 18px; } + .bi-custom-show .show-content .buttons { + margin-top: 18px; } + .bi-custom-show .show-content .buttons div { + margin: 0 4px; } + +.bi-custom-show .show-more { + text-align: left !important; + height: 73px; + background: #F2F4F7; + margin-bottom: 10px; + padding: 5px; + margin-top: 10px; } + +.link-font .b-font:before { + content: "\e759"; + color: inherit; } + +.link-text-font .b-font:before { + content: "\e763"; + color: inherit; } + +.info-font .b-font:before { + content: "\e63c"; + color: inherit; } + +.delete-font .b-font:before { + content: "\e6c4"; + color: inherit; } + + +/*# sourceMappingURL=style.css.map*/ \ No newline at end of file diff --git a/designer-base/src/main/resources/com/fr/design/upm/warn.js b/designer-base/src/main/resources/com/fr/design/upm/warn.js index 1eb5fb640..be4b06909 100644 --- a/designer-base/src/main/resources/com/fr/design/upm/warn.js +++ b/designer-base/src/main/resources/com/fr/design/upm/warn.js @@ -4,7 +4,7 @@ window.onload = function () { text: PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Resource_Warn"), height: 30 }); - let callback = function(text) { + let callback = function(status, text) { download.setValue(text); }; let buttonOK = BI.createWidget({ diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java index 5fa180ffe..10664b340 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapSourceChoosePane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.map.designer.type; import com.fr.base.Parameter; import com.fr.base.Utils; +import com.fr.decision.webservice.v10.map.WMSFactory; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.file.HistoryTemplateListPane; @@ -19,6 +20,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.JTemplate; import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpClient; +import com.fr.geojson.helper.GEOJSONHelper; import com.fr.plugin.chart.base.GisLayer; import com.fr.plugin.chart.base.ViewCenter; import com.fr.plugin.chart.map.VanChartMapPlot; @@ -26,9 +28,7 @@ import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; import com.fr.plugin.chart.map.layer.WMSLayer; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.map.server.CompatibleGEOJSONHelper; -import com.fr.geojson.helper.GEOJSONHelper; import com.fr.plugin.chart.map.server.MapLayerConfigManager; -import com.fr.plugin.chart.service.WMSFactory; import com.fr.plugin.chart.type.GISLayerType; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; @@ -57,6 +57,7 @@ import java.awt.event.ItemListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.util.ArrayList; +import java.util.List; /** * Created by Mitisky on 16/5/11. @@ -380,7 +381,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { public void actionPerformed(ActionEvent e) { new SwingWorker() { - private java.util.List list; + private java.util.List list = new ArrayList<>(); @Override protected Void doInBackground() throws Exception { @@ -392,7 +393,11 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { } String res = httpClient.getResponseText(); - list = WMSFactory.readLayers(res); + List layers = WMSFactory.readLayers(res); + list.clear(); + for (String layer : layers) { + list.add(new WMSLayer(layer, false)); + } return null; } diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/FormWidgetAuthorityEditPane.java b/designer-form/src/main/java/com/fr/design/designer/properties/FormWidgetAuthorityEditPane.java index 6f84aaa32..b66293cfc 100644 --- a/designer-form/src/main/java/com/fr/design/designer/properties/FormWidgetAuthorityEditPane.java +++ b/designer-form/src/main/java/com/fr/design/designer/properties/FormWidgetAuthorityEditPane.java @@ -4,14 +4,18 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.tree.TreePath; import com.fr.design.constants.LayoutConstants; -import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.AuthorityEditPane; @@ -22,6 +26,9 @@ import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; /** @@ -34,15 +41,21 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { private Widget[] widgets = null; private UICheckBox widgetVisible = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Visible")); private UICheckBox widgetAvailable = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Enabled")); + private String[] selectedArray; private ItemListener visibleItemListener = new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (selectedRoles == null) { return; } - if (widgets != null && widgets.length > 0) { - for (int i = 0; i < widgets.length; i++) { - widgets[i].changeVisibleAuthorityState(selectedRoles, widgetVisible.isSelected()); + initSelectedArray(); + if (ArrayUtils.isEmpty(selectedArray)) { + return; + } + for (String selectedRole : selectedArray) { + for (Widget widget : widgets) { + widget.changeVisibleAuthorityState(selectedRole, widgetVisible.isSelected()); } } doAfterAuthority(); @@ -51,6 +64,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { private ItemListener usableItemListener = new ItemListener() { + @Override public void itemStateChanged(ItemEvent e) { String selectedRoles = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); if (ComparatorUtils.equals(selectedRoles, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Role"))) { @@ -59,9 +73,13 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { if (selectedRoles == null) { return; } - if (widgets != null && widgets.length > 0) { - for (int i = 0; i < widgets.length; i++) { - widgets[i].changeUsableAuthorityState(selectedRoles, widgetAvailable.isSelected()); + initSelectedArray(); + if (ArrayUtils.isEmpty(selectedArray)) { + return; + } + for (String selectedRole : selectedArray) { + for (Widget widget : widgets) { + widget.changeUsableAuthorityState(selectedRole, widgetAvailable.isSelected()); } } doAfterAuthority(); @@ -78,7 +96,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { private void doAfterAuthority() { designer.repaint(); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); RolesAlreadyEditedPane.getInstance().refreshDockingView(); RolesAlreadyEditedPane.getInstance().setReportAndFSSelectedRoles(); RolesAlreadyEditedPane.getInstance().repaint(); @@ -90,6 +108,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { * * @date 2014-12-21-下午6:19:43 */ + @Override public void populateType() { type.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Form_Widget_Config")); } @@ -99,15 +118,16 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { * * @date 2014-12-21-下午7:12:27 */ + @Override public void populateName() { - String nameText = ""; if (widgets == null || widgets.length <= 0) { return; } - for (int i = 0; i < widgets.length; i++) { - nameText += "," + widgets[i].getClass().getSimpleName(); + List widgetNames = new ArrayList(); + for (Widget widget : widgets) { + widgetNames.add(widget.getClass().getSimpleName()); } - name.setText(nameText.substring(1)); + name.setText(StableUtils.join(widgetNames, ",")); } /** @@ -116,6 +136,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { * @return 面板 * @date 2014-12-21-下午6:19:03 */ + @Override public JPanel populateCheckPane() { checkPane.add(populateWidgetCheckPane(), BorderLayout.CENTER); checkPane.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); @@ -138,10 +159,11 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { /** * 对单元格区域进行操作时的权限编辑页面 */ + @Override public void populateDetials() { //更新说明要是JWorkBook的话,说明鼠标焦点又改变了 - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setAuthorityMode(true); - signelSelection(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().setAuthorityMode(true); + singleSelection(); refreshCreator(); //如果是布局选中不支持的元素则显示“该元素不支持权限控制” @@ -186,8 +208,8 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { //实现单选 - private void signelSelection() { - if (HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().isJWorkBook()) { + private void singleSelection() { + if (HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().isJWorkBook()) { //清工具栏 JComponent component = DesignerContext.getDesignerFrame().getToolbarComponent(); if (component instanceof AuthorityEditToolBarComponent) { @@ -195,7 +217,7 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { } //清空报表主体的单元格选择 - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().removeTemplateSelection(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().removeTemplateSelection(); } } @@ -204,5 +226,40 @@ public class FormWidgetAuthorityEditPane extends AuthorityEditPane { widgets = size == 0 ? null : designer.getSelectionModel().getSelection().getSelectedWidgets(); } + private void initSelectedArray() { + TreePath[] selectionPaths = ReportAndFSManagePane.getInstance().getRoleTree().getCheckBoxTreeSelectionModel().getSelectionPaths(); + if (selectionPaths.length == 1) { + if (((ExpandMutableTreeNode) (selectionPaths[0].getLastPathComponent())).getChildCount() > 0) { + ExpandMutableTreeNode node = (ExpandMutableTreeNode) ((ExpandMutableTreeNode) (selectionPaths[0].getLastPathComponent())).getLastChild(); + selectedArray = new String[node.getChildCount()]; + for (int i = 0, len = node.getChildCount(); i < len; i++) { + ExpandMutableTreeNode treeNode = (ExpandMutableTreeNode) node.getChildAt(i); + String nodeName = treeNode.getUserObject().toString(); + selectedArray[i] = nodeName; + } + } else { + selectedArray = pathToString(selectionPaths); + } + } else { + selectedArray = pathToString(selectionPaths); + } + } + + private String[] pathToString(TreePath[] path) { + List roles = new ArrayList(); + if (!ArrayUtils.isEmpty(path)) { + for (TreePath tempPath : path) { + String temp = tempPath.toString(); + boolean exist = StringUtils.isNotEmpty(temp) && temp.startsWith("[") && temp.endsWith("]"); + if (exist) { + temp = temp.substring(1, temp.length() - 1); + String[] selectedRoles = temp.split("," + StringUtils.BLANK); + String role = selectedRoles[2].trim(); + roles.add(role); + } + } + } + return roles.toArray(new String[0]); + } } diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPaneNoPop.java b/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPaneNoPop.java index 313b57147..051c7bd49 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPaneNoPop.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPaneNoPop.java @@ -23,4 +23,9 @@ public class FormHyperlinkGroupPaneNoPop extends FormHyperlinkGroupPane{ protected boolean isNewStyle() { return false; } + + @Override + public void saveSettings() { + // do nothing + } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index 04864c98a..ff8ef4411 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -195,7 +195,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { Component[] components = xWFitLayout.getComponents(); xWFitLayout.removeAll(); layout.resetStyle(); - XWAbsoluteBodyLayout xwAbsoluteBodyLayout = new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)); + XWAbsoluteBodyLayout xwAbsoluteBodyLayout = xWFitLayout.getBackupParent() == null ? new XWAbsoluteBodyLayout(wAbsoluteBodyLayout, new Dimension(0, 0)) : (XWAbsoluteBodyLayout) xWFitLayout.getBackupParent(); xWFitLayout.getLayoutAdapter().addBean(xwAbsoluteBodyLayout, 0, 0); for (Component component : components) { XCreator xCreator = (XCreator) component; @@ -208,6 +208,7 @@ public class FRFitLayoutDefinePane extends AbstractDataModify { } xwAbsoluteBodyLayout.add(component); } + xWFitLayout.setBackupParent(xwAbsoluteBodyLayout); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); formDesigner.getSelectionModel().setSelectedCreators( FormSelectionUtils.rebuildSelection(xWFitLayout, new Widget[]{wAbsoluteBodyLayout})); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 07136bc1e..6e72e98fe 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -68,6 +68,7 @@ import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; +import com.fr.general.ImageWithSuffix; import com.fr.general.ModuleContext; import com.fr.grid.Grid; import com.fr.grid.GridUtils; @@ -89,6 +90,7 @@ import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.worksheet.WorkSheet; import com.fr.stable.ArrayUtils; +import com.fr.stable.CoreGraphHelper; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.module.Module; @@ -621,7 +623,7 @@ public class JWorkBook extends JTemplate { if (workBook instanceof WorkBookAdapter) { elem.setValue(new CellImagePainter(cellImage)); } else { - elem.setValue(cellImage.getImage()); + elem.setValue(ImageWithSuffix.build(cellImage.getImage(),cellImage.getSuffix())); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/AbstractSendDataToCloud.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/AbstractSendDataToCloud.java index da98e4778..77f370d9d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/AbstractSendDataToCloud.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/AbstractSendDataToCloud.java @@ -98,9 +98,11 @@ public abstract class AbstractSendDataToCloud implements XMLable { } private void generateThisPageFile(DataList points) { - File file = null; try { JSONArray jsonArray = dealWithSendFunctionContent(points); + if (jsonArray == null) { + return; + } //生成json文件 fileEntityBuilder.generateFile(jsonArray, getFileEntityBuilder().getFolderName()); } catch (Exception e) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/FocusPointMessageUploader.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/FocusPointMessageUploader.java index 214806c2e..62f822af5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/FocusPointMessageUploader.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/impl/FocusPointMessageUploader.java @@ -38,6 +38,9 @@ public class FocusPointMessageUploader extends AbstractSendDataToCloud { @Override public JSONArray dealWithSendFunctionContent(DataList focusPoints) { + if (focusPoints == null) { + return null; + } JSONArray ja = new JSONArray(); for(T t:focusPoints.getList()){ FocusPoint focusPoint = (FocusPoint)t; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java index dac28a627..10a1ee0bd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/socketio/DesignerSocketIO.java @@ -5,7 +5,7 @@ import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.design.EnvChangeEntrance; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.loghandler.DesignerLogHandler; +import com.fr.design.mainframe.loghandler.DesignerLogger; import com.fr.event.EventDispatcher; import com.fr.log.FineLoggerFactory; import com.fr.report.RemoteDesignConstants; @@ -46,7 +46,7 @@ public class DesignerSocketIO { if (ArrayUtils.isNotEmpty(objects)) { try { LoggingEvent event = SerializerHelper.deserialize((byte[]) objects[0]); - DesignerLogHandler.getInstance().printLoggingEvent(event); + DesignerLogger.log(event); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java b/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java index 77a662d6d..ba57676ec 100644 --- a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java @@ -2,16 +2,15 @@ package com.fr.design.report; import com.fr.base.BaseUtils; import com.fr.base.Style; -import com.fr.base.frpx.pack.PictureCollection; -import com.fr.base.frpx.util.ImageIOHelper; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.style.background.image.ImageFileChooser; import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.design.utils.ImageUtils; import com.fr.design.utils.gui.GUICoreUtils; - +import com.fr.general.ImageWithSuffix; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.painter.CellImagePainter; @@ -28,6 +27,7 @@ import java.awt.GridLayout; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; import java.io.File; /** @@ -46,11 +46,6 @@ public class SelectImagePane extends BasicPane { private Image previewImage = null; - /** - * 默认格式 - */ - private String suffix = PictureCollection.DEFAULT_SUFFIX; - private File imageFile; public SelectImagePane() { @@ -127,13 +122,12 @@ public class SelectImagePane extends BasicPane { if (selectedFile != null && selectedFile.isFile()) { String filePath = selectedFile.getPath(); - suffix = ImageIOHelper.getSuffix(filePath); - Image image = BaseUtils.readImage(filePath); + BufferedImage image = BaseUtils.readImage(filePath); CoreGraphHelper.waitForImage(image); imageFile = selectedFile; setImageStyle(); - previewPane.setImage(image); + previewPane.setImageWithSuffix(ImageWithSuffix.build(image, ImageUtils.getImageType(selectedFile))); previewPane.setImageStyle(imageStyle); previewImage = image; } else { @@ -184,7 +178,6 @@ public class SelectImagePane extends BasicPane { setImage((Image) value); } else if (value instanceof CellImagePainter) { setImage(((CellImagePainter) value).getImage()); - suffix = ((CellImagePainter) value).getSuffix(); } style = cell.getStyle(); @@ -214,11 +207,8 @@ public class SelectImagePane extends BasicPane { public CellImage update() { CellImage cellImage = new CellImage(); - cellImage.setImage(previewPane.getImage()); + cellImage.setImage(previewPane.getImageWithSuffix()); cellImage.setStyle(this.imageStyle); - if (suffix != null) { - cellImage.setSuffix(suffix); - } return cellImage; } diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/ParameterTreeComboBox.java b/designer-realize/src/main/java/com/fr/design/widget/ui/ParameterTreeComboBox.java index e7db157a9..0383b83b7 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/ParameterTreeComboBox.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/ParameterTreeComboBox.java @@ -161,7 +161,7 @@ public class ParameterTreeComboBox extends FRTreeComboBox { // 全局数据源参数 parameters = new Parameter[0]; Calculator c = Calculator.createCalculator(); - TableDataConfig tableDataConfig = TableDataConfig.getInstance(); + TableDataConfig tableDataConfig = TableDataConfig.getInstance().mirror(); Iterator nameIt = tableDataConfig.getTableDatas().keySet().iterator(); while (nameIt.hasNext()) { TableData tableData = tableDataConfig.getTableData(nameIt.next()); diff --git a/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java index 4c4342291..e68bd907b 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/GridCornerMouseHandler.java @@ -29,6 +29,8 @@ public class GridCornerMouseHandler extends MouseInputAdapter { private void doSelectAll() { ElementCasePane reportPane = this.gridCorner.getElementCasePane(); + // 全选时,停止编辑状态 + reportPane.getGrid().stopEditing(); ColumnRow lastColumnRow = GridUtils.getAdjustLastColumnRowOfReportPane(reportPane); reportPane.setSelection(new CellSelection(0, 0, lastColumnRow.getColumn(), lastColumnRow.getRow())); diff --git a/designer-realize/src/main/java/com/fr/start/SplashContext.java b/designer-realize/src/main/java/com/fr/start/SplashContext.java index 17eff62ba..87a4237e0 100644 --- a/designer-realize/src/main/java/com/fr/start/SplashContext.java +++ b/designer-realize/src/main/java/com/fr/start/SplashContext.java @@ -1,6 +1,7 @@ package com.fr.start; import com.fr.design.DesignerEnvManager; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -26,6 +27,7 @@ public class SplashContext { public static final String SPLASH_PATH = getSplashPath(); public static final String SPLASH_CACHE_NAME = SPLASH_PATH.substring(SPLASH_PATH.lastIndexOf("/") + 1); private static final int FETCH_ONLINE_MAX_TIMES = 50; + private static final String THANKS = Toolkit.i18nText("Fine-Design_Report_Thanks_To"); private static final SplashContext SPLASH_CONTEXT = new SplashContext(); @@ -147,7 +149,7 @@ public class SplashContext { if (shouldShowThanks()) { tryFetchOnline(); if (StringUtils.isNotEmpty(guest)) { - updateThanksLog(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Thanks_To") + guest); + updateThanksLog(THANKS + guest); } } } @@ -175,4 +177,4 @@ public class SplashContext { return "/com/fr/design/images/splash_10.gif"; } } -} +} \ No newline at end of file