diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 7c37b13b88..ae06d6fa13 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -14,6 +14,7 @@ import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.style.color.ColorSelectConfigManager; @@ -23,6 +24,8 @@ import com.fr.general.ComparatorUtils; import com.fr.general.FRLogFormatter; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import com.fr.general.xml.GeneralXMLTools; import com.fr.log.FineLoggerFactory; import com.fr.stable.CommonUtils; @@ -146,7 +149,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { /** * alphafine */ - private AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); + private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance(); private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance(); @@ -182,6 +185,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { public static DesignerEnvManager getEnvManager(boolean needCheckEnv) { if (designerEnvManager == null) { designerEnvManager = new DesignerEnvManager(); + //REPORT-15332有一个国际化调用比较早,需要在这边就设置好locale,由于后台GeneralContext默认是China + GeneralContext.setLocale(designerEnvManager.getLanguage()); try { XMLTools.readFileXML(designerEnvManager, designerEnvManager.getDesignerEnvFile()); } catch (Exception e) { @@ -695,7 +700,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @return 是否加入产品改良 */ public boolean isJoinProductImprove() { - return joinProductImprove; + LocaleMark localeMark = LocaleCenter.getMark(ProductImproveMark.class); + return localeMark.getValue() && this.joinProductImprove; } /** @@ -1517,7 +1523,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } private void readAlphaFineAttr(XMLableReader reader) { - reader.readXMLObject(this.alphaFineConfigManager = new AlphaFineConfigManager()); + reader.readXMLObject(this.alphaFineConfigManager = AlphaFineConfigManager.getInstance()); } private void readHttpsParas(XMLableReader reader) { diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 110b97563c..c1c11553f7 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -22,9 +22,9 @@ import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; import com.fr.workspace.Workspace; -import com.fr.workspace.connect.AuthException; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; +import com.fr.workspace.engine.exception.WorkspaceAuthException; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -102,11 +102,7 @@ public class EnvChangeEntrance { return false; } - //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 - JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - if (template != null) { - template.refreshToolArea(); - } + WorkContext.switchTo(workspace, new WorkContextCallback() { @Override public void done() { @@ -119,8 +115,13 @@ public class EnvChangeEntrance { } } }); + //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (template != null) { + template.refreshToolArea(); + } - } catch (AuthException | RegistEditionException e) { + } catch (WorkspaceAuthException | RegistEditionException e) { // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); strategy.showTip(new PopTip() { diff --git a/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java new file mode 100644 index 0000000000..9ab799bccd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/community/FacebookFansAction.java @@ -0,0 +1,41 @@ +package com.fr.design.actions.community; + +import com.fr.design.menu.MenuKeySet; +import com.fr.design.utils.BrowseUtils; +import com.fr.general.CloudCenter; +import com.fr.general.IOUtils; + +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; + +public class FacebookFansAction extends UpAction { + + public FacebookFansAction() { + this.setMenuKeySet(FACEBOOKFANS); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/bbs/facebook.png")); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + BrowseUtils.browser(CloudCenter.getInstance().acquireUrlByKind("facebook.fans.tw")); + } + + public static final MenuKeySet FACEBOOKFANS = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'F'; + } + + @Override + public String getMenuName() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community_FaceBook_Fans"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; +} 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 8e9fd5b32e..f3cb21bc70 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 @@ -1,15 +1,16 @@ package com.fr.design.actions.community; -import com.fr.base.BaseUtils; import com.fr.design.actions.UpdateAction; +import com.fr.design.locale.impl.VideoMark; 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 com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import javax.swing.*; import java.awt.event.ActionEvent; -import java.util.Locale; + public class VideoAction extends UpdateAction { @@ -19,21 +20,15 @@ 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")); } @Override public void actionPerformed(ActionEvent arg0) { - String url; - if (GeneralContext.getLocale().equals(Locale.US)) { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); - } else { - url = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); - } - BrowseUtils.browser(url); - + LocaleMark localeMark = LocaleCenter.getMark(VideoMark.class); + BrowseUtils.browser(localeMark.getValue()); } public static final MenuKeySet VIDEO = new MenuKeySet() { @Override diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java index eb652abb81..08273202d1 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferenceAction.java @@ -4,9 +4,10 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.KeySetUtils; @@ -38,9 +39,10 @@ public class PreferenceAction extends UpdateAction { preferencePane.update(DesignerEnvManager.getEnvManager()); DesignerEnvManager.loadLogSetting(); DesignerEnvManager.getEnvManager().saveXMLFile(); - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); jt.refreshToolArea(); preferencePane.showRestartDialog(); + DesignerFrameFileDealerPane.getInstance().refreshDockingView(); } }); diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 9293500812..2a856f159d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -2,11 +2,13 @@ package com.fr.design.actions.file; import com.fr.base.BaseUtils; import com.fr.config.Configuration; +import com.fr.config.ServerPreferenceConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.DialogActionListener; import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.ibutton.UIButton; @@ -30,6 +32,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; +import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.general.log.Log4jConfig; import com.fr.locale.InterProviderFactory; @@ -78,6 +81,7 @@ public class PreferencePane extends BasicPane { private static final int CACHING_DEFAULT = 5; private static final int CACHING_GAP = 5; private static final int MEMORY_TIP_LABEL_MAX_WIDTH = 230; + private static final int OFFSET_HEIGHT = 50; private static final String TYPE = "pressed"; private static final String DISPLAY_TYPE = "+"; @@ -132,10 +136,11 @@ public class PreferencePane extends BasicPane { private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox; private UIDictionaryComboBox languageComboBox; private IntegerEditor portEditor; - private UITextField jdkHomeTextField; private UICheckBox oracleSpace; private UISpinner cachingTemplateSpinner; private UICheckBox openDebugComboBox; + private UICheckBox useOptimizedUPMCheckbox; + private UICheckBox useUniverseDBMCheckbox; private UICheckBox joinProductImproveCheckBox; private UICheckBox autoPushUpdateCheckBox; @@ -190,6 +195,16 @@ public class PreferencePane extends BasicPane { debuggerPane.add(openDebugComboBox, BorderLayout.CENTER); advancePane.add(debuggerPane); + JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager")); + useOptimizedUPMCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); + upmSelectorPane.add(useOptimizedUPMCheckbox); + advancePane.add(upmSelectorPane); + + JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Manager")); + useUniverseDBMCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Use_Universe_Database_Manager")); + dbmSelectorPane.add(useUniverseDBMCheckbox); + advancePane.add(dbmSelectorPane); + JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Product_Improve")); joinProductImproveCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Join_Product_Improve")); improvePane.add(joinProductImproveCheckBox); @@ -210,7 +225,7 @@ public class PreferencePane extends BasicPane { JPanel vcsPane = FRGUIPaneFactory.createVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Vcs_Title")); generalPane.add(vcsPane); remindVcsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Remind")); - remindVcsLabel.setVisible(!VcsHelper.needInit()); + remindVcsLabel.setVisible(!VcsHelper.getInstance().needInit()); vcsEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_SaveAuto")); saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete")); saveIntervalEditor = new IntegerEditor(60); @@ -219,8 +234,8 @@ public class PreferencePane extends BasicPane { enableVcsPanel.add(vcsEnableCheckBox); enableVcsPanel.add(remindVcsLabel); JPanel intervalPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); - UILabel everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every")); - UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay")); + final UILabel everyLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Every")); + final UILabel delayLabel = new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Delay")); intervalPanel.add(useIntervalCheckBox); intervalPanel.add(everyLabel); intervalPanel.add(saveIntervalEditor); @@ -233,10 +248,14 @@ public class PreferencePane extends BasicPane { saveCommitCheckBox.setEnabled(true); saveIntervalEditor.setEnabled(true); useIntervalCheckBox.setEnabled(true); + everyLabel.setEnabled(true); + delayLabel.setEnabled(true); } else { saveCommitCheckBox.setEnabled(false); saveIntervalEditor.setEnabled(false); useIntervalCheckBox.setEnabled(false); + everyLabel.setEnabled(false); + delayLabel.setEnabled(false); } } }); @@ -376,10 +395,10 @@ public class PreferencePane extends BasicPane { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preference_Pagination_Line_Color")); - gridLineColorTBButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + gridLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); gridLineColorTBButton.setEnabled(this.isEnabled()); - paginationLineColorTBButton = new UIColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); + paginationLineColorTBButton = new UIColorButton(IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); paginationLineColorTBButton.setEnabled(this.isEnabled()); JPanel leftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); @@ -595,7 +614,7 @@ public class PreferencePane extends BasicPane { defaultStringToFormulaBox.setSelected(false); } VcsConfigManager vcsConfigManager = designerEnvManager.getVcsConfigManager(); - if (VcsHelper.needInit()) { + if (VcsHelper.getInstance().needInit()) { vcsEnableCheckBox.setSelected(vcsConfigManager.isVcsEnable()); } else { vcsEnableCheckBox.setEnabled(false); @@ -630,6 +649,9 @@ public class PreferencePane extends BasicPane { this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); openDebugComboBox.setSelected(designerEnvManager.isOpenDebug()); + useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); + + useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); this.oracleSpace.setSelected(designerEnvManager.isOracleSystemSpace()); this.cachingTemplateSpinner.setValue(designerEnvManager.getCachingTemplateLimit()); @@ -725,6 +747,19 @@ public class PreferencePane extends BasicPane { } }); + Configurations.update(new Worker() { + @Override + public void run() { + ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected()); + ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected()); + } + + @Override + public Class[] targets() { + return new Class[] {ServerPreferenceConfig.class}; + } + }); + } @@ -757,4 +792,9 @@ public class PreferencePane extends BasicPane { } }); } + + @Override + public BasicDialog showWindow(Window window, DialogActionListener l) { + return showWindowWithCustomSize(window, l, new Dimension(BasicDialog.DEFAULT.width, this.getPreferredSize().height + OFFSET_HEIGHT)); + } } 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 de223e2ccc..f3bfe5622e 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/file/export/AbstractExportAction.java b/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java index 536fc87ee5..17d19aab71 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/export/AbstractExportAction.java @@ -1,7 +1,7 @@ package com.fr.design.actions.file.export; -import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.JTemplateAction; +import com.fr.design.base.mode.DesignModeContext; import com.fr.design.gui.iprogressbar.FRProgressBar; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -9,6 +9,7 @@ import com.fr.design.mainframe.JTemplate; import com.fr.exception.RemoteDesignPermissionDeniedException; import com.fr.file.FILE; import com.fr.file.FILEChooserPane; +import com.fr.file.RenameExportFILE; import com.fr.file.filter.ChooseFileFilter; import com.fr.io.exporter.DesignExportType; import com.fr.io.exporter.ExporterKey; @@ -92,12 +93,17 @@ public abstract class AbstractExportAction> extends JT int saveValue = fileChooserPane.showSaveDialog(DesignerContext.getDesignerFrame(), "." + this.getDefaultExtension()); if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) { FILE target = fileChooserPane.getSelectedFILE(); + //rename 方式导出 + target = RenameExportFILE.create(target); try { target.mkfile(); } catch (Exception exp) { FineLoggerFactory.getLogger().error("Error In Make New File", exp); } - FineLoggerFactory.getLogger().info("\"" + target.getName() + "\"" + Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!"); + FineLoggerFactory.getLogger().info( + "\"" + RenameExportFILE.recoverFileName(target.getName()) + "\"" + + Toolkit.i18nText("Fine-Design_Report_Prepare_Export") + "!" + ); progressbar = new FRProgressBar( createExportWork(getSource(), target, para), @@ -124,7 +130,7 @@ public abstract class AbstractExportAction> extends JT private boolean processNotSaved() { //当前编辑的模板 E e = getEditingComponent(); - if (!e.isALLSaved() && !DesignerMode.isVcsMode()) { + if (!e.isALLSaved() && !DesignModeContext.isVcsMode()) { e.stopEditing(); int returnVal = JOptionPane.showConfirmDialog( DesignerContext.getDesignerFrame(), @@ -149,7 +155,7 @@ public abstract class AbstractExportAction> extends JT private SwingWorker createExportWork(final FILE source, final FILE target, final Map parameterMap) { final String path = source.getPath(); - final String name = target.getName(); + final String name = RenameExportFILE.recoverFileName(target.getName()); return new SwingWorker() { @@ -162,7 +168,6 @@ public abstract class AbstractExportAction> extends JT dealExporter(outputStream, path, parameterMap); this.setProgress(80); outputStream.flush(); - outputStream.close(); this.setProgress(100); FineLoggerFactory.getLogger().info("\"" + name + "\"" + Toolkit.i18nText("Fine-Design_Report_Finish_Export") + "!"); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java new file mode 100644 index 0000000000..4b09de8562 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/help/FineUIAction.java @@ -0,0 +1,67 @@ +package com.fr.design.actions.help; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.ui.ModernUIPane; +import com.fr.locale.InterProviderFactory; +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.impl.FineUI; + +import java.awt.event.ActionEvent; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-03-08 + */ +public class FineUIAction extends UpdateAction { + + public FineUIAction() { + setName("FineUI"); + } + + @Override + public void actionPerformed(final ActionEvent e) { + ModernUIPane pane = new ModernUIPane.Builder<>() +// .prepare(new ScriptContextAdapter() { +// @Override +// public void onScriptContextCreated(ScriptContextEvent event) { +// JSValue pool = event.getBrowser().executeJavaScriptAndReturnValue("window.Pool"); +// pool.asObject().setProperty("i18n", new I18n()); +// } +// }) + .withComponent(new AssembleComponent() { + + @Override + public ScriptPath script(RequestClient req) { + return ScriptPath.build("/com/fr/design/ui/help/demo.js"); + } + + @Override + public Atom[] refer() { + return new Atom[] {FineUI.KEY}; + } + }) + .build(); + BasicDialog dialog = pane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + + } + }); + dialog.setVisible(true); + + } + + public static class I18n { + + public String i18nText(String key) { + return InterProviderFactory.getProvider().getLocText(key); + } + } +} 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 58221a03a8..5de31eb311 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,18 +1,15 @@ package com.fr.design.actions.help; -import com.fr.base.BaseUtils; -import com.fr.base.Utils; 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; import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.stable.os.OperatingSystem; import com.fr.third.org.apache.http.HttpStatus; import com.fr.third.org.apache.http.StatusLine; import com.fr.third.org.apache.http.client.methods.HttpGet; @@ -21,60 +18,37 @@ import javax.swing.KeyStroke; import java.awt.Desktop; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; -import java.io.File; -import java.io.IOException; 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()); } - private void nativeExcuteMacInstallHomePrograms(String appName) { - String installHome = StableUtils.getInstallHome(); - if(installHome == null) { - FineLoggerFactory.getLogger().error("Can not find the install home, please check it."); - } else { - String appPath = StableUtils.pathJoin(new String[]{installHome, "bin", appName}); - if(!(new File(appPath)).exists()) { - FineLoggerFactory.getLogger().error(appPath + " can not be found."); - } - - String cmd = "open " + appPath; - Runtime runtime = Runtime.getRuntime(); - - try { - runtime.exec(cmd); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - - } - } /** * 动作 * @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; } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } - - if (OperatingSystem.isUnix()) { - nativeExcuteMacInstallHomePrograms("helptutorial.app"); - } else { - Utils.nativeExcuteInstallHomePrograms("helptutorial.exe"); - } + FineLoggerFactory.getLogger().warn(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Offline_Helptutorial_Msg")); } // 生成帮助文档 sitecenter key, help.zh_CN.10 @@ -116,4 +90,4 @@ public class TutorialAction extends UpdateAction { } }; -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index c853db1698..0296327097 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -1,19 +1,29 @@ package com.fr.design.actions.help.alphafine; +import com.fr.general.ComparatorUtils; import com.fr.license.function.VT4FR; import com.fr.stable.OperatingSystem; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; +import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; /** - * Created by XiaXiang on 2017/4/5. + * AlphaFine配置类 + * + * @author XiaXiang + * @date 2017/4/5 */ public class AlphaFineConfigManager implements XMLable { + private static final long serialVersionUID = -8170289826729582122L; private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); /** * 是否开启alphafine @@ -56,12 +66,12 @@ public class AlphaFineConfigManager implements XMLable { */ private boolean containPlugin = true; /** - * 分词搜索 - */ + * 分词搜索 + */ private boolean needSegmentationCheckbox = true; /** - * 智能客服 - */ + * 智能客服 + */ private boolean needIntelligentCustomerService = true; /** * 快捷键 @@ -71,24 +81,30 @@ public class AlphaFineConfigManager implements XMLable { * 是否提醒 */ private boolean needRemind = true; + + private Map actionSearchTextCache = new HashMap<>(8); + + private String cacheBuildNO; /** * 直接操作菜单次数 */ private int operateCount; + private AlphaFineConfigManager() { + } + public static AlphaFineConfigManager getInstance() { return alphaFineConfigManager; } public static boolean isALPHALicAvailable() { - + return VT4FR.AlphaFine.isSupport(); } @Override public Object clone() throws CloneNotSupportedException { - AlphaFineConfigManager manager = (AlphaFineConfigManager) super.clone(); - return manager; + return super.clone(); } @Override @@ -107,9 +123,33 @@ public class AlphaFineConfigManager implements XMLable { this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts())); this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true)); this.setOperateCount(reader.getAttrAsInt("operateCount", 0)); - + } else if (reader.isChildNode()) { + if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) { + readActionSearchTextCacheXML(reader); + } } + } + /** + * 读出搜索缓存 + */ + private void readActionSearchTextCacheXML(XMLableReader reader) { + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader reader) { + if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) { + setCacheBuildNO(reader.getAttrAsString("buildNO", "")); + } else if (ComparatorUtils.equals(reader.getTagName(), "item")) { + String tmpVal = reader.getElementValue(); + if (tmpVal != null) { + actionSearchTextCache.put(reader.getAttrAsString("key", ""), tmpVal); + } else { + actionSearchTextCache.put(reader.getAttrAsString("key", ""), StringUtils.EMPTY); + } + + } + } + }); } @Override @@ -128,6 +168,18 @@ public class AlphaFineConfigManager implements XMLable { .attr("operateCount", this.getOperateCount()) .attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox()) .attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService()); + writeActionSearchTextCacheXML(writer); + writer.end(); + } + + /** + * 写入搜索缓存 + */ + private void writeActionSearchTextCacheXML(XMLPrintWriter writer) { + writer.startTAG("ActionSearchTextCache").attr("buildNO", cacheBuildNO); + for (Map.Entry item : actionSearchTextCache.entrySet()) { + writer.startTAG("item").attr("key", item.getKey()).textNode(item.getValue()).end(); + } writer.end(); } @@ -262,4 +314,25 @@ public class AlphaFineConfigManager implements XMLable { public void setOperateCount(int operateCount) { this.operateCount = operateCount; } + + @NotNull + public Map getActionSearchTextCache() { + return Collections.unmodifiableMap(actionSearchTextCache); + } + + public void setActionSearchTextCache(@NotNull String key, @NotNull String value) { + this.actionSearchTextCache.put(key, value); + } + + @NotNull + public String getCacheBuildNO() { + if (cacheBuildNO == null) { + return StringUtils.EMPTY; + } + return cacheBuildNO; + } + + public void setCacheBuildNO(@NotNull String cacheBuildNO) { + this.cacheBuildNO = cacheBuildNO; + } } 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 89f2ac3c3f..76b11b2ff9 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/actions/server/PluginManagerAction.java b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java index ecd0d961a1..1b7d7bbc47 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/PluginManagerAction.java @@ -1,10 +1,11 @@ package com.fr.design.actions.server; -import com.fr.base.BaseUtils; +import com.fr.config.ServerPreferenceConfig; import com.fr.design.actions.UpdateAction; import com.fr.design.extra.WebViewDlgHelper; import com.fr.design.menu.MenuKeySet; - +import com.fr.design.upm.UpmFinder; +import com.fr.general.IOUtils; import javax.swing.*; import java.awt.event.ActionEvent; @@ -20,12 +21,17 @@ public class PluginManagerAction extends UpdateAction { this.setMenuKeySet(PLUGIN_MANAGER); this.setName(getMenuKeySet().getMenuKeySetName()); this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/server/plugin.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/server/plugin.png")); } @Override public void actionPerformed(ActionEvent e) { - WebViewDlgHelper.createPluginDialog(); + // 可以启用新版本的插件商店(使用JxBrowser作为容器) + if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) { + UpmFinder.showUPMDialog(); + } else { + WebViewDlgHelper.createPluginDialog(); + } } public static final MenuKeySet PLUGIN_MANAGER = new MenuKeySet() { diff --git a/designer-base/src/main/java/com/fr/design/bridge/exec/JSBridge.java b/designer-base/src/main/java/com/fr/design/bridge/exec/JSBridge.java new file mode 100644 index 0000000000..4c79952436 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/bridge/exec/JSBridge.java @@ -0,0 +1,17 @@ +package com.fr.design.bridge.exec; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-18 + * 用于标记一个方法是用于和JS做桥接的,避免被误删除 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) +public @interface JSBridge { +} diff --git a/designer-base/src/main/java/com/fr/design/bridge/exec/JSCallback.java b/designer-base/src/main/java/com/fr/design/bridge/exec/JSCallback.java new file mode 100644 index 0000000000..0a0451b54d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/bridge/exec/JSCallback.java @@ -0,0 +1,18 @@ +package com.fr.design.bridge.exec; + +/** + * Created by ibm on 2017/5/27. + */ +public class JSCallback { + + private JSExecutor executeScript; + + public JSCallback(JSExecutor jsExecutor) { + this.executeScript = jsExecutor; + } + + public void execute(String newValue) { + executeScript.executor(newValue); + } +} + diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/JSExecutor.java b/designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java similarity index 72% rename from designer-base/src/main/java/com/fr/design/extra/exe/callback/JSExecutor.java rename to designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java index 2adbadc87e..9ded472eb3 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/JSExecutor.java +++ b/designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java @@ -1,4 +1,4 @@ -package com.fr.design.extra.exe.callback; +package com.fr.design.bridge.exec; /** * Created by ibm on 2017/6/21. diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/JSCallback.java b/designer-base/src/main/java/com/fr/design/bridge/exec/JSUtils.java similarity index 59% rename from designer-base/src/main/java/com/fr/design/extra/exe/callback/JSCallback.java rename to designer-base/src/main/java/com/fr/design/bridge/exec/JSUtils.java index d01446ee01..730a283e15 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/JSCallback.java +++ b/designer-base/src/main/java/com/fr/design/bridge/exec/JSUtils.java @@ -1,46 +1,20 @@ -package com.fr.design.extra.exe.callback; +package com.fr.design.bridge.exec; +import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import javafx.application.Platform; -import javafx.scene.web.WebEngine; import netscape.javascript.JSObject; +import java.util.ArrayList; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * Created by ibm on 2017/5/27. + * @author richie + * @version 10.0 + * Created by richie on 2019-04-18 */ -public class JSCallback { - - private JSExecutor executeScript; - - public JSCallback(final WebEngine webEngine, final JSObject callback) { - init(webEngine, callback); - } - - public void init(final WebEngine webEngine, final JSObject callback){ - executeScript = new JSExecutor() { - @Override - public void executor(final String newValue) { - Platform.runLater(new Runnable() { - @Override - public void run() { - String fun = "(" + callback + ")(\"" + trimText(newValue) + "\")"; - try { - webEngine.executeScript(fun); - } catch (Exception e) { - webEngine.executeScript("alert(\"" + e.getMessage() + "\")"); - } - } - }); - } - }; - } - - public void execute(String newValue) { - executeScript.executor(newValue); - } +public class JSUtils { /** @@ -60,7 +34,7 @@ public class JSCallback { * @param old 原始字符串 * @return 处理之后的字符串 */ - private String trimText(String old) { + public static String trimText(String old) { if (StringUtils.isNotBlank(old)) { String b = filterHtmlTag(old); return b.replaceAll("\\\\n", StringUtils.EMPTY).replaceAll("\\\\t", StringUtils.EMPTY).replaceAll("\"", "\\\\\"").replaceAll("\'", "\\\\\'").replaceAll("\\\\\\\\", "\\\\\\\\\\\\"); @@ -73,7 +47,7 @@ public class JSCallback { * @param origin 原始字符串 * @return 处理之后的字符串 */ - private String filterHtmlTag(String origin) { + public static String filterHtmlTag(String origin) { String regHtml = "<[^>]+>"; Pattern patternHtml = Pattern.compile(regHtml, Pattern.CASE_INSENSITIVE); Matcher matchHtml = patternHtml.matcher(origin); @@ -81,5 +55,15 @@ public class JSCallback { return origin; } + public String[] jsObjectToStringArray(JSObject obj) { + if (obj == null) { + return ArrayUtils.EMPTY_STRING_ARRAY; + } + int len = (int) obj.getMember("length"); + List list = new ArrayList<>(); + for (int i = 0; i < len; i++) { + list.add(obj.getSlot(i).toString()); + } + return list.toArray(new String[len]); + } } - diff --git a/designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java b/designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java new file mode 100644 index 0000000000..9b79199330 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/constants/DesignerLaunchStatus.java @@ -0,0 +1,39 @@ +package com.fr.design.constants; + +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Null; + +/** + * 设计器启动事件类型 + * + * @author vito + * @date 2019-06-18 + */ +public enum DesignerLaunchStatus implements Event { + /** + * 初始化环境完成 + */ + WORKSPACE_INIT_COMPLETE, + + /** + * 设计器模块启动完成 + */ + DESIGNER_INIT_COMPLETE, + + /** + * 启动完成 + */ + OPEN_LAST_FILE_COMPLETE; + + private static DesignerLaunchStatus status; + + public static DesignerLaunchStatus getStatus() { + return status; + } + + public static void setStatus(DesignerLaunchStatus state) { + status = state; + EventDispatcher.asyncFire(DesignerLaunchStatus.getStatus()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java index bed0dc96b0..a18ae856eb 100644 --- a/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java @@ -147,6 +147,7 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp private boolean isIncludeUnderline(String name) { return ComparatorUtils.equals(name.indexOf(StoreProcedureAssist.GROUP_MARKER), -1) ? false : true; } + public abstract void addDataPane(final AbstractTableDataPane uPanel, String paneName); public abstract TableDataTree getDataTree(); diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 9c892de011..44de37ea82 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -41,7 +41,7 @@ import javax.swing.event.ChangeListener; import java.io.ByteArrayOutputStream; import java.text.Collator; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedHashMap; @@ -123,6 +123,7 @@ public abstract class DesignTableDataManager { * @param dsNameChangedMap 改变名字的数据集 */ public static void fireDSChanged(Map dsNameChangedMap) { + clearGlobalDs(); if (!dsNameChangedMap.isEmpty()) { setDsNameChangedMap(dsNameChangedMap); } @@ -334,15 +335,9 @@ public abstract class DesignTableDataManager { private static void addStoreProcedureData(java.util.Map resMap) { ProcedureConfig procedureConfig = ProcedureConfig.getInstance(); - String[] namearray = new String[0]; - @SuppressWarnings("unchecked") - java.util.Iterator nameIt = procedureConfig.getProcedures().keySet().iterator(); - while (nameIt.hasNext()) { - namearray = (String[]) ArrayUtils.add(namearray, nameIt.next()); - } - Arrays.sort(namearray, Collator.getInstance(java.util.Locale.CHINA)); - - for (String name : namearray) { + List names = new ArrayList<>(procedureConfig.getProcedures().keySet()); + Collections.sort(names, Collator.getInstance(java.util.Locale.CHINA)); + for (String name : names) { StoreProcedure storeProcedure = procedureConfig.getProcedure(name); if (globalDsCache.containsKey(name)) { resMap.put(name, globalDsCache.get(name)); 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 9ec67adb64..413a0f00d1 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/data/datapane/TableDataTreePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java index 37aa4ef123..56f81e9a5b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTreePane.java @@ -324,4 +324,31 @@ public class TableDataTreePane extends BasicTableDataTreePane { dataTree.refresh(); return Collections.unmodifiableMap(tdNameMap); } + public void addDataPane(final AbstractTableDataPane uPanel, String paneName) { + final NamePane nPanel = uPanel.asNamePane(); + nPanel.setObjectName(paneName); + final String oldName = paneName; + + allDSNames = DesignTableDataManager.getAllDSNames(tc.getBook()); + + DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); + tc.renameTableData(oldName, nPanel.getObjectName(), false); + TableDataSource tds = tc.getBook(); + TableData td = uPanel.updateBean(); + if (td instanceof TableDataSourceDependent) { + ((TableDataSourceDependent) td).setTableDataSource(tds); + } + String tdName = nPanel.getObjectName(); + tds.putTableData(tdName, td); + Map map = new HashMap(); + if (!ComparatorUtils.equals(oldName, tdName)) { + map.put(oldName, tdName); + } + fireDSChanged(map); + tc.fireTargetModified(); + tc.parameterChanged(); + int[] rows = dataTree.getSelectionRows(); + dataTree.refreshChildByName(tdName); + dataTree.setSelectionRows(rows); + } } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index d441d51160..85b8fbd7d3 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -29,6 +29,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.syntax.ui.rsyntaxtextarea.SyntaxConstants; import com.fr.design.gui.syntax.ui.rtextarea.RTextScrollPane; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ToolBarDef; @@ -211,10 +212,13 @@ public class DBTableDataPane extends AbstractTableDataPane { isShareCheckBox.setBackground(Color.WHITE); maxPanel = new MaxMemRowCountPanel(); maxPanel.setBorder(null); + JPanel wrapMaxPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + wrapMaxPanel.add(maxPanel); + wrapMaxPanel.setPreferredSize(new Dimension(250, 20)); UIToolbar editToolBar = ToolBarDef.createJToolBar(); toolBarDef.updateToolBar(editToolBar); editToolBar.add(isShareCheckBox); - editToolBar.add(maxPanel); + editToolBar.add(wrapMaxPanel); return editToolBar; } 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 0000000000..3410af0444 --- /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 0000000000..1a01a8641b --- /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 0000000000..9239b9d4d4 --- /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 0000000000..e29a9f6698 --- /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 0000000000..577acada97 --- /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 8c70536505..4809e536c6 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 @@ -2,13 +2,18 @@ package com.fr.design.dialog; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; - -import com.fr.stable.core.PropertyChangeAdapter; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.core.PropertyChangeAdapter; -import javax.swing.*; +import javax.swing.JPanel; import javax.swing.event.DocumentEvent; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dialog; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Window; /* * _denny: 这里的BasicPane通常会有populate & update方法 @@ -35,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); } /** @@ -95,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); } /** @@ -120,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); } /** @@ -144,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); } /** @@ -168,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); @@ -178,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; @@ -298,18 +260,20 @@ public abstract class BasicPane extends JPanel { public void checkValid() throws Exception { } - public static final class NamePane extends BasicPane { + public static class NamePane extends BasicPane { private UITextField nameTextField; + private UILabel Name; private BasicPane centerPane; private UILabel showfield; private PropertyChangeAdapter changeListener; - private NamePane(BasicPane bPane) { + public NamePane(BasicPane bPane) { this.setLayout(new BorderLayout(4, 4)); nameTextField = new UITextField(30); + Name = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Name") + ":"); JPanel northPane = new JPanel(new BorderLayout(4, 4)); - northPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Name") + ":"), BorderLayout.WEST); + northPane.add(Name, BorderLayout.WEST); northPane.add(nameTextField, BorderLayout.CENTER); northPane.add(showfield = new UILabel(" "), BorderLayout.EAST); showfield.setForeground(new Color(204, 0, 1)); @@ -343,6 +307,12 @@ public abstract class BasicPane extends JPanel { } } + @Override + public void setVisible(boolean isVisible) { + this.nameTextField.setVisible(isVisible); + this.Name.setVisible(isVisible); + } + public String getObjectName() { return this.nameTextField.getText().trim(); } @@ -365,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/editor/editor/DateEditor.java b/designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java index 3b1abe6f00..c40161ba6c 100644 --- a/designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java +++ b/designer-base/src/main/java/com/fr/design/editor/editor/DateEditor.java @@ -153,6 +153,10 @@ public class DateEditor extends Editor { this.uiDatePicker.setSelectedItem(new Date()); } + public UIDatePicker getUiDatePicker() { + return uiDatePicker; + } + /** * Request focus */ diff --git a/designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java b/designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java index 77c6bcf8f1..c14fe870fc 100644 --- a/designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java +++ b/designer-base/src/main/java/com/fr/design/event/DesignerOpenedListener.java @@ -9,5 +9,5 @@ public interface DesignerOpenedListener extends EventListener { /** * Invoked when the target of the listener has changed the rpt content. */ - public void designerOpened(); + void designerOpened(); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginJavaFxExecutor.java b/designer-base/src/main/java/com/fr/design/extra/PluginJavaFxExecutor.java new file mode 100644 index 0000000000..c3863a46df --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/extra/PluginJavaFxExecutor.java @@ -0,0 +1,42 @@ +package com.fr.design.extra; + +import com.fr.design.bridge.exec.JSExecutor; +import com.fr.design.bridge.exec.JSUtils; +import javafx.application.Platform; +import javafx.scene.web.WebEngine; +import netscape.javascript.JSObject; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-18 + */ +public class PluginJavaFxExecutor implements JSExecutor { + + public static PluginJavaFxExecutor create(WebEngine webEngine, JSObject callback) { + return new PluginJavaFxExecutor(webEngine, callback); + } + + private WebEngine webEngine; + private JSObject callback; + + private PluginJavaFxExecutor(WebEngine webEngine, JSObject callback) { + this.webEngine = webEngine; + this.callback = callback; + } + + @Override + public void executor(final String newValue) { + Platform.runLater(new Runnable() { + @Override + public void run() { + String fun = "(" + callback + ")(\"" + JSUtils.trimText(newValue) + "\")"; + try { + webEngine.executeScript(fun); + } catch (Exception e) { + webEngine.executeScript("alert(\"" + e.getMessage() + "\")"); + } + } + }); + } +} diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java index 99e02bdc14..7745786303 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginOperateUtils.java @@ -3,7 +3,7 @@ package com.fr.design.extra; import com.fr.config.MarketConfig; import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallOnlineCallback; -import com.fr.design.extra.exe.callback.JSCallback; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.extra.exe.callback.ModifyStatusCallback; import com.fr.design.extra.exe.callback.UninstallPluginCallback; import com.fr.design.extra.exe.callback.UpdateFromDiskCallback; diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java index 1674616c97..1c9e518e30 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginUtils.java @@ -244,6 +244,8 @@ public class PluginUtils { jo.put("onTrial", pluginContext.isOnTrial()); jo.put("deadline", getDeadline(pluginContext)); jo.put("registerFailed", pluginContext.isRegisterFailed()); + jo.put("selfState", pluginContext.getSelfState()); + jo.put("switchedReason", pluginContext.getSwitchedReason()); ja.put(jo); } }catch (Exception e){ diff --git a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java index 02a51ad3f2..492bbfd97d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java +++ b/designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java @@ -3,6 +3,7 @@ package com.fr.design.extra; import com.fr.base.passport.FinePassportManager; import com.fr.config.MarketConfig; import com.fr.design.RestartHelper; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.UIDialog; import com.fr.design.extra.exe.GetInstalledPluginsExecutor; import com.fr.design.extra.exe.GetPluginCategoriesExecutor; @@ -11,12 +12,9 @@ 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; -import com.fr.design.extra.exe.callback.JSCallback; import com.fr.design.gui.ilable.UILabel; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; - import com.fr.general.CloudCenter; -import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginMarker; @@ -172,7 +170,7 @@ public class PluginWebBridge { * @param callback 回调函数 */ public void installPluginOnline(final String pluginInfo, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback); } @@ -183,7 +181,7 @@ public class PluginWebBridge { * @param filePath 插件包的路径 */ public void installPluginFromDisk(final String filePath, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); File file = new File(filePath); PluginOperateUtils.installPluginFromDisk(file, jsCallback); } @@ -194,7 +192,7 @@ public class PluginWebBridge { * @param pluginInfo 插件信息 */ public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); } @@ -204,7 +202,7 @@ public class PluginWebBridge { * @param pluginIDs 插件集合 */ public void updatePluginOnline(JSObject pluginIDs, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); String[] pluginInfos = jsObjectToStringArray(pluginIDs); List pluginMarkerList = new ArrayList(); for (int i = 0; i < pluginInfos.length; i++) { @@ -219,7 +217,7 @@ public class PluginWebBridge { * @param filePath 插件包的路径 */ public void updatePluginFromDisk(String filePath, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); File file = new File(filePath); PluginOperateUtils.updatePluginFromDisk(file, jsCallback); } @@ -230,7 +228,7 @@ public class PluginWebBridge { * @param pluginID 插件ID */ public void setPluginActive(String pluginID, final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); PluginOperateUtils.setPluginActive(pluginID, jsCallback); } @@ -427,7 +425,7 @@ public class PluginWebBridge { * @param callback */ public void registerLoginInfo(final JSObject callback) { - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); PluginOperateUtils.getLoginInfo(jsCallback, uiLabel); } @@ -559,7 +557,7 @@ public class PluginWebBridge { } public void getPackInfo(final JSObject callback){ - JSCallback jsCallback = new JSCallback(webEngine, callback); + JSCallback jsCallback = new JSCallback(PluginJavaFxExecutor.create(webEngine, callback)); jsCallback.execute(StringUtils.EMPTY); } diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java index 1e170c8443..e8096efbf7 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallFromDiskCallback.java @@ -1,5 +1,6 @@ package com.fr.design.extra.exe.callback; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.extra.PluginOperateUtils; import com.fr.design.extra.PluginUtils; diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java index 9b86641e66..23b6679b69 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/InstallOnlineCallback.java @@ -1,5 +1,6 @@ package com.fr.design.extra.exe.callback; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.extra.PluginOperateUtils; import com.fr.log.FineLoggerFactory; diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java index 681180053e..b7b817ef4c 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/ModifyStatusCallback.java @@ -1,5 +1,6 @@ package com.fr.design.extra.exe.callback; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.extra.PluginUtils; import com.fr.plugin.manage.control.PluginTaskCallback; diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java index a6f781b94b..db8a69188a 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UninstallPluginCallback.java @@ -1,5 +1,6 @@ package com.fr.design.extra.exe.callback; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.extra.PluginUtils; import com.fr.log.FineLoggerFactory; diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java index cd0ccab848..26315fd030 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateFromDiskCallback.java @@ -1,5 +1,6 @@ package com.fr.design.extra.exe.callback; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.extra.PluginOperateUtils; import com.fr.design.extra.PluginUtils; diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java index c857960c78..28f4f6a31f 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/callback/UpdateOnlineCallback.java @@ -1,5 +1,6 @@ package com.fr.design.extra.exe.callback; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.extra.PluginOperateUtils; import com.fr.log.FineLoggerFactory; diff --git a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java index f790eca94f..fc46ff59bd 100644 --- a/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java +++ b/designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java @@ -41,17 +41,17 @@ public class HistoryTemplateListCache implements CallbackEvent { private List> historyList; private JTemplate editingTemplate; - private static volatile HistoryTemplateListCache THIS; + private static volatile HistoryTemplateListCache instacne; public static HistoryTemplateListCache getInstance() { - if (THIS == null) { + if (instacne == null) { synchronized (HistoryTemplateListCache.class) { - if (THIS == null) { - THIS = new HistoryTemplateListCache(); + if (instacne == null) { + instacne = new HistoryTemplateListCache(); } } } - return THIS; + return instacne; } private HistoryTemplateListCache() { @@ -66,8 +66,8 @@ public class HistoryTemplateListCache implements CallbackEvent { public void closeSelectedReport(JTemplate selected) { DesignModuleFactory.clearChartPropertyPane(); DesignTableDataManager.closeTemplate(selected); - //直接关闭模板的时候退出权限编辑 - if (DesignModeContext.isAuthorityEditing()) { + //直接关闭模板的时候(当且仅当设计器tab上只剩一个模板)退出权限编辑 + if (DesignModeContext.isAuthorityEditing() && historyList.size() <= 1) { DesignerContext.getDesignerFrame().closeAuthorityEditing(); } if (contains(selected) == -1) { @@ -263,9 +263,9 @@ public class HistoryTemplateListCache implements CallbackEvent { JTemplate template = iterator.next(); String tPath = template.getPath(); if (isDir ? tPath.startsWith(path) : tPath.equals(path)) { + int size = getHistoryCount(); iterator.remove(); int index = iterator.nextIndex(); - int size = getHistoryCount(); if (size == index + 1 && index > 0) { //如果删除的是后一个Tab,则定位到前一个 MutilTempalteTabPane.getInstance().setSelectedIndex(index - 1); diff --git a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java index 65989dfccf..968f72a599 100644 --- a/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java @@ -751,8 +751,11 @@ public class MutilTempalteTabPane extends JComponent { JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); selectedIndex = HistoryTemplateListCache.getInstance().contains(template); } - //如果是已后台关闭的模板,则重新打开文件 - openedTemplate.get(selectedIndex).activeOldJTemplate(); + if (selectedIndex < openedTemplate.size()) { + //如果是已后台关闭的模板,则重新打开文件 + openedTemplate.get(selectedIndex).activeOldJTemplate(); + } + } } diff --git a/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java b/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java new file mode 100644 index 0000000000..44acc11902 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/OemProcessor.java @@ -0,0 +1,38 @@ +package com.fr.design.fun; + +import com.fr.design.menu.MenuDef; +import com.fr.start.SplashStrategy; + +import java.awt.image.BufferedImage; +import java.util.List; + +/** + * 设计器Oem接口 + */ +public interface OemProcessor { + public static final String MARK_STRING = "OemProcessor"; + + /** + * 启动动画,如果不替换则返回null + * + * @return + */ + SplashStrategy createSplashStrategy(); + + /** + * 替换标题图标--DesignerFrame.initTitleIcon + * 如果不替换则返回null + * + * @return + */ + List createTitleIcon(); + + /** + * 处理设计器菜单(增删改) + * + * @param menuDefs 已加载的菜单 + * @return 新的菜单数组 + */ + MenuDef[] dealWithMenuDef(MenuDef[] menuDefs); + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java new file mode 100644 index 0000000000..d49bfdf246 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractOemProcessor.java @@ -0,0 +1,25 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.OemProcessor; +import com.fr.design.menu.MenuDef; +import com.fr.start.SplashStrategy; + +import java.awt.image.BufferedImage; +import java.util.List; + +public abstract class AbstractOemProcessor implements OemProcessor{ + @Override + public MenuDef[] dealWithMenuDef(MenuDef[] menuDefs) { + return menuDefs; + } + + @Override + public List createTitleIcon() { + return null; + } + + @Override + public SplashStrategy createSplashStrategy() { + return null; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java index 9d16d6787a..01d9e7dd32 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java @@ -1,12 +1,11 @@ package com.fr.design.gui.chart; -import javax.swing.JComponent; - -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; -import com.fr.stable.core.PropertyChangeAdapter; +import com.fr.chartx.attr.ChartProvider; import com.fr.stable.core.PropertyChangeListener; +import javax.swing.JComponent; + /** * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-7-10 上午09:19:36 @@ -18,8 +17,8 @@ public abstract class MiddleChartComponent extends JComponent { public abstract BaseChartCollection update(); public abstract void reset(); - - public abstract BaseChart getEditingChart(); - - public abstract void addStopEditingListener(PropertyChangeListener list); + + public abstract ChartProvider getEditingChart(); + + public abstract void addStopEditingListener(PropertyChangeListener list); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java index c51aeaaecc..4bb286dbc0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlUpdatePane.java @@ -60,7 +60,8 @@ class JControlUpdatePane extends JPanel { elEditing = el; NameableCreator[] creators = listControlPane.creators(); - for (int i = 0, len = updatePanes.length; i < len; i++) { + //倒序的原因是为了让一些继承内置连接类的插件实现能够生效REPORT-15409 + for (int i = updatePanes.length - 1; i > -1; i--) { Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper); if (ob2Populate != null) { if (updatePanes[i] == null) { diff --git a/designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java b/designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java index 788d1104e8..62cf793470 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/SingleObjectComboBoxModel.java @@ -1,6 +1,7 @@ package com.fr.design.gui.date; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; @@ -9,7 +10,7 @@ import java.util.Date; public class SingleObjectComboBoxModel extends AbstractListModel implements ComboBoxModel { private SimpleDateFormat dateFormat; - private String selectedDate = ""; + private String selectedDate = StringUtils.EMPTY; public SingleObjectComboBoxModel() { } @@ -28,6 +29,7 @@ public class SingleObjectComboBoxModel extends AbstractListModel implements Comb public void setSelectedItem(Object anItem) { if (anItem == null) { + selectedDate = StringUtils.EMPTY; return; } if (anItem instanceof Date) { diff --git a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java b/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java index aa9cabd498..fb44f618f8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java +++ b/designer-base/src/main/java/com/fr/design/gui/date/UIDatePicker.java @@ -6,6 +6,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JComboBox; @@ -157,7 +158,11 @@ public class UIDatePicker extends UIComboBox implements Serializable { * 设置当前选择的日期 */ public void setSelectedDate(Date date) throws ParseException { - this.setSelectedItem(dateFormat.format(date)); + if (date == null) { + this.setSelectedItem(null); + } else { + this.setSelectedItem(dateFormat.format(date)); + } } public void setSelectedItem(Object anObject) { @@ -215,8 +220,11 @@ public class UIDatePicker extends UIComboBox implements Serializable { try { String strDate = comboBox.getSelectedItem().toString(); synchronized (this) { - Date selectionDate = dateFormat.parse(strDate); - calendarPanel.setSelectedDate(selectionDate); + Date selectionDate = new Date(); + if (StringUtils.isNotBlank(strDate)) { + selectionDate = dateFormat.parse(strDate); + } + calendarPanel.setSelectedDate(selectionDate); calendarPanel.updateHMS(); } } catch (Exception e) { diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java b/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java index 8981016982..0c02e6c5cd 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/BaseHyperlinkGroup.java @@ -4,6 +4,7 @@ import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.module.DesignModuleFactory; import com.fr.js.JavaScript; import com.fr.stable.Filter; +import org.jetbrains.annotations.NotNull; /** * 基础的超级链接类型, 不包括图表相关超链. @@ -18,6 +19,8 @@ public class BaseHyperlinkGroup implements HyperlinkGroupType { * * @return NameableCreator[] */ + @NotNull + @Override public NameableCreator[] getHyperlinkCreators() { return DesignModuleFactory.getCreators4Hyperlink(); } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java index 8db0b9b948..4c5aec60ec 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupType.java @@ -3,6 +3,7 @@ package com.fr.design.gui.frpane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.js.JavaScript; import com.fr.stable.Filter; +import org.jetbrains.annotations.NotNull; /** * 超级链接 支持的类型 种类. @@ -17,6 +18,7 @@ public interface HyperlinkGroupType { * * @return NameableCreator[] */ + @NotNull NameableCreator[] getHyperlinkCreators(); 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 36183f1078..19823d8b42 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/gui/ibutton/UIToggleButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java index 4b89752356..45c878419e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIToggleButton.java @@ -25,10 +25,13 @@ import com.fr.stable.StringUtils; * @since 2012-5-11下午4:28:24 */ public class UIToggleButton extends UIButton implements GlobalNameObserver{ + + private static final int ICON_COUNT = 2; private boolean isSelected; private boolean isEventBannded = false; private String toggleButtonName = ""; private GlobalNameListener globalNameListener = null; + private Icon[] icons; public UIToggleButton() { this(StringUtils.EMPTY); @@ -53,9 +56,9 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ * @param icons */ public UIToggleButton(Icon[] icons) { - super(icons[0], null, icons[1]); - setSelectedIcon(icons[1]); + super(icons[0], null, null); setExtraPainted(true); + this.icons = icons; addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { @@ -73,10 +76,10 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ * @param icons */ public UIToggleButton(Icon[] icons, boolean needRelease) { - super(icons[0], null, icons[1]); + super(icons[0], null, null); setBorderPainted(true); - setSelectedIcon(icons[1]); setExtraPainted(true); + this.icons = icons; if (!needRelease) { addActionListener(new AbstractAction() { @Override @@ -92,6 +95,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ addMouseListener(getMouseListener()); } + @Override public void setGlobalName(String name){ toggleButtonName = name ; } @@ -100,6 +104,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ * * @return */ + @Override public boolean isSelected() { return isSelected; } @@ -115,12 +120,15 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ super.setSelected(isSelected); if (this.isSelected != isSelected) { this.isSelected = isSelected; - repaint(); + refresh(isSelected); } } + + @Override protected void initListener(){ if(shouldResponseChangeListener()){ this.addChangeListener(new ChangeListener() { + @Override public void stateChanged(ChangeEvent e) { if (uiObserverListener == null) { return; @@ -138,10 +146,30 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ if (this.isSelected != isSelected) { this.isSelected = isSelected; fireSelectedChanged(); - repaint(); + refresh(isSelected); } } + + + private void refresh(final boolean isSelected) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Icon[] icons = UIToggleButton.this.icons; + if (icons != null && icons.length == ICON_COUNT) { + if (isSelected) { + UIToggleButton.this.setIcon(icons[1]); + } else { + UIToggleButton.this.setIcon(icons[0]); + } + } + UIToggleButton.this.repaint(); + } + }); + } + + protected MouseListener getMouseListener() { return new MouseAdapter() { @Override @@ -157,6 +185,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ this.isEventBannded = ban; } + @Override protected void fireStateChanged() { } @@ -187,6 +216,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ } } + @Override protected void paintOtherBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); @@ -200,6 +230,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ * * @return 如果需要响应观察者事件则返回true,否则返回false */ + @Override public boolean shouldResponseChangeListener() { return true; } @@ -208,6 +239,7 @@ public class UIToggleButton extends UIButton implements GlobalNameObserver{ * * @param listener 观察者监听事件 */ + @Override public void registerNameListener(GlobalNameListener listener) { globalNameListener = listener; } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java index 11fbaf8c84..9bbca6d2bc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/AlignmentPane.java @@ -20,8 +20,10 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.utils.gui.UIComponentUtils; import com.fr.event.EventDispatcher; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.plugin.ExtraClassManager; import com.fr.plugin.context.PluginContext; import com.fr.plugin.manage.PluginFilter; @@ -94,11 +96,11 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO imageLayoutComboBox = new UIComboBox(LAYOUT); initTextRotationCombox(); - Icon[][] hAlignmentIconArray = {{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png")}, - {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png")}, - {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")}, - {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")}, - {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}}; + Icon[][] hAlignmentIconArray = {{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_left_normal_white.png")}, + {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_center_normal_white.png")}, + {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_right_normal_white.png")}, + {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/h_s_normal_white.png")}, + {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/defaultAlignment_white.png")}}; Integer[] hAlignment = new Integer[]{Constants.LEFT, Constants.CENTER, Constants.RIGHT, Integer.valueOf(Constants.DISTRIBUTED), Constants.NULL}; hAlignmentPane = new UIButtonGroup(hAlignmentIconArray, hAlignment); hAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Right"), @@ -106,9 +108,9 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO hPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); vPaneContainer = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); - Icon[][] vAlignmentIconArray = {{BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal_white.png")}, - {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")}, - {BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}}; + Icon[][] vAlignmentIconArray = {{IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_top_normal_white.png")}, + {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_center_normal_white.png")}, + {IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal.png"), IOUtils.readIcon("/com/fr/design/images/m_format/cellstyle/v_down_normal_white.png")}}; Integer[] vAlignment = new Integer[]{Constants.TOP, Constants.CENTER, Constants.BOTTOM}; vAlignmentPane = new UIButtonGroup(vAlignmentIconArray, vAlignment); vAlignmentPane.setAllToolTips(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Center"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Tooltips_Bottom")}); @@ -210,9 +212,11 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO private JPanel basicPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; + UILabel horizontalLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal") + " ", SwingConstants.LEFT); + UIComponentUtils.setLineWrap(horizontalLabel); Component[][] components = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Horizontal") + " ", SwingConstants.LEFT), hPaneContainer}, + new Component[]{horizontalLabel, hPaneContainer}, new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style_Alignment_Pane_Vertical") + " ", SwingConstants.RIGHT), vPaneContainer}, new Component[]{null, null} @@ -304,6 +308,7 @@ public class AlignmentPane extends AbstractBasicStylePane implements GlobalNameO * * @param style the new style. */ + @Override public void populateBean(Style style) { hAlignmentPane.setSelectedItem(BaseUtils.getAlignment4Horizontal(style)); vAlignmentPane.setSelectedItem(style.getVerticalAlignment()); diff --git a/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java b/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java index 3a52f4c502..9d5e713051 100644 --- a/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java @@ -22,16 +22,18 @@ public class BorderIcon implements Icon { this.cellBorderStyle = cellBorderStyle; } + @Override public int getIconHeight() { return height; } + @Override public int getIconWidth() { return width; } - public static void drawLine(Graphics g, double x1, double y1, double x2, + private void drawLine(Graphics g, double x1, double y1, double x2, double y2, int lineStyle, Color color) { g.setColor(color); x1--; @@ -63,6 +65,7 @@ public class BorderIcon implements Icon { } } + @Override public void paintIcon(Component c, Graphics g, int x, int y) { int defaultWidth = c.getWidth(); int defaultHeight = c.getHeight(); @@ -81,9 +84,9 @@ public class BorderIcon implements Icon { cellBorderStyle.getBottomColor()); drawLine(gr, x1, y1, x1, y2, cellBorderStyle.getLeftStyle(), cellBorderStyle.getLeftColor()); - drawLine(gr, defaultWidth / 2, x1, defaultWidth / 2, x2, + drawLine(gr, defaultWidth / 2, y1, defaultWidth / 2, y2, cellBorderStyle.getVerticalStyle(), cellBorderStyle.getVerticalColor()); - drawLine(gr, y1, defaultHeight / 2, y2, defaultHeight / 2, + drawLine(gr, x1, defaultHeight / 2, x2, defaultHeight / 2, cellBorderStyle.getHorizontalStyle(), cellBorderStyle.getHorizontalColor()); } diff --git a/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java b/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java index 7f1468a450..8e794f1924 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java +++ b/designer-base/src/main/java/com/fr/design/javascript/beautify/JavaScriptFormatHelper.java @@ -1,16 +1,16 @@ package com.fr.design.javascript.beautify; -import com.fr.log.FineLoggerFactory; +import com.eclipsesource.v8.V8; +import com.eclipsesource.v8.V8Array; +import com.eclipsesource.v8.V8Object; +import com.eclipsesource.v8.utils.V8ObjectUtils; import com.fr.general.IOUtils; -import com.fr.script.ScriptFactory; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.EncodeConstants; -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptException; import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; +import java.io.UnsupportedEncodingException; public class JavaScriptFormatHelper { @@ -34,15 +34,21 @@ public class JavaScriptFormatHelper { */ public static String beautify(String jsCode, BeautifyOption option) { InputStream resourceAsStream = IOUtils.readResource("com/fr/design/javascript/beautify/beautify.js"); - ScriptEngine scriptEngine = ScriptFactory.newScriptEngine(); String result = jsCode; + V8 v8 = V8.createV8Runtime(); try { - Reader reader = new InputStreamReader(resourceAsStream); - scriptEngine.eval(reader); - Invocable invocable = (Invocable) scriptEngine; - result = (String) invocable.invokeFunction("js_beautify_global", jsCode, option.toFormatArgument()); - } catch (ScriptException | NoSuchMethodException e) { + v8.executeVoidScript(IOUtils.inputStream2String(resourceAsStream, EncodeConstants.ENCODING_UTF_8)); + V8Array parameters = new V8Array(v8); + parameters.push(jsCode); + V8Object arg = V8ObjectUtils.toV8Object(v8, option.toFormatArgument()); + parameters.push(arg); + result = v8.executeStringFunction("js_beautify_global", parameters); + parameters.release(); + arg.release(); + } catch (UnsupportedEncodingException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + v8.release(true); } return result; } diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java new file mode 100644 index 0000000000..b7a05975cb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/ProductImproveMark.java @@ -0,0 +1,31 @@ +package com.fr.design.locale.impl; + +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class ProductImproveMark implements LocaleMark { + + private Map map = new HashMap<>(); + + public ProductImproveMark() { + map.put(Locale.CHINA, true); + map.put(Locale.TAIWAN, false); + map.put(Locale.US, false); + map.put(Locale.KOREA, false); + map.put(Locale.JAPAN, false); + } + + @Override + public Boolean getValue() { + Boolean result = map.get(GeneralContext.getLocale()); + return result == null ? false : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java new file mode 100644 index 0000000000..790108978f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SplashMark.java @@ -0,0 +1,35 @@ +package com.fr.design.locale.impl; + +import com.fr.design.DesignerEnvManager; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class SplashMark implements LocaleMark { + + private Map map = new HashMap(); + private static final String SPLASH_PATH = "/com/fr/design/images/splash_10.gif"; + private static final String SPLASH_EN_PATH = "/com/fr/design/images/splash_10_en.gif"; + private static final String SPLASH_JP_PATH = "/com/fr/design/images/splash_10_jp.gif"; + + public SplashMark() { + map.put(Locale.CHINA, SPLASH_PATH); + map.put(Locale.KOREA, SPLASH_EN_PATH); + map.put(Locale.JAPAN, SPLASH_JP_PATH); + map.put(Locale.US, SPLASH_EN_PATH); + map.put(Locale.TAIWAN, SPLASH_EN_PATH); + } + + @Override + public String getValue() { + String result = map.get(DesignerEnvManager.getEnvManager().getLanguage()); + return result == null ? SPLASH_EN_PATH : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java new file mode 100644 index 0000000000..61de25937c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/SupportLocaleImpl.java @@ -0,0 +1,44 @@ +package com.fr.design.locale.impl; + +import com.fr.general.locale.SupportLocale; + +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +/** + * 某些国际化环境支持的操作 + * 需要增加/删除支持的语言 统一在这里修改 无须改动业务代码 + * 后续有新的不同语言下的差异操作 添加新的枚举 + * @author Hades + * @date 2019/6/24 + */ +public enum SupportLocaleImpl implements SupportLocale { + + /** + * 社区菜单支持的国际化环境 + */ + COMMUNITY { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.CHINA); + set.add(Locale.TAIWAN); + return set; + } + }, + + /** + * Facebook支持的国际化环境 + */ + FACEBOOK { + @Override + public Set support() { + Set set = new HashSet(); + set.add(Locale.TAIWAN); + return set; + } + } + + +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java new file mode 100644 index 0000000000..3739c49f6a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/UserInfoMark.java @@ -0,0 +1,36 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class UserInfoMark implements LocaleMark { + + private Map map = new HashMap<>(); + private static final String CN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.cn"); + private static final String EN_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.en"); + private static final String TW_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.tw"); + private static final String JP_LOGIN_HTML = CloudCenter.getInstance().acquireUrlByKind("frlogin.jp"); + + public UserInfoMark() { + map.put(Locale.CHINA, CN_LOGIN_HTML); + map.put(Locale.KOREA, EN_LOGIN_HTML); + map.put(Locale.JAPAN, JP_LOGIN_HTML); + map.put(Locale.US, EN_LOGIN_HTML); + map.put(Locale.TAIWAN, TW_LOGIN_HTML); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? EN_LOGIN_HTML : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java b/designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java new file mode 100644 index 0000000000..2071faba3f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/locale/impl/VideoMark.java @@ -0,0 +1,35 @@ +package com.fr.design.locale.impl; + +import com.fr.general.CloudCenter; +import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleMark; + +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +/** + * @author Hades + * @date 2019/6/24 + */ +public class VideoMark implements LocaleMark { + + private Map map = new HashMap<>(); + private static final String VIDEO_EN = CloudCenter.getInstance().acquireUrlByKind("bbs.video.en"); + private static final String VIDEO_CN = CloudCenter.getInstance().acquireUrlByKind("bbs.video"); + private static final String VIDEO_TW = CloudCenter.getInstance().acquireUrlByKind("bbs.video.tw"); + + public VideoMark() { + map.put(Locale.CHINA, VIDEO_CN); + map.put(Locale.KOREA, VIDEO_EN); + map.put(Locale.JAPAN, VIDEO_EN); + map.put(Locale.US, VIDEO_EN); + map.put(Locale.TAIWAN, VIDEO_TW); + } + + @Override + public String getValue() { + String result = map.get(GeneralContext.getLocale()); + return result == null ? VIDEO_EN : result; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignAuthorityEventType.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignAuthorityEventType.java new file mode 100644 index 0000000000..fc1d0ab5a0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignAuthorityEventType.java @@ -0,0 +1,11 @@ +package com.fr.design.mainframe; + +import com.fr.event.Event; + +public enum DesignAuthorityEventType implements Event { + + // 退出权限编辑 + StartEdit, + // 进入权限编辑 + StopEdit; +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 2cc83543c3..277ca93eb5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -24,6 +24,7 @@ import com.fr.design.file.MutilTempalteTabPane; import com.fr.design.file.NewTemplatePane; import com.fr.design.file.SaveSomeTemplatePane; import com.fr.design.file.TemplateTreePane; +import com.fr.design.fun.OemProcessor; import com.fr.design.fun.TitlePlaceProcessor; import com.fr.design.fun.impl.AbstractTemplateTreeShortCutProvider; import com.fr.design.gui.ibutton.UIButton; @@ -36,9 +37,11 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; +import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.menu.MenuManager; import com.fr.design.menu.ShortCut; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.event.EventDispatcher; import com.fr.exception.DecryptTemplateException; import com.fr.file.FILE; import com.fr.file.FILEFactory; @@ -56,6 +59,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; import com.fr.stable.project.ProjectConstants; +import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceConnectionInfo; @@ -304,16 +308,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } }); - this.addDesignerOpenedListener(new DesignerOpenedListener() { - - @Override - public void designerOpened() { - - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite(); - reCalculateFrameSize(); - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize(); - } - }); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setVisible(false); this.setExtendedState(JFrame.MAXIMIZED_BOTH); @@ -322,7 +316,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta initMenuPane(); this.progressDialog = new ProgressDialog(this); } - + + public void resizeFrame() { + + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setComposite(); + reCalculateFrameSize(); + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().doResize(); + } + public void closeAuthorityEditing() { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); WestRegionContainerPane.getInstance().replaceDownPane( @@ -333,6 +334,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta needToAddAuhtorityPaint(); refreshDottedLine(); fireAuthorityStateToNomal(); + EventDispatcher.fire(DesignAuthorityEventType.StopEdit, DesignerFrame.this); } /** @@ -456,8 +458,19 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta try { @SuppressWarnings("unchecked") - List image = ICODecoder.read(DesignerFrame.class - .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); + OemProcessor oemProcessor = OemHandler.findOem(); + List image = null; + if (oemProcessor != null) { + try { + image = oemProcessor.createTitleIcon(); + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + if (image == null) { + image = ICODecoder.read(DesignerFrame.class + .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); + } this.setIconImages(image); } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); @@ -909,6 +922,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } jt.addJTemplateActionListener(this); jt.addTargetModifiedListener(this); + jt.addJTemplateActionListener(VcsHelper.getInstance()); centerTemplateCardPane.showJTemplate(jt); setTitle(); layeredPane.repaint(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index 265e7dfe60..b48433c5ce 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; @@ -26,6 +27,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.ui.FileVersionsPanel; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.ShortCut; @@ -49,7 +51,6 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.workspace.WorkContext; -import com.fr.design.mainframe.vcs.common.VcsHelper; import javax.swing.BorderFactory; import javax.swing.JDialog; @@ -79,6 +80,9 @@ import static javax.swing.JOptionPane.WARNING_MESSAGE; public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarStateChangeListener, ResponseDataSourceChange { + private static final String FILE = "file"; + private static volatile DesignerFrameFileDealerPane THIS; + static { GeneralContext.listenPluginRunningChanged(new PluginEventListener() { @@ -95,10 +99,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt }); } - private static final String FILE = "file"; - - private static volatile DesignerFrameFileDealerPane THIS; - private List otherToolbarStateChangeListeners = new ArrayList<>(); private FileOperations selectedOperation; @@ -118,25 +118,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt private VcsAction vcsAction = new VcsAction(); - /** - * 刷新 - */ - public void refresh() { - selectedOperation.refresh(); - } - - public static DesignerFrameFileDealerPane getInstance() { - - if (THIS == null) { - synchronized (DesignerFrameFileDealerPane.class) { - if (THIS == null) { - THIS = new DesignerFrameFileDealerPane(); - } - } - } - return THIS; - } - private DesignerFrameFileDealerPane() { setLayout(new BorderLayout()); @@ -164,6 +145,24 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt stateChange(); } + public static DesignerFrameFileDealerPane getInstance() { + + if (THIS == null) { + synchronized (DesignerFrameFileDealerPane.class) { + if (THIS == null) { + THIS = new DesignerFrameFileDealerPane(); + } + } + } + return THIS; + } + + /** + * 刷新 + */ + public void refresh() { + selectedOperation.refresh(); + } public final void setCurrentEditingTemplate(JTemplate jt) { @@ -202,15 +201,31 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt for (ShortCut shortCut : extraShortCuts) { toolbarDef.addShortCut(shortCut); } - if (VcsHelper.needInit()) { - toolbarDef.addShortCut(vcsAction); - } + addVcsAction(toolbarDef); toolbarDef.updateToolBar(toolBar); resetActionStatus(); refresh(); } + /** + * 添加VcsAction + * @param toolbarDef + */ + private void addVcsAction(ToolBarDef toolbarDef) { + if (VcsHelper.getInstance().needInit()) { + vcsAction = new VcsAction(); + if (FineClusterConfig.getInstance().isCluster()) { + vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_NotSupportRemote")); + } else { + vcsAction.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); + } + toolbarDef.addShortCut(vcsAction); + + } + } + + private void resetActionStatus() { newFolderAction.setEnabled(false); @@ -255,6 +270,41 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } } + private boolean isCurrentEditing(String path) { + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + String editing = jt.getEditingFILE().getPath(); + return ComparatorUtils.equals(editing, path); + } + + /** + * 按钮状态改变 + */ + @Override + public void stateChange() { + + int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath(); + + // 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用 + boolean singleSelected = selectedPathNum == 1; + newFolderAction.setEnabled(singleSelected); + renameAction.setEnabled(singleSelected); + showInExplorerAction.setEnabled(singleSelected); + // 删除操作在至少选中一个时可用 + boolean selected = selectedPathNum > 0; + delFileAction.setEnabled(selected); + // 刷新操作始终可用 + refreshTreeAction.setEnabled(true); + //触发vcsAction变化 + vcsAction.fireVcsActionChange(); + + // 其他状态 + otherStateChange(); + } + + public FileOperations getSelectedOperation() { + return selectedOperation; + } + /* * 新建文件夹 */ @@ -287,8 +337,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt * 版本管理 */ private class VcsAction extends UpdateAction { + public VcsAction() { - this.setName(Toolkit.i18nText("Fine-Design_Vcs_Title")); this.setSmallIcon(VcsHelper.VCS_LIST_PNG); } @@ -299,15 +349,44 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt boolean isCurrentEditing = isCurrentEditing(path); - // 如果模板正在编辑,保存后再打开版本管理 - if (isCurrentEditing) { - saveCurrentEditingTemplate(); - } - // 如果模板已经打开了,关掉,避免出现2个同名tab(1个是模板,1个是版本) closeOpenedTemplate(path, isCurrentEditing); FileVersionsPanel fileVersionTablePanel = FileVersionsPanel.getInstance(); fileVersionTablePanel.showFileVersionsPane(); + stateChange(); + + } + + /** + * 版本管理可用状态的监控 + */ + private void fireVcsActionChange() { + if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.getInstance().isUnSelectedTemplate() || FineClusterConfig.getInstance().isCluster()) { + setEnabled(false); + return; + } + + + + + if (WorkContext.getCurrent() != null) { + if (!WorkContext.getCurrent().isLocal()) { + //当前环境为远程环境时 + FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode(); + if (selectedOperation.getFilePath() != null) { + if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) { + setEnabled(false); + } else { + setEnabled(true); + } + } else { + setEnabled(false); + } + } else { + //当前环境为本地环境时 + setEnabled(selectedOperation.getFilePath() != null); + } + } } private void closeOpenedTemplate(String path, boolean isCurrentEditing) { @@ -326,19 +405,6 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } - private void saveCurrentEditingTemplate() { - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - jt.stopEditing(); - jt.saveTemplate(); - jt.requestFocus(); - } - - private boolean isCurrentEditing(String path) { - JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); - String editing = jt.getEditingFILE().getPath(); - return ComparatorUtils.equals(editing, path); - } - /** * 在系统资源管理器中打开 */ @@ -436,65 +502,10 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt } selectedOperation.deleteFile(); stateChange(); + DesignerContext.getDesignerFrame().setTitle(); } } - /** - * 按钮状态改变 - */ - @Override - public void stateChange() { - - int selectedPathNum = TemplateTreePane.getInstance().countSelectedPath(); - - // 新建文件夹,重命名操作,在explorer中打开三个操作在选中单个文件夹或者文件时可用,其他情况不可用 - boolean singleSelected = selectedPathNum == 1; - newFolderAction.setEnabled(singleSelected); - renameAction.setEnabled(singleSelected); - showInExplorerAction.setEnabled(singleSelected); - // 删除操作在至少选中一个时可用 - boolean selected = selectedPathNum > 0; - delFileAction.setEnabled(selected); - // 刷新操作始终可用 - refreshTreeAction.setEnabled(true); - handleVcsAction(); - - // 其他状态 - otherStateChange(); - } - - private void handleVcsAction() { - if (!DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() || VcsHelper.isUnSelectedTemplate()) { - vcsAction.setEnabled(false); - return; - } - - if (WorkContext.getCurrent() != null) { - if (!WorkContext.getCurrent().isLocal()) { - //当前环境为远程环境时 - FileNode node = TemplateTreePane.getInstance().getTemplateFileTree().getSelectedFileNode(); - if (selectedOperation.getFilePath() != null) { - if (node.getLock() != null && !ComparatorUtils.equals(node.getUserID(), node.getLock())) { - vcsAction.setEnabled(false); - } else { - vcsAction.setEnabled(true); - } - } else { - vcsAction.setEnabled(false); - } - } else { - //当前环境为本地环境时 - vcsAction.setEnabled(selectedOperation.getFilePath() != null); - } - } - } - - - - public FileOperations getSelectedOperation() { - return selectedOperation; - } - /** * 重命名对话框 * 支持快捷键Enter,ESC diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java index 94a1427b08..8b32d14273 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java @@ -30,7 +30,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener // 判断是否切换设计器状态到禁止拷贝剪切 if (jt.getTarget().getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(DesignerMode.BAN_COPY_AND_CUT); - } else if (!DesignModeContext.isVcsMode()){ + } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()){ DesignModeContext.switchTo(DesignerMode.NORMAL); } DesignerFrameFileDealerPane.getInstance().setCurrentEditingTemplate(jt); @@ -38,7 +38,8 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener component.onLostFocus(); remove(component); } - add(component = jt, BorderLayout.CENTER); + component = jt; + add(component, BorderLayout.CENTER); validate(); repaint(); revalidate(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index e8f1b0093b..852130c1e0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -12,6 +12,7 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.TableDataSourceAction; import com.fr.design.actions.edit.RedoAction; import com.fr.design.actions.edit.UndoAction; @@ -39,7 +40,6 @@ import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TimeConsumeTimer; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.VcsScene; -import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.menu.MenuDef; import com.fr.design.menu.NameSeparator; import com.fr.design.menu.ShortCut; @@ -112,7 +112,7 @@ public abstract class JTemplate> // 判断是否切换设计器状态到禁止拷贝剪切 if (t.getAttrMark(DesignBanCopyAttrMark.XML_TAG) != null) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.BAN_COPY_AND_CUT); - } else if (!DesignModeContext.isVcsMode()) { + } else if (!DesignModeContext.isVcsMode() && !DesignModeContext.isAuthorityEditing()) { DesignModeContext.switchTo(com.fr.design.base.mode.DesignerMode.NORMAL); } this.template = t; @@ -543,9 +543,6 @@ public abstract class JTemplate> return false; } collectInfo(); - if (DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable()) { - VcsHelper.dealWithVcs(this); - } return this.saveFile(); } @@ -606,7 +603,11 @@ public abstract class JTemplate> editingFILE = fileChooser.getSelectedFILE(); } - boolean lockedTarget = WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath()); + boolean lockedTarget = + // 目标本地文件 + !editingFILE.isEnvFile() || + // 目标远程文件 + WorkContext.getCurrent().get(TplOperator.class).saveAs(editingFILE.getPath()); if (lockedTarget) { boolean saved = saveNewFile(editingFILE, oldName); // 目标文件保存成功并且源文件不一致的情况下,把源文件锁释放掉 @@ -686,7 +687,6 @@ public abstract class JTemplate> this.saved = true; this.authoritySaved = true; DesignerContext.getDesignerFrame().setTitle(); - this.fireJTemplateSaved(); return true; } @@ -827,7 +827,7 @@ public abstract class JTemplate> // Process the listeners last to first, notifying // those that are interested in this event - for (int i = listeners.length - 2; i >= 0; i -= 2) { + for (int i = listeners.length - 1; i >= 0; i -= 1) { if (listeners[i] == JTemplateActionListener.class) { ((JTemplateActionListener) listeners[i + 1]).templateSaved(this); } 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 7f794b708b..afa6fc9077 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 6b9882397f..24b3ebfc42 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 35abeb82cc..79e94d3991 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 0000000000..b2b35da1cd --- /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/mainframe/mobile/ui/DownMenuStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java index ff76e5fed5..c5e19e8819 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/DownMenuStyleDefinePane.java @@ -2,7 +2,6 @@ package com.fr.design.mainframe.mobile.ui; import com.fr.base.GraphHelper; import com.fr.base.Icon; -import com.fr.base.IconManager; import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.gui.ilable.UILabel; @@ -11,6 +10,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.widget.UITitleSplitLine; import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.WidgetInfoConfig; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.general.FRFont; import com.fr.general.cardtag.mobile.DownMenuStyle; @@ -40,6 +40,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf { super(tagLayout); } + @Override protected void createExtraConfPane(JPanel centerPane) { JPanel panel = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 0); panel.setBorder(BorderFactory.createEmptyBorder(0, 20, 5, 20)); @@ -134,12 +135,13 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf { private static final int GAP = 6; private static final String PAINT_ICON = "fund_white"; private static final String ICON_PATH = "/com/fr/web/images/fund_white.png"; - private LineDescription splitLine; + private transient LineDescription splitLine; public DownMenuStylePreviewPane() { this.setBackground(Color.decode("#3888EE")); } + @Override public void repaint() { super.repaint(); } @@ -172,7 +174,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf { g2d.setColor(oldColor); } Icon icon = new Icon(PAINT_ICON, ICON_PATH); - g2d.drawImage(IconManager.getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null); + g2d.drawImage(WidgetInfoConfig.getInstance().getIconManager().getDefaultIconImage(icon), (eachWidth - ICON_OFFSET) / 2, (panelHeight - ICON_OFFSET - GAP - fontHeight) / 2, null); g2d.drawString(displayName, (eachWidth - width) / 2, (panelHeight + ICON_OFFSET + GAP - fontHeight) / 2 + ascent); Stroke oldStroke = g2d.getStroke(); if (splitLine.getLineStyle() != 0) { @@ -187,6 +189,7 @@ public class DownMenuStyleDefinePane extends StyleDefinePaneWithSelectConf { } + @Override public void populateConfig(MobileTemplateStyle templateStyle) { super.populateConfig(templateStyle); this.splitLine = ((DownMenuStyle) templateStyle).getSplitLine(); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java index 0996c260ce..9a13ed9d79 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.template.info; import com.fr.base.FRContext; +import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; import com.fr.log.FineLoggerFactory; import com.fr.stable.ProductConstants; @@ -12,12 +13,15 @@ import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; -import com.fr.workspace.WorkContext; +import com.fr.third.org.apache.commons.io.FileUtils; +import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -32,6 +36,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_FILE_NAME = "tpl.info"; private static TemplateInfoCollector instance; + private static final int MAX_SIZE = 512 * 1024 * 1024; private Map templateInfoMap; private DesignerOpenHistory designerOpenHistory; @@ -132,13 +137,24 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { if (!getInfoFile().exists()) { return; } - try { - XMLableReader xmlReader = XMLableReader.createXMLableReader(new FileReader(getInfoFile())); - xmlReader.readXMLObject(this); - } catch (XMLStreamException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + + XMLableReader reader = null; + try (InputStream in = new FileInputStream(getInfoFile())) { + // XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了 + reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER); + reader.readXMLObject(this); } catch (FileNotFoundException e) { // do nothing + } catch (XMLStreamException | IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (XMLStreamException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } } } @@ -152,7 +168,7 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { } private boolean shouldCollectInfo() { - return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); + return FileUtils.sizeOf(getInfoFile()) <= MAX_SIZE && DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); } /** @@ -160,8 +176,12 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter { */ private void saveInfo() { try { - FileOutputStream out = new FileOutputStream(getInfoFile()); + ByteArrayOutputStream out = new ByteArrayOutputStream(); XMLTools.writeOutputStreamXML(this, out); + out.flush(); + out.close(); + String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8); + FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8); } catch (Exception ex) { FineLoggerFactory.getLogger().error(ex.getMessage()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index cc51482565..8a739f54f1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -6,12 +6,14 @@ package com.fr.design.mainframe.toolbar; import com.fr.base.FRContext; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; +import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.BBSAction; import com.fr.design.actions.community.BugAction; import com.fr.design.actions.community.CenterAction; import com.fr.design.actions.community.CusDemandAction; +import com.fr.design.actions.community.FacebookFansAction; import com.fr.design.actions.community.NeedAction; import com.fr.design.actions.community.QuestionAction; import com.fr.design.actions.community.SignAction; @@ -24,6 +26,7 @@ import com.fr.design.actions.file.OpenTemplateAction; import com.fr.design.actions.file.PreferenceAction; import com.fr.design.actions.file.SwitchExistEnv; import com.fr.design.actions.help.AboutAction; +import com.fr.design.actions.help.FineUIAction; import com.fr.design.actions.help.TutorialAction; import com.fr.design.actions.help.WebDemoAction; import com.fr.design.actions.help.alphafine.AlphaFineAction; @@ -36,6 +39,7 @@ import com.fr.design.actions.server.PlatformManagerAction; import com.fr.design.actions.server.PluginManagerAction; import com.fr.design.file.NewTemplatePane; import com.fr.design.fun.MenuHandler; +import com.fr.design.fun.OemProcessor; import com.fr.design.fun.TableDataPaneProcessor; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -54,6 +58,10 @@ import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.utils.ThemeUtils; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleAction; +import com.fr.general.locale.LocaleCenter; +import com.fr.design.locale.impl.SupportLocaleImpl; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; import com.fr.plugin.manage.PluginFilter; @@ -62,6 +70,7 @@ import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; +import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import javax.swing.JComponent; @@ -146,7 +155,6 @@ public abstract class ToolBarMenuDock { } }; - private static final String FINEREPORT = "FineReport"; private static final int MENUBAR_HEIGHT = 22; private static final List PLUGIN_LISTENERS = new ArrayList<>(); @@ -198,6 +206,18 @@ public abstract class ToolBarMenuDock { }; this.menus = menus(plus); + try { + OemProcessor oemProcessor = OemHandler.findOem(); + if (oemProcessor != null) { + this.menus = oemProcessor.dealWithMenuDef(this.menus); + if (this.menus == null) { + this.menus = menus(plus); + } + } + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + this.menus = menus(plus); + } for (int i = 0; i < menus.length; i++) { menus[i].setHasRecMenu(true); UIMenu subMenu = menus[i].createJMenu(); @@ -223,7 +243,7 @@ public abstract class ToolBarMenuDock { public MenuDef[] menus(final ToolBarMenuDockPlus plus) { //删除之前创建的插件菜单监听 clearPluginListeners(); - java.util.List menuList = new java.util.ArrayList(); + final java.util.List menuList = new java.util.ArrayList(); // 添加文件菜单 menuList.add(createFileMenuDef(plus)); @@ -241,10 +261,13 @@ public abstract class ToolBarMenuDock { // 添加帮助菜单 menuList.add(createHelpMenuDef()); - if (GeneralContext.getLocale().equals(Locale.CHINA) || GeneralContext.getLocale().equals(Locale.TAIWAN)) { - // 添加社区菜单 - addCommunityMenuDef(menuList); - } + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + addCommunityMenuDef(menuList); + } + }, SupportLocaleImpl.COMMUNITY); + // 添加全部UpdateAction到actionmanager中 addAllUpdateActionsToList(menuList); @@ -499,9 +522,14 @@ public abstract class ToolBarMenuDock { if (AlphaFineConfigManager.isALPHALicAvailable()) { shortCuts.add(new AlphaFineAction()); } + shortCuts.add(SeparatorDef.DEFAULT); + if (DesignerEnvManager.getEnvManager().isOpenDebug()) { + shortCuts.add(new FineUIAction()); + } shortCuts.add(new AboutAction()); - return shortCuts.toArray(new ShortCut[shortCuts.size()]); + + return shortCuts.toArray(new ShortCut[0]); } /** @@ -510,7 +538,7 @@ public abstract class ToolBarMenuDock { * @return 社区菜单的子菜单 */ public ShortCut[] createCommunityShortCuts() { - java.util.List shortCuts = new ArrayList(); + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new BBSAction()); shortCuts.add(new VideoAction()); shortCuts.add(new TutorialAction()); @@ -521,6 +549,12 @@ public abstract class ToolBarMenuDock { shortCuts.add(new CusDemandAction()); shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); + LocaleCenter.buildAction(new LocaleAction() { + @Override + public void execute() { + shortCuts.add(new FacebookFansAction()); + } + }, SupportLocaleImpl.FACEBOOK); return shortCuts.toArray(new ShortCut[shortCuts.size()]); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java index dcc053e126..7f6ec1eb71 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/UpdateActionManager.java @@ -1,29 +1,46 @@ package com.fr.design.mainframe.toolbar; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.actions.UpdateAction; +import com.fr.design.actions.help.alphafine.AlphaFineConfigManager; +import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.gui.frpane.LoadingBasicPane; -import com.fr.design.utils.concurrent.ThreadFactoryBuilder; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.event.Null; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; -import javax.swing.JPanel; +import javax.swing.*; +import java.util.HashMap; import java.util.List; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** - * Created by XiaXiang on 2017/4/13. + * 按钮面板管理类 + * + * @author XiaXiang + * @date 2017/4/13 */ public class UpdateActionManager { private static UpdateActionManager updateActionManager = null; + private List updateActions; - private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor( - 1, 2, - 30000L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(), - new ThreadFactoryBuilder().setNameFormat("alphafine-thread-%s").build());//目前测下来一个线程慢慢做处理总共大概也只要两秒,暂时就这样 + + private Map updateActionsIndexCache = new HashMap<>(16); + + private static boolean isRegisterIndexSearchTextTask = false; + + /** + * 限制初始化 + */ + private UpdateActionManager() { + } public synchronized static UpdateActionManager getUpdateActionManager() { if (updateActionManager == null) { @@ -55,22 +72,92 @@ public class UpdateActionManager { return null; } - public synchronized void dealWithSearchText(final String paneClass, final UpdateAction updateAction) { - threadPoolExecutor.allowCoreThreadTimeOut(true); - threadPoolExecutor.execute(new Runnable() { + /** + * 处理action的搜索文本。 + * 缓存逻辑: + * 1.首次索引或缓存失效的时候(更新版本会使缓存失效),会将索引缓存存到env.xml, + * 下次直接加载。 + * 2.需要重新索引,则等待设计器初始化完毕之后单线程运行索引任务。 + * + * @param paneClass 面板类名 + * @param updateAction 待处理的updateAction + */ + public void dealWithSearchText(String paneClass, UpdateAction updateAction) { + Map actionSearchTextCache = AlphaFineConfigManager.getInstance().getActionSearchTextCache(); + if (!cacheValid() + || actionSearchTextCache.isEmpty() + || !actionSearchTextCache.containsKey(paneClass)) { + if (!updateActionsIndexCache.containsKey(paneClass)) { + updateActionsIndexCache.put(paneClass, updateAction); + } + registerIndexSearchTextTask(); + } else { + updateAction.setSearchText(actionSearchTextCache.get(paneClass)); + } + } + + /** + * 缓存是否有效。 + * 注意:开发工程版本为不是安装版本, + * 索引只会出现在首次启动。 + * + * @return true有效,false失效 + */ + private boolean cacheValid() { + return ComparatorUtils.equals(GeneralUtils.readBuildNO(), AlphaFineConfigManager.getInstance().getCacheBuildNO()); + } + + /** + * 由于是UI线程不考虑并发问题 + */ + private void registerIndexSearchTextTask() { + if (isRegisterIndexSearchTextTask) { + return; + } + isRegisterIndexSearchTextTask = true; + // 没有缓存或者缓存失效的时候,等待设计器启动之后开始索引任务 + EventDispatcher.listen(DesignerLaunchStatus.OPEN_LAST_FILE_COMPLETE, new Listener() { @Override - public void run() { - JPanel panel = null; - try { - panel = (JPanel) StableUtils.classForName(paneClass).newInstance(); - if (panel instanceof LoadingBasicPane) { - panel = ((LoadingBasicPane) panel).getAllComponents(); - } - updateAction.setSearchText(updateAction.getComponentTexts(panel, "_", new StringBuffer(), new StringBuffer(), new StringBuffer())); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + public void on(Event event, Null param) { + // 使用单线程索引 + ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("IndexAlphaFineSearchText")); + for (Map.Entry cache : updateActionsIndexCache.entrySet()) { + es.execute(new IndexTask(cache.getKey(), cache.getValue())); } + updateActionsIndexCache = null; + es.shutdown(); + // 标记一下缓存版本 + AlphaFineConfigManager.getInstance().setCacheBuildNO(GeneralUtils.readBuildNO()); } }); } + + /** + * 索引任务 + */ + class IndexTask implements Runnable { + private String className; + private UpdateAction updateAction; + + IndexTask(String className, UpdateAction updateAction) { + this.className = className; + this.updateAction = updateAction; + } + + @Override + public void run() { + JPanel panel; + try { + panel = (JPanel) StableUtils.classForName(className).newInstance(); + if (panel instanceof LoadingBasicPane) { + panel = ((LoadingBasicPane) panel).getAllComponents(); + } + String componentTexts = updateAction.getComponentTexts(panel, "_", new StringBuffer(), new StringBuffer(), new StringBuffer()); + updateAction.setSearchText(componentTexts); + AlphaFineConfigManager.getInstance().setActionSearchTextCache(className, componentTexts); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java index bbb6e9d9b5..f61bba67a8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsConfigManager.java @@ -11,10 +11,10 @@ import com.fr.stable.xml.XMLableReader; public class VcsConfigManager implements XMLReadable, XMLWriter { public static final String XML_TAG = "VcsConfigManager"; private static volatile VcsConfigManager instance = new VcsConfigManager(); - private boolean vcsEnable; - private boolean saveCommit; - private boolean useInterval; - private int saveInterval; + private boolean vcsEnable = true; + private boolean saveCommit = true; + private boolean useInterval = true; + private int saveInterval = 60; public static VcsConfigManager getInstance() { return instance; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java index 9933fc0e74..67ab8dfb06 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsCacheFileNodeFile.java @@ -6,9 +6,11 @@ import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.stable.StableUtils; import com.fr.workspace.WorkContext; -import com.fr.workspace.resource.WorkResource; import com.fr.workspace.resource.WorkResourceOutputStream; +import com.fr.workspace.server.lock.TplOperator; +import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; +import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.OutputStream; @@ -29,19 +31,21 @@ public class VcsCacheFileNodeFile extends FileNodeFILE { * @throws Exception */ @Override - public InputStream asInputStream() { + public InputStream asInputStream() throws Exception { if (node == null) { return null; } - + String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath(); String envPath = node.getEnvPath(); - // envPath必须以vcs开头 - if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { + // envPath必须以VcsCacheRelativePath开头 + if (!envPath.startsWith(vcsCacheDir)) { return null; } - - InputStream in = WorkContext.getCurrent().get(WorkResource.class) - .openStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1))); + InputStream in = new ByteArrayInputStream( + WorkContext.getCurrent().get(TplOperator.class).readAndLockFile( + StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1)) + ) + ); return envPath.endsWith(".cpt") || envPath.endsWith(".frm") ? XMLEncryptUtils.decodeInputStream(in) : in; @@ -59,13 +63,13 @@ public class VcsCacheFileNodeFile extends FileNodeFILE { if (ComparatorUtils.equals(node, null)) { return null; } - + String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath(); String envPath = node.getEnvPath(); - // envPath必须以reportLets开头 - if (!envPath.startsWith(VcsHelper.VCS_CACHE_DIR)) { + // envPath必须以VcsCacheRelativePath开头 + if (!envPath.startsWith(vcsCacheDir)) { return null; } - return new WorkResourceOutputStream(StableUtils.pathJoin(VcsHelper.VCS_CACHE_DIR, envPath.substring(VcsHelper.VCS_CACHE_DIR.length() + 1))); + return new WorkResourceOutputStream(StableUtils.pathJoin(vcsCacheDir, envPath.substring(vcsCacheDir.length() + 1))); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index d5c8c01657..0b3213ac52 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.vcs.common; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.TemplateTreePane; @@ -7,6 +8,7 @@ import com.fr.design.gui.itree.filetree.TemplateFileTree; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JTemplateActionListener; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.ui.FileVersionTable; import com.fr.general.IOUtils; @@ -17,6 +19,7 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; +import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; import javax.swing.Icon; import javax.swing.border.EmptyBorder; @@ -28,27 +31,13 @@ import static com.fr.stable.StableUtils.pathJoin; /** * Created by XiaXiang on 2019/4/17. */ -public class VcsHelper { - - private final static String VCS_DIR = "vcs"; - public final static String VCS_CACHE_DIR = pathJoin(VCS_DIR, "cache"); - private static final int MINUTE = 60 * 1000; - private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10"; - - - public final static String CURRENT_USERNAME = WorkContext.getCurrent().isLocal() - ? Toolkit.i18nText("Fine-Design_Vcs_Local_User") - : WorkContext.getCurrent().getConnection().getUserName(); +public class VcsHelper implements JTemplateActionListener { public final static Color TABLE_SELECT_BACKGROUND = new Color(0xD8F2FD); public final static Color COPY_VERSION_BTN_COLOR = new Color(0x419BF9); - - public final static EmptyBorder EMPTY_BORDER = new EmptyBorder(10, 10, 0, 10); - + public final static EmptyBorder EMPTY_BORDER_MEDIUM = new EmptyBorder(5, 10, 0, 10); public final static EmptyBorder EMPTY_BORDER_BOTTOM = new EmptyBorder(10, 10, 10, 10); - - public final static Icon VCS_LIST_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/vcs_list.png"); public final static Icon VCS_BACK_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/vcs_back.png"); public final static Icon VCS_FILTER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_filter@1x.png"); @@ -56,8 +45,16 @@ public class VcsHelper { public final static Icon VCS_DELETE_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_delete.png"); public final static Icon VCS_USER_PNG = IOUtils.readIcon("/com/fr/design/images/vcs/icon_user@1x.png"); public final static Icon VCS_REVERT = IOUtils.readIcon("/com/fr/design/images/vcs/icon_revert.png"); + public final static int OFFSET = 2; + private static final int MINUTE = 60 * 1000; + private final static String VCS_PLUGIN_ID = "com.fr.plugin.vcs.v10"; + private static final VcsHelper instance = new VcsHelper(); + + public static VcsHelper getInstance() { + return instance; + } - private static int containsFolderCounts() { + private int containsFolderCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { return 0; @@ -71,7 +68,13 @@ public class VcsHelper { return fileTree.getSelectionPaths().length - fileTree.getSelectedTemplatePaths().length; } - private static int selectedTemplateCounts() { + public String getCurrentUsername() { + return WorkContext.getCurrent().isLocal() + ? Toolkit.i18nText("Fine-Design_Vcs_Local_User") + : WorkContext.getCurrent().getConnection().getUserName(); + } + + private int selectedTemplateCounts() { TemplateFileTree fileTree = TemplateTreePane.getInstance().getTemplateFileTree(); if (fileTree.getSelectionPaths() == null) { return 0; @@ -80,17 +83,18 @@ public class VcsHelper { return fileTree.getSelectedTemplatePaths().length; } - public static boolean isUnSelectedTemplate() { - return VcsHelper.containsFolderCounts() + VcsHelper.selectedTemplateCounts() != 1; + public boolean isUnSelectedTemplate() { + return containsFolderCounts() + selectedTemplateCounts() != 1; } - public static String getEditingFilename() { + private String getEditingFilename() { + String vcsCacheDir = VcsFileSystem.getInstance().getVcsCacheRelativePath(); JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); String editingFilePath = jt.getEditingFILE().getPath(); if (editingFilePath.startsWith(ProjectConstants.REPORTLETS_NAME)) { editingFilePath = editingFilePath.replaceFirst(ProjectConstants.REPORTLETS_NAME, StringUtils.EMPTY); - } else if (editingFilePath.startsWith(VcsHelper.VCS_CACHE_DIR)) { - editingFilePath = editingFilePath.replaceFirst(VcsHelper.VCS_CACHE_DIR, StringUtils.EMPTY); + } else if (editingFilePath.startsWith(vcsCacheDir)) { + editingFilePath = editingFilePath.replaceFirst(vcsCacheDir, StringUtils.EMPTY); } if (editingFilePath.startsWith("/")) { editingFilePath = editingFilePath.substring(1); @@ -98,23 +102,28 @@ public class VcsHelper { return editingFilePath; } - public static boolean needDeleteVersion(VcsEntity entity) { - if (entity == null || !DesignerEnvManager.getEnvManager().getVcsConfigManager().isUseInterval()) { + private boolean needDeleteVersion(VcsEntity entity) { + VcsConfigManager configManager = DesignerEnvManager.getEnvManager().getVcsConfigManager(); + if (entity == null || !configManager.isUseInterval()) { + return false; + } + if (configManager.isSaveCommit() && StringUtils.isNotBlank(entity.getCommitMsg())) { return false; } - return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE && StringUtils.isBlank(entity.getCommitMsg()); + return new Date().getTime() - entity.getTime().getTime() < DesignerEnvManager.getEnvManager().getVcsConfigManager().getSaveInterval() * MINUTE; } - public static boolean needInit() { + public boolean needInit() { PluginContext context = PluginManager.getContext(VCS_PLUGIN_ID); - return context == null || !context.isActive(); + return context == null || !context.isRunning(); } /** * 版本控制 + * * @param jt */ - public static void dealWithVcs(final JTemplate jt) { + public void fireVcs(final JTemplate jt) { new Thread(new Runnable() { @Override public void run() { @@ -127,14 +136,14 @@ public class VcsHelper { latestFileVersion = entity.getVersion(); } if (jt.getEditingFILE() instanceof VcsCacheFileNodeFile) { - operator.saveVersionFromCache(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); + operator.saveVersionFromCache(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); FileVersionTable.getInstance().updateModel(1, WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", ""))); } else { - operator.saveVersion(VcsHelper.CURRENT_USERNAME, fileName, StringUtils.EMPTY, latestFileVersion + 1); + operator.saveVersion(getCurrentUsername(), fileName, StringUtils.EMPTY, latestFileVersion + 1); } - VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndex(fileName, 1); - if (VcsHelper.needDeleteVersion(oldEntity)) { + VcsEntity oldEntity = WorkContext.getCurrent().get(VcsOperator.class).getFileVersionByIndexAndUsername(fileName, getCurrentUsername(), 1); + if (needDeleteVersion(oldEntity)) { operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion()); } @@ -144,4 +153,25 @@ public class VcsHelper { } + @Override + public void templateOpened(JTemplate jt) { + + } + + /** + * 模板保存时 处理. + * + * @param jt 模板 + */ + @Override + public void templateSaved(JTemplate jt) { + if (needInit() && DesignerEnvManager.getEnvManager().getVcsConfigManager().isVcsEnable() && !FineClusterConfig.getInstance().isCluster()) { + fireVcs(jt); + } + } + + @Override + public void templateClosed(JTemplate jt) { + + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java index f6533de4df..105a9b872a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/EditFileVersionDialog.java @@ -7,17 +7,19 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.locale.InterProviderFactory; -import com.fr.report.ReportContext; +import com.fr.log.FineLoggerFactory; import com.fr.report.entity.VcsEntity; +import com.fr.stable.StringUtils; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.vcs.VcsOperator; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; import java.awt.Frame; -import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -80,8 +82,11 @@ public class EditFileVersionDialog extends UIDialog { @Override public void actionPerformed(ActionEvent e) { entity.setCommitMsg(msgTestArea.getText()); - ReportContext.getInstance().getVcsController().saveOrUpdateFileVersion(entity); + WorkContext.getCurrent().get(VcsOperator.class).updateVersion(entity); setVisible(false); + String path = DesignerFrameFileDealerPane.getInstance().getSelectedOperation().getFilePath(); + FileVersionTable table = FileVersionTable.getInstance(); + table.updateModel(table.getSelectedRow(), WorkContext.getCurrent().get(VcsOperator.class).getVersions(path.replaceFirst("/", StringUtils.EMPTY))); } }); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java index a7f7f5ef0a..125d4bc4e0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellEditor.java @@ -8,6 +8,7 @@ import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.mainframe.vcs.common.VcsCacheFileNodeFile; import com.fr.file.filetree.FileNode; +import com.fr.general.ComparatorUtils; import com.fr.report.entity.VcsEntity; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; @@ -53,9 +54,13 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe //先关闭当前打开的模板版本 JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); jt.stopEditing(); - MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); - MutilTempalteTabPane.getInstance().closeFormat(jt); - MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(jt); + //只有模板路径一致时关闭当前模板 + if (ComparatorUtils.equals(fileOfVersion, jt.getPath())) { + MutilTempalteTabPane.getInstance().setIsCloseCurrent(true); + MutilTempalteTabPane.getInstance().closeFormat(jt); + MutilTempalteTabPane.getInstance().closeSpecifiedTemplate(jt); + } + //再打开cache中的模板 DesignerContext.getDesignerFrame().openTemplate(new VcsCacheFileNodeFile(new FileNode(fileOfVersion, false))); @@ -63,7 +68,7 @@ public class FileVersionCellEditor extends AbstractCellEditor implements TableCe double height = editor.getPreferredSize().getHeight(); if (table.getRowHeight(row) != height) { - table.setRowHeight(row, (int) height); + table.setRowHeight(row, (int) height + VcsHelper.OFFSET); } return editor; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java index c1cc23fc45..40fa02c1fe 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionCellRender.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.vcs.ui; +import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.report.entity.VcsEntity; import javax.swing.JPanel; @@ -34,7 +35,7 @@ public class FileVersionCellRender implements TableCellRenderer { double height = editor.getPreferredSize().getHeight(); if (table.getRowHeight(row) != height) { - table.setRowHeight(row, (int) height); + table.setRowHeight(row, (int) height + VcsHelper.OFFSET); } return editor; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java index 33076a07f0..15d8bae63e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionDialog.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.vcs.ui; +import com.fr.analysis.cloud.DateUtils; import com.fr.design.dialog.UIDialog; import com.fr.design.editor.editor.DateEditor; import com.fr.design.gui.date.UIDatePicker; @@ -14,6 +15,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; import javax.swing.AbstractAction; +import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -45,7 +47,7 @@ public class FileVersionDialog extends UIDialog { upBox.setBorder(VcsHelper.EMPTY_BORDER); upBox.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_buildTime") + " ")); upBox.add(Box.createHorizontalGlue()); - dateEditor = new DateEditor(new Date(), true, StringUtils.EMPTY, UIDatePicker.STYLE_CN_DATE1); + dateEditor = new VcsDateEditor(new Date(), true, StringUtils.EMPTY, UIDatePicker.STYLE_CN_DATE1); upBox.add(dateEditor); Box downBox = Box.createHorizontalBox(); downBox.setBorder(VcsHelper.EMPTY_BORDER); @@ -62,8 +64,10 @@ public class FileVersionDialog extends UIDialog { @Override public void actionPerformed(ActionEvent e) { FileVersionDialog.this.setVisible(false); - Date date = dateEditor.getValue(); - List vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, date, new Date(date.getTime() + DELAY), textField.getText()); + Date editorDate = dateEditor.getValue(); + Date start = editorDate == null ? new Date(0) : editorDate; + Date end = editorDate == null ? DateUtils.getLastHour() : new Date(start.getTime() + DELAY); + List vcsEntities = WorkContext.getCurrent().get(VcsOperator.class).getFilterVersions(fileName, start, end, textField.getText()); FileVersionTable.getInstance().updateModel(1, vcsEntities); } @@ -74,16 +78,29 @@ public class FileVersionDialog extends UIDialog { FileVersionDialog.this.setVisible(false); } }); + VcsLabel resetLabel = new VcsLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_resetValue"), VcsHelper.COPY_VERSION_BTN_COLOR); + resetLabel.setBorder(BorderFactory.createEmptyBorder(10, 160, 0, 10)); + resetLabel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dateEditor.setValue(null); + textField.setText(null); + FileVersionDialog.this.repaint(); + } + }); panel.add(upBox, BorderLayout.NORTH); panel.add(downBox, BorderLayout.CENTER); panel.add(buttonPane, BorderLayout.SOUTH); - add(panel); - setSize(new Dimension(230, 105)); - centerWindow(this); + JPanel filterPane = new JPanel(new BorderLayout()); + filterPane.add(resetLabel, BorderLayout.NORTH); + filterPane.add(panel, BorderLayout.CENTER); + add(filterPane); + setSize(new Dimension(230, 125)); + centerWindow(frame); } private void centerWindow(Window window) { - window.setLocation(0, 95); + this.setLocation(window.getX(), 95); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java index 9d892ba535..ff0a93fa8b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionFirstRowPanel.java @@ -15,7 +15,7 @@ public class FileVersionFirstRowPanel extends JPanel { super(new BorderLayout()); Box upPane = Box.createVerticalBox(); upPane.setBorder(new EmptyBorder(5, 10, 5, 10)); - upPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Local_User"))); + upPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Current"))); add(upPane, BorderLayout.CENTER); } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java index 657e990cc4..cd01d409c4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionRowPanel.java @@ -43,13 +43,13 @@ public class FileVersionRowPanel extends JPanel { // version + username Box upPane = Box.createHorizontalBox(); - upPane.setBorder(VcsHelper.EMPTY_BORDER); + upPane.setBorder(VcsHelper.EMPTY_BORDER_MEDIUM); upPane.add(versionLabel); upPane.add(Box.createHorizontalGlue()); // msg - msgLabel.setBorder(VcsHelper.EMPTY_BORDER); + msgLabel.setBorder(VcsHelper.EMPTY_BORDER_MEDIUM); msgLabel.setOpaque(false); msgLabel.setBackground(new Color(0, 0, 0, 0)); msgLabel.setEditable(false); @@ -63,6 +63,7 @@ public class FileVersionRowPanel extends JPanel { public void actionPerformed(ActionEvent evt) { if (JOptionPane.showConfirmDialog(null, Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Confirm"), Toolkit.i18nText("Fine-Design_Vcs_Version_Revert_Title"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + vcsEntity.setUsername(VcsHelper.getInstance().getCurrentUsername()); WorkContext.getCurrent().get(VcsOperator.class).rollbackTo(vcsEntity); FileVersionsPanel.getInstance().exitVcs(vcsEntity.getFilename()); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java index 7f9fc56fe3..4d9b6e35e6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/FileVersionsPanel.java @@ -19,7 +19,6 @@ import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.menu.ToolBarDef; import com.fr.file.FileNodeFILE; import com.fr.file.filetree.FileNode; -import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; @@ -101,7 +100,8 @@ public class FileVersionsPanel extends BasicPane { } private void showFilterPane() { - versionDialog = new FileVersionDialog(DesignerContext.getDesignerFrame(), templatePath); + String savePath = templatePath.startsWith("/") ? templatePath.substring(1) : templatePath; + versionDialog = new FileVersionDialog(DesignerContext.getDesignerFrame(), savePath); versionDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java new file mode 100644 index 0000000000..74b65ecfe2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsDateEditor.java @@ -0,0 +1,37 @@ +package com.fr.design.mainframe.vcs.ui; + +import com.fr.design.editor.editor.DateEditor; +import com.fr.log.FineLoggerFactory; + +import java.text.ParseException; +import java.util.Date; + +/** + * Created by XiaXiang on 2019/5/14. + */ +public class VcsDateEditor extends DateEditor { + private Date tempValue; + + public VcsDateEditor(Date value, boolean format, String name, int dateFormat) { + super(value, format, name, dateFormat); + this.tempValue = value; + } + + @Override + public Date getValue() { + if (tempValue == null) { + return null; + } + return super.getValue(); + } + + @Override + public void setValue(Date value) { + this.tempValue = value; + try { + getUiDatePicker().setSelectedDate(value); + } catch (ParseException parseException) { + FineLoggerFactory.getLogger().error(parseException.getMessage(), parseException); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java new file mode 100755 index 0000000000..a0180a1379 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsLabel.java @@ -0,0 +1,32 @@ +package com.fr.design.mainframe.vcs.ui; + + +import com.fr.design.gui.ilable.ActionLabel; +import com.fr.design.gui.ilable.UILabel; + +import java.awt.Color; +import java.awt.Graphics; + +/** + * Created by XiaXiang on 2019/5/15. + */ +public class VcsLabel extends ActionLabel { + + + public VcsLabel(String text, Color color) { + super(text); + this.setForeground(color); + } + + public void paintComponent(Graphics g) { + if (ui != null) { + Graphics scratchGraphics = (g == null) ? null : g.create(); + try { + ui.update(scratchGraphics, this); + } + finally { + scratchGraphics.dispose(); + } + } + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java b/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java index dde3acec6c..07c51312ec 100644 --- a/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java @@ -2,25 +2,27 @@ package com.fr.design.menu; import com.fr.design.gui.itoolbar.UIToolBarUI; import com.fr.design.gui.itoolbar.UIToolbar; +import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** * Define toolbar.. */ -public class ToolBarDef { - +public class ToolBarDef { + // item List. private List shortcutList = new ArrayList(); - /* + /** * 一个static的方法生成一个JToolBar */ public static UIToolbar createJToolBar(final Color background) { - UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI(){ + UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT, new UIToolBarUI() { @Override public void paint(Graphics g, JComponent c) { Graphics2D g2 = (Graphics2D) g; @@ -33,13 +35,13 @@ public class ToolBarDef { } - /* + /** * 一个static的方法生成一个JToolBar */ public static UIToolbar createJToolBar() { - UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT); + UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT); toolbar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0)); - return toolbar; + return toolbar; } public ToolBarDef() { @@ -49,31 +51,34 @@ public class ToolBarDef { return this.shortcutList.size(); } + @Nullable public ShortCut getShortCut(int index) { return this.shortcutList.get(index); } -// 用可变参数,方便添加数组 + /** + * 用可变参数,方便添加数组 + */ public void addShortCut(ShortCut... shortcut) { - for(ShortCut i : shortcut){ - this.shortcutList.add(i); - } + Collections.addAll(this.shortcutList, shortcut); } - + public void clearShortCuts() { this.shortcutList.clear(); } - /* + /** * 根据当前的ToolBarDef,更新toolBar */ public void updateToolBar(UIToolbar toolBar) { toolBar.removeAll(); - + int actionCount = this.getShortCutCount(); for (int i = 0; i < actionCount; i++) { - ShortCut shortcut = this.getShortCut(i); - shortcut.intoJToolBar(toolBar); + ShortCut shortcut = this.getShortCut(i); + if (shortcut != null) { + shortcut.intoJToolBar(toolBar); + } } } diff --git a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java index 22ea7aa359..74cf7cbd35 100644 --- a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java +++ b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java @@ -16,6 +16,7 @@ import com.fr.design.parameter.ParameterReader; import com.fr.form.ui.Widget; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; +import org.jetbrains.annotations.NotNull; import java.awt.Dialog; import java.awt.Frame; @@ -65,8 +66,9 @@ public class DesignModuleFactory { instance.creators4Hyperlink = nameableCreators; } + @NotNull public static NameableCreator[] getCreators4Hyperlink() { - return instance.creators4Hyperlink; + return instance.creators4Hyperlink == null? new NameableCreator[0]:instance.creators4Hyperlink; } public static void registerExtraWidgetOptions(WidgetOption[] options) { diff --git a/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java b/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java index a412e0a8a8..d839461dda 100644 --- a/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java +++ b/designer-base/src/main/java/com/fr/design/roleAuthority/ReportAndFSManagePane.java @@ -11,18 +11,29 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignAuthorityEventType; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.DockingView; import com.fr.design.menu.ToolBarDef; - - -import javax.swing.*; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.ScrollPaneConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; +import javax.swing.tree.DefaultTreeSelectionModel; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -40,6 +51,15 @@ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSo private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; + static { + EventDispatcher.listen(DesignAuthorityEventType.StopEdit, new Listener() { + + public void on(Event event, DesignerFrame param) { + DefaultTreeSelectionModel model = roleTree.getCheckBoxTreeSelectionModel(); + model.removeSelectionPaths(model.getSelectionPaths()); + } + }); + } private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; 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 0e5cbe4635..bc4f3f41cc 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 601f0ac36f..3962692c73 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,5 +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); } } 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 6636e28744..04d2f0f853 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 @@ -1,7 +1,13 @@ 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; +import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.web.struct.AssembleComponent; import com.fr.web.struct.AtomBuilder; import com.fr.web.struct.PathGroup; @@ -11,7 +17,15 @@ 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; /** * @author richie @@ -21,6 +35,7 @@ import java.io.InputStream; public class EmbProtocolHandler implements ProtocolHandler { private AssembleComponent component; + private Map map; public EmbProtocolHandler() { @@ -30,33 +45,58 @@ public class EmbProtocolHandler implements ProtocolHandler { this.component = component; } + public EmbProtocolHandler(AssembleComponent component, Map map) { + this.component = component; + this.map = map; + } + + public EmbProtocolHandler(Map map) { + this.map = map; + } @Override public URLResponse onRequest(URLRequest req) { + InputStream inputStream = null; try { String path = req.getURL(); - if (path.startsWith("emb:dynamic")) { + 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 = 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 { + } else { int index = path.indexOf("="); if (index > 0) { path = path.substring(index + 1); } else { path = path.substring(4); } - InputStream inputStream = IOUtils.readResource(path); + inputStream = IOUtils.readResource(path); return Assistant.inputStream2Response(inputStream, path); } - } catch (Exception ignore) { - + } 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(); @@ -78,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 81f9e051b5..4a92d3715c 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 @@ -2,6 +2,10 @@ package com.fr.design.ui; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.web.struct.AssembleComponent; import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.BrowserPreferences; @@ -14,8 +18,11 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; import com.teamdev.jxbrowser.chromium.events.ScriptContextListener; import com.teamdev.jxbrowser.chromium.swing.BrowserView; -import javax.swing.JSplitPane; -import java.awt.BorderLayout; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Map; /** * @author richie @@ -39,17 +46,38 @@ public class ModernUIPane extends BasicPane { setLayout(new BorderLayout()); BrowserPreferences.setChromiumSwitches("--disable-google-traffic"); if (DesignerEnvManager.getEnvManager().isOpenDebug()) { - JSplitPane splitPane = new JSplitPane(); - add(splitPane, BorderLayout.CENTER); - splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); - splitPane.setDividerLocation(500); + UIToolbar toolbar = new UIToolbar(); + add(toolbar, BorderLayout.NORTH); + UIButton openDebugButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Open_Debug_Window")); + 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 + public void actionPerformed(ActionEvent e) { + showDebuggerDialog(); + } + }); + + reloadButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + 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(); - splitPane.setLeftComponent(new BrowserView(browser)); - Browser debugger = new Browser(); - debugger.loadURL(browser.getRemoteDebuggingURL()); - BrowserView debuggerView = new BrowserView(debugger); - splitPane.setRightComponent(debuggerView); + add(new BrowserView(browser), BorderLayout.CENTER); } else { initializeBrowser(); add(new BrowserView(browser), BorderLayout.CENTER); @@ -57,6 +85,18 @@ public class ModernUIPane extends BasicPane { } } + private void showDebuggerDialog() { + JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this)); + Browser debugger = new Browser(); + BrowserView debuggerView = new BrowserView(debugger); + dialog.add(debuggerView, BorderLayout.CENTER); + dialog.setSize(new Dimension(800, 400)); + GUICoreUtils.centerWindow(dialog); + dialog.setVisible(true); + dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + debugger.loadURL(browser.getRemoteDebuggingURL()); + } + private void initializeBrowser() { browser = new Browser(); // 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的 @@ -68,6 +108,24 @@ public class ModernUIPane extends BasicPane { }); } + /** + * 转向一个新的地址,相当于重新加载 + * @param url 新的地址 + */ + public void redirect(String url) { + 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"; @@ -126,6 +184,16 @@ public class ModernUIPane extends BasicPane { return this; } + /** + * 加载url指向的资源 + * @param url 文件的地址 + */ + public Builder withURL(final String url, Map map) { + Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(map)); + pane.browser.loadURL(url); + return this; + } + /** * 加载Atom组件 * @param component Atom组件 @@ -136,6 +204,17 @@ public class ModernUIPane extends BasicPane { return this; } + /** + * 加载Atom组件 + * @param component Atom组件 + */ + public Builder withComponent(AssembleComponent component, Map map) { + Assistant.setEmbProtocolHandler(pane.browser, new EmbProtocolHandler(component, map)); + pane.browser.loadURL("emb:dynamic"); + return this; + } + + /** * 加载html文本内容 * @param html 要加载html文本内容 diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java index ab093605e1..d35b1dd543 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateDialog.java @@ -37,6 +37,7 @@ class DesignerPushUpdateDialog extends UIDialog { static void createAndShow(final Frame parent, final DesignerUpdateInfo updateInfo) { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { DesignerPushUpdateDialog dialog = new DesignerPushUpdateDialog(parent); dialog.populate(updateInfo); diff --git a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java index dcb5d45fd2..44cfb146b1 100644 --- a/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java +++ b/designer-base/src/main/java/com/fr/design/update/push/DesignerPushUpdateManager.java @@ -1,5 +1,6 @@ package com.fr.design.update.push; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.event.DesignerOpenedListener; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; @@ -13,12 +14,17 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + /** * Created by plough on 2019/4/8. */ public class DesignerPushUpdateManager { private static final String SPLIT_CHAR = "-"; private static DesignerPushUpdateManager singleton; + private final ExecutorService checkUpdateService = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignerCheckUpdate")); + private final ExecutorService updateService = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignerUpdate")); private DesignerUpdateInfo updateInfo; @@ -94,7 +100,7 @@ public class DesignerPushUpdateManager { * 检查更新,如果有合适的更新版本,则弹窗 */ private void checkAndPop() { - new Thread() { + checkUpdateService.execute(new Runnable() { @Override public void run() { if (!shouldPopUp()) { @@ -104,7 +110,8 @@ public class DesignerPushUpdateManager { final DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); DesignerPushUpdateDialog.createAndShow(designerFrame, updateInfo); } - }.start(); + }); + checkUpdateService.shutdown(); } private boolean shouldPopUp() { @@ -146,14 +153,15 @@ public class DesignerPushUpdateManager { * 跳转到更新升级窗口,并自动开始更新 */ void doUpdate() { - new Thread() { + updateService.execute(new Runnable() { @Override public void run() { UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); dialog.setAutoUpdateAfterInit(); dialog.showDialog(); } - }.start(); + }); + updateService.shutdown(); } /** diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java index cc22902169..df16261931 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreResultDialog.java @@ -1,6 +1,5 @@ package com.fr.design.update.ui.dialog; -import com.fr.base.FRContext; import com.fr.design.RestartHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ilable.UILabel; @@ -8,6 +7,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.update.domain.UpdateConstants; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; +import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; @@ -175,8 +175,8 @@ public class RestoreResultDialog extends JDialog { String backupDir = UpdateConstants.DESIGNER_BACKUP_DIR; for (String file : files) { map.put(StableUtils.pathJoin(installHome, backupDir, jarRestoreDir, file), - StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); - list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); + StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); + list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 5e5943051e..e59cc09fff 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -1,6 +1,5 @@ package com.fr.design.update.ui.dialog; -import com.fr.base.FRContext; import com.fr.design.RestartHelper; import com.fr.design.constants.LayoutConstants; import com.fr.design.dialog.UIDialog; @@ -23,6 +22,7 @@ import com.fr.design.update.ui.widget.UpdateInfoTableCellRender; import com.fr.design.update.ui.widget.UpdateInfoTableModel; import com.fr.design.update.ui.widget.UpdateInfoTextAreaCellRender; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.DateUtils; import com.fr.general.GeneralContext; @@ -30,6 +30,7 @@ import com.fr.general.GeneralUtils; import com.fr.general.IOUtils; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; +import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; @@ -38,6 +39,7 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; +import com.fr.third.org.apache.commons.codec.digest.DigestUtils; import com.fr.workspace.WorkContext; import com.sun.java.swing.plaf.motif.MotifProgressBarUI; @@ -372,9 +374,7 @@ public class UpdateMainDialog extends UIDialog { new SwingWorker() { @Override protected JSONObject doInBackground() throws Exception { - HttpClient hc = new HttpClient(SiteCenter.getInstance().acquireUrlByKind("jar10.update")); - hc.setTimeout(UpdateConstants.CONNECTION_TIMEOUT); - return new JSONObject(hc.getResponseText()); + return new JSONObject(HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update"))); } @Override @@ -621,8 +621,11 @@ public class UpdateMainDialog extends UIDialog { long downloadSize = jo.optLong("size"); if (ComparatorUtils.equals(category, "server")) { File currentJAR = new File(StableUtils.pathJoin(WorkContext.getCurrent().getPath(), ProjectConstants.LIB_NAME, downloadName)); - if (currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize)) { - //假如大小一样的jar包就不要下载了 + String currentMD5 = getCurrentJarMD5(currentJAR); + String downloadMD5 = jo.optString("md5"); + boolean exist = currentJAR.exists() && ComparatorUtils.equals(currentJAR.length(), downloadSize) && ComparatorUtils.equals(currentMD5, downloadMD5); + if (exist) { + // 如果jar包存在且MD5值和大小与oss上的一致 不下载 continue; } } @@ -631,6 +634,31 @@ public class UpdateMainDialog extends UIDialog { } } + /** + * 获取当前jar的md5 + * @param currentJAR + * @return + */ + private String getCurrentJarMD5(File currentJAR) { + String md5 = StringUtils.EMPTY; + FileInputStream input = null; + try { + input = new FileInputStream(currentJAR); + md5 = DigestUtils.md5Hex(input); + } catch (Exception ignore) { + + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + return md5; + } + /** * jar包更新按钮监听器 */ @@ -707,7 +735,7 @@ public class UpdateMainDialog extends UIDialog { for (String file : files) { try { IOUtils.copy( - new File(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)), + new File(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)), new File(StableUtils.pathJoin(todayBackupDir))); } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage()); @@ -748,8 +776,8 @@ public class UpdateMainDialog extends UIDialog { private void putNewFilesToInstallEnv(String installHome, String[] files, Map map, java.util.List list) { for (String file : files) { map.put(StableUtils.pathJoin(installHome, UpdateConstants.DOWNLOAD_DIR, file), - StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); - list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, FRContext.getCommonOperator().getAppName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); + StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); + list.add(StableUtils.pathJoin(installHome, UpdateConstants.APPS_FOLDER_NAME, ProductConstants.getAppFolderName(), ProjectConstants.WEBINF_NAME, ProjectConstants.LIB_NAME, file)); } } 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 new file mode 100644 index 0000000000..6a4b752fd1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/UpmBridge.java @@ -0,0 +1,468 @@ +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; +import com.fr.design.extra.PluginOperateUtils; +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; +import com.fr.design.i18n.Toolkit; +import com.fr.design.upm.event.CertificateEvent; +import com.fr.design.upm.event.DownloadEvent; +import com.fr.design.upm.exec.UpmBrowserExecutor; +import com.fr.design.upm.task.UpmTaskWorker; +import com.fr.event.EventDispatcher; +import com.fr.general.CloudCenter; +import com.fr.general.GeneralUtils; +import com.fr.json.JSONObject; +import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginMarker; +import com.fr.stable.ArrayUtils; +import com.fr.stable.StringUtils; +import com.teamdev.jxbrowser.chromium.Browser; +import com.teamdev.jxbrowser.chromium.JSArray; +import com.teamdev.jxbrowser.chromium.JSFunction; +import com.teamdev.jxbrowser.chromium.JSObject; + +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import java.awt.*; +import java.io.File; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; +import java.util.concurrent.FutureTask; +import java.util.concurrent.RunnableFuture; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-12 + * 桥接Java和JavaScript的类 + */ +public class UpmBridge { + + public static UpmBridge getBridge(Browser browser) { + return new UpmBridge(browser); + } + + private JSObject window; + + private UpmBridge(Browser browser) { + this.window = browser.executeJavaScriptAndReturnValue("window").asObject(); + } + + /** + * 更新插件管理中心资源文件,这个方法仅仅是为了语义上的作用(更新) + * @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 { + UpmResourceLoader.INSTANCE.download(); + UpmResourceLoader.INSTANCE.install(); + return null; + } + + @Override + protected void done() { + try { + get(); + 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, "error", Toolkit.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download_Error")); + FineLoggerFactory.getLogger().error(e.getMessage(), e); + EventDispatcher.fire(DownloadEvent.ERROR, "error"); + } + } + }.execute(); + } + + /** + * 获取upm的版本信息 + * @return 版本信息 + */ + @JSBridge + public String getVersion() { + return ServerPreferenceConfig.getInstance().getOptimizedUPMVersion(); + } + + @JSBridge + public String i18nText(String key) { + return Toolkit.i18nText(key); + } + + @JSBridge + public void closeWindow() { + UpmFinder.closeWindow(); + } + + + @JSBridge + public boolean isDesigner() { + return true; + } + + @JSBridge + public void getPackInfo(final JSFunction callback) { + 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(); + } + + /** + * 在线获取插件分类 + * + * @param callback 回调函数 + */ + @JSBridge + public void getPluginCategories(final JSFunction callback) { + UpmTaskWorker task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginCategoriesExecutor()); + task.execute(); + } + + /** + * 根据条件获取在线插件 + * + * @param info 插件信息 + * @param callback 回调函数 + */ + @JSBridge + public void getPluginFromStoreNew(String info, final JSFunction callback) { + UpmTaskWorker task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetPluginFromStoreExecutor(new JSONObject(info))); + task.execute(); + } + + /** + * 已安装插件检查更新 + */ + @JSBridge + public void readUpdateOnline(final JSFunction callback) { + UpmTaskWorker task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new ReadUpdateOnlineExecutor()); + task.execute(); + } + + /** + * 获取已经安装的插件的数组 + */ + @JSBridge + public void getInstalledPlugins(final JSFunction callback) { + UpmTaskWorker task = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new GetInstalledPluginsExecutor()); + task.execute(); + } + + /** + * 从插件服务器上更新选中的插件 + * + * @param pluginIDs 插件集合 + */ + @JSBridge + public void updatePluginOnline(Object pluginIDs, final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + List pluginMarkerList = new ArrayList<>(); + if (pluginIDs instanceof String) { + pluginMarkerList.add(PluginUtils.createPluginMarker(pluginIDs.toString())); + } else if (pluginIDs instanceof JSArray) { + JSArray pluginInfos = (JSArray) pluginIDs; + for (int i = 0, len = pluginInfos.length(); i < len; i++) { + String value = pluginInfos.get(i).asString().getValue(); + pluginMarkerList.add(PluginUtils.createPluginMarker(value)); + } + } + PluginOperateUtils.updatePluginOnline(pluginMarkerList, jsCallback); + } + + /** + * 搜索在线插件 + * + * @param keyword 关键字 + */ + @JSBridge + public void searchPlugin(String keyword, final JSFunction callback) { + UpmTaskWorker worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new SearchOnlineExecutor(keyword)); + worker.execute(); + } + + /** + * 从磁盘上选择插件安装包进行安装 + * + * @param filePath 插件包的路径 + */ + @JSBridge + public void installPluginFromDisk(final String filePath, final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + File file = new File(filePath); + PluginOperateUtils.installPluginFromDisk(file, jsCallback); + } + + /** + * 卸载当前选中的插件 + * + * @param pluginInfo 插件信息 + */ + @JSBridge + public void uninstallPlugin(final String pluginInfo, final boolean isForce, final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + PluginOperateUtils.uninstallPlugin(pluginInfo, isForce, jsCallback); + } + + /** + * 从插件服务器上安装插件 + * + * @param pluginInfo 插件的ID + * @param callback 回调函数 + */ + @JSBridge + public void installPluginOnline(final String pluginInfo, final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + PluginMarker pluginMarker = PluginUtils.createPluginMarker(pluginInfo); + PluginOperateUtils.installPluginOnline(pluginMarker, jsCallback); + } + + /** + * 从磁盘上选择插件安装包进行插件升级 + * + * @param filePath 插件包的路径 + */ + public void updatePluginFromDisk(String filePath, final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + File file = new File(filePath); + PluginOperateUtils.updatePluginFromDisk(file, jsCallback); + } + + /** + * 修改选中的插件的活跃状态 + * + * @param pluginID 插件ID + */ + @JSBridge + public void setPluginActive(String pluginID, final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + PluginOperateUtils.setPluginActive(pluginID, jsCallback); + } + + /** + * 选择文件对话框 + * + * @return 选择的文件的路径 + */ + @JSBridge + public String showFileChooser() { + return showFileChooserWithFilter(StringUtils.EMPTY, StringUtils.EMPTY); + } + + /** + * 选择文件对话框 + * + * @param des 过滤文件描述 + * @param filter 文件的后缀 + * @return 选择的文件的路径 + * 这里换用JFileChooser会卡死,不知道为什么 + */ + @JSBridge + public String showFileChooserWithFilter(final String des, final String filter) { + RunnableFuture future = new FutureTask<>(new Callable() { + @Override + public String call() { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + + if (StringUtils.isNotEmpty(filter)) { + fileChooser.setFileFilter(new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filter))); + } + + int result = fileChooser.showOpenDialog(UpmFinder.getDialog()); + if (result == JFileChooser.APPROVE_OPTION) { + return fileChooser.getSelectedFile().getAbsolutePath(); + } + return null; + } + }); + SwingUtilities.invokeLater(future); + try { + return future.get(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + /** + * 选择文件对话框 + * + * @param des 过滤文件描述 + * @param args 文件的后缀 + * @return 选择的文件的路径 + */ + @JSBridge + public String showFileChooserWithFilters(final String des, final Object args) { + RunnableFuture future = new FutureTask<>(new Callable() { + @Override + public String call() { + JFileChooser fileChooser = new JFileChooser(); + List filterList = new ArrayList<>(); + if (args instanceof String) { + filterList.add(GeneralUtils.objectToString(args)); + } else if (args instanceof JSArray) { + JSArray array = (JSArray)args; + for (int i = 0, len = array.length(); i < len; i ++) { + filterList.add(array.get(i).getStringValue()); + } + } + String[] filters = filterList.toArray(new String[0]); + if (ArrayUtils.isNotEmpty(filters)) { + FileNameExtensionFilter filter = new FileNameExtensionFilter(des, UpmUtils.findMatchedExtension(filters)); + fileChooser.setFileFilter(filter); + } + int result = fileChooser.showOpenDialog(UpmFinder.getDialog()); + if (result == JFileChooser.APPROVE_OPTION) { + return fileChooser.getSelectedFile().getAbsolutePath(); + } + return null; + } + }); + SwingUtilities.invokeLater(future); + try { + return future.get(); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return null; + } + + ////////登录相关/////// + + /** + * 获取系统登录的用户名 + */ + @JSBridge + public String getLoginInfo(final JSFunction callback) { + registerLoginInfo(callback); + return MarketConfig.getInstance().getBbsUsername(); + } + + /** + * 系统登录注册 + * + * @param callback 回调函数 + */ + @JSBridge + public void registerLoginInfo(final JSFunction callback) { + JSCallback jsCallback = new JSCallback(UpmBrowserExecutor.create(window, callback)); + String username = MarketConfig.getInstance().getBbsUsername(); + if (StringUtils.isEmpty(username)) { + jsCallback.execute(StringUtils.EMPTY); + EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY); + } else { + jsCallback.execute(username); + EventDispatcher.fire(CertificateEvent.LOGIN, username); + } + } + + + /** + * 设计器端的用户登录 + * + * @param username 用户名 + * @param password 密码 + * @param callback 回调函数 + */ + @JSBridge + public void defaultLogin(String username, String password, final JSFunction callback) { + UpmTaskWorker worker = new UpmTaskWorker<>(new JSCallback(UpmBrowserExecutor.create(window, callback)), new PluginLoginExecutor(username, password)); + worker.execute(); + } + + /** + * 清除用户信息 + */ + public void clearUserInfo() { + MarketConfig.getInstance().setInShowBBsName(StringUtils.EMPTY); + FinePassportManager.getInstance().logout(); + EventDispatcher.fire(CertificateEvent.LOGOUT, StringUtils.EMPTY); + } + + /** + * 打开论坛消息界面 + */ + @JSBridge + public void getPriviteMessage() { + try { + String loginUrl = CloudCenter.getInstance().acquireUrlByKind("bbs.default"); + Desktop.getDesktop().browse(new URI(loginUrl)); + } catch (Exception exp) { + FineLoggerFactory.getLogger().info(exp.getMessage()); + } + } + + /** + * 忘记密码 + */ + @JSBridge + public void forgetHref() { + try { + Desktop.getDesktop().browse(new URI(CloudCenter.getInstance().acquireUrlByKind("bbs.reset"))); + } catch (Exception e) { + 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/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java new file mode 100644 index 0000000000..5b90d43307 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -0,0 +1,68 @@ +package com.fr.design.upm; + +import com.fr.base.FRContext; +import com.fr.design.dialog.UIDialog; +import com.fr.design.mainframe.DesignerContext; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.stable.StableUtils; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceEvent; + +import javax.swing.*; +import java.io.File; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-12 + */ +public class UpmFinder { + + private static final String UPM_DIR = "/upm"; + private static final String MAIN_RESOURCE_PATH = UPM_DIR + "/plugin_design.html"; + + public static String installHome = FRContext.getCommonOperator().getWebRootPath(); + + private static UIDialog dialog = null; + + static { + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { + @Override + public void on(Event event, Workspace param) { + installHome = FRContext.getCommonOperator().getWebRootPath(); + } + }); + } + + public static boolean checkUPMResourcesExist() { + String mainJsPath = StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH); + File file = new File(mainJsPath); + return file.exists(); + } + + public static String getMainResourcePath() { + return "file:///" + StableUtils.pathJoin(installHome, MAIN_RESOURCE_PATH); + } + + public static UIDialog getDialog() { + return dialog; + } + + public static void showUPMDialog() { + UpmShowPane upmPane = new UpmShowPane(); + if (dialog == null) { + dialog = new UpmShowDialog(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/upm/UpmShowDialog.java b/designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java new file mode 100644 index 0000000000..704e011218 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowDialog.java @@ -0,0 +1,34 @@ +package com.fr.design.upm; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.UIDialog; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.StableUtils; + +import javax.swing.*; +import java.awt.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-12 + */ +public class UpmShowDialog extends UIDialog { + + private static final Dimension DEFAULT_SHOP = new Dimension(900, 700); + + public UpmShowDialog(Frame frame, BasicPane pane) { + super(frame); + setUndecorated(true); + JPanel panel = (JPanel) getContentPane(); + panel.setLayout(new BorderLayout()); + add(pane, BorderLayout.CENTER); + setSize(DEFAULT_SHOP); + GUICoreUtils.centerWindow(this); + setResizable(false); + } + + @Override + public void checkValid() throws Exception { + } +} 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 new file mode 100644 index 0000000000..57b225920a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/UpmShowPane.java @@ -0,0 +1,69 @@ +package com.fr.design.upm; + +import com.fr.design.dialog.BasicPane; +import com.fr.design.ui.ModernUIPane; +import com.fr.design.upm.event.DownloadEvent; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +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-04-12 + * Update Plugin Manager容器 + */ +public class UpmShowPane extends BasicPane { + + private ModernUIPane modernUIPane; + + @Override + protected String title4PopupWindow() { + return "UPM"; + } + + public UpmShowPane() { + setLayout(new BorderLayout()); + if (UpmFinder.checkUPMResourcesExist()) { + modernUIPane = new ModernUIPane.Builder<>() + .prepare(new ScriptContextAdapter() { + @Override + public void onScriptContextCreated(ScriptContextEvent event) { + JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); + window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); + } + }) + .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) + .prepare(new ScriptContextAdapter() { + @Override + public void onScriptContextCreated(ScriptContextEvent event) { + JSValue window = event.getBrowser().executeJavaScriptAndReturnValue("window"); + window.asObject().setProperty("PluginHelper", UpmBridge.getBridge(event.getBrowser())); + } + }).build(); + EventDispatcher.listen(DownloadEvent.SUCCESS, new Listener() { + @Override + public void on(Event event, String param) { + modernUIPane.redirect(UpmFinder.getMainResourcePath(), UpmUtils.renderMap()); + } + }); + } + add(modernUIPane, BorderLayout.CENTER); + } + +} 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 new file mode 100644 index 0000000000..d27b6721a4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/UpmUtils.java @@ -0,0 +1,44 @@ +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 + * @version 10.0 + * Created by richie on 2019-04-18 + */ +public class UpmUtils { + + public static String[] findMatchedExtension(String... extensions) { + List list = new ArrayList<>(); + for (String ext : extensions) { + String[] arr = ext.split("\\."); + list.add(arr[arr.length - 1]); + } + 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/WarnComponent.java b/designer-base/src/main/java/com/fr/design/upm/WarnComponent.java new file mode 100644 index 0000000000..3ab134acf1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/WarnComponent.java @@ -0,0 +1,33 @@ +package com.fr.design.upm; + +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.impl.FineUI; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-12 + */ +public class WarnComponent extends AssembleComponent { + + public static final WarnComponent KEY = new WarnComponent(); + + private WarnComponent() { + + } + + @Override + public ScriptPath script(RequestClient req) { + return ScriptPath.build("com/fr/design/upm/warn.js"); + } + + @Override + public Atom[] refer() { + return new Atom[]{ + FineUI.KEY + }; + } +} diff --git a/designer-base/src/main/java/com/fr/design/upm/event/CertificateEvent.java b/designer-base/src/main/java/com/fr/design/upm/event/CertificateEvent.java new file mode 100644 index 0000000000..5710768449 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/event/CertificateEvent.java @@ -0,0 +1,12 @@ +package com.fr.design.upm.event; + +import com.fr.event.Event; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-18 + */ +public enum CertificateEvent implements Event { + LOGIN,LOGOUT +} 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 new file mode 100644 index 0000000000..25b4f0a9ea --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/event/DownloadEvent.java @@ -0,0 +1,13 @@ +package com.fr.design.upm.event; + +import com.fr.event.Event; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-12 + */ +public enum DownloadEvent implements Event { + + SUCCESS, ERROR, UPDATE +} diff --git a/designer-base/src/main/java/com/fr/design/upm/exec/UpmBrowserExecutor.java b/designer-base/src/main/java/com/fr/design/upm/exec/UpmBrowserExecutor.java new file mode 100644 index 0000000000..572f7b5f23 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/exec/UpmBrowserExecutor.java @@ -0,0 +1,30 @@ +package com.fr.design.upm.exec; + +import com.fr.design.bridge.exec.JSExecutor; +import com.teamdev.jxbrowser.chromium.JSFunction; +import com.teamdev.jxbrowser.chromium.JSObject; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-18 + */ +public class UpmBrowserExecutor implements JSExecutor { + + public static UpmBrowserExecutor create(JSObject window, JSFunction callback) { + return new UpmBrowserExecutor(window, callback); + } + + private JSObject window; + private JSFunction callback; + + private UpmBrowserExecutor(JSObject window, JSFunction callback) { + this.window = window; + this.callback = callback; + } + + @Override + public void executor(String newValue) { + callback.invoke(window, newValue); + } +} diff --git a/designer-base/src/main/java/com/fr/design/upm/task/UpmTaskWorker.java b/designer-base/src/main/java/com/fr/design/upm/task/UpmTaskWorker.java new file mode 100644 index 0000000000..4de5198376 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/upm/task/UpmTaskWorker.java @@ -0,0 +1,52 @@ +package com.fr.design.upm.task; + +import com.fr.design.bridge.exec.JSCallback; +import com.fr.design.bridge.exec.JSUtils; +import com.fr.design.extra.Process; +import com.fr.design.extra.exe.Command; +import com.fr.design.extra.exe.Executor; +import com.fr.stable.StringUtils; + +import javax.swing.*; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-04-17 + */ +public class UpmTaskWorker extends SwingWorker { + + private Executor executor; + private JSCallback callback; + + public UpmTaskWorker(final JSCallback callback, final Executor executor) { + this.executor = executor; + this.callback = callback; + } + + @Override + protected V doInBackground() throws Exception { + Command[] commands = executor.getCommands(); + for (Command command : commands) { + String message = command.getExecuteMessage(); + if (StringUtils.isNotBlank(message)) { + publish(message); + } + command.run(new Process() { + @Override + public void process(String s) { + if (StringUtils.isNotBlank(s)) { + publish(JSUtils.trimText(s)); + } + } + }); + } + return null; + } + + @Override + protected void done() { + String result = executor.getTaskFinishMessage(); + callback.execute(result); + } +} diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 8687461a1c..befe47c55e 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -1,8 +1,8 @@ package com.fr.design.utils; -import com.fr.base.BaseUtils; import com.fr.base.FeedBackInfo; import com.fr.base.ServerConfig; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.DesignerEnvProcessor; @@ -14,8 +14,7 @@ import com.fr.general.FRFont; import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; -import com.fr.stable.CodeUtils; -import com.fr.stable.EncodeConstants; +import com.fr.stable.CommonCodeUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.start.ServerStarter; @@ -33,32 +32,33 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.io.UnsupportedEncodingException; import java.net.ServerSocket; import java.net.Socket; import java.net.URI; -import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.Enumeration; import java.util.Locale; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * Some util method of Designer */ public class DesignUtils { - private static final int MESSAGEPORT = 51462; - private static final int TIME_OUT = 20 * 1000; + private static int port = DesignerPort.MESSAGE_PORT; - public synchronized static void setPort(int port) { - DesignUtils.port = port; + private DesignUtils() { } - private static int port = MESSAGEPORT; - - private DesignUtils() { + public synchronized static void setPort(int port) { + DesignUtils.port = port; } + public static int getPort() { + return port; + } /** * 通过端口是否被占用判断设计器有没有启动 @@ -70,8 +70,7 @@ public class DesignUtils { try { new Socket("localhost", port); return true; - } catch (Exception exp) { - + } catch (Exception ignored) { } return false; } @@ -82,7 +81,7 @@ public class DesignUtils { * @param lines 命令行 */ public static void clientSend(String[] lines) { - if (lines != null && lines.length <= 0) { + if (lines == null || lines.length == 0) { return; } Socket socket = null; @@ -90,18 +89,21 @@ public class DesignUtils { try { socket = new Socket("localhost", port); - writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), EncodeConstants.ENCODING_UTF_8))); + writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8))); for (int i = 0; i < lines.length; i++) { writer.println(lines[i]); } - writer.flush(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } finally { try { - writer.close(); - socket.close(); + if (writer != null) { + writer.close(); + } + if (socket != null) { + socket.close(); + } } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -114,47 +116,53 @@ public class DesignUtils { * @param startPort 端口 * @param suffixs 文件后缀 */ - public static void creatListeningServer(final int startPort, final String[] suffixs) { - Thread serverSocketThread = new Thread() { + public static void createListeningServer(final int startPort, final String[] suffixs) { + ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignClientListener")); + service.execute(new Runnable() { + @Override public void run() { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(startPort); } catch (IOException e1) { - FineLoggerFactory.getLogger().error("Cannot create server socket on" + port); + FineLoggerFactory.getLogger().error("Cannot create server socket on " + port); } while (true) { try { - Socket socket = serverSocket.accept(); // 接收客户连接 - BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), EncodeConstants.ENCODING_UTF_8)); - String line = null; - while ((line = reader.readLine()) != null) { - if (line.startsWith("demo")) { - DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); - ServerStarter.browserDemoURL(); - } else if (StringUtils.isNotEmpty(line)) { - File f = new File(line); - String path = f.getAbsolutePath(); - - boolean isMatch = false; - for (int i = 0; i < suffixs.length; i++) { - isMatch = isMatch || path.endsWith(suffixs[i]); - } - if (isMatch) { - DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); + if (serverSocket != null) { + // 接收客户连接 + Socket socket = serverSocket.accept(); + BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); + String line; + while ((line = reader.readLine()) != null) { + if (line.startsWith("demo")) { + DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); + ServerStarter.browserDemoURL(); + } else if (StringUtils.isNotEmpty(line)) { + File f = new File(line); + String path = f.getAbsolutePath(); + + boolean isMatch = false; + for (String suffix : suffixs) { + isMatch = isMatch || path.endsWith(suffix); + } + if (isMatch) { + DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); + } } } + reader.close(); + socket.close(); + } else { + FineLoggerFactory.getLogger().error("Cannot create server socket on " + port); + break; } - - reader.close(); - socket.close(); - } catch (IOException e) { - + } catch (IOException ignored) { } } } - }; - serverSocketThread.start(); + }); + } /** @@ -278,19 +286,18 @@ public class DesignUtils { */ public static void visitEnvServerByParameters(String baseRoute, String[] names, String[] values) { int len = Math.min(ArrayUtils.getLength(names), ArrayUtils.getLength(values)); - String[] segs = new String[len]; + String[] nameValuePairs = new String[len]; for (int i = 0; i < len; i++) { - try { - //设计器里面据说为了改什么界面统一, 把分隔符统一用File.separator, 意味着在windows里面报表路径变成了\ - //以前的超链, 以及预览url什么的都是/, 产品组的意思就是用到的地方替换下, 真恶心. - String value = values[i].replaceAll("\\\\", "/"); - segs[i] = URLEncoder.encode(CodeUtils.cjkEncode(names[i]), EncodeConstants.ENCODING_UTF_8) + "=" + URLEncoder.encode(CodeUtils.cjkEncode(value), "UTF-8"); - } catch (UnsupportedEncodingException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } + //设计器里面据说为了改什么界面统一, 把分隔符统一用File.separator, 意味着在windows里面报表路径变成了\ + //以前的超链, 以及预览url什么的都是/, 产品组的意思就是用到的地方替换下, 真恶心. + String value = values[i].replaceAll("\\\\", "/"); + // 两次 encode 支持中文和特殊符号,避免跳转登录后预览400报错 + nameValuePairs[i] = + CommonCodeUtils.encodeURIComponent(CommonCodeUtils.encodeURIComponent(names[i])) + + "=" + CommonCodeUtils.encodeURIComponent(CommonCodeUtils.encodeURIComponent(value)); } - String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY); - + String postfixOfUri = (nameValuePairs.length > 0 ? "?" + StableUtils.join(nameValuePairs, "&") : StringUtils.EMPTY); + if (!WorkContext.getCurrent().isLocal()) { try { String urlPath = getWebBrowserPath(); @@ -305,8 +312,7 @@ public class DesignUtils { + "/" + web + "/" + ServerConfig.getInstance().getServletName() + baseRoute + postfixOfUri; ServerStarter.browserURLWithLocalEnv(url); - } catch (Throwable e) { - // + } catch (Throwable ignored) { } } } @@ -321,87 +327,6 @@ public class DesignUtils { return urlPath; } - //TODO:august:下个版本,要把下面的图片都放在一个preload文件夹下,表示可以预先加载。然后遍历一下就可以了,不用这么一个一个的写了 - - /** - * 预加载 - */ - public static void preLoadingImages() { - BaseUtils.readIcon("com/fr/design/images/custombtn/baobiaozhuti.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/baobiaozhuti_hover.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/baobiaozhuti_click.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/canshujiemian.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/canshujiemian_hover.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/canshujiemian_click.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/setting.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/setting_hover.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/setting_click.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/page.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/page_hover.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/page_click.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/form.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/form_hover.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/form_click.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/edit.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/edit_hover.png"); - BaseUtils.readIcon("com/fr/design/images/custombtn/edit_click.png"); - BaseUtils.readIcon("com/fr/base/images/oem/addworksheet.png"); - BaseUtils.readIcon("com/fr/design/images/sheet/addpolysheet.png"); - BaseUtils.readIcon("com/fr/base/images/oem/worksheet.png"); - BaseUtils.readIcon("com/fr/design/images/sheet/polysheet.png"); - BaseUtils.readIcon("com/fr/design/images/sheet/left_right_btn.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/cellPop.png"); - BaseUtils.readIcon("/com/fr/design/images/docking/right.gif"); - BaseUtils.readIcon("/com/fr/design/images/docking/left.gif"); - BaseUtils.readIcon("/com/fr/design/images/m_file/save.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/excel.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/pdf.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/word.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/svg.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/csv.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/text.png"); - BaseUtils.readIcon("/com/fr/design/images/m_web/datasource.png"); - BaseUtils.readIcon("/com/fr/design/images/m_report/webreportattribute.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/pageSetup.png"); - BaseUtils.readIcon("/com/fr/design/images/m_report/header.png"); - BaseUtils.readIcon("/com/fr/design/images/m_report/footer.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/saveAs.png"); - BaseUtils.readIcon("/com/fr/design/images/m_report/background.png"); - loadOtherImages(); - } - - - private static void loadOtherImages() { - BaseUtils.readIcon("/com/fr/design/images/m_report/reportWriteAttr.png"); - BaseUtils.readIcon("/com/fr/design/images/m_report/linearAttr.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/bindColumn.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/text.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/chart.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/image.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/bias.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/subReport.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/insertRow.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/insertColumn.png"); - BaseUtils.readIcon("/com/fr/design/images/m_format/highlight.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/hyperLink.png"); - BaseUtils.readIcon("/com/fr/design/images/m_edit/merge.png"); - BaseUtils.readIcon("/com/fr/design/images/m_edit/unmerge.png"); - BaseUtils.readIcon("/com/fr/design/images/m_file/export.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/cell.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/float.png"); - BaseUtils.readIcon("/com/fr/design/images/m_edit/undo.png"); - BaseUtils.readIcon("/com/fr/design/images/m_edit/redo.png"); - BaseUtils.readIcon("/com/fr/design/images/m_edit/cut.png"); - BaseUtils.readIcon("/com/fr/design/images/m_edit/paste.png"); - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/leftAlignment.png"); - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/centerAlignment.png"); - BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/rightAlignment.png"); - BaseUtils.readIcon("/com/fr/design/images/m_format/noboder.png"); - BaseUtils.readIcon("/com/fr/design/images/gui/color/background.png"); - BaseUtils.readIcon("/com/fr/design/images/m_insert/floatPop.png"); - } - - /** * 将用户反馈发送至服务器 * diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java new file mode 100644 index 0000000000..7c082800ed --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java @@ -0,0 +1,26 @@ +package com.fr.design.utils; + +/** + * 为的就是能替换 DesignPort.class 实现多开,因此避免编译器常量编译展开优化 + */ +public class DesignerPort { + private DesignerPort() { + } + + /** + * 设计器端口,避免编译期常量优化展开 + */ + public static final int MESSAGE_PORT = getMessagePort(); + /** + * 设计器端口,避免编译期常量优化展开 + */ + public static final int DEBUG_MESSAGE_PORT = getDebugMessagePort(); + + private static int getMessagePort() { + return 51462; + } + + private static int getDebugMessagePort() { + return 51463; + } +} 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 33f928a466..389b9981e9 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/utils/gui/UIComponentUtils.java b/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java index 3e1f98555f..d2e9704658 100644 --- a/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/gui/UIComponentUtils.java @@ -2,6 +2,8 @@ package com.fr.design.utils.gui; import com.fr.design.gui.core.UITextComponent; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; import com.fr.stable.StringUtils; import javax.swing.JComponent; @@ -9,6 +11,7 @@ import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; +import java.util.Locale; /** * 包含 UI 组件相关的工具方法 @@ -45,15 +48,18 @@ public class UIComponentUtils { } private static void insertPrefixToText(UITextComponent comp, String prefix) { - if (comp == null) { + if (comp == null || ComparatorUtils.equals(Locale.CHINA, GeneralContext.getLocale())) { + // 最初是为了解决日文国际化显示不全,而增加的换行功能。中文不需要换行。 + // windows 下,字体为宋体时,对于 JLabel、JCheckBox、JButton 等控件,使用换行后,文字会下移,可能导致文字下半部分被截断。 + // 因此中文直接返回,不加换行逻辑。 return; } - String text = comp.getText(); - if (StringUtils.isEmpty(comp.getText()) || text.startsWith(HTML_TAG)) { + String text = comp.getText(); + if (StringUtils.isEmpty(text) || text.startsWith(HTML_TAG)) { return; } - comp.setText(prefix + comp.getText()); + comp.setText(prefix + text); } /** diff --git a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index b85ac113d5..74a4990300 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java @@ -291,7 +291,7 @@ public class CustomIconPane extends BasicPane { Configurations.update(new WorkerFacade(WidgetInfoConfig.class) { @Override public void run() { - WidgetInfoConfig.getInstance().setIconManager(IconManager.getIconManager()); + WidgetInfoConfig.getInstance().setIconManager(iconManager); } }); 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 78accb96b3..42bcfae0aa 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/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index 2e36ea5d8a..6692155dce 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -279,7 +279,12 @@ public class DBManipulationPane extends BasicBeanPane { addSubmitConditionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane(); + final DSColumnLiteConditionPane conditionPane = new DSColumnLiteConditionPane() { + @Override + protected boolean isNeedDoWithCondition(Condition liteCondition) { + return liteCondition != null; + } + }; String[] columns = chooseTable.currentColumnNames(); if (columns != null && columns.length > 0) { conditionPane.populateColumns(chooseTable.currentColumnNames()); 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 b0f3e9dd48..9b97c43599 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; @@ -19,8 +21,8 @@ import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.third.guava.base.Strings; import com.fr.workspace.WorkContext; -import com.fr.workspace.connect.AuthException; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.exception.WorkspaceAuthException; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -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())); @@ -523,7 +532,7 @@ public class RemoteEnvPane extends BasicBeanPane { DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey()); try { return WorkContext.getConnector().testConnection(connection); - } catch (AuthException ignored) { + } catch (WorkspaceAuthException ignored) { return null; } } @@ -532,27 +541,9 @@ public class RemoteEnvPane extends BasicBeanPane { protected void done() { okButton.setEnabled(true); try { - TestConnectionResult result = TestConnectionResult.parse(get(), connection); - if (result == TestConnectionResult.Fully_Success) { - message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful")); - uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon")); - } - - if (result == TestConnectionResult.Partly_Sucess) { - message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistence_Test")); - uiLabel.setIcon(UIManager.getIcon("OptionPane.warningIcon")); - } - - if (result == TestConnectionResult.Fully_Failed) { - message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); - uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); - } - - if (result == TestConnectionResult.Auth_Failed) { - message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed")); - uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon")); - } + message.setText(result.getText()); + uiLabel.setIcon(result.getIcon()); } catch (InterruptedException | ExecutionException e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); diff --git a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java index 357d4f38cb..5362dbbd83 100644 --- a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java +++ b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java @@ -1,62 +1,104 @@ package com.fr.env; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.stable.AssistUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; +import javax.swing.Icon; +import javax.swing.UIManager; + /** * 测试连接的结果。 * 不改变原有逻辑的情况下,加入一层转化。 * 根据这里的转化结果,判断需要提示哪些内容。 - * + *

* created by Harrison on 2018/12/20 **/ public enum TestConnectionResult { /** * 完全成功, 版本匹配,测试连接成功。 */ - Fully_Success, + FULLY_SUCCESS { + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.informationIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"); + } + }, /** * 不完全成功,版本不匹配,但测试连接成功。 */ - Partly_Sucess, + PARTLY_SUCCESS { + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.warningIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistence_Test"); + } + }, /** * 完全失败,直接没连上 */ - Fully_Failed, + FULLY_FAILED { + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.errorIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"); + } + }, /** * 验证 Token 失败 */ - Auth_Failed; + AUTH_FAILED { + @Override + public Icon getIcon() { + return UIManager.getIcon("OptionPane.errorIcon"); + } + + @Override + public String getText() { + return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); + } + }; + + public abstract Icon getIcon(); + + public abstract String getText(); public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) { if (value == null) { - return Auth_Failed; + return AUTH_FAILED; } - if (!value) { - return Fully_Failed; + return FULLY_FAILED; } try { - String serverVersion = new FunctionalHttpRequest(info).getServerVersion(); if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) { - return Fully_Success; + return FULLY_SUCCESS; } - - return Partly_Sucess; + return PARTLY_SUCCESS; } catch (Exception e) { - // 发生异常,说明没连接上。返回完全失败。 FineLoggerFactory.getLogger().error(e.getMessage()); - return Fully_Failed; + return FULLY_FAILED; } - - } } diff --git a/designer-base/src/main/java/com/fr/file/AbstractFILE.java b/designer-base/src/main/java/com/fr/file/AbstractFILE.java new file mode 100644 index 0000000000..866ea2c2b1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/file/AbstractFILE.java @@ -0,0 +1,93 @@ +package com.fr.file; + +import javax.swing.Icon; +import java.io.InputStream; +import java.io.OutputStream; + +public abstract class AbstractFILE implements FILE { + + @Override + public String prefix() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isDirectory() { + throw new UnsupportedOperationException(); + } + + @Override + public String getName() { + throw new UnsupportedOperationException(); + } + + @Override + public Icon getIcon() { + throw new UnsupportedOperationException(); + } + + @Override + public String getPath() { + throw new UnsupportedOperationException(); + } + + @Override + public void setPath(String path) { + throw new UnsupportedOperationException(); + } + + @Override + public FILE getParent() { + throw new UnsupportedOperationException(); + } + + @Override + public FILE[] listFiles() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean createFolder(String name) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean mkfile() throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public boolean exists() { + throw new UnsupportedOperationException(); + } + + @Override + public void closeTemplate() throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public InputStream asInputStream() throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public OutputStream asOutputStream() throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public String getEnvFullName() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isMemFile() { + throw new UnsupportedOperationException(); + } + + @Override + public boolean isEnvFile() { + throw new UnsupportedOperationException(); + } +} diff --git a/designer-base/src/main/java/com/fr/file/FileFILE.java b/designer-base/src/main/java/com/fr/file/FileFILE.java index 5331cd7785..c4f58fa1a3 100644 --- a/designer-base/src/main/java/com/fr/file/FileFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileFILE.java @@ -201,7 +201,7 @@ public class FileFILE implements FILE { OutputStream out; try { StableUtils.makesureFileExist(file); - out = new FileOutputStream(file, true); + out = new FileOutputStream(file, false); } catch (Exception e) { throw SessionLocalManager.createLogPackedException(e); } diff --git a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java index 7f73fc7081..dce2c38e0b 100644 --- a/designer-base/src/main/java/com/fr/file/FileNodeFILE.java +++ b/designer-base/src/main/java/com/fr/file/FileNodeFILE.java @@ -7,6 +7,9 @@ import com.fr.design.file.NodeAuthProcessor; import com.fr.design.gui.itree.filetree.FileNodeComparator; import com.fr.design.gui.itree.filetree.FileTreeIcon; import com.fr.design.i18n.Toolkit; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.io.EncryptUtils; @@ -15,6 +18,8 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceEvent; import com.fr.workspace.resource.WorkResourceTempRenameStream; import com.fr.workspace.server.lock.TplOperator; @@ -26,6 +31,21 @@ import java.util.Arrays; public class FileNodeFILE implements FILE { + + private static String webRootPath = FRContext.getCommonOperator().getWebRootPath(); + private static String[] supportTypes = FRContext.getFileNodes().getSupportedTypes(); + + static { + EventDispatcher.listen(WorkspaceEvent.AfterSwitch, new Listener() { + @Override + public void on(Event event, Workspace workspace) { + webRootPath = FRContext.getCommonOperator().getWebRootPath(); + supportTypes = FRContext.getFileNodes().getSupportedTypes(); + } + }); + } + + private FileNode node; //记录下FILE对应的运行环境,每次创建都设置下当前的运行环境 @@ -95,7 +115,7 @@ public class FileNodeFILE implements FILE { @Override public String prefix() { - if (ComparatorUtils.equals(getEnvPath(), FRContext.getCommonOperator().getWebRootPath())) { + if (ComparatorUtils.equals(getEnvPath(), webRootPath)) { return FILEFactory.WEBREPORT_PREFIX; } return FILEFactory.ENV_PREFIX; @@ -212,7 +232,7 @@ public class FileNodeFILE implements FILE { try { FileNode[] nodeArray; nodeArray = listFile(node.getEnvPath()); - Arrays.sort(nodeArray, new FileNodeComparator(FRContext.getFileNodes().getSupportedTypes())); + Arrays.sort(nodeArray, new FileNodeComparator(supportTypes)); return fileNodeArray2FILEArray(nodeArray, envPath); } catch (Exception e) { @@ -235,7 +255,7 @@ public class FileNodeFILE implements FILE { private FileNode[] listFile(String rootFilePath) { try { - if (ComparatorUtils.equals(envPath, FRContext.getCommonOperator().getWebRootPath())) { + if (ComparatorUtils.equals(envPath, webRootPath)) { return FRContext.getFileNodes().listWebRootFile(rootFilePath); } else { return FRContext.getFileNodes().list(rootFilePath); diff --git a/designer-base/src/main/java/com/fr/file/RenameExportFILE.java b/designer-base/src/main/java/com/fr/file/RenameExportFILE.java new file mode 100644 index 0000000000..8b03e943f6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/file/RenameExportFILE.java @@ -0,0 +1,102 @@ +package com.fr.file; + +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.third.org.apache.commons.io.FileUtils; +import com.fr.web.session.SessionLocalManager; + +import javax.swing.Icon; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +public class RenameExportFILE extends AbstractFILE { + + private static final String EXPORT_SUFFIX = ".FRExportTmp"; + + private FILE file; + + private RenameExportFILE(FILE file) { + this.file = new FileFILE(new File(file.getPath() + EXPORT_SUFFIX)); + } + + public static RenameExportFILE create(FILE file) { + return new RenameExportFILE(file); + } + + public static String recoverFileName(String fileName) { + if (StringUtils.isEmpty(fileName) || !fileName.endsWith(EXPORT_SUFFIX)) { + return fileName; + } + return fileName.substring(0, fileName.lastIndexOf(EXPORT_SUFFIX)); + } + + @Override + public String prefix() { + return file.prefix(); + } + + @Override + public boolean isDirectory() { + return false; + } + + @Override + public String getName() { + return file.getName(); + } + + @Override + public Icon getIcon() { + return null; + } + + @Override + public String getPath() { + return file.getPath(); + } + + + @Override + public FILE getParent() { + return file.getParent(); + } + + + @Override + public boolean mkfile() throws Exception { + return file.mkfile(); + } + + @Override + public boolean exists() { + return file.exists(); + } + + @Override + public OutputStream asOutputStream() throws Exception { + + final File localeFile = new File(file.getPath()); + OutputStream out; + try { + StableUtils.makesureFileExist(localeFile); + out = new FileOutputStream(localeFile, false) { + @Override + public void close() throws IOException { + super.close(); + String path = file.getPath(); + if (localeFile.exists()) { + FileUtils.copyFile(localeFile, new File(recoverFileName(path))); + if (localeFile.getPath().endsWith(EXPORT_SUFFIX)) { + FileUtils.forceDelete(localeFile); + } + } + } + }; + } catch (Exception e) { + throw SessionLocalManager.createLogPackedException(e); + } + return out; + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/file/StashedFILE.java b/designer-base/src/main/java/com/fr/file/StashedFILE.java index 4bc9b431ea..454433874e 100644 --- a/designer-base/src/main/java/com/fr/file/StashedFILE.java +++ b/designer-base/src/main/java/com/fr/file/StashedFILE.java @@ -1,15 +1,13 @@ package com.fr.file; import javax.swing.Icon; -import javax.transaction.NotSupportedException; import java.io.ByteArrayInputStream; import java.io.InputStream; -import java.io.OutputStream; /** * 切换环境用于暂存的文件类型 */ -public class StashedFILE implements FILE { +public class StashedFILE extends AbstractFILE { private FILE file; private byte[] content; @@ -44,31 +42,6 @@ public class StashedFILE implements FILE { return file.getPath(); } - @Override - public void setPath(String path) { - throw new UnsupportedOperationException(); - } - - @Override - public FILE getParent() { - throw new UnsupportedOperationException(); - } - - @Override - public FILE[] listFiles() { - throw new UnsupportedOperationException(); - } - - @Override - public boolean createFolder(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean mkfile() throws Exception { - throw new UnsupportedOperationException(); - } - @Override public boolean exists() { return false; @@ -84,11 +57,6 @@ public class StashedFILE implements FILE { return new ByteArrayInputStream(content); } - @Override - public OutputStream asOutputStream() throws Exception { - throw new NotSupportedException(); - } - @Override public String getEnvFullName() { return file.getEnvFullName(); @@ -103,4 +71,9 @@ public class StashedFILE implements FILE { public boolean isEnvFile() { return false; } + + @Override + public String toString() { + return FILEFactory.MEM_PREFIX + getName(); + } } diff --git a/designer-base/src/main/java/com/fr/start/BaseDesigner.java b/designer-base/src/main/java/com/fr/start/BaseDesigner.java index 3e466ed1f3..05d41a1e78 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -31,39 +31,36 @@ import java.lang.reflect.Method; * The main class of Report Designer. */ public abstract class BaseDesigner extends ToolBarMenuDock { - private static final int PERCENT_TEN = 10; - private static final int PERCENT_SIXTY = 60; - private static final int PERCENT_NINTY= 90; - private static final int PERCENT_COMPLETE= 100; - + private static final int LOAD_TREE_MAXNUM = 10; + + private final String[] args; public BaseDesigner(String[] args) { - - init(args); + + this.args = args; + init(); } - - private void init(String[] args) { - //初始化 - EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing")); + + private void init() { // 初始化look and feel.这个在预加载之前执行是因为lookAndFeel里的东西,预加载时也要用到 DesignUtils.initLookAndFeel(); // 初始化Log Handler DesignerEnvManager.loadLogSetting(); createDesignerFrame(); } - - public void show(final String[] args) { + + public void show() { collectUserInformation(); - DesignerContext.getDesignerFrame().updateProgress(PERCENT_TEN); - showDesignerFrame(args, DesignerContext.getDesignerFrame(), false); - DesignerContext.getDesignerFrame().updateProgress(PERCENT_SIXTY); + showDesignerFrame(false); + + //TODO: 2019-06-14 这里有啥作用? DesignerContext.getDesignerFrame().refreshEnv(); - DesignerContext.getDesignerFrame().updateProgress(PERCENT_NINTY); for (int i = 0; !TemplateTreePane.getInstance().getTemplateFileTree().isTemplateShowing() && i < LOAD_TREE_MAXNUM; i++) { TemplateTreePane.getInstance().getTemplateFileTree().refresh(); } - DesignerContext.getDesignerFrame().updateProgress(PERCENT_COMPLETE); + DesignerContext.getDesignerFrame().setVisible(true); + DesignerContext.getDesignerFrame().resizeFrame(); } @@ -71,10 +68,9 @@ public abstract class BaseDesigner extends ToolBarMenuDock { new DesignerFrame(this); } - - - private void showDesignerFrame(String[] args, final DesignerFrame df, - boolean isException) { + + + private void showDesignerFrame(boolean isException) { try { FILE file = null; if (args != null && args.length > 0) { @@ -101,12 +97,13 @@ public abstract class BaseDesigner extends ToolBarMenuDock { file = FILEFactory.createFILE(FILEFactory.ENV_PREFIX + DesignerEnvManager.getEnvManager().getLastOpenFile()); } + DesignerFrame df = DesignerContext.getDesignerFrame(); isException = openFile(df, isException, file); df.fireDesignerOpened(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); if (!isException) { - showDesignerFrame(args, df, true); + showDesignerFrame(true); } else { System.exit(0); } @@ -137,19 +134,14 @@ public abstract class BaseDesigner extends ToolBarMenuDock { df.getSelectedJTemplate().requestGridFocus(); return isException; } - - - /** - * @param window - */ + private void enableFullScreenMode(Window window) { String className = "com.apple.eawt.FullScreenUtilities"; String methodName = "setWindowCanFullScreen"; try { Class clazz = Class.forName(className); - Method method = clazz.getMethod(methodName, new Class[]{ - Window.class, boolean.class}); + Method method = clazz.getMethod(methodName, Window.class, boolean.class); method.invoke(null, window, true); } catch (Throwable t) { FineLoggerFactory.getLogger().error("Full screen mode is not supported"); diff --git a/designer-base/src/main/java/com/fr/start/OemHandler.java b/designer-base/src/main/java/com/fr/start/OemHandler.java new file mode 100644 index 0000000000..b127e07f43 --- /dev/null +++ b/designer-base/src/main/java/com/fr/start/OemHandler.java @@ -0,0 +1,14 @@ +package com.fr.start; + +import com.fr.design.fun.OemProcessor; +import com.fr.stable.bridge.StableFactory; + +/** + * OEM处理中心 + */ +public class OemHandler { + + public static OemProcessor findOem() { + return StableFactory.getMarkedInstanceObjectFromClass(OemProcessor.MARK_STRING, OemProcessor.class); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/start/ServerStarter.java b/designer-base/src/main/java/com/fr/start/ServerStarter.java index 6d20cf12a5..d4e1143c61 100644 --- a/designer-base/src/main/java/com/fr/start/ServerStarter.java +++ b/designer-base/src/main/java/com/fr/start/ServerStarter.java @@ -1,6 +1,7 @@ package com.fr.start; import com.fr.base.ServerConfig; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; import com.fr.design.utils.BrowseUtils; import com.fr.general.ComparatorUtils; @@ -14,29 +15,28 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ServerStarter { - + /** * 预览Demo * 找默认工作目录,不应该按照名字去找,而应该按照安装路径,因为默认工作目录的名字可能会改变。 */ public static void browserDemoURL() { - + if (!WorkContext.getCurrent().isLocal()) { //有问题,这里拿不到远程的http端口 BrowseUtils.browser(WorkContext.getCurrent().getPath()); - } - else if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 + } else if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 String web = GeneralContext.getCurrentAppNameOfEnv(); browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName()); - }else{ + } else { initDemoServerAndBrowser(); } } - + private static void initDemoServerAndBrowser() { - + try { FineEmbedServer.start(); } finally { @@ -44,7 +44,7 @@ public class ServerStarter { BrowseUtils.browser("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName()); } } - + /** * 本地环境浏览url * @@ -52,9 +52,9 @@ public class ServerStarter { */ public static void browserURLWithLocalEnv(final String url) { - if(!FineEmbedServerMonitor.getInstance().isComplete()){ + if (!FineEmbedServerMonitor.getInstance().isComplete()) { FineEmbedServerMonitor.getInstance().monitor(); - ExecutorService service = Executors.newSingleThreadExecutor(); + ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("ServerStarter")); service.submit(new Runnable() { @Override @@ -68,7 +68,7 @@ public class ServerStarter { } }); service.shutdown(); - }else{ + } else { FineEmbedServer.start(); BrowseUtils.browser(url); } diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java index 2d08b286d5..0955c16e57 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerActivator.java @@ -6,6 +6,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; import com.fr.module.ModuleRole; import com.fr.stable.EncodeConstants; +import com.fr.stable.ProductConstants; import com.fr.startup.FineWebApplicationInitializer; import com.fr.third.springframework.web.SpringServletContainerInitializer; import com.fr.third.springframework.web.context.support.AnnotationConfigWebApplicationContext; @@ -62,6 +63,8 @@ public class FineEmbedServerActivator extends Activator { // 设置解码uri使用的字符编码 tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8); String docBase = new File(WorkContext.getCurrent().getPath()).getParent(); + //内置的上下文是自己定的,这里把WEB_APP_NAME一并设置了,否则下面appName是/null + ProductConstants.setWebAppName(ProductConstants.getAppFolderName()); String appName = "/" + FRContext.getCommonOperator().getAppName(); Context context = tomcat.addContext(appName, docBase); Tomcat.initWebappDefaults(context); diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java index ee54a80de7..5807773bff 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java @@ -1,5 +1,6 @@ package com.fr.start.server; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.event.Event; import com.fr.event.EventDispatcher; @@ -66,7 +67,7 @@ public class FineEmbedServerMonitor { } public void monitor() { - ExecutorService service = Executors.newSingleThreadExecutor(); + ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("FineEmbedServerMonitor")); service.submit(new Runnable() { @Override 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 0000000000..5f6220c748 --- /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 0000000000..5208edfa3b --- /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/images/bbs/facebook.png b/designer-base/src/main/resources/com/fr/design/images/bbs/facebook.png new file mode 100644 index 0000000000..9e5dc8af2c Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/bbs/facebook.png differ diff --git a/designer-base/src/main/resources/com/fr/design/ui/InitNameSpace.js b/designer-base/src/main/resources/com/fr/design/ui/InitNameSpace.js index 0274d5fa50..03b2bb32ae 100644 --- a/designer-base/src/main/resources/com/fr/design/ui/InitNameSpace.js +++ b/designer-base/src/main/resources/com/fr/design/ui/InitNameSpace.js @@ -1,6 +1,6 @@ -var arr ="%s".split(".").reverse(); -var create = function (obj, names) { - var name = names.pop(); +let arr ="%s".split(".").reverse(); +let create = function (obj, names) { + let name = names.pop(); if (!name) { return; } diff --git a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css index 521c8cdbbf..58c03ecba5 100644 --- a/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css +++ b/designer-base/src/main/resources/com/fr/design/ui/update/push/pushUpdate.css @@ -5,7 +5,7 @@ body { background-size: 100% 100% !important; -moz-background-size: 100% 100% !important; - font-family: PingFangSC-Regular, Georgia, "Nimbus Roman No9 L", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif CN", STSong, "AR PL New Sung", "AR PL SungtiL GB", NSimSun, SimSun, "TW\-Sung", "WenQuanYi Bitmap Song", "AR PL UMing CN", "AR PL UMing HK", "AR PL UMing TW", "AR PL UMing TW MBE", PMingLiU, MingLiU, serif !important; + font-family: "PingFang SC", "Microsoft YaHei", "Myriad Pro", "OpenSans", Verdana, SimSun, sans-serif !important; } .close-btn { @@ -27,7 +27,7 @@ body { } .font-bold { - font-weight: bold; + font-weight: 500; } .title { 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 new file mode 100644 index 0000000000..be4b069097 --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/upm/warn.js @@ -0,0 +1,61 @@ +window.onload = function () { + let label = BI.createWidget({ + type: "bi.label", + text: PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Resource_Warn"), + height: 30 + }); + let callback = function(status, text) { + download.setValue(text); + }; + let buttonOK = BI.createWidget({ + type: "bi.button", + text: PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Download"), + level: 'common', + height: 30, + handler: function () { + PluginHelper.startDownload(callback); + } + }); + let buttonClose = BI.createWidget({ + type: "bi.button", + text: PluginHelper.i18nText("Fine-Design_Basic_Update_Plugin_Manager_Close"), + level: 'warning', + height: 30, + handler: function () { + PluginHelper.closeWindow(); + } + }); + + let download = BI.createWidget({ + type: "bi.label", + height: 30 + }); + let left = 300; + let top = 200; + BI.createWidget({ + type: "bi.absolute", + element: "body", + items: [ + { + el: label, + left: left, + top: top + }, + { + el : buttonOK, + left : left, + top : top + 40 + }, + { + el : buttonClose, + left : left + 100, + top : top + 40 + }, + { + el : download, + left : left, + top : top + 80 + } + ] + }); +}; \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java b/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java index 7e4dad651a..dc1e871b4b 100644 --- a/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java +++ b/designer-base/src/test/java/com/fr/design/actions/help/TutorialActionTest.java @@ -7,7 +7,7 @@ import junit.framework.TestCase; import java.util.Locale; import java.util.UUID; -public class TutorialActionTest extends TestCase{ +public class TutorialActionTest extends TestCase { public void testCreateKey() { TutorialAction action = new TutorialAction(); @@ -24,6 +24,7 @@ public class TutorialActionTest extends TestCase{ GeneralContext.setLocale(pt); String ptKey = action.createDocKey(); assertTrue(ptKey.contains(pt.toString())); + GeneralContext.setLocale(Locale.CHINA); } public void testServerOnline() { diff --git a/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java new file mode 100644 index 0000000000..8d2f522c06 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java @@ -0,0 +1,102 @@ +package com.fr.design.data; + +import com.fr.base.TableData; +import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.design.data.tabledata.wrapper.TableDataFactory; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.file.ProcedureConfig; +import com.fr.file.TableDataConfig; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.HashMap; +import java.util.Map; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({TableDataFactory.class, StoreProcedure.class, TableDataConfig.class, ProcedureConfig.class}) +@SuppressStaticInitializationFor({"com.fr.design.data.tabledata.wrapper.TableDataFactory"}) +public class DesignTableDataManagerTest { + + @Test + public void testFireDataChange() { + + DesignTableDataManager.envChange(); + + + PowerMock.mockStatic(TableDataConfig.class); + + TableDataConfig config = EasyMock.mock(TableDataConfig.class); + TableDataConfig config2 = EasyMock.mock(TableDataConfig.class); + + TableData td1 = EasyMock.mock(TableData.class); + TableData td2 = EasyMock.mock(TableData.class); + TableData td3 = EasyMock.mock(TableData.class); + TableData td4 = EasyMock.mock(TableData.class); + EasyMock.expect(config.getTableData("firstData")).andReturn(td1).once(); + EasyMock.expect(config.getTableData("secondData")).andReturn(td2).once(); + EasyMock.expect(config2.getTableData("firstData")).andReturn(td3).once(); + EasyMock.expect(config2.getTableData("secondData")).andReturn(td4).once(); + + EasyMock.expect(TableDataConfig.getInstance()).andReturn(config).once().andReturn(config2).once(); + + PowerMock.mockStatic(TableDataFactory.class); + EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config)) + .andReturn(new String[]{"firstData", "secondData"}).once(); + EasyMock.expect(TableDataFactory.getSortOfChineseNameOfServerData(config2)) + .andReturn(new String[]{"firstData", "secondData"}).once(); + + + ProcedureConfig proConfig = EasyMock.mock(ProcedureConfig.class); + StoreProcedure pc1 = PowerMock.createMock(StoreProcedure.class); + StoreProcedure pc2 = PowerMock.createMock(StoreProcedure.class); + ProcedureConfig proConfig2 = EasyMock.mock(ProcedureConfig.class); + StoreProcedure pc3 = PowerMock.createMock(StoreProcedure.class); + StoreProcedure pc4 = PowerMock.createMock(StoreProcedure.class); + + Map procedureMap = new HashMap<>(); + procedureMap.put("firstPRO", pc1); + procedureMap.put("secondPRO", pc2); + EasyMock.expect(proConfig.getProcedure("firstPRO")).andReturn(pc1).once(); + EasyMock.expect(proConfig.getProcedure("secondPRO")).andReturn(pc2).once(); + + Map procedureMap2 = new HashMap<>(); + procedureMap2.put("firstPRO", pc3); + procedureMap2.put("secondPRO", pc4); + EasyMock.expect(proConfig2.getProcedure("firstPRO")).andReturn(pc3).once(); + EasyMock.expect(proConfig2.getProcedure("secondPRO")).andReturn(pc4).once(); + + EasyMock.expect(proConfig.getProcedures()).andReturn(procedureMap).once(); + EasyMock.expect(proConfig2.getProcedures()).andReturn(procedureMap2).once(); + + PowerMock.mockStatic(ProcedureConfig.class); + EasyMock.expect(ProcedureConfig.getInstance()).andReturn(proConfig).once().andReturn(proConfig2).once(); + + EasyMock.replay(proConfig, config, config2, proConfig2); + PowerMock.replay(TableDataFactory.class, TableDataConfig.class, ProcedureConfig.class); + + + Map map = DesignTableDataManager.getAllEditingDataSet(null); + Assert.assertEquals(4, map.size()); + Assert.assertSame(pc1, map.get("firstPRO").getTableData()); + Assert.assertSame(pc2, map.get("secondPRO").getTableData()); + Assert.assertSame(td1, map.get("firstData").getTableData()); + Assert.assertSame(td2, map.get("secondData").getTableData()); + + DesignTableDataManager.fireDSChanged(new HashMap()); + + Map map2 = DesignTableDataManager.getAllEditingDataSet(null); + Assert.assertEquals(4, map2.size()); + Assert.assertSame(pc3, map2.get("firstPRO").getTableData()); + Assert.assertSame(pc4, map2.get("secondPRO").getTableData()); + Assert.assertSame(td3, map2.get("firstData").getTableData()); + Assert.assertSame(td4, map2.get("secondData").getTableData()); + + + } +} diff --git a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java index 75c9c9e5ba..b53d47780c 100644 --- a/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java +++ b/designer-base/src/test/java/com/fr/design/formula/FunctionConstantsTest.java @@ -2,6 +2,7 @@ package com.fr.design.formula; import com.fr.general.GeneralUtils; import com.fr.invoke.Reflect; +import com.fr.log.FineLoggerFactory; import org.easymock.EasyMock; import org.junit.Test; import org.junit.runner.RunWith; @@ -9,10 +10,10 @@ import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import static junit.framework.Assert.fail; import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertTrue; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; /** * Created by plough on 2018/12/7. @@ -20,6 +21,7 @@ import static org.junit.Assert.assertFalse; @RunWith(PowerMockRunner.class) @PrepareForTest(GeneralUtils.class) public class FunctionConstantsTest { + @Test public void testNewInstanceFail() throws Exception { try { @@ -31,7 +33,7 @@ public class FunctionConstantsTest { } @Test - public void testEmbedFuntionsAfterStaticInit() { + public void testEmbedFunctionsAfterStaticInit() { NameAndTypeAndFunctionList[] embFunctionLists = FunctionConstants.EMBFUNCTIONS; // 一共有 8 个分类 assertEquals(8, embFunctionLists.length); @@ -43,13 +45,17 @@ public class FunctionConstantsTest { } @Test - public void testCommonFuntionsAfterStaticInit() { + public void testCommonFunctionsAfterStaticInit() { NameAndFunctionList commonFunctionList = FunctionConstants.COMMON; assertEquals(9, commonFunctionList.getDescriptions().length); } @Test public void testIsCustomFormulaPathRunWithCode() { + // mock 的 GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes() + // 会影响 FunctionConstants.class 静态代码块 loadEmbededFunctions 执行,先加载这个类,执行静态代码块 + FineLoggerFactory.getLogger().info(String.valueOf(FunctionConstants.EMBFUNCTIONS.length)); + PowerMock.mockStatic(GeneralUtils.class); EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes(); PowerMock.replayAll(); @@ -63,6 +69,10 @@ public class FunctionConstantsTest { @Test public void testIsCustomFormulaPathRunWithJar() { + // mock 的 GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes() + // 会影响 FunctionConstants.class 静态代码块 loadEmbededFunctions 执行,先加载这个类,执行静态代码块 + FineLoggerFactory.getLogger().info(String.valueOf(FunctionConstants.EMBFUNCTIONS.length)); + PowerMock.mockStatic(GeneralUtils.class); EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("Build#release-2018.12.10.12.11.09.95").anyTimes(); PowerMock.replayAll(); diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java index e83a523fc4..d93a7476a9 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java @@ -56,6 +56,8 @@ public class TemplateInfoCollectorTest { initialFileContent = FileUtils.readFileToString(new File(filePath), "utf-8"); Reflect.on(TemplateInfoCollector.class).set("instance", null); + // 后执行 testReadXML 用例时,之前保留的单例会造成影响 + Reflect.on(DesignerOpenHistory.class).set("singleton", null); } @After @@ -89,7 +91,7 @@ public class TemplateInfoCollectorTest { assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}",templateInfo.getProcessMapJsonString()); + "\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", templateInfo.getProcessMapJsonString()); assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\"," + "\"jar_time\":\"不是安装版本\",\"create_time\":\"2019-03-26 16:13\"," + @@ -118,7 +120,7 @@ public class TemplateInfoCollectorTest { assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}",templateInfo.getProcessMapJsonString()); + "\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", templateInfo.getProcessMapJsonString()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); assertEquals(templateID, consumingMap.get("templateID")); diff --git a/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java b/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java index c875716a5b..c7dd4b6821 100644 --- a/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java +++ b/designer-base/src/test/java/com/fr/design/ui/FineUIDemo.java @@ -2,10 +2,8 @@ package com.fr.design.ui; import com.fr.design.DesignerEnvManager; -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.WindowConstants; -import java.awt.BorderLayout; +import javax.swing.*; +import java.awt.*; /** * @author richie diff --git a/designer-base/src/test/java/com/fr/design/ui/ModernUIPaneTest.java b/designer-base/src/test/java/com/fr/design/ui/ModernUIPaneTest.java index f5c8aaaa92..9676ee998a 100644 --- a/designer-base/src/test/java/com/fr/design/ui/ModernUIPaneTest.java +++ b/designer-base/src/test/java/com/fr/design/ui/ModernUIPaneTest.java @@ -2,13 +2,8 @@ package com.fr.design.ui; import com.fr.design.DesignerEnvManager; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.WindowConstants; -import java.awt.BorderLayout; -import java.awt.FlowLayout; +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamComponent.java b/designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamComponent.java new file mode 100644 index 0000000000..6299fb860a --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamComponent.java @@ -0,0 +1,40 @@ +package com.fr.design.ui.report; + +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.ParserType; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; +import com.fr.web.struct.impl.FineUI; + +/** + * Created by windy on 2019/3/25. + * 报表服务器参数demo使用 + */ +public class ReportServerParamComponent extends AssembleComponent { + + public static final ReportServerParamComponent KEY = new ReportServerParamComponent(); + + private ReportServerParamComponent() { + + } + + @Override + public Atom[] refer() { + return new Atom[] { + FineUI.KEY + }; + } + + @Override + public ScriptPath script(RequestClient req) { + return ScriptPath.build("/com/fr/design/ui/script/report.js"); + } + + @Override + public StylePath style() { + + return StylePath.build("/com/fr/design/ui/script/report.css", ParserType.DYNAMIC); + } +} diff --git a/designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamDemo.java b/designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamDemo.java new file mode 100644 index 0000000000..42199134dc --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/ui/report/ReportServerParamDemo.java @@ -0,0 +1,29 @@ +package com.fr.design.ui.report; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.ui.ModernUIPane; +import com.fr.design.ui.ModernUIPaneTest; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by windy on 2019/3/25. + * 报表服务器参数demo + */ +public class ReportServerParamDemo { + + public static void main(String... args) { + final JFrame frame = new JFrame(); + frame.setSize(660, 600); + JPanel contentPane = (JPanel) frame.getContentPane(); + // 是否需要开启调试窗口 + DesignerEnvManager.getEnvManager().setOpenDebug(true); + + final ModernUIPane pane = new ModernUIPane.Builder() + .withComponent(ReportServerParamComponent.KEY).build(); + contentPane.add(pane, BorderLayout.CENTER); + frame.setVisible(true); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + } +} diff --git a/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingComponent.java b/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingComponent.java new file mode 100644 index 0000000000..333c6ab108 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingComponent.java @@ -0,0 +1,40 @@ +package com.fr.design.ui.report; + +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.ParserType; +import com.fr.web.struct.category.ScriptPath; +import com.fr.web.struct.category.StylePath; +import com.fr.web.struct.impl.FineUI; + +/** + * Created by windy on 2019/3/26. + * 模板Web属性demo使用 + */ +public class TemplateWebSettingComponent extends AssembleComponent { + + public static final TemplateWebSettingComponent KEY = new TemplateWebSettingComponent(); + + private TemplateWebSettingComponent() { + + } + + @Override + public Atom[] refer() { + return new Atom[] { + FineUI.KEY + }; + } + + @Override + public ScriptPath script(RequestClient req) { + return ScriptPath.build("/com/fr/design/ui/script/template.js"); + } + + @Override + public StylePath style() { + + return StylePath.build("/com/fr/design/ui/script/template.css", ParserType.DYNAMIC); + } +} diff --git a/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java b/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java new file mode 100644 index 0000000000..b267b1346a --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/ui/report/TemplateWebSettingDemo.java @@ -0,0 +1,28 @@ +package com.fr.design.ui.report; + +import com.fr.design.DesignerEnvManager; +import com.fr.design.ui.ModernUIPane; +import com.fr.design.ui.ModernUIPaneTest; + +import javax.swing.*; +import java.awt.*; + +/** + * Created by windy on 2019/3/26. + * 模板Web属性demo + */ +public class TemplateWebSettingDemo { + public static void main(String... args) { + final JFrame frame = new JFrame(); + frame.setSize(660, 600); + JPanel contentPane = (JPanel) frame.getContentPane(); + // 是否需要开启调试窗口 + DesignerEnvManager.getEnvManager().setOpenDebug(true); + + final ModernUIPane pane = new ModernUIPane.Builder() + .withComponent(TemplateWebSettingComponent.KEY).build(); + contentPane.add(pane, BorderLayout.CENTER); + frame.setVisible(true); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + } +} diff --git a/designer-base/src/test/java/com/fr/file/StashedFILETest.java b/designer-base/src/test/java/com/fr/file/StashedFILETest.java new file mode 100644 index 0000000000..f3c358574b --- /dev/null +++ b/designer-base/src/test/java/com/fr/file/StashedFILETest.java @@ -0,0 +1,23 @@ +package com.fr.file; + +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; + +public class StashedFILETest { + + /** + * 用于测试暂存文件未保存时的提示 + */ + @Test + public void testToString() { + FILE file = EasyMock.mock(FILE.class); + String name = "getA.cpt"; + EasyMock.expect(file.getName()).andReturn(name).once(); + EasyMock.replay(file); + FILE stashedFILE = new StashedFILE(file, new byte[0]); + String expectString = FILEFactory.MEM_PREFIX + name; + Assert.assertEquals(expectString, stashedFILE + ""); + EasyMock.verify(file); + } +} diff --git a/designer-base/src/test/resources/com/fr/design/ui/demo.html b/designer-base/src/test/resources/com/fr/design/ui/demo.html index 2beae25a78..9e5211c89e 100644 --- a/designer-base/src/test/resources/com/fr/design/ui/demo.html +++ b/designer-base/src/test/resources/com/fr/design/ui/demo.html @@ -10,6 +10,12 @@ return Pool.data; }; +

测试页面,请点击最下面的按钮
diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/css/js/common/settingtab/settingtab.css b/designer-base/src/test/resources/com/fr/design/ui/script/css/js/common/settingtab/settingtab.css new file mode 100644 index 0000000000..05d98d1557 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/css/js/common/settingtab/settingtab.css @@ -0,0 +1,12 @@ +.bi-setting-tab .tab-group { + background-color: #F2F4F7; + font-size: 12px; +} +.bi-setting-tab .tab-group .tab-item:hover { + color: #3685f2; +} +.bi-setting-tab .tab-group .tab-item.active { + background-color: #ffffff; + color: #3685f2; + border-top: 3px solid #3685f2; +} diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/css/js/index.css b/designer-base/src/test/resources/com/fr/design/ui/script/css/js/index.css new file mode 100644 index 0000000000..e69de29bb2 diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/bar.container.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/bar.container.js new file mode 100644 index 0000000000..dd682b2e6c --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/bar.container.js @@ -0,0 +1,41 @@ +!(function(){ + /** + * 带确定取消的通用控件 + */ + var Bar = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-settings-bar-container", + el: { + + } + }, + + render: function() { + return { + type: "bi.vtape", + items: [this.options.el, { + type: "bi.right_vertical_adapt", + height: 24, + rgap: 10, + vgap: 10, + items: [{ + type: "bi.button", + level: "ignore", + text: BI.i18nText("Fine-Design_Report_OK"), + handler: function() { + + } + }, { + type: "bi.button", + level: "ignore", + text: BI.i18nText("Fine-Design_Basic_Engine_Cancel"), + handler: function() { + + } + }] + }] + } + } + }) + BI.shortcut("bi.settings.bar_container", Bar) +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/edit.list.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/edit.list.js new file mode 100644 index 0000000000..a7c77c0d79 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/edit.list.js @@ -0,0 +1,89 @@ +!(function () { + /** + * 事件设置 + */ + var List = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-edit-list" + }, + + render: function () { + var self = this; + return { + type: "bi.vtape", + vgap: 5, + items: [{ + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.icon_button", + cls: "text-add-tip-font", + width: 24, + height: 24, + handler: function() { + self.group.addItems([self._createItem()]) + } + }, { + type: "bi.icon_button", + cls: "close-font", + width: 24, + height: 24, + handler: function() { + self.group.removeItemAt(); + } + }, { + type: "bi.icon_button", + cls: "close-font", + width: 24, + height: 24, + handler: function() { + self.removeItemAt(self._getIndexOfItemValue(self.group.getValue())) + } + }] + }, { + type: "bi.button_group", + cls: "bi-border bi-card", + ref: function(_ref) { + self.group = _ref; + }, + items: [] + }] + }; + }, + + _getIndexOfItemValue: function(values) { + values = BI.isArray(values) ? values : [values]; + var indexes = []; + BI.each(this.group.getAllButtons(), function(idx, button){ + if(BI.contains(values, button.getValue())) { + indexes.push(idx); + } + }); + return indexes; + }, + + _createItem: function() { + return { + type: "bi.text_button", + textAlign: "left", + hgap: 10, + text: "选项" + this.group.getAllButtons().length, + cls: "bi-list-item-select", + value: BI.UUID() + }; + }, + + populate: function(items) { + this.group.populate(items); + }, + + addItems: function(items) { + + }, + + removeItemAt: function(indexes) { + this.group.removeItemAt(indexes); + } + }); + BI.shortcut("bi.report.server.param_setting.edit_list", List); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/form.rowbackground.setting.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/form.rowbackground.setting.js new file mode 100644 index 0000000000..d50cfa57ed --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/form.rowbackground.setting.js @@ -0,0 +1,33 @@ +!(function () { + /** + * 填报当前编辑行背景设置相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-form-background-setting" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + items: [{ + type: "bi.multi_select_item", + logic: { + dynamic: true + }, + iconWrapperWidth: 16, + text: BI.i18nText("Fine-Design_Report_Set_Face_Write_Current_Edit_Row_Background") + }, { + el: { + type: "bi.color_chooser", + width: 24, + height: 24 + }, + lgap: 10 + }] + }; + } + }); + BI.shortcut("bi.report.form_background_setting", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/globalsingle.combo.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/globalsingle.combo.js new file mode 100644 index 0000000000..7a6df9c95d --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/globalsingle.combo.js @@ -0,0 +1,54 @@ +!(function () { + /** + * + * 为模板单独设置的相关项 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-global-or-single-combo", + value: 1 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + rgap: 10, + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Blow_Set") + }, { + type: "bi.text_value_combo", + width: 200, + ref: function(_ref) { + self.combo = _ref; + }, + value: o.value, + items: [{ + text: BI.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Form_Using_Server_Report_View_Settings"), + value: 2 + }], + listerners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }] + }; + }, + + getValue: function() { + return self.combo.getValue(); + }, + + setValue: function(v) { + this.combo.setValue(v); + } + }); + BI.shortcut("bi.report.global_or_single_combo", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/leavesetting.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/leavesetting.js new file mode 100644 index 0000000000..680a8c8bf0 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/leavesetting.js @@ -0,0 +1,53 @@ +!(function () { + /** + * 离开提示/直接显示控件/自动暂存相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-leave-setting", + value: [1] + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.button_group", + value: o.value, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Unload_Check"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Basic_Engine_Event_Show_Widgets"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Write_Auto_Stash"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt", + rgap: 5 + }], + ref: function(_ref) { + self.group = _ref; + } + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.leave_setting", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/reportshow.location.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/reportshow.location.js new file mode 100644 index 0000000000..41a2a40e88 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/reportshow.location.js @@ -0,0 +1,53 @@ +!(function () { + /** + * 报表显示位置相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-report-show-location" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Show_Location") + }, { + type: "bi.button_group", + ref: function(_ref) { + self.group = _ref; + }, + value: 2, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Center_Display"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Left_Display"), + value: 2 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.left", + lgap: 10 + }] + }] + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.server.param_setting.report_show_location", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/settingtab/settingtab.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/settingtab/settingtab.js new file mode 100644 index 0000000000..c047e9a9b6 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/settingtab/settingtab.js @@ -0,0 +1,59 @@ +!(function () { + + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-setting-tab", + value: "", + tabItems: [], + cardCreator: BI.emptyFn + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vtape", + items: [{ + type: "bi.vertical_adapt", + cls: "tab-group", + items: [{ + type: "bi.button_group", + layouts: [{ + type: "bi.left" + }], + value: o.value, + items: BI.map(o.tabItems, function(idx, item){ + return { + el: BI.extend({ + type: "bi.text_button", + hgap: 10, + height: 24 + }, item) + }; + }), + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function (v) { + self.tableTab.setSelect(v); + } + }], + ref: function (_ref) { + // self.buttons = _ref; + } + }], + height: 24 + }, { + type: "bi.tab", + cls: "bi-card", + showIndex: o.value, + cardCreator: this.options.cardCreator, + ref: function (ref) { + self.tableTab = ref; + } + }] + }; + } + }); + + BI.shortcut("bi.setting.tab", Tab); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/settingtab/settingtab.less b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/settingtab/settingtab.less new file mode 100644 index 0000000000..186eb32810 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/settingtab/settingtab.less @@ -0,0 +1,17 @@ +@import "../../index.less"; +.bi-setting-tab { + & .tab-group { + background-color: @color-bi-background-light-gray; + font-size: @font-size-12; + & .tab-item { + &:hover { + color: @color-bi-text-highlight; + } + &.active { + background-color: @color-bi-background-default; + color: @color-bi-text-highlight; + border-top: 3px solid @color-bi-text-highlight; + } + } + } +} \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/sheetlabel.position.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/sheetlabel.position.js new file mode 100644 index 0000000000..e4e7acc77b --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/sheetlabel.position.js @@ -0,0 +1,53 @@ +!(function () { + /** + * sheet标签页显示位置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-report-show-location" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Sheet_Label_Page_Display_Position") + }, { + type: "bi.button_group", + ref: function(_ref) { + self.group = _ref; + }, + value: 2, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Form_Base_Top"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Bottom"), + value: 2 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.left", + lgap: 10 + }] + }] + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.sheet_label_location", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toobar/toobar.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toobar/toobar.js new file mode 100644 index 0000000000..74f83ef97b --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toobar/toobar.js @@ -0,0 +1,126 @@ +!(function(){ + var ToolBar = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-settings-tool-bar", + value: [1] + }, + + render: function() { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.left_right_vertical_adapt", + height: 24, + bgap: 15, + rhgap: 10, + items: { + left: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Mobile_ToolBar"), + width: 70, + textAlign: "left" + }, { + type: "bi.button_group", + value: o.value, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_ToolBar_Top"), + value: 1, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + if(this.isSelected()) { + self._populateDefault(); + } else { + self.topRegion.populate(); + } + } + }] + }, { + text: BI.i18nText("Fine-Design_Report_ToolBar_Bottom"), + value: 2 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + ref: function(_ref) { + self.group = _ref; + }, + layouts: [{ + type: "bi.left" + }], + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }], + right: [{ + el: { + type: "bi.text_button", + cls: "bi-border", + text: BI.i18nText("Fine-Design_Basic_Scale_Custom_Button"), + handler: function() { + + }, + hgap: 5 + } + }, { + el: { + type: "bi.text_button", + cls: "bi-border", + text: BI.i18nText("Fine-Design_Report_Restore_Default"), + handler: function() { + + }, + hgap: 5 + } + }] + } + }, { + el: { + type: "bi.settings.tool_bar.region", + height: 56, + title: BI.i18nText("Fine-Design_Report_ToolBar_Top"), + ref: function(_ref) { + self.topRegion = _ref; + }, + items: BI.contains(o.value, 1) ? this._createDefaultItems() : [] + }, + bgap: 20 + }, { + type: "bi.settings.tool_bar.region", + height: 56, + title: BI.i18nText("Fine-Design_Report_ToolBar_Bottom"), + ref: function(_ref) { + self.bottomRegion = _ref; + } + }] + } + }, + + _createDefaultItems: function() { + return BI.createItems(BI.Constants.getConstant("bi.constant.report.template.web_setting.tools"), { + type: "bi.icon_text_item", + height: 24, + extraCls: "bi-background bi-list-item-select bi-border-radius", + logic: { + dynamic: true + }, + textHgap: 10, + value: BI.UUID() + }) + }, + + _populateDefault: function() { + this.topRegion.populate(this._createDefaultItems()); + } + }) + BI.shortcut("bi.settings.tool_bar", ToolBar) +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toobar/toolbar.region.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toobar/toolbar.region.js new file mode 100644 index 0000000000..6fbd6f5ff3 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toobar/toolbar.region.js @@ -0,0 +1,42 @@ +!(function(){ + var Region = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-settings-tool-bar-region", + title: "" + }, + + render: function() { + var self = this, o = this.options; + return [{ + type: "bi.button_group", + cls: "bi-border", + items: o.items, + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt", + hgap: 10 + }], + ref: function(_ref) { + self.group = _ref; + } + }, { + type: "bi.absolute", + items: [{ + el: { + type: "bi.label", + cls: "bi-background", + text: o.title + }, + top: -10, + left: 10 + }] + }] + }, + + populate: function(items) { + this.group.populate(items); + } + }) + BI.shortcut("bi.settings.tool_bar.region", Region); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toolbarHeight.select.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toolbarHeight.select.js new file mode 100644 index 0000000000..e2524e8753 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/toolbarHeight.select.js @@ -0,0 +1,67 @@ +!(function () { + /** + * 工具栏高度相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-tool-bar-height-select", + height: 24, + value: 2 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + el: { + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Mobile_ToolBar_Height") + }, + rgap: 10 + }, { + type: "bi.button_group", + value: o.value, + ref: function(_ref) { + self.group = _ref; + }, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Tool_Bar_High"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Tool_Bar_Middle"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Tool_Bar_Low"), + value: 3 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.vertical_adapt" + }], + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }] + + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.server.param_setting.tool_bar_height_select", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/common/usetoolbar.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/usetoolbar.js new file mode 100644 index 0000000000..d0107db328 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/common/usetoolbar.js @@ -0,0 +1,47 @@ +!(function () { + /** + * 使用工具栏相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-use-tool-bar" + }, + + render: function () { + var self = this; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + el: { + type: "bi.multi_select_item", + ref: function(_ref) { + self.multiSelect = _ref; + }, + hgap: 5, + selected: true, + text: BI.i18nText("Fine-Design_Report_Use_ToolBar"), + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + } + }, { + type: "bi.text_button", + cls: "bi-card bi-border", + text: BI.i18nText("Fine-Design_Report_Edit"), + hgap: 10 + }] + }; + }, + + getValue: function() { + return self.multiSelect.getSelected(); + }, + + setValue: function(v) { + this.multiSelect.setSelected(v); + } + }); + BI.shortcut("bi.report.server.param_setting.use_tool_bar", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/enum.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/enum.js new file mode 100644 index 0000000000..943d4d1030 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/enum.js @@ -0,0 +1,30 @@ +window.BICst = window.BICst || {}; +BICst.REPORT_SERVER_PARAM = { + SPLIT_PAGE_PREVIEW_SETTING: 1, + FORM_PAGE_SETTING: 2, + DATA_ANALYSIS_SETTING: 3, + IMPORT_CSS: 4, + IMPORT_JS: 5, + ERROR_TEMPLATE_DEFINE: 6, + PRINT_SETTING: 7 +}; +BICst.REPORT_TEMPLATE_WEB_SETTING = { + BASE: 1, + PRINT: 2, + SPLIT_PAGE_PREVIEW_SETTING: 3, + FORM_PAGE_SETTING: 4, + DATA_ANALYSIS_SETTING: 5, + BROWSER: 6, + IMPORT_CSS: 7, + IMPORT_JS: 8 +}; + +BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS = { + FIRST_PAGE: 1, + PRE_PAGE: 2, + NEXT_PAGE: 3, + LAST_PAGE: 4, + PRINT: 5, + EXPORT: 6, + EMAIL: 7 +}; \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/i18n.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/i18n.js new file mode 100644 index 0000000000..01974dc998 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/i18n.js @@ -0,0 +1,53 @@ +BI.addI18n({ + "Fine-Design_Report_WEB_Pagination_Setting": "分页预览设置", + "Fine-Design_Report_WEB_Write_Setting": "填报页面设置", + "Fine-Design_Report_Data_Analysis_Settings": "数据分析设置", + "Fine-Design_Report_ReportServerP_Import_Css": "引用Css", + "Fine-Design_Report_ReportServerP_Import_JavaScript": "引用JavaScript", + "Fine-Design_Report_Error_Handler_Template": "出错模板定义", + "Fine-Design_Report_Print_Setting": "打印设置", + "Fine-Design_Report_Mobile_ToolBar": "工具栏", + "Fine-Design_Report_Tool_Bar_High": "高", + "Fine-Design_Report_Tool_Bar_Middle": "中", + "Fine-Design_Report_Tool_Bar_Low": "低", + "Fine-Design_Report_Mobile_ToolBar_Height": "工具栏高度", + "Fine-Design_Report_Is_Paint_Page": "以图片方式显示", + "Fine-Design_Report_IS_Auto_Scale": "iframe嵌入时自动缩放", + "Fine-Design_Report_IS_TD_HEAVY_EXPORT": "重方式输出格子", + "Fine-Design_Report_Use_ToolBar": "使用工具栏", + "Fine-Design_Report_Show_Location": "报表显示位置", + "Fine-Design_Report_Center_Display": "居中展示", + "Fine-Design_Report_Left_Display": "左展示", + "Fine-Design_Report_Editing_Listeners": "事件编辑", + "Fine-Design_Report_Edit": "编辑", + "Fine-Design_Report_Sheet_Label_Page_Display_Position": "sheet标签页显示位置:", + "Fine-Design_Form_Base_Top": "上", + "Fine-Design_Report_Bottom": "下", + "Fine-Design_Report_Set_Face_Write_Current_Edit_Row_Background": "当前编辑行背景设置", + "Fine-Design_Report_Unload_Check": "未提交离开提示", + "Fine-Design_Basic_Engine_Event_Show_Widgets": "直接显示控件", + "Fine-Design_Report_Write_Auto_Stash": "自动暂存", + "Fine-Design_Report_Engine_Sort_Sort": "排序", + "Fine-Design_Report_Engine_Selection_Filter": "条件筛选", + "Fine-Design_Report_Engine_List_Filter": "列表筛选", + "Fine-Design_Basic_Engine_Cancel": "取消", + "Fine-Design_Report_OK": "确定", + "Fine-Design_Report_Basic": "基本", + "Fine-Design_Report_Printer(Server)": "打印机(服务器)", + "Fine-Design_Report_Browser_Background": "浏览器背景", + "Fine-Design_Report_I_Want_To_Set_Single": "为该模板单独设置", + "Fine-Design_Form_Using_Server_Report_View_Settings": "采用服务器设置", + "Fine-Design_Report_Blow_Set": "以下设置:", + "Fine-Design_Report_PageSetup_Page": "页面", + "Fine-Design_Report_ToolBar_Top": "顶部工具栏", + "Fine-Design_Report_ToolBar_Bottom": "底部工具栏", + "Fine-Design_Basic_Scale_Custom_Button": "自定义", + "Fine-Design_Report_Restore_Default": "恢复默认", + "Fine-Design_Report_Engine_ReportServerP_First": "首页", + "Fine-Design_Report_Engine_ReportServerP_Previous": "上一页", + "Fine-Design_Report_Engine_ReportServerP_Next": "下一页", + "Fine-Design_Report_Engine_ReportServerP_Last": "末页", + "Fine-Design_Report_Engine_Print": "打印", + "Fine-Design_Report_Engine_Export": "导出", + "Fine-Design_Report_Engine_Email": "邮件" +}); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/index.less b/designer-base/src/test/resources/com/fr/design/ui/script/js/index.less new file mode 100644 index 0000000000..8844ce72d8 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/index.less @@ -0,0 +1 @@ +@import "../../fineui/src/less/index.less"; \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/data.analysis.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/data.analysis.js new file mode 100644 index 0000000000..29459d1f8f --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/data.analysis.js @@ -0,0 +1,59 @@ +!(function () { + /** + * 服务器 数据分析设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-data-analysis" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.button_group", + height: 24, + value: [1,2,3], + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Engine_Sort_Sort"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Selection_Filter"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Engine_List_Filter"), + value: 2 + }], { + type: "bi.multi_select_item", + logic: { + dynamic: true + }, + iconWrapperWidth: 16, + hgap: 5 + }), + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt" + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24, + value: true + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.data_analysis", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/form.page.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/form.page.js new file mode 100644 index 0000000000..c0f78f54e5 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/form.page.js @@ -0,0 +1,69 @@ +!(function () { + + /** + * 服务器 填报预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-form-page" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.grid", + height: 78, + columns: 2, + rows: 2, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.report.sheet_label_location", + height: 24 + } + }, { + column: 1, + row: 0, + el: { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + } + }, { + column: 0, + row: 1, + el: { + type: "bi.report.form_background_setting", + height: 24 + } + }, { + column: 1, + row: 1, + el: { + type: "bi.report.leave_setting", + height: 24 + } + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24, + value: true + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.form_page", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/page.preview.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/page.preview.js new file mode 100644 index 0000000000..09f59b0945 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/card/page.preview.js @@ -0,0 +1,66 @@ +!(function () { + /** + * 服务器 分页预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-page-preview" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.server.param_setting.report_show_location", + height: 24 + }, { + type: "bi.button_group", + height: 92, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + el: { + text: BI.i18nText("Fine-Design_Report_Is_Paint_Page"), + value: 1 + }, + bgap: 10 + }, { + el: { + text: BI.i18nText("Fine-Design_Report_IS_Auto_Scale"), + value: 2 + }, + bgap: 10 + }, { + text: BI.i18nText("Fine-Design_Report_IS_TD_HEAVY_EXPORT"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + layouts: [{ + type: "bi.vertical" + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24 + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.page_preview", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/reportserver.constants.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/reportserver.constants.js new file mode 100644 index 0000000000..eb2a257dab --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/reportserver.constants.js @@ -0,0 +1,33 @@ +!(function () { + BI.constant("bi.constant.report.server.param_setting", [ + { + text: BI.i18nText("Fine-Design_Report_WEB_Pagination_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Write_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.FORM_PAGE_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Data_Analysis_Settings"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.DATA_ANALYSIS_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.IMPORT_CSS + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.IMPORT_JS + }, { + text: BI.i18nText("Fine-Design_Report_Error_Handler_Template"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.ERROR_TEMPLATE_DEFINE + }, { + text: BI.i18nText("Fine-Design_Report_Print_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.PRINT_SETTING + }] + ); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/reportserver.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/reportserver.js new file mode 100644 index 0000000000..41e206b662 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/reportserverparam/reportserver.js @@ -0,0 +1,50 @@ +!(function () { + + /** + * 报表服务器参数面板 + */ + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-report-server-param-setting" + }, + + render: function () { + return { + type: "bi.setting.tab", + value: BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING, + tabItems: BI.Constants.getConstant("bi.constant.report.server.param_setting"), + cardCreator: BI.bind(this._createCard, this) + }; + }, + + _createCard: function (v) { + switch (v) { + case BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING: + return { + type: "bi.report.server.param_setting.page_preview" + }; + case BICst.REPORT_SERVER_PARAM.FORM_PAGE_SETTING: + return { + type: "bi.report.server.param_setting.form_page" + }; + case BICst.REPORT_SERVER_PARAM.DATA_ANALYSIS_SETTING: + return { + type: "bi.report.server.param_setting.data_analysis" + } + case BICst.REPORT_SERVER_PARAM.IMPORT_CSS: + case BICst.REPORT_SERVER_PARAM.IMPORT_JS: + case BICst.REPORT_SERVER_PARAM.ERROR_TEMPLATE_DEFINE: + case BICst.REPORT_SERVER_PARAM.PRINT_SETTING: + default: + return { + type: "bi.label", + text: "1" + }; + } + } + + }); + + BI.shortcut("bi.report.server.param_setting", Tab); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/card/form.page.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/card/form.page.js new file mode 100644 index 0000000000..1dddc66072 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/card/form.page.js @@ -0,0 +1,64 @@ +!(function () { + /** + * 填报页面设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-form-page" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.global_or_single_combo", + height: 24 + }, { + type: "bi.grid", + height: 78, + columns: 2, + rows: 2, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.report.sheet_label_location" + } + }, { + column: 1, + row: 0, + el: { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + } + }, { + column: 0, + row: 1, + el: { + type: "bi.report.form_background_setting" + } + }, { + column: 1, + row: 1, + el: { + type: "bi.report.leave_setting" + } + }] + }, { + type: "bi.settings.tool_bar", + height: 180 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.template.web_setting.form_page", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/card/page.preview.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/card/page.preview.js new file mode 100644 index 0000000000..39ac4be76f --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/card/page.preview.js @@ -0,0 +1,73 @@ +!(function () { + /** + * 分页预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-page-preview" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.global_or_single_combo", + height: 24 + }, { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + }, { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_PageSetup_Page"), + textAlign: "right", + width: 70 + }, { + el: { + type: "bi.button_group", + height: 24, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Is_Paint_Page"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_IS_Auto_Scale"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_IS_TD_HEAVY_EXPORT"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + layouts: [{ + type: "bi.left", + lgap: 5 + }] + }, + lgap: 10 + }] + }, { + type: "bi.settings.tool_bar", + height: 180 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.template.web_setting.page_preview", Analysis); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/templateweb.constants.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/templateweb.constants.js new file mode 100644 index 0000000000..8ac65da150 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/templateweb.constants.js @@ -0,0 +1,69 @@ +!(function () { + BI.constant("bi.constant.report.template.web_setting", [ + { + text: BI.i18nText("Fine-Design_Report_Basic"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.BASE + }, { + text: BI.i18nText("Fine-Design_Report_Printer(Server)"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.PRINT + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Pagination_Setting"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Write_Setting"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.FORM_PAGE_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Data_Analysis_Settings"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.DATA_ANALYSIS_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Browser_Background"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.BROWSER + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_CSS + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_JS + }] + ); + + BI.constant("bi.constant.report.template.web_setting.tools", [ + { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_First"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.FIRST_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Previous"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.PRE_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Next"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.NEXT_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Last"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.LAST_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Print"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.PRINT + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Export"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.EXPORT + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Email"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.EMAIL + }] + ); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/templateweb.js b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/templateweb.js new file mode 100644 index 0000000000..7cca5cc908 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/js/templatewebproperties/templateweb.js @@ -0,0 +1,48 @@ +!(function () { + + /** + * 模板Web属性面板 + */ + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-report-template-web-setting" + }, + + render: function () { + return { + type: "bi.setting.tab", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING, + tabItems: BI.Constants.getConstant("bi.constant.report.template.web_setting"), + cardCreator: BI.bind(this._createCard, this) + }; + }, + + _createCard: function (v) { + switch (v) { + case BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING: + return { + type: "bi.report.template.web_setting.page_preview" + } + case BICst.REPORT_TEMPLATE_WEB_SETTING.FORM_PAGE_SETTING: + return { + type: "bi.report.template.web_setting.form_page" + } + case BICst.REPORT_TEMPLATE_WEB_SETTING.DATA_ANALYSIS_SETTING: + case BICst.REPORT_TEMPLATE_WEB_SETTING.BASE: + case BICst.REPORT_TEMPLATE_WEB_SETTING.PRINT: + case BICst.REPORT_TEMPLATE_WEB_SETTING.BROWSER: + case BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_CSS: + case BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_JS: + default: + return { + type: "bi.label", + text: "1" + }; + } + } + + }); + + BI.shortcut("bi.report.template.web_setting", Tab); +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/report.css b/designer-base/src/test/resources/com/fr/design/ui/script/report.css new file mode 100644 index 0000000000..05d98d1557 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/report.css @@ -0,0 +1,12 @@ +.bi-setting-tab .tab-group { + background-color: #F2F4F7; + font-size: 12px; +} +.bi-setting-tab .tab-group .tab-item:hover { + color: #3685f2; +} +.bi-setting-tab .tab-group .tab-item.active { + background-color: #ffffff; + color: #3685f2; + border-top: 3px solid #3685f2; +} diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/report.js b/designer-base/src/test/resources/com/fr/design/ui/script/report.js new file mode 100644 index 0000000000..baa357cb3a --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/report.js @@ -0,0 +1,1328 @@ +!(function(){ + /** + * 带确定取消的通用控件 + */ + var Bar = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-settings-bar-container", + el: { + + } + }, + + render: function() { + return { + type: "bi.vtape", + items: [this.options.el, { + type: "bi.right_vertical_adapt", + height: 24, + rgap: 10, + vgap: 10, + items: [{ + type: "bi.button", + level: "ignore", + text: BI.i18nText("Fine-Design_Report_OK"), + handler: function() { + + } + }, { + type: "bi.button", + level: "ignore", + text: BI.i18nText("Fine-Design_Basic_Engine_Cancel"), + handler: function() { + + } + }] + }] + } + } + }) + BI.shortcut("bi.settings.bar_container", Bar) +})();!(function () { + /** + * 事件设置 + */ + var List = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-edit-list" + }, + + render: function () { + var self = this; + return { + type: "bi.vtape", + vgap: 5, + items: [{ + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.icon_button", + cls: "text-add-tip-font", + width: 24, + height: 24, + handler: function() { + self.group.addItems([self._createItem()]) + } + }, { + type: "bi.icon_button", + cls: "close-font", + width: 24, + height: 24, + handler: function() { + self.group.removeItemAt(); + } + }, { + type: "bi.icon_button", + cls: "close-font", + width: 24, + height: 24, + handler: function() { + self.removeItemAt(self._getIndexOfItemValue(self.group.getValue())) + } + }] + }, { + type: "bi.button_group", + cls: "bi-border bi-card", + ref: function(_ref) { + self.group = _ref; + }, + items: [] + }] + }; + }, + + _getIndexOfItemValue: function(values) { + values = BI.isArray(values) ? values : [values]; + var indexes = []; + BI.each(this.group.getAllButtons(), function(idx, button){ + if(BI.contains(values, button.getValue())) { + indexes.push(idx); + } + }); + return indexes; + }, + + _createItem: function() { + return { + type: "bi.text_button", + textAlign: "left", + hgap: 10, + text: "选项" + this.group.getAllButtons().length, + cls: "bi-list-item-select", + value: BI.UUID() + }; + }, + + populate: function(items) { + this.group.populate(items); + }, + + addItems: function(items) { + + }, + + removeItemAt: function(indexes) { + this.group.removeItemAt(indexes); + } + }); + BI.shortcut("bi.report.server.param_setting.edit_list", List); +})();!(function () { + /** + * 填报当前编辑行背景设置相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-form-background-setting" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + items: [{ + type: "bi.multi_select_item", + logic: { + dynamic: true + }, + iconWrapperWidth: 16, + text: BI.i18nText("Fine-Design_Report_Set_Face_Write_Current_Edit_Row_Background") + }, { + el: { + type: "bi.color_chooser", + width: 24, + height: 24 + }, + lgap: 10 + }] + }; + } + }); + BI.shortcut("bi.report.form_background_setting", Analysis); +})();!(function () { + /** + * + * 为模板单独设置的相关项 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-global-or-single-combo", + value: 1 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + rgap: 10, + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Blow_Set") + }, { + type: "bi.text_value_combo", + width: 200, + ref: function(_ref) { + self.combo = _ref; + }, + value: o.value, + items: [{ + text: BI.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Form_Using_Server_Report_View_Settings"), + value: 2 + }], + listerners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }] + }; + }, + + getValue: function() { + return self.combo.getValue(); + }, + + setValue: function(v) { + this.combo.setValue(v); + } + }); + BI.shortcut("bi.report.global_or_single_combo", Analysis); +})();!(function () { + /** + * 离开提示/直接显示控件/自动暂存相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-leave-setting", + value: [1] + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.button_group", + value: o.value, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Unload_Check"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Basic_Engine_Event_Show_Widgets"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Write_Auto_Stash"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt", + rgap: 5 + }], + ref: function(_ref) { + self.group = _ref; + } + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.leave_setting", Analysis); +})();!(function () { + /** + * 报表显示位置相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-report-show-location" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Show_Location") + }, { + type: "bi.button_group", + ref: function(_ref) { + self.group = _ref; + }, + value: 2, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Center_Display"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Left_Display"), + value: 2 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.left", + lgap: 10 + }] + }] + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.server.param_setting.report_show_location", Analysis); +})();!(function () { + + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-setting-tab", + value: "", + tabItems: [], + cardCreator: BI.emptyFn + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vtape", + items: [{ + type: "bi.vertical_adapt", + cls: "tab-group", + items: [{ + type: "bi.button_group", + layouts: [{ + type: "bi.left" + }], + value: o.value, + items: BI.map(o.tabItems, function(idx, item){ + return { + el: BI.extend({ + type: "bi.text_button", + hgap: 10, + height: 24 + }, item) + }; + }), + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function (v) { + self.tableTab.setSelect(v); + } + }], + ref: function (_ref) { + // self.buttons = _ref; + } + }], + height: 24 + }, { + type: "bi.tab", + cls: "bi-card", + showIndex: o.value, + cardCreator: this.options.cardCreator, + ref: function (ref) { + self.tableTab = ref; + } + }] + }; + } + }); + + BI.shortcut("bi.setting.tab", Tab); +})();!(function () { + /** + * sheet标签页显示位置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-report-show-location" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Sheet_Label_Page_Display_Position") + }, { + type: "bi.button_group", + ref: function(_ref) { + self.group = _ref; + }, + value: 2, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Form_Base_Top"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Bottom"), + value: 2 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.left", + lgap: 10 + }] + }] + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.sheet_label_location", Analysis); +})();!(function(){ + var ToolBar = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-settings-tool-bar", + value: [1] + }, + + render: function() { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.left_right_vertical_adapt", + height: 24, + bgap: 15, + rhgap: 10, + items: { + left: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Mobile_ToolBar"), + width: 70, + textAlign: "left" + }, { + type: "bi.button_group", + value: o.value, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_ToolBar_Top"), + value: 1, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + if(this.isSelected()) { + self._populateDefault(); + } else { + self.topRegion.populate(); + } + } + }] + }, { + text: BI.i18nText("Fine-Design_Report_ToolBar_Bottom"), + value: 2 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + ref: function(_ref) { + self.group = _ref; + }, + layouts: [{ + type: "bi.left" + }], + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }], + right: [{ + el: { + type: "bi.text_button", + cls: "bi-border", + text: BI.i18nText("Fine-Design_Basic_Scale_Custom_Button"), + handler: function() { + + }, + hgap: 5 + } + }, { + el: { + type: "bi.text_button", + cls: "bi-border", + text: BI.i18nText("Fine-Design_Report_Restore_Default"), + handler: function() { + + }, + hgap: 5 + } + }] + } + }, { + el: { + type: "bi.settings.tool_bar.region", + height: 56, + title: BI.i18nText("Fine-Design_Report_ToolBar_Top"), + ref: function(_ref) { + self.topRegion = _ref; + }, + items: BI.contains(o.value, 1) ? this._createDefaultItems() : [] + }, + bgap: 20 + }, { + type: "bi.settings.tool_bar.region", + height: 56, + title: BI.i18nText("Fine-Design_Report_ToolBar_Bottom"), + ref: function(_ref) { + self.bottomRegion = _ref; + } + }] + } + }, + + _createDefaultItems: function() { + return BI.createItems(BI.Constants.getConstant("bi.constant.report.template.web_setting.tools"), { + type: "bi.icon_text_item", + height: 24, + extraCls: "bi-background bi-list-item-select bi-border-radius", + logic: { + dynamic: true + }, + textHgap: 10, + value: BI.UUID() + }) + }, + + _populateDefault: function() { + this.topRegion.populate(this._createDefaultItems()); + } + }) + BI.shortcut("bi.settings.tool_bar", ToolBar) +})();!(function(){ + var Region = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-settings-tool-bar-region", + title: "" + }, + + render: function() { + var self = this, o = this.options; + return [{ + type: "bi.button_group", + cls: "bi-border", + items: o.items, + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt", + hgap: 10 + }], + ref: function(_ref) { + self.group = _ref; + } + }, { + type: "bi.absolute", + items: [{ + el: { + type: "bi.label", + cls: "bi-background", + text: o.title + }, + top: -10, + left: 10 + }] + }] + }, + + populate: function(items) { + this.group.populate(items); + } + }) + BI.shortcut("bi.settings.tool_bar.region", Region); +})();!(function () { + /** + * 工具栏高度相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-tool-bar-height-select", + height: 24, + value: 2 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + el: { + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Mobile_ToolBar_Height") + }, + rgap: 10 + }, { + type: "bi.button_group", + value: o.value, + ref: function(_ref) { + self.group = _ref; + }, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Tool_Bar_High"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Tool_Bar_Middle"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Tool_Bar_Low"), + value: 3 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.vertical_adapt" + }], + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }] + + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.server.param_setting.tool_bar_height_select", Analysis); +})();!(function () { + /** + * 使用工具栏相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-use-tool-bar" + }, + + render: function () { + var self = this; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + el: { + type: "bi.multi_select_item", + ref: function(_ref) { + self.multiSelect = _ref; + }, + hgap: 5, + selected: true, + text: BI.i18nText("Fine-Design_Report_Use_ToolBar"), + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + } + }, { + type: "bi.text_button", + cls: "bi-card bi-border", + text: BI.i18nText("Fine-Design_Report_Edit"), + hgap: 10 + }] + }; + }, + + getValue: function() { + return self.multiSelect.getSelected(); + }, + + setValue: function(v) { + this.multiSelect.setSelected(v); + } + }); + BI.shortcut("bi.report.server.param_setting.use_tool_bar", Analysis); +})();window.BICst = window.BICst || {}; +BICst.REPORT_SERVER_PARAM = { + SPLIT_PAGE_PREVIEW_SETTING: 1, + FORM_PAGE_SETTING: 2, + DATA_ANALYSIS_SETTING: 3, + IMPORT_CSS: 4, + IMPORT_JS: 5, + ERROR_TEMPLATE_DEFINE: 6, + PRINT_SETTING: 7 +}; +BICst.REPORT_TEMPLATE_WEB_SETTING = { + BASE: 1, + PRINT: 2, + SPLIT_PAGE_PREVIEW_SETTING: 3, + FORM_PAGE_SETTING: 4, + DATA_ANALYSIS_SETTING: 5, + BROWSER: 6, + IMPORT_CSS: 7, + IMPORT_JS: 8 +}; + +BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS = { + FIRST_PAGE: 1, + PRE_PAGE: 2, + NEXT_PAGE: 3, + LAST_PAGE: 4, + PRINT: 5, + EXPORT: 6, + EMAIL: 7 +};BI.addI18n({ + "Fine-Design_Report_WEB_Pagination_Setting": "分页预览设置", + "Fine-Design_Report_WEB_Write_Setting": "填报页面设置", + "Fine-Design_Report_Data_Analysis_Settings": "数据分析设置", + "Fine-Design_Report_ReportServerP_Import_Css": "引用Css", + "Fine-Design_Report_ReportServerP_Import_JavaScript": "引用JavaScript", + "Fine-Design_Report_Error_Handler_Template": "出错模板定义", + "Fine-Design_Report_Print_Setting": "打印设置", + "Fine-Design_Report_Mobile_ToolBar": "工具栏", + "Fine-Design_Report_Tool_Bar_High": "高", + "Fine-Design_Report_Tool_Bar_Middle": "中", + "Fine-Design_Report_Tool_Bar_Low": "低", + "Fine-Design_Report_Mobile_ToolBar_Height": "工具栏高度", + "Fine-Design_Report_Is_Paint_Page": "以图片方式显示", + "Fine-Design_Report_IS_Auto_Scale": "iframe嵌入时自动缩放", + "Fine-Design_Report_IS_TD_HEAVY_EXPORT": "重方式输出格子", + "Fine-Design_Report_Use_ToolBar": "使用工具栏", + "Fine-Design_Report_Show_Location": "报表显示位置", + "Fine-Design_Report_Center_Display": "居中展示", + "Fine-Design_Report_Left_Display": "左展示", + "Fine-Design_Report_Editing_Listeners": "事件编辑", + "Fine-Design_Report_Edit": "编辑", + "Fine-Design_Report_Sheet_Label_Page_Display_Position": "sheet标签页显示位置:", + "Fine-Design_Form_Base_Top": "上", + "Fine-Design_Report_Bottom": "下", + "Fine-Design_Report_Set_Face_Write_Current_Edit_Row_Background": "当前编辑行背景设置", + "Fine-Design_Report_Unload_Check": "未提交离开提示", + "Fine-Design_Basic_Engine_Event_Show_Widgets": "直接显示控件", + "Fine-Design_Report_Write_Auto_Stash": "自动暂存", + "Fine-Design_Report_Engine_Sort_Sort": "排序", + "Fine-Design_Report_Engine_Selection_Filter": "条件筛选", + "Fine-Design_Report_Engine_List_Filter": "列表筛选", + "Fine-Design_Basic_Engine_Cancel": "取消", + "Fine-Design_Report_OK": "确定", + "Fine-Design_Report_Basic": "基本", + "Fine-Design_Report_Printer(Server)": "打印机(服务器)", + "Fine-Design_Report_Browser_Background": "浏览器背景", + "Fine-Design_Report_I_Want_To_Set_Single": "为该模板单独设置", + "Fine-Design_Form_Using_Server_Report_View_Settings": "采用服务器设置", + "Fine-Design_Report_Blow_Set": "以下设置:", + "Fine-Design_Report_PageSetup_Page": "页面", + "Fine-Design_Report_ToolBar_Top": "顶部工具栏", + "Fine-Design_Report_ToolBar_Bottom": "底部工具栏", + "Fine-Design_Basic_Scale_Custom_Button": "自定义", + "Fine-Design_Report_Restore_Default": "恢复默认", + "Fine-Design_Report_Engine_ReportServerP_First": "首页", + "Fine-Design_Report_Engine_ReportServerP_Previous": "上一页", + "Fine-Design_Report_Engine_ReportServerP_Next": "下一页", + "Fine-Design_Report_Engine_ReportServerP_Last": "末页", + "Fine-Design_Report_Engine_Print": "打印", + "Fine-Design_Report_Engine_Export": "导出", + "Fine-Design_Report_Engine_Email": "邮件" +});!(function () { + /** + * 服务器 数据分析设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-data-analysis" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.button_group", + height: 24, + value: [1,2,3], + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Engine_Sort_Sort"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Selection_Filter"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Engine_List_Filter"), + value: 2 + }], { + type: "bi.multi_select_item", + logic: { + dynamic: true + }, + iconWrapperWidth: 16, + hgap: 5 + }), + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt" + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24, + value: true + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.data_analysis", Analysis); +})();!(function () { + + /** + * 服务器 填报预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-form-page" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.grid", + height: 78, + columns: 2, + rows: 2, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.report.sheet_label_location", + height: 24 + } + }, { + column: 1, + row: 0, + el: { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + } + }, { + column: 0, + row: 1, + el: { + type: "bi.report.form_background_setting", + height: 24 + } + }, { + column: 1, + row: 1, + el: { + type: "bi.report.leave_setting", + height: 24 + } + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24, + value: true + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.form_page", Analysis); +})();!(function () { + /** + * 服务器 分页预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-page-preview" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.server.param_setting.report_show_location", + height: 24 + }, { + type: "bi.button_group", + height: 92, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + el: { + text: BI.i18nText("Fine-Design_Report_Is_Paint_Page"), + value: 1 + }, + bgap: 10 + }, { + el: { + text: BI.i18nText("Fine-Design_Report_IS_Auto_Scale"), + value: 2 + }, + bgap: 10 + }, { + text: BI.i18nText("Fine-Design_Report_IS_TD_HEAVY_EXPORT"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + layouts: [{ + type: "bi.vertical" + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24 + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.page_preview", Analysis); +})();!(function () { + BI.constant("bi.constant.report.server.param_setting", [ + { + text: BI.i18nText("Fine-Design_Report_WEB_Pagination_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Write_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.FORM_PAGE_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Data_Analysis_Settings"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.DATA_ANALYSIS_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.IMPORT_CSS + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.IMPORT_JS + }, { + text: BI.i18nText("Fine-Design_Report_Error_Handler_Template"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.ERROR_TEMPLATE_DEFINE + }, { + text: BI.i18nText("Fine-Design_Report_Print_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.PRINT_SETTING + }] + ); +})();!(function () { + + /** + * 报表服务器参数面板 + */ + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-report-server-param-setting" + }, + + render: function () { + return { + type: "bi.setting.tab", + value: BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING, + tabItems: BI.Constants.getConstant("bi.constant.report.server.param_setting"), + cardCreator: BI.bind(this._createCard, this) + }; + }, + + _createCard: function (v) { + switch (v) { + case BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING: + return { + type: "bi.report.server.param_setting.page_preview" + }; + case BICst.REPORT_SERVER_PARAM.FORM_PAGE_SETTING: + return { + type: "bi.report.server.param_setting.form_page" + }; + case BICst.REPORT_SERVER_PARAM.DATA_ANALYSIS_SETTING: + return { + type: "bi.report.server.param_setting.data_analysis" + } + case BICst.REPORT_SERVER_PARAM.IMPORT_CSS: + case BICst.REPORT_SERVER_PARAM.IMPORT_JS: + case BICst.REPORT_SERVER_PARAM.ERROR_TEMPLATE_DEFINE: + case BICst.REPORT_SERVER_PARAM.PRINT_SETTING: + default: + return { + type: "bi.label", + text: "1" + }; + } + } + + }); + + BI.shortcut("bi.report.server.param_setting", Tab); +})();!(function () { + /** + * 填报页面设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-form-page" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.global_or_single_combo", + height: 24 + }, { + type: "bi.grid", + height: 78, + columns: 2, + rows: 2, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.report.sheet_label_location" + } + }, { + column: 1, + row: 0, + el: { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + } + }, { + column: 0, + row: 1, + el: { + type: "bi.report.form_background_setting" + } + }, { + column: 1, + row: 1, + el: { + type: "bi.report.leave_setting" + } + }] + }, { + type: "bi.settings.tool_bar", + height: 180 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.template.web_setting.form_page", Analysis); +})();!(function () { + /** + * 分页预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-page-preview" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.global_or_single_combo", + height: 24 + }, { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + }, { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_PageSetup_Page"), + textAlign: "right", + width: 70 + }, { + el: { + type: "bi.button_group", + height: 24, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Is_Paint_Page"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_IS_Auto_Scale"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_IS_TD_HEAVY_EXPORT"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + layouts: [{ + type: "bi.left", + lgap: 5 + }] + }, + lgap: 10 + }] + }, { + type: "bi.settings.tool_bar", + height: 180 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.template.web_setting.page_preview", Analysis); +})();!(function () { + BI.constant("bi.constant.report.template.web_setting", [ + { + text: BI.i18nText("Fine-Design_Report_Basic"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.BASE + }, { + text: BI.i18nText("Fine-Design_Report_Printer(Server)"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.PRINT + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Pagination_Setting"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Write_Setting"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.FORM_PAGE_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Data_Analysis_Settings"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.DATA_ANALYSIS_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Browser_Background"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.BROWSER + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_CSS + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_JS + }] + ); + + BI.constant("bi.constant.report.template.web_setting.tools", [ + { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_First"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.FIRST_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Previous"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.PRE_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Next"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.NEXT_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Last"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.LAST_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Print"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.PRINT + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Export"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.EXPORT + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Email"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.EMAIL + }] + ); +})();!(function () { + + /** + * 模板Web属性面板 + */ + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-report-template-web-setting" + }, + + render: function () { + return { + type: "bi.setting.tab", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING, + tabItems: BI.Constants.getConstant("bi.constant.report.template.web_setting"), + cardCreator: BI.bind(this._createCard, this) + }; + }, + + _createCard: function (v) { + switch (v) { + case BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING: + return { + type: "bi.report.template.web_setting.page_preview" + } + case BICst.REPORT_TEMPLATE_WEB_SETTING.FORM_PAGE_SETTING: + return { + type: "bi.report.template.web_setting.form_page" + } + case BICst.REPORT_TEMPLATE_WEB_SETTING.DATA_ANALYSIS_SETTING: + case BICst.REPORT_TEMPLATE_WEB_SETTING.BASE: + case BICst.REPORT_TEMPLATE_WEB_SETTING.PRINT: + case BICst.REPORT_TEMPLATE_WEB_SETTING.BROWSER: + case BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_CSS: + case BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_JS: + default: + return { + type: "bi.label", + text: "1" + }; + } + } + + }); + + BI.shortcut("bi.report.template.web_setting", Tab); +})();!(function(){ + window.addEventListener("load", function (ev) { + BI.createWidget({ + type:"bi.absolute", + element: "body", + items: [{ + el: { + type: "bi.settings.bar_container", + el: { + type: "bi.report.server.param_setting" + } + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }) +})(); \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/template.css b/designer-base/src/test/resources/com/fr/design/ui/script/template.css new file mode 100644 index 0000000000..05d98d1557 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/template.css @@ -0,0 +1,12 @@ +.bi-setting-tab .tab-group { + background-color: #F2F4F7; + font-size: 12px; +} +.bi-setting-tab .tab-group .tab-item:hover { + color: #3685f2; +} +.bi-setting-tab .tab-group .tab-item.active { + background-color: #ffffff; + color: #3685f2; + border-top: 3px solid #3685f2; +} diff --git a/designer-base/src/test/resources/com/fr/design/ui/script/template.js b/designer-base/src/test/resources/com/fr/design/ui/script/template.js new file mode 100644 index 0000000000..7693577848 --- /dev/null +++ b/designer-base/src/test/resources/com/fr/design/ui/script/template.js @@ -0,0 +1,1328 @@ +!(function(){ + /** + * 带确定取消的通用控件 + */ + var Bar = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-settings-bar-container", + el: { + + } + }, + + render: function() { + return { + type: "bi.vtape", + items: [this.options.el, { + type: "bi.right_vertical_adapt", + height: 24, + rgap: 10, + vgap: 10, + items: [{ + type: "bi.button", + level: "ignore", + text: BI.i18nText("Fine-Design_Report_OK"), + handler: function() { + + } + }, { + type: "bi.button", + level: "ignore", + text: BI.i18nText("Fine-Design_Basic_Engine_Cancel"), + handler: function() { + + } + }] + }] + } + } + }) + BI.shortcut("bi.settings.bar_container", Bar) +})();!(function () { + /** + * 事件设置 + */ + var List = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-edit-list" + }, + + render: function () { + var self = this; + return { + type: "bi.vtape", + vgap: 5, + items: [{ + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.icon_button", + cls: "text-add-tip-font", + width: 24, + height: 24, + handler: function() { + self.group.addItems([self._createItem()]) + } + }, { + type: "bi.icon_button", + cls: "close-font", + width: 24, + height: 24, + handler: function() { + self.group.removeItemAt(); + } + }, { + type: "bi.icon_button", + cls: "close-font", + width: 24, + height: 24, + handler: function() { + self.removeItemAt(self._getIndexOfItemValue(self.group.getValue())) + } + }] + }, { + type: "bi.button_group", + cls: "bi-border bi-card", + ref: function(_ref) { + self.group = _ref; + }, + items: [] + }] + }; + }, + + _getIndexOfItemValue: function(values) { + values = BI.isArray(values) ? values : [values]; + var indexes = []; + BI.each(this.group.getAllButtons(), function(idx, button){ + if(BI.contains(values, button.getValue())) { + indexes.push(idx); + } + }); + return indexes; + }, + + _createItem: function() { + return { + type: "bi.text_button", + textAlign: "left", + hgap: 10, + text: "选项" + this.group.getAllButtons().length, + cls: "bi-list-item-select", + value: BI.UUID() + }; + }, + + populate: function(items) { + this.group.populate(items); + }, + + addItems: function(items) { + + }, + + removeItemAt: function(indexes) { + this.group.removeItemAt(indexes); + } + }); + BI.shortcut("bi.report.server.param_setting.edit_list", List); +})();!(function () { + /** + * 填报当前编辑行背景设置相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-form-background-setting" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + items: [{ + type: "bi.multi_select_item", + logic: { + dynamic: true + }, + iconWrapperWidth: 16, + text: BI.i18nText("Fine-Design_Report_Set_Face_Write_Current_Edit_Row_Background") + }, { + el: { + type: "bi.color_chooser", + width: 24, + height: 24 + }, + lgap: 10 + }] + }; + } + }); + BI.shortcut("bi.report.form_background_setting", Analysis); +})();!(function () { + /** + * + * 为模板单独设置的相关项 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-global-or-single-combo", + value: 1 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + rgap: 10, + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Blow_Set") + }, { + type: "bi.text_value_combo", + width: 200, + ref: function(_ref) { + self.combo = _ref; + }, + value: o.value, + items: [{ + text: BI.i18nText("Fine-Design_Report_I_Want_To_Set_Single"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Form_Using_Server_Report_View_Settings"), + value: 2 + }], + listerners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }] + }; + }, + + getValue: function() { + return self.combo.getValue(); + }, + + setValue: function(v) { + this.combo.setValue(v); + } + }); + BI.shortcut("bi.report.global_or_single_combo", Analysis); +})();!(function () { + /** + * 离开提示/直接显示控件/自动暂存相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-leave-setting", + value: [1] + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.button_group", + value: o.value, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Unload_Check"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Basic_Engine_Event_Show_Widgets"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Write_Auto_Stash"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt", + rgap: 5 + }], + ref: function(_ref) { + self.group = _ref; + } + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.leave_setting", Analysis); +})();!(function () { + /** + * 报表显示位置相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-report-show-location" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Show_Location") + }, { + type: "bi.button_group", + ref: function(_ref) { + self.group = _ref; + }, + value: 2, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Center_Display"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Left_Display"), + value: 2 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.left", + lgap: 10 + }] + }] + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.server.param_setting.report_show_location", Analysis); +})();!(function () { + + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-setting-tab", + value: "", + tabItems: [], + cardCreator: BI.emptyFn + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vtape", + items: [{ + type: "bi.vertical_adapt", + cls: "tab-group", + items: [{ + type: "bi.button_group", + layouts: [{ + type: "bi.left" + }], + value: o.value, + items: BI.map(o.tabItems, function(idx, item){ + return { + el: BI.extend({ + type: "bi.text_button", + hgap: 10, + height: 24 + }, item) + }; + }), + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function (v) { + self.tableTab.setSelect(v); + } + }], + ref: function (_ref) { + // self.buttons = _ref; + } + }], + height: 24 + }, { + type: "bi.tab", + cls: "bi-card", + showIndex: o.value, + cardCreator: this.options.cardCreator, + ref: function (ref) { + self.tableTab = ref; + } + }] + }; + } + }); + + BI.shortcut("bi.setting.tab", Tab); +})();!(function () { + /** + * sheet标签页显示位置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-report-show-location" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Sheet_Label_Page_Display_Position") + }, { + type: "bi.button_group", + ref: function(_ref) { + self.group = _ref; + }, + value: 2, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Form_Base_Top"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Bottom"), + value: 2 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.left", + lgap: 10 + }] + }] + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.sheet_label_location", Analysis); +})();!(function(){ + var ToolBar = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-settings-tool-bar", + value: [1] + }, + + render: function() { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.left_right_vertical_adapt", + height: 24, + bgap: 15, + rhgap: 10, + items: { + left: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Mobile_ToolBar"), + width: 70, + textAlign: "left" + }, { + type: "bi.button_group", + value: o.value, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_ToolBar_Top"), + value: 1, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + if(this.isSelected()) { + self._populateDefault(); + } else { + self.topRegion.populate(); + } + } + }] + }, { + text: BI.i18nText("Fine-Design_Report_ToolBar_Bottom"), + value: 2 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + ref: function(_ref) { + self.group = _ref; + }, + layouts: [{ + type: "bi.left" + }], + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }], + right: [{ + el: { + type: "bi.text_button", + cls: "bi-border", + text: BI.i18nText("Fine-Design_Basic_Scale_Custom_Button"), + handler: function() { + + }, + hgap: 5 + } + }, { + el: { + type: "bi.text_button", + cls: "bi-border", + text: BI.i18nText("Fine-Design_Report_Restore_Default"), + handler: function() { + + }, + hgap: 5 + } + }] + } + }, { + el: { + type: "bi.settings.tool_bar.region", + height: 56, + title: BI.i18nText("Fine-Design_Report_ToolBar_Top"), + ref: function(_ref) { + self.topRegion = _ref; + }, + items: BI.contains(o.value, 1) ? this._createDefaultItems() : [] + }, + bgap: 20 + }, { + type: "bi.settings.tool_bar.region", + height: 56, + title: BI.i18nText("Fine-Design_Report_ToolBar_Bottom"), + ref: function(_ref) { + self.bottomRegion = _ref; + } + }] + } + }, + + _createDefaultItems: function() { + return BI.createItems(BI.Constants.getConstant("bi.constant.report.template.web_setting.tools"), { + type: "bi.icon_text_item", + height: 24, + extraCls: "bi-background bi-list-item-select bi-border-radius", + logic: { + dynamic: true + }, + textHgap: 10, + value: BI.UUID() + }) + }, + + _populateDefault: function() { + this.topRegion.populate(this._createDefaultItems()); + } + }) + BI.shortcut("bi.settings.tool_bar", ToolBar) +})();!(function(){ + var Region = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-settings-tool-bar-region", + title: "" + }, + + render: function() { + var self = this, o = this.options; + return [{ + type: "bi.button_group", + cls: "bi-border", + items: o.items, + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt", + hgap: 10 + }], + ref: function(_ref) { + self.group = _ref; + } + }, { + type: "bi.absolute", + items: [{ + el: { + type: "bi.label", + cls: "bi-background", + text: o.title + }, + top: -10, + left: 10 + }] + }] + }, + + populate: function(items) { + this.group.populate(items); + } + }) + BI.shortcut("bi.settings.tool_bar.region", Region); +})();!(function () { + /** + * 工具栏高度相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-tool-bar-height-select", + height: 24, + value: 2 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + el: { + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_Mobile_ToolBar_Height") + }, + rgap: 10 + }, { + type: "bi.button_group", + value: o.value, + ref: function(_ref) { + self.group = _ref; + }, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Tool_Bar_High"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Tool_Bar_Middle"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Tool_Bar_Low"), + value: 3 + }], { + type: "bi.single_select_radio_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.vertical_adapt" + }], + listeners: [{ + eventName: "EVENT_CHANGE", + action: function() { + + } + }] + }] + + }; + }, + + getValue: function() { + return self.group.getValue(); + }, + + setValue: function(v) { + this.group.setValue(v); + } + }); + BI.shortcut("bi.report.server.param_setting.tool_bar_height_select", Analysis); +})();!(function () { + /** + * 使用工具栏相关 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-use-tool-bar" + }, + + render: function () { + var self = this; + return { + type: "bi.vertical_adapt", + height: 24, + items: [{ + el: { + type: "bi.multi_select_item", + ref: function(_ref) { + self.multiSelect = _ref; + }, + hgap: 5, + selected: true, + text: BI.i18nText("Fine-Design_Report_Use_ToolBar"), + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + } + }, { + type: "bi.text_button", + cls: "bi-card bi-border", + text: BI.i18nText("Fine-Design_Report_Edit"), + hgap: 10 + }] + }; + }, + + getValue: function() { + return self.multiSelect.getSelected(); + }, + + setValue: function(v) { + this.multiSelect.setSelected(v); + } + }); + BI.shortcut("bi.report.server.param_setting.use_tool_bar", Analysis); +})();window.BICst = window.BICst || {}; +BICst.REPORT_SERVER_PARAM = { + SPLIT_PAGE_PREVIEW_SETTING: 1, + FORM_PAGE_SETTING: 2, + DATA_ANALYSIS_SETTING: 3, + IMPORT_CSS: 4, + IMPORT_JS: 5, + ERROR_TEMPLATE_DEFINE: 6, + PRINT_SETTING: 7 +}; +BICst.REPORT_TEMPLATE_WEB_SETTING = { + BASE: 1, + PRINT: 2, + SPLIT_PAGE_PREVIEW_SETTING: 3, + FORM_PAGE_SETTING: 4, + DATA_ANALYSIS_SETTING: 5, + BROWSER: 6, + IMPORT_CSS: 7, + IMPORT_JS: 8 +}; + +BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS = { + FIRST_PAGE: 1, + PRE_PAGE: 2, + NEXT_PAGE: 3, + LAST_PAGE: 4, + PRINT: 5, + EXPORT: 6, + EMAIL: 7 +};BI.addI18n({ + "Fine-Design_Report_WEB_Pagination_Setting": "分页预览设置", + "Fine-Design_Report_WEB_Write_Setting": "填报页面设置", + "Fine-Design_Report_Data_Analysis_Settings": "数据分析设置", + "Fine-Design_Report_ReportServerP_Import_Css": "引用Css", + "Fine-Design_Report_ReportServerP_Import_JavaScript": "引用JavaScript", + "Fine-Design_Report_Error_Handler_Template": "出错模板定义", + "Fine-Design_Report_Print_Setting": "打印设置", + "Fine-Design_Report_Mobile_ToolBar": "工具栏", + "Fine-Design_Report_Tool_Bar_High": "高", + "Fine-Design_Report_Tool_Bar_Middle": "中", + "Fine-Design_Report_Tool_Bar_Low": "低", + "Fine-Design_Report_Mobile_ToolBar_Height": "工具栏高度", + "Fine-Design_Report_Is_Paint_Page": "以图片方式显示", + "Fine-Design_Report_IS_Auto_Scale": "iframe嵌入时自动缩放", + "Fine-Design_Report_IS_TD_HEAVY_EXPORT": "重方式输出格子", + "Fine-Design_Report_Use_ToolBar": "使用工具栏", + "Fine-Design_Report_Show_Location": "报表显示位置", + "Fine-Design_Report_Center_Display": "居中展示", + "Fine-Design_Report_Left_Display": "左展示", + "Fine-Design_Report_Editing_Listeners": "事件编辑", + "Fine-Design_Report_Edit": "编辑", + "Fine-Design_Report_Sheet_Label_Page_Display_Position": "sheet标签页显示位置:", + "Fine-Design_Form_Base_Top": "上", + "Fine-Design_Report_Bottom": "下", + "Fine-Design_Report_Set_Face_Write_Current_Edit_Row_Background": "当前编辑行背景设置", + "Fine-Design_Report_Unload_Check": "未提交离开提示", + "Fine-Design_Basic_Engine_Event_Show_Widgets": "直接显示控件", + "Fine-Design_Report_Write_Auto_Stash": "自动暂存", + "Fine-Design_Report_Engine_Sort_Sort": "排序", + "Fine-Design_Report_Engine_Selection_Filter": "条件筛选", + "Fine-Design_Report_Engine_List_Filter": "列表筛选", + "Fine-Design_Basic_Engine_Cancel": "取消", + "Fine-Design_Report_OK": "确定", + "Fine-Design_Report_Basic": "基本", + "Fine-Design_Report_Printer(Server)": "打印机(服务器)", + "Fine-Design_Report_Browser_Background": "浏览器背景", + "Fine-Design_Report_I_Want_To_Set_Single": "为该模板单独设置", + "Fine-Design_Form_Using_Server_Report_View_Settings": "采用服务器设置", + "Fine-Design_Report_Blow_Set": "以下设置:", + "Fine-Design_Report_PageSetup_Page": "页面", + "Fine-Design_Report_ToolBar_Top": "顶部工具栏", + "Fine-Design_Report_ToolBar_Bottom": "底部工具栏", + "Fine-Design_Basic_Scale_Custom_Button": "自定义", + "Fine-Design_Report_Restore_Default": "恢复默认", + "Fine-Design_Report_Engine_ReportServerP_First": "首页", + "Fine-Design_Report_Engine_ReportServerP_Previous": "上一页", + "Fine-Design_Report_Engine_ReportServerP_Next": "下一页", + "Fine-Design_Report_Engine_ReportServerP_Last": "末页", + "Fine-Design_Report_Engine_Print": "打印", + "Fine-Design_Report_Engine_Export": "导出", + "Fine-Design_Report_Engine_Email": "邮件" +});!(function () { + /** + * 服务器 数据分析设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-data-analysis" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.button_group", + height: 24, + value: [1,2,3], + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Engine_Sort_Sort"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Selection_Filter"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_Engine_List_Filter"), + value: 2 + }], { + type: "bi.multi_select_item", + logic: { + dynamic: true + }, + iconWrapperWidth: 16, + hgap: 5 + }), + chooseType: BI.Selection.Multi, + layouts: [{ + type: "bi.vertical_adapt" + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24, + value: true + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.data_analysis", Analysis); +})();!(function () { + + /** + * 服务器 填报预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-form-page" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.grid", + height: 78, + columns: 2, + rows: 2, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.report.sheet_label_location", + height: 24 + } + }, { + column: 1, + row: 0, + el: { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + } + }, { + column: 0, + row: 1, + el: { + type: "bi.report.form_background_setting", + height: 24 + } + }, { + column: 1, + row: 1, + el: { + type: "bi.report.leave_setting", + height: 24 + } + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24, + value: true + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.form_page", Analysis); +})();!(function () { + /** + * 服务器 分页预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-page-preview" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.server.param_setting.report_show_location", + height: 24 + }, { + type: "bi.button_group", + height: 92, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + el: { + text: BI.i18nText("Fine-Design_Report_Is_Paint_Page"), + value: 1 + }, + bgap: 10 + }, { + el: { + text: BI.i18nText("Fine-Design_Report_IS_Auto_Scale"), + value: 2 + }, + bgap: 10 + }, { + text: BI.i18nText("Fine-Design_Report_IS_TD_HEAVY_EXPORT"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + layouts: [{ + type: "bi.vertical" + }] + }, { + type: "bi.report.server.param_setting.use_tool_bar", + height: 24 + }, { + type: "bi.report.server.param_setting.tool_bar_height_select", + height: 24 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.server.param_setting.page_preview", Analysis); +})();!(function () { + BI.constant("bi.constant.report.server.param_setting", [ + { + text: BI.i18nText("Fine-Design_Report_WEB_Pagination_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Write_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.FORM_PAGE_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Data_Analysis_Settings"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.DATA_ANALYSIS_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.IMPORT_CSS + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.IMPORT_JS + }, { + text: BI.i18nText("Fine-Design_Report_Error_Handler_Template"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.ERROR_TEMPLATE_DEFINE + }, { + text: BI.i18nText("Fine-Design_Report_Print_Setting"), + cls: "tab-item", + value: BICst.REPORT_SERVER_PARAM.PRINT_SETTING + }] + ); +})();!(function () { + + /** + * 报表服务器参数面板 + */ + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-report-server-param-setting" + }, + + render: function () { + return { + type: "bi.setting.tab", + value: BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING, + tabItems: BI.Constants.getConstant("bi.constant.report.server.param_setting"), + cardCreator: BI.bind(this._createCard, this) + }; + }, + + _createCard: function (v) { + switch (v) { + case BICst.REPORT_SERVER_PARAM.SPLIT_PAGE_PREVIEW_SETTING: + return { + type: "bi.report.server.param_setting.page_preview" + }; + case BICst.REPORT_SERVER_PARAM.FORM_PAGE_SETTING: + return { + type: "bi.report.server.param_setting.form_page" + }; + case BICst.REPORT_SERVER_PARAM.DATA_ANALYSIS_SETTING: + return { + type: "bi.report.server.param_setting.data_analysis" + } + case BICst.REPORT_SERVER_PARAM.IMPORT_CSS: + case BICst.REPORT_SERVER_PARAM.IMPORT_JS: + case BICst.REPORT_SERVER_PARAM.ERROR_TEMPLATE_DEFINE: + case BICst.REPORT_SERVER_PARAM.PRINT_SETTING: + default: + return { + type: "bi.label", + text: "1" + }; + } + } + + }); + + BI.shortcut("bi.report.server.param_setting", Tab); +})();!(function () { + /** + * 填报页面设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-form-page" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.global_or_single_combo", + height: 24 + }, { + type: "bi.grid", + height: 78, + columns: 2, + rows: 2, + items: [{ + column: 0, + row: 0, + el: { + type: "bi.report.sheet_label_location" + } + }, { + column: 1, + row: 0, + el: { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + } + }, { + column: 0, + row: 1, + el: { + type: "bi.report.form_background_setting" + } + }, { + column: 1, + row: 1, + el: { + type: "bi.report.leave_setting" + } + }] + }, { + type: "bi.settings.tool_bar", + height: 180 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.template.web_setting.form_page", Analysis); +})();!(function () { + /** + * 分页预览设置 + */ + var Analysis = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-report-server-param-setting-page-preview" + }, + + render: function () { + return { + type: "bi.vtape", + vgap: 10, + hgap: 10, + items: [{ + type: "bi.report.global_or_single_combo", + height: 24 + }, { + type: "bi.report.server.param_setting.report_show_location", + height: 24 + }, { + type: "bi.vertical_adapt", + height: 24, + items: [{ + type: "bi.label", + text: BI.i18nText("Fine-Design_Report_PageSetup_Page"), + textAlign: "right", + width: 70 + }, { + el: { + type: "bi.button_group", + height: 24, + chooseType: BI.Selection.Multi, + items: BI.createItems([{ + text: BI.i18nText("Fine-Design_Report_Is_Paint_Page"), + value: 1 + }, { + text: BI.i18nText("Fine-Design_Report_IS_Auto_Scale"), + value: 2 + }, { + text: BI.i18nText("Fine-Design_Report_IS_TD_HEAVY_EXPORT"), + value: 3 + }], { + type: "bi.multi_select_item", + hgap: 5, + logic: { + dynamic: true + }, + iconWrapperWidth: 16 + }), + layouts: [{ + type: "bi.left", + lgap: 5 + }] + }, + lgap: 10 + }] + }, { + type: "bi.settings.tool_bar", + height: 180 + }, { + type: "bi.label", + height: 24, + textAlign: "left", + text: BI.i18nText("Fine-Design_Report_Editing_Listeners") + ":", + }, { + type: "bi.report.server.param_setting.edit_list" + }] + }; + } + }); + BI.shortcut("bi.report.template.web_setting.page_preview", Analysis); +})();!(function () { + BI.constant("bi.constant.report.template.web_setting", [ + { + text: BI.i18nText("Fine-Design_Report_Basic"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.BASE + }, { + text: BI.i18nText("Fine-Design_Report_Printer(Server)"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.PRINT + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Pagination_Setting"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_WEB_Write_Setting"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.FORM_PAGE_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Data_Analysis_Settings"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.DATA_ANALYSIS_SETTING + }, { + text: BI.i18nText("Fine-Design_Report_Browser_Background"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.BROWSER + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_Css"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_CSS + }, { + text: BI.i18nText("Fine-Design_Report_ReportServerP_Import_JavaScript"), + cls: "tab-item", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_JS + }] + ); + + BI.constant("bi.constant.report.template.web_setting.tools", [ + { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_First"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.FIRST_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Previous"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.PRE_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Next"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.NEXT_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_ReportServerP_Last"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.LAST_PAGE + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Print"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.PRINT + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Export"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.EXPORT + }, { + text: BI.i18nText("Fine-Design_Report_Engine_Email"), + cls: "close-font", + value: BICst.REPORT_TEMPLATE_WEB_SETTING_TOOLS.EMAIL + }] + ); +})();!(function () { + + /** + * 模板Web属性面板 + */ + var Tab = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-report-template-web-setting" + }, + + render: function () { + return { + type: "bi.setting.tab", + value: BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING, + tabItems: BI.Constants.getConstant("bi.constant.report.template.web_setting"), + cardCreator: BI.bind(this._createCard, this) + }; + }, + + _createCard: function (v) { + switch (v) { + case BICst.REPORT_TEMPLATE_WEB_SETTING.SPLIT_PAGE_PREVIEW_SETTING: + return { + type: "bi.report.template.web_setting.page_preview" + } + case BICst.REPORT_TEMPLATE_WEB_SETTING.FORM_PAGE_SETTING: + return { + type: "bi.report.template.web_setting.form_page" + } + case BICst.REPORT_TEMPLATE_WEB_SETTING.DATA_ANALYSIS_SETTING: + case BICst.REPORT_TEMPLATE_WEB_SETTING.BASE: + case BICst.REPORT_TEMPLATE_WEB_SETTING.PRINT: + case BICst.REPORT_TEMPLATE_WEB_SETTING.BROWSER: + case BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_CSS: + case BICst.REPORT_TEMPLATE_WEB_SETTING.IMPORT_JS: + default: + return { + type: "bi.label", + text: "1" + }; + } + } + + }); + + BI.shortcut("bi.report.template.web_setting", Tab); +})();!(function(){ + window.addEventListener("load", function (ev) { + BI.createWidget({ + type:"bi.absolute", + element: "body", + items: [{ + el: { + type: "bi.settings.bar_container", + el: { + type: "bi.report.template.web_setting" + } + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }) +})(); \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index 3a8abb56e5..8c3f56ae01 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -2,9 +2,9 @@ package com.fr.design; import com.fr.chart.base.ChartConstants; import com.fr.chart.base.ChartInternationalNameContentBean; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.IndependentChartUIProvider; @@ -41,6 +41,7 @@ import com.fr.design.module.DesignModuleFactory; import com.fr.form.ui.ChartEditor; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; +import com.fr.locale.InterProviderFactory; import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.plugin.chart.area.VanChartAreaPlot; import com.fr.plugin.chart.bubble.VanChartBubblePlot; @@ -99,7 +100,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static com.fr.chart.charttypes.ChartTypeManager.CHART_PRIORITY; +import static com.fr.chart.charttypes.ChartTypeManager.DEFAULT_PRIORITY; +import static com.fr.chart.charttypes.ChartTypeManager.DEPRECATED_CHART_PRIORITY; import static com.fr.chart.charttypes.ChartTypeManager.VAN_CHART_PRIORITY; /** @@ -158,14 +160,14 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; int index = 0; for (ChartInternationalNameContentBean bean : typeName) { - String plotID = bean.getPlotID(); - Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); + String plotID = bean.getChartID(); + ChartProvider[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(plotID)) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); - child[index] = new ChartWidgetOption(com.fr.design.i18n.Toolkit.i18nText(bean.getName()), icon, ChartEditor.class, plotID); + child[index] = new ChartWidgetOption(InterProviderFactory.getProvider().getLocText(bean.getName()), icon, ChartEditor.class, plotID); index++; } @@ -198,23 +200,23 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr private static void readDefault() { - addChartTypeInterface(CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.LINE_CHART, new LineIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.BAR_CHART, new BarIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.PIE_CHART, new PieIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.METER_CHART, new MeterIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.MAP_CHART, new MapIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface()); - addChartTypeInterface(CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.COLUMN_CHART, new ColumnIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.LINE_CHART, new LineIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BAR_CHART, new BarIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.PIE_CHART, new PieIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.AREA_CHART, new AreaIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.SCATTER_CHART, new XYScatterIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.BUBBLE_CHART, new BubbleIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RADAR_CHART, new RadarIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.STOCK_CHART, new StockIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.METER_CHART, new MeterIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.RANGE_CHART, new RangeIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.CUSTOM_CHART, new CustomIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GANTT_CHART, new GanttIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.DONUT_CHART, new DonutIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.MAP_CHART, new MapIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.GIS_CHAER, new GisMapIndependentChartInterface()); + addChartTypeInterface(DEPRECATED_CHART_PRIORITY, ChartConstants.FUNNEL_CHART, new FunnelIndependentChartInterface()); } private static void addChartTypeInterface(String priority, String plotID, IndependentChartUIProvider provider) { @@ -251,7 +253,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr * * @param paneList pane容器 */ - public void addPlotTypePaneList(List> paneList, Map>> allChartTypePane) { + public void addPlotTypePaneList(List> paneList, Map>> allChartTypePane) { List priorityList = getPriorityInOrder(); for (Integer aPriorityList : priorityList) { @@ -261,7 +263,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr } - public void addPlotTypePaneList(String priority, List> paneList, Map>> allChartTypePane) { + public void addPlotTypePaneList(String priority, List> paneList, Map>> allChartTypePane) { if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { @@ -280,7 +282,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr paneList.add(pane); if (allChartTypePane.get(priority) == null) { - allChartTypePane.put(priority, new LinkedHashMap>()); + allChartTypePane.put(priority, new LinkedHashMap>()); } allChartTypePane.get(priority).put(plotID, pane); } @@ -447,9 +449,10 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr return true; } - public boolean needChartChangePane(Chart chart) { - if (chart != null && chart.getPlot() != null) { - IndependentChartUIProvider provider = getChartTypeInterface(chart.getPlot().getPlotID()); + public boolean needChartChangePane(ChartProvider chart) { + if (chart != null) { + String chartID = chart.getID(); + IndependentChartUIProvider provider = getChartTypeInterface(chartID); if (provider != null) { return provider.needChartChangePane(); } @@ -462,7 +465,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public void mount(PluginSingleInjection injection) { if (isIndependentChartUIProvider(injection)) { - String priority = injection.getAttribute("priority", CHART_PRIORITY); + String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); String plotID = injection.getAttribute("plotID"); IndependentChartUIProvider instance = (IndependentChartUIProvider) injection.getObject(); addChartTypeInterface(priority, plotID, instance); @@ -474,7 +477,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public void demount(PluginSingleInjection injection) { if (isIndependentChartUIProvider(injection)) { - String priority = injection.getAttribute("priority", CHART_PRIORITY); + String priority = injection.getAttribute("priority", DEFAULT_PRIORITY); String plotID = injection.getAttribute("plotID"); removeChartTypeInterface(priority, plotID); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java index 7fefabd3e3..6ff6e0639d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartCommonWizardPane.java @@ -1,7 +1,7 @@ package com.fr.design.chart; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.attr.ChartProvider; public abstract class ChartCommonWizardPane extends ChartWizardPane { private static final long serialVersionUID = 2467967841657570498L; @@ -11,12 +11,12 @@ public abstract class ChartCommonWizardPane extends ChartWizardPane { if (cc == null) { return; } - - populate(cc.getSelectedChart()); + + populate(cc.getSelectedChartProvider()); } - - public abstract void populate(Chart chart); - - public abstract void update(Chart oldChart); + + public abstract void populate(ChartProvider chart); + + public abstract void update(ChartProvider oldChart); } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java deleted file mode 100644 index e0493cc70d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.fr.design.chart; - -import com.fr.chart.chartattr.Chart; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.beans.BasicBeanPane; -import com.fr.design.gui.controlpane.JListControlPane; -import com.fr.design.gui.controlpane.NameObjectCreator; -import com.fr.design.gui.controlpane.NameableCreator; -import com.fr.design.layout.FRGUIPaneFactory; - -import com.fr.general.NameObject; -import com.fr.stable.Nameable; - -import java.awt.*; -import java.util.HashMap; - -/** - * 管理图表类型Pane - * @author kunsnat: ChartComponent移出. - */ -public class ChartControlPane extends JListControlPane { - private static final long serialVersionUID = 7336270815128413184L; - - public ChartControlPane() { - super(); - // 重新设定大小. 因为JControlPane默认的(450,450) 不适合图表这边 @ChartSize -// this.setPreferredSize(new Dimension(770, 520)); - } - - @Override - public NameableCreator[] createNameableCreators() { - return new NameableCreator[] { - new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Chart"), Chart.class, ChartTypeUpdatePane.class) - }; - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Manage_Chart_Type"); - } - - public void populate(ChartCollection cc) { - if(cc == null)return; - - NameObject[] nameObjects = new NameObject[cc.getChartCount()]; - for (int i = 0; i < nameObjects.length; i++) { - nameObjects[i] = new NameObject(cc.getChartName(i), cc.getChart(i)); - } - - populate(nameObjects); - // kunsnat: 选中当前图表选中的name - String chartSelectedName = cc.getChartName(cc.getSelectedIndex() < cc.getChartCount() ? cc.getSelectedIndex() : 0); - setSelectedName(chartSelectedName); - } - - public void update(ChartCollection cc) { - HashMap namesChart = new HashMap();// 暂存判断是否有必要更新 - for(int i = 0; i < cc.getChartCount(); i++) { - try { - namesChart.put(cc.getChartName(i), cc.getChart(i).clone()); - } catch (CloneNotSupportedException e) { - - } - } - - Nameable[] nameables = update(); - if (nameables.length == 0 || cc == null) { - return; - } - - cc.removeAllNameObject(); - String select = getSelectedName(); - for (int i = 0; i < nameables.length; i++) { - if (nameables[i] instanceof NameObject && ((NameObject)nameables[i]).getObject() instanceof Chart) { - NameObject no = (NameObject)nameables[i]; - - String name = no.getName(); - Chart chart = (Chart)no.getObject(); - if(namesChart.containsKey(name)) { - Chart tmpChart = (Chart)namesChart.get(name); - if(chart.getPlot() != null && tmpChart.getPlot() != null - && chart.getPlot().match4GUI(tmpChart.getPlot())) { - chart = tmpChart;// 代替之前做过编辑的Chart - } - } - cc.addNamedChart(name, chart); - if(no.getName().equals(select)) { - cc.setSelectedIndex(i); - } - } - } - } - - /* - * alex:继承UpdatePane的ChartTypePane - */ - public static class ChartTypeUpdatePane extends BasicBeanPane { - private static final long serialVersionUID = -7058348930816218415L; - private Chart editing; - - private ChartTypePane typePane; - - public ChartTypeUpdatePane() { - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - - typePane = new ChartTypePane(); - this.add(typePane, BorderLayout.CENTER); - } - - @Override - protected String title4PopupWindow() { - return "Chart Type"; - } - - @Override - public void populateBean(Chart ob) { - editing = ob; - typePane.populate(ob); - } - - @Override - public Chart updateBean() { - typePane.update(editing); - - return editing; - } - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java index c3213c10ba..2034f45918 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java @@ -4,6 +4,7 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.gui.ChartComponent; +import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.design.module.ChartEmptyDataStyleAction; @@ -53,6 +54,8 @@ public class ChartDesignerActivator extends Activator implements Prepare { DesignImageEvent.registerDefaultCallbackEvent(HistoryTemplateListPane.getInstance()); DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper()); + DesignerLaunchStatus.setStatus(DesignerLaunchStatus.DESIGNER_INIT_COMPLETE); + ChartTypeInterfaceManager.addPluginChangedListener(); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java index de7d08a2b0..257fb8826e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartTypePane.java @@ -5,24 +5,20 @@ package com.fr.design.chart; */ import com.fr.chart.base.ChartInternationalNameContentBean; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartIcon; -import com.fr.chart.chartattr.MapPlot; -import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.license.exception.RegistEditionException; -import com.fr.license.function.VT4FR; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.JList; -import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.ListCellRenderer; @@ -35,21 +31,22 @@ public class ChartTypePane extends ChartCommonWizardPane { private static final long serialVersionUID = -1175602484968520546L; private ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstanceWithCheck().getAllChartBaseNames(); - private Chart[][] charts4Icon = null; + private ChartProvider[][] charts4Icon = null; { - charts4Icon = new Chart[this.typeName.length][]; + charts4Icon = new ChartProvider[this.typeName.length][]; for (int i = 0; i < this.typeName.length; i++) { - Chart[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getPlotID()); + ChartProvider[] rowCharts = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.typeName[i].getChartID()); int rowChartsCount = rowCharts.length; - charts4Icon[i] = new Chart[rowChartsCount]; + charts4Icon[i] = new ChartProvider[rowChartsCount]; for (int j = 0; j < rowChartsCount; j++) { try { - charts4Icon[i][j] = (Chart) rowCharts[j].clone(); - charts4Icon[i][j].setTitle(null); - if(charts4Icon[i][j].getPlot() != null){ - charts4Icon[i][j].getPlot().setLegend(null); - } + charts4Icon[i][j] = (ChartProvider) rowCharts[j].clone(); + //todo@shinerefactor 老图表也是提供一张图片 这边就不用setTitle(null) 然后实时去画 +// charts4Icon[i][j].setTitle(null); +// if(charts4Icon[i][j].getPlot() != null){ +// charts4Icon[i][j].getPlot().setLegend(null); +// } } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -67,7 +64,7 @@ public class ChartTypePane extends ChartCommonWizardPane { mainTypeList = new JList(defaultListModel); for (int i = 0; i < typeName.length; i++) { - defaultListModel.insertElementAt(com.fr.design.i18n.Toolkit.i18nText(typeName[i].getName()), i); + defaultListModel.insertElementAt(InterProviderFactory.getProvider().getLocText(typeName[i].getName()), i); } mainTypeList.addListSelectionListener(listSelectionListener); @@ -120,7 +117,7 @@ public class ChartTypePane extends ChartCommonWizardPane { protected ListSelectionListener listSelectionListener = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { int main_index = mainTypeList.getSelectedIndex(); - Chart[] sub_charts = ChartTypePane.this.charts4Icon[main_index]; + ChartProvider[] sub_charts = ChartTypePane.this.charts4Icon[main_index]; ChartTypePane.this.iconListModel.clear(); for (int i = 0; i < sub_charts.length; i++) { ChartTypePane.this.iconListModel.addElement(new ChartIcon(sub_charts[i])); @@ -130,56 +127,14 @@ public class ChartTypePane extends ChartCommonWizardPane { }; public String getChartName(ChartIcon chartIcon) { - Chart chart = (Chart)chartIcon.getChart(); - return chart.getChartName(); + ChartProvider chart = chartIcon.getChart(); + return ChartTypeManager.getInstanceWithCheck().getChartName(chart.getID()); } - public void populate(Chart chart) { - if (chart == null) { - return; - } - Plot plot = chart.getPlot(); - - int mainIndex = 0; - int subIndex = 0; - - for (int i = 0; i < typeName.length; i++) { - Chart[] charts = ChartTypeManager.getInstanceWithCheck().getChartTypes(typeName[i].getPlotID()); - for (int j = 0; j < charts.length; j++) { - if (charts[j].getPlot().match4GUI(plot)) { - mainIndex = i; - subIndex = j; - // 一旦匹配 立马中断 - break; - } - } - } - - mainTypeList.setSelectedIndex(mainIndex); - iconViewList.setSelectedIndex(subIndex); - } - - public void update(Chart oldChart) { - String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID(); - Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; - if(chart.getPlot() != null){ - if(chart.getPlot() instanceof MapPlot && !supportMap()){ - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Not_Supported")); - throw new RegistEditionException(VT4FR.ChartMap); - } - - if (chart.getPlot() != null) { - try { - oldChart.changePlotInNewType((Plot) chart.getPlot().clone()); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - } + public void populate(ChartProvider chart) { } - private boolean supportMap() { - return VT4FR.ChartMap.isSupport(); + public void update(ChartProvider oldChart) { } public void update(ChartCollection cc) { @@ -187,12 +142,12 @@ public class ChartTypePane extends ChartCommonWizardPane { return; } - Chart chart4Update = cc.getSelectedChart(); + ChartProvider chart4Update = cc.getSelectedChartProvider(); if (chart4Update == null) { - String plotID = typeName[mainTypeList.getSelectedIndex()].getPlotID(); - Chart chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; + String plotID = typeName[mainTypeList.getSelectedIndex()].getChartID(); + ChartProvider chart = ChartTypeManager.getInstance().getChartTypes(plotID)[iconViewList.getSelectedIndex()]; try{ - chart4Update = (Chart)chart.clone(); + chart4Update = (ChartProvider) chart.clone(); cc.addChart(chart4Update); }catch (CloneNotSupportedException ex){ FineLoggerFactory.getLogger().error(ex.getMessage(), ex); diff --git a/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java b/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java index a84cfd693e..79323d73de 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/axis/MinMaxValuePane.java @@ -35,9 +35,9 @@ public class MinMaxValuePane extends JPanel { minValueField = new UITextField(6); maxCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Max_Value")); maxValueField = new UITextField(6); - isCustomMainUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Main_Graduation_Unit")); + isCustomMainUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Main_Type")); mainUnitField = new UITextField(6); - isCustomSecUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Second_Graduation_Unit")); + isCustomSecUnitBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Second_Type")); secUnitField = new UITextField(6); double p = TableLayout.PREFERRED; diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index 769218c7fa..31baca0715 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -1,7 +1,6 @@ package com.fr.design.chart.gui; import com.fr.base.ScreenResolution; -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartGlyph; import com.fr.base.chart.chartdata.CallbackEvent; @@ -10,6 +9,7 @@ import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.AxisGlyph; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.chart.gui.active.ActiveGlyph; import com.fr.design.chart.gui.active.ChartActiveGlyph; import com.fr.design.file.HistoryTemplateListPane; @@ -162,7 +162,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene return (this.chartCollection4Design == null) ? 0 : this.chartCollection4Design.getChartCount(); } - public BaseChart getEditingChart() { + public ChartProvider getEditingChart() { return editingChart; } diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java index f621c545f5..753bb47cd3 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java @@ -1,7 +1,6 @@ package com.fr.design.chart.gui; -import com.fr.chart.chartattr.Chart; -import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.base.chart.BaseChartGetter; import com.fr.design.gui.core.WidgetOption; import com.fr.form.ui.ChartEditor; import com.fr.form.ui.Widget; @@ -38,14 +37,11 @@ public class ChartWidgetOption extends WidgetOption { Class clz = widgetClass(); try { ChartEditor widget = clz.newInstance(); - Chart chart = ChartTypeManager.getInstanceWithCheck().getChartTypes(this.chartID)[0]; - widget.addChart((Chart) chart.clone()); + widget.setChartCollection(BaseChartGetter.createChartCollection(this.chartID)); return widget; } catch (InstantiationException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } catch (IllegalAccessException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java index a27d2387a1..83d471068d 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/active/action/ChartComponentAction.java @@ -1,11 +1,9 @@ package com.fr.design.chart.gui.active.action; -import com.fr.base.chart.BaseChart; -import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartglyph.AxisGlyph; -import com.fr.design.chart.gui.ChartComponent; import com.fr.design.actions.UpdateAction; +import com.fr.design.chart.gui.ChartComponent; /** * Created by IntelliJ IDEA. @@ -29,18 +27,10 @@ public abstract class ChartComponentAction extends UpdateAction { chartComponent.repaint(); } - public BaseChart getEditingChart() { - return chartComponent.getEditingChart(); - } - public ChartCollection getChartCollection() { return chartComponent.getChartCollection(); } - public Axis getActiveAxis() { - return chartComponent.getActiveAxis(); - } - public AxisGlyph getActiveAxisGlyph() { return chartComponent.getActiveAxisGlyph(); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java index c3db9b7ef3..7083da6818 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java @@ -1,11 +1,11 @@ package com.fr.design.chart.series.SeriesCondition.impl; -import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.chart.web.ChartHyperPoplink; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.hyperlink.AbstractHyperLinkPane; @@ -66,10 +66,10 @@ public class ChartHyperPoplinkPane extends AbstractHyperLinkPane extends ChartDataPane { + + public AbstractChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + protected abstract void populate(T t); + + protected abstract T update(); + + @Override + public void populate(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + + this.removeAll(); + this.add(createContentPane(), BorderLayout.CENTER); + + ChartDataDefinitionProvider dataSetCollection = chart.getChartDataDefinition(); + + populate((T) dataSetCollection); + + this.initAllListeners(); + this.validate(); + } + + + @Override + public void update(ChartCollection collection) { + if (collection == null) { + return; + } + VanChart chart = collection.getSelectedChart(VanChart.class); + if (chart == null) { + return; + } + + chart.setChartDataDefinition(update()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java new file mode 100644 index 0000000000..e418e0c300 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/GanttChartDataPane.java @@ -0,0 +1,39 @@ +package com.fr.design.chartx; + +import com.fr.chartx.data.GanttChartDataDefinition; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.van.chart.map.designer.VanChartGroupPane; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/5/22. + */ +public class GanttChartDataPane extends AbstractChartDataPane { + + private MultiCategoryChartDataPane dataPane; + private MultiCategoryChartDataPane linkPane; + + @Override + protected JPanel createContentPane() { + dataPane = new MultiCategoryChartDataPane(listener); + linkPane = new MultiCategoryChartDataPane(listener); + return new VanChartGroupPane(new String[]{"data", "link"}, new JPanel[]{dataPane, linkPane}) { + }; + } + + public GanttChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected void populate(GanttChartDataDefinition ganttChartDataDefinition) { + dataPane.populate(ganttChartDataDefinition.getDataDefinition()); + linkPane.populate(ganttChartDataDefinition.getLinkDefinition()); + } + + @Override + protected GanttChartDataDefinition update() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java new file mode 100644 index 0000000000..721fc8480e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/MultiCategoryChartDataPane.java @@ -0,0 +1,43 @@ +package com.fr.design.chartx; + +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.design.chartx.fields.diff.MultiCategoryCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiCategoryDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/5/22. + */ +public class MultiCategoryChartDataPane extends AbstractChartDataPane { + + private SingleDataPane singleDataPane; + + public MultiCategoryChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected void populate(AbstractDataDefinition dataDefinition) { + singleDataPane.populateBean(dataDefinition); + } + + @Override + protected AbstractDataDefinition update() { + return singleDataPane.updateBean(); + } + + @Override + protected JPanel createContentPane() { + singleDataPane = createSingleDataPane(); + return singleDataPane; + } + + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiCategoryDataSetFieldsPane(), new MultiCategoryCellDataFieldsPane()); + } + + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java new file mode 100644 index 0000000000..952bca3cdc --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/MultiPieChartDataPane.java @@ -0,0 +1,21 @@ +package com.fr.design.chartx; + +import com.fr.design.chartx.fields.diff.MultiPieCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.MultiPieDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieChartDataPane extends MultiCategoryChartDataPane { + + public MultiPieChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new MultiPieDataSetFieldsPane(), new MultiPieCellDataFieldsPane()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java new file mode 100644 index 0000000000..6773081527 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/WordCloudChartDataPane.java @@ -0,0 +1,20 @@ +package com.fr.design.chartx; + +import com.fr.design.chartx.fields.diff.WordCloudCellDataFieldsPane; +import com.fr.design.chartx.fields.diff.WordCloudDataSetFieldsPane; +import com.fr.design.chartx.single.SingleDataPane; +import com.fr.design.gui.frpane.AttributeChangeListener; + +/** + * Created by shine on 2019/5/22. + */ +public class WordCloudChartDataPane extends MultiCategoryChartDataPane { + public WordCloudChartDataPane(AttributeChangeListener listener) { + super(listener); + } + + @Override + protected SingleDataPane createSingleDataPane() { + return new SingleDataPane(new WordCloudDataSetFieldsPane(), new WordCloudCellDataFieldsPane()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java new file mode 100644 index 0000000000..443fea07a7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -0,0 +1,252 @@ +package com.fr.design.chartx.component; + +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; +import com.fr.design.chartx.component.correlation.CalculateComboBoxEditorComponent; +import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; +import com.fr.design.chartx.component.correlation.UIComboBoxEditorComponent; +import com.fr.design.chartx.component.correlation.UITextFieldEditorComponent; +import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; +import com.fr.extended.chart.UIComboBoxWithNone; +import com.fr.general.GeneralUtils; +import com.fr.stable.StringUtils; + +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2018/9/12. + * 系列名使用字段名or字段值的抽象的pane 支持多种属性结构的存取 + */ +public abstract class AbstractCustomFieldComboBoxPane extends UIComboBoxPane { + + private AbstractUseFieldValuePane useFieldValuePane; + + private AbstractCustomFieldNamePane customFieldNamePane; + + private List fieldList = new ArrayList(); + + @Override + protected void initLayout() { + this.setLayout(new BorderLayout(0, 6)); + JPanel northPane = new JPanel(new BorderLayout()); + northPane.add(jcb, BorderLayout.CENTER); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20)); + northPane.add(label, BorderLayout.WEST); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + } + + @Override + protected List> initPaneList() { + useFieldValuePane = createUseFieldValuePane(); + customFieldNamePane = createCustomFieldNamePane(); + List> list = new ArrayList>(); + list.add(useFieldValuePane); + list.add(paneWrapper()); + return list; + } + + private FurtherBasicBeanPane paneWrapper() { + FurtherBasicBeanPane pane = new FurtherBasicBeanPane() { + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Name"); + } + + @Override + public boolean accept(Object ob) { + return false; + } + + @Override + public void reset() { + } + + @Override + public void populateBean(Object ob) { + } + + @Override + public Object updateBean() { + return null; + } + }; + pane.setLayout(new BorderLayout(0, 6)); + pane.add(customFieldNamePane, BorderLayout.CENTER); + return pane; + } + + protected abstract AbstractUseFieldValuePane createUseFieldValuePane(); + + protected abstract AbstractCustomFieldNamePane createCustomFieldNamePane(); + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + protected boolean valueComboBoxHasNone() { + return false; + } + + public void checkBoxUse(boolean hasUse) { + jcb.setEnabled(hasUse); + useFieldValuePane.checkBoxUse(hasUse); + } + + public void clearAllBoxList() { + useFieldValuePane.clearAllBoxList(); + fieldList.clear(); + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList); + fieldList = columnNameList; + } + + protected void populateCustomFieldNamePane(T t) { + customFieldNamePane.populateBean(t); + } + + protected void updateCustomFieldNamePane(T t) { + customFieldNamePane.updateBean(t); + } + + protected void populateUseFieldValuePane(T t) { + useFieldValuePane.populateBean(t); + } + + protected void updateUseFieldValuePane(T t) { + useFieldValuePane.updateBean(t); + } + + protected abstract class AbstractUseFieldValuePane extends FurtherBasicBeanPane { + private UIComboBox series; + private UIComboBox value; + private CalculateComboBox function; + + public AbstractUseFieldValuePane() { + initComponents(); + } + + private void initComponents() { + + series = new UIComboBox(); + value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox(); + + function = new CalculateComboBox(); + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), SwingConstants.LEFT), series}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), function}, + }; + + double p = TableLayout.PREFERRED; + double[] columnSize = {78, 122}; + double[] rowSize = {p, p, p}; + + JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + + this.setLayout(new BorderLayout(0, 6)); + this.add(panel, BorderLayout.CENTER); + } + + public void checkBoxUse(boolean hasUse) { + series.setEnabled(hasUse); + value.setEnabled(hasUse); + function.setEnabled(hasUse); + } + + public void clearAllBoxList() { + DataPaneHelper.clearBoxItems(series); + DataPaneHelper.clearBoxItems(value); + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + DataPaneHelper.refreshBoxItems(series, columnNameList); + DataPaneHelper.refreshBoxItems(value, columnNameList); + } + + protected void populateSeries(String item) { + series.setSelectedItem(item); + } + + protected void populateValue(String item) { + value.setSelectedItem(item); + } + + protected void populateFunction(AbstractDataFunction _function) { + function.populateBean(_function); + } + + protected String updateSeries() { + return GeneralUtils.objectToString(series.getSelectedItem()); + } + + protected String updateValue() { + return GeneralUtils.objectToString(value.getSelectedItem()); + } + + protected AbstractDataFunction updateFunction() { + return function.updateBean(); + } + + @Override + public boolean accept(Object ob) { + return true; + } + + @Override + public void reset() { + } + + @Override + public String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value"); + } + + @Override + public T updateBean() { + return null; + } + } + + protected abstract class AbstractCustomFieldNamePane extends AbstractCorrelationPane { + + @Override + protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { + return new FieldEditorComponentWrapper[]{ + new UIComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Field_Name")) { + @Override + protected List items() { + return fieldList; + } + }, + new UITextFieldEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), + new CalculateComboBoxEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Summary_Method")) + }; + } + + @Override + protected Object[] createLine() { + return new String[]{StringUtils.EMPTY, StringUtils.EMPTY, Toolkit.i18nText("Fine-Design_Chart_Use_None")}; + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java new file mode 100644 index 0000000000..2a8154d7bb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPane.java @@ -0,0 +1,168 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.general.IOUtils; + +import javax.swing.BoxLayout; +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + + +/** + * Created by shine on 2019/4/10. + * 一列组件 可增可删,通过JComponent后面的加减button增删。 + */ +public abstract class AbstractMultiComponentPane extends JPanel { + private static final int COM_W = 96; + private static final int H = 20; + private static final int ICON_W = 20; + + private JPanel boxPane; + private UIButton addButton; + + private T firstFieldComponent; + + private List categoryComponentList = new ArrayList(); + + + protected abstract T createFirstFieldComponent(); + + protected abstract T createOtherFieldComponent(); + + protected abstract void populateField(T component, ColumnField field); + + protected abstract void updateField(T component, ColumnField field); + + public AbstractMultiComponentPane() { + + UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Category")); + label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + + firstFieldComponent = createFirstFieldComponent(); + firstFieldComponent.setPreferredSize(new Dimension(COM_W, H)); + + addButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + addButton.setPreferredSize(new Dimension(ICON_W, H)); + addButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (canAdd()) { + addNewComboBox(); + } + } + }); + + final JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + + panel.add(label); + panel.add(firstFieldComponent); + panel.add(addButton); + + boxPane = new JPanel(); + boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); + + this.setLayout(new BorderLayout(4, 0)); + this.add(panel, BorderLayout.NORTH); + this.add(boxPane, BorderLayout.CENTER); + } + + private JPanel addComboBoxAndButtonToBox(T uiComboBox, UIButton uiButton) { + final JPanel panel = new JPanel(); + panel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + + panel.add(uiComboBox); + panel.add(uiButton); + + boxPane.add(panel); + categoryComponentList.add(uiComboBox); + + return panel; + } + + private void addNewComboBox() { + final T comboBox = createOtherFieldComponent(); + comboBox.setPreferredSize(new Dimension(COM_W, H)); + + UIButton delButton = new UIButton(IOUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); + delButton.setPreferredSize(new Dimension(ICON_W, H)); + + final JPanel panel = addComboBoxAndButtonToBox(comboBox, delButton); + + delButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boxPane.remove(panel); + categoryComponentList.remove(comboBox); + checkAddButton(); + relayoutPane(); + } + }); + + relayoutPane(); + checkAddButton(); + } + + private void relayoutPane() { + this.revalidate(); + } + + private void checkAddButton() { + addButton.setEnabled(canAdd()); + } + + private boolean canAdd() { + return categoryComponentList.size() < 3; + } + + public List componentList() { + List list = new ArrayList<>(categoryComponentList); + list.add(firstFieldComponent); + return list; + } + + public void populate(List categoryList) { + int comboBoxSize = categoryComponentList.size(), + len = categoryList.size(); + + if (len > 0) { + populateField(firstFieldComponent, categoryList.get(0)); + } + + for (int i = 1; i < len; i++) { + if (i > comboBoxSize) { + addNewComboBox(); + } + T comboBox = categoryComponentList.get(i - 1); + populateField(comboBox, categoryList.get(i)); + } + + checkAddButton(); + relayoutPane(); + } + + public void update(List categoryList) { + categoryList.clear(); + + ColumnField temp1 = new ColumnField(); + categoryList.add(temp1); + updateField(firstFieldComponent, temp1); + + for (T comboBox : categoryComponentList) { + ColumnField temp = new ColumnField(); + categoryList.add(temp); + updateField(comboBox, temp); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java new file mode 100644 index 0000000000..b24743c762 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractMultiComponentPaneWithUISpinner.java @@ -0,0 +1,150 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + * 一列组件 可增可删,通过UISpinner增删。 + */ +public abstract class AbstractMultiComponentPaneWithUISpinner extends JPanel { + + private UISpinner levelNumSpinner; + + private List levelComponentList = new ArrayList(); + + private JPanel levelPane; + + private int currentNum = 3; + + public AbstractMultiComponentPaneWithUISpinner() { + initComps(); + } + + public List getComponentList() { + return levelComponentList; + } + + protected abstract T createJComponent(); + + protected abstract void populateField(T component, ColumnField field); + + protected abstract void updateField(T component, ColumnField field); + + protected void initComps() { + + this.setLayout(new BorderLayout(0, 6)); + + levelNumSpinner = new UISpinner(1, 15, 1, currentNum) { + @Override + protected void fireStateChanged() { + //先处理自身的空间布局 + refreshLevelPane(); + //然后更新数据 + super.fireStateChanged(); + } + + @Override + public void setTextFieldValue(double value) { + //如果为0,则没有改变值 + if (value == 0) { + return; + } + super.setTextFieldValue(value); + } + }; + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level_Number")), levelNumSpinner}, + }; + + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, new double[]{TableLayout.PREFERRED}, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); + + this.add(northPane, BorderLayout.NORTH); + + initLevelPane(); + } + + private void initLevelPane() { + double[] rows = new double[currentNum]; + + Component[][] components = new Component[currentNum][2]; + + List newList = new ArrayList(); + + int maxSize = levelComponentList.size(); + for (int i = 0; i < currentNum; i++) { + rows[i] = TableLayout.PREFERRED; + T component = i < maxSize ? levelComponentList.get(i) : createJComponent(); + newList.add(component); + + components[i] = new Component[]{ + new UILabel(Toolkit.i18nText("Fine-Design_Chart_Level") + String.valueOf(i + 1)), + component + }; + } + + levelComponentList = newList; + + levelPane = TableLayoutHelper.createGapTableLayoutPane(components, rows, new double[]{ChartDataPane.LABEL_WIDTH, 122}, 0, 6); + + this.add(levelPane, BorderLayout.CENTER); + } + + private void refreshLevelPane() { + if (levelNumSpinner == null) { + return; + } + + int newNum = (int) levelNumSpinner.getValue(); + + if (newNum != currentNum) { + currentNum = newNum; + this.remove(levelPane); + this.initLevelPane(); + } + + refreshPane(); + } + + private void refreshPane() { + this.validate(); + this.repaint(); + this.revalidate(); + } + + public void populate(List categoryList) { + int len = categoryList.size(); + levelNumSpinner.setValue(len); + + refreshLevelPane(); + + for (int i = 0; i < len; i++) { + ColumnField columnField = categoryList.get(i); + T component = levelComponentList.get(i); + populateField(component, columnField); + } + } + + public void update(List categoryList) { + categoryList.clear(); + + for (T comboBox : levelComponentList) { + ColumnField temp = new ColumnField(); + categoryList.add(temp); + updateField(comboBox, temp); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java new file mode 100644 index 0000000000..7c494aac1e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractSingleFilterPane.java @@ -0,0 +1,171 @@ +package com.fr.design.chartx.component; + +import com.fr.base.Utils; +import com.fr.chartx.data.field.DataFilterProperties; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.TableLayout; +import com.fr.design.mainframe.chart.gui.data.PresentComboBox; +import com.fr.design.mainframe.chart.gui.style.AbstractChartTabPane; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; + +/** + * Created by shine on 2019/07/18. + */ +public abstract class AbstractSingleFilterPane extends AbstractChartTabPane { + + private static final int FIL_HEIGHT = 150; + + private UICheckBox useTopCheckBox; + + private UITextField topNumTextField; + private UICheckBox hideNullCheckBox; + private UICheckBox mergeOtherCheckBox; + + private PresentComboBox present; + + private AbstractAttrNoScrollPane parent; + + private JPanel topPane; + + public AbstractSingleFilterPane() { + super(true); + //todo@shinerefactor present的时候这边可以整理下 + // this.parent = parent; + } + + @Override + public Dimension getPreferredSize() { + Dimension dim = super.getPreferredSize(); + dim.height = FIL_HEIGHT; + return dim; + } + + + protected void layoutContentPane() { + super.layoutContentPane(); + leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); + } + + public void reloaPane(JPanel pane) { + super.reloaPane(pane); + leftcontentPane.setBorder(BorderFactory.createEmptyBorder()); + } + + @Override + protected JPanel createContentPane() { + this.setLayout(new BorderLayout()); + JPanel pane = initPane(); + this.add(pane, BorderLayout.NORTH); + return pane; + } + + + private JPanel initPane() { + useTopCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Only_Use_Before_Records")); + JPanel panel1 = new JPanel(new BorderLayout()); + JPanel panel2 = new JPanel(new BorderLayout()); + panel1.add(useTopCheckBox, BorderLayout.NORTH); + topNumTextField = new UITextField(); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Records_Num")); + mergeOtherCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_CombineOther")); + mergeOtherCheckBox.setSelected(true); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + Component[][] components = new Component[][]{ + new Component[]{label, topNumTextField}, + new Component[]{mergeOtherCheckBox, null} + }; + + topPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + topPane.setBorder(BorderFactory.createEmptyBorder(10, 15, 0, 0)); + //默认不显示 + topPane.setVisible(false); + panel1.add(topPane, BorderLayout.CENTER); + hideNullCheckBox = new UICheckBox(title4PopupWindow() + " is null, hidden"); + panel2.add(hideNullCheckBox, BorderLayout.NORTH); + + useTopCheckBox.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + checkBoxUse(); + } + }); + + present = new PresentComboBox() { + protected void fireChange() { + fire(); + } + }; + JPanel presentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Present"), present); + panel2.add(presentPane, BorderLayout.SOUTH); + + double[] column = {f}; + double[] row = {p, p}; + Component[][] coms = new Component[][]{ + new Component[]{panel1}, + new Component[]{panel2} + }; + return TableLayout4VanChartHelper.createGapTableLayoutPane(coms, row, column); + } + + + private void fire() { + if (this.parent != null) { + parent.attributeChanged(); + } + } + + /** + * 检查Box是否可用 + */ + public void checkBoxUse() { + topPane.setVisible(useTopCheckBox.isSelected()); + } + + @Override + public void populateBean(DataFilterProperties ob) { + useTopCheckBox.setSelected(ob.isUseTop()); + + topNumTextField.setText(String.valueOf(ob.getTop())); + + hideNullCheckBox.setSelected(ob.isHideNull()); + + mergeOtherCheckBox.setSelected(ob.isMerge()); + + present.populate(ob.getPresent()); + + checkBoxUse(); + } + + @Override + public DataFilterProperties updateBean() { + DataFilterProperties dataFilterProperties = new DataFilterProperties(); + + dataFilterProperties.setUseTop(useTopCheckBox.isSelected()); + + Number number = Utils.objectToNumber(topNumTextField.getText(), true); + if (number != null) { + dataFilterProperties.setTop(number.intValue()); + } + dataFilterProperties.setHideNull(hideNullCheckBox.isSelected()); + + dataFilterProperties.setMerge(mergeOtherCheckBox.isSelected()); + + dataFilterProperties.setPresent(present.update()); + + return dataFilterProperties; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java new file mode 100644 index 0000000000..fe6d7db76c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/CellDataSeriesValueCorrelationPane.java @@ -0,0 +1,56 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.SeriesValueField; +import com.fr.design.chartx.component.correlation.AbstractCorrelationPane; +import com.fr.design.chartx.component.correlation.FieldEditorComponentWrapper; +import com.fr.design.chartx.component.correlation.TinyFormulaPaneEditorComponent; +import com.fr.design.i18n.Toolkit; +import com.fr.general.GeneralUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/4. + */ +public class CellDataSeriesValueCorrelationPane extends AbstractCorrelationPane { + + @Override + protected FieldEditorComponentWrapper[] createFieldEditorComponentWrappers() { + return new FieldEditorComponentWrapper[]{ + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Name")), + new TinyFormulaPaneEditorComponent(Toolkit.i18nText("Fine-Design_Chart_Series_Value")) + }; + } + + @Override + protected List covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { + List result = new ArrayList(); + + List seriesValueFieldList = seriesValueCorrelationDefinition.getSeriesValueFieldList(); + for (SeriesValueField seriesValueField : seriesValueFieldList) { + Object[] array = new Object[]{seriesValueField.getSeries().getFieldName(), seriesValueField.getValue().getFieldName()}; + result.add(array); + } + + return result; + } + + @Override + protected void setTableModelListToTBean(List tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { + List seriesValueFieldList = new ArrayList(); + + for (Object[] oneLine : tableValues) { + SeriesValueField seriesValueField = new SeriesValueField(); + ColumnField series = new ColumnField(GeneralUtils.objectToString(oneLine[0])); + ColumnField value = new ColumnField(GeneralUtils.objectToString(oneLine[1])); + seriesValueField.setSeries(series); + seriesValueField.setValue(value); + seriesValueFieldList.add(seriesValueField); + } + + seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFieldList); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java new file mode 100644 index 0000000000..f1716a0ae0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPane.java @@ -0,0 +1,40 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.extended.chart.UIComboBoxWithNone; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/4/12. + */ +public class MultiComboBoxPane extends AbstractMultiComponentPane { + private List currentBoxItems = new ArrayList(); + + public void setCurrentBoxItems(List currentBoxItems) { + this.currentBoxItems = currentBoxItems; + } + + @Override + protected UIComboBox createFirstFieldComponent() { + return new UIComboBoxWithNone(); + } + + @Override + protected UIComboBox createOtherFieldComponent() { + return new UIComboBox(currentBoxItems.toArray(new Object[currentBoxItems.size()])); + } + + @Override + protected void populateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.updateField(component, field); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java new file mode 100644 index 0000000000..8b20768e2d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiComboBoxPaneWithUISpinner.java @@ -0,0 +1,40 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiComboBoxPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner { + private List currentBoxList = new ArrayList(); + + @Override + protected void initComps() { + currentBoxList = new ArrayList(); + super.initComps(); + } + + public void setCurrentBoxList(List currentBoxList) { + this.currentBoxList = currentBoxList; + } + + @Override + protected UIComboBox createJComponent() { + return new UIComboBox(currentBoxList.toArray(new Object[currentBoxList.size()])); + } + + @Override + protected void populateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(UIComboBox component, ColumnField field) { + AbstractDataSetFieldsPane.updateField(component, field); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java new file mode 100644 index 0000000000..5e56b967c4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPane.java @@ -0,0 +1,31 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; + +/** + * Created by shine on 2019/4/12. + */ +public class MultiTinyFormulaPane extends AbstractMultiComponentPane { + @Override + protected TinyFormulaPane createFirstFieldComponent() { + return new TinyFormulaPane(); + } + + @Override + protected TinyFormulaPane createOtherFieldComponent() { + return new TinyFormulaPane(); + } + + @Override + protected void populateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.updateField(component, field); + + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java new file mode 100644 index 0000000000..e3bbf4b848 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MultiTinyFormulaPaneWithUISpinner.java @@ -0,0 +1,25 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; + +/** + * Created by shine on 2019/6/19. + */ +public class MultiTinyFormulaPaneWithUISpinner extends AbstractMultiComponentPaneWithUISpinner { + @Override + protected TinyFormulaPane createJComponent() { + return new TinyFormulaPane(); + } + + @Override + protected void populateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.populateField(component, field); + } + + @Override + protected void updateField(TinyFormulaPane component, ColumnField field) { + AbstractCellDataFieldsPane.updateField(component, field); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java new file mode 100644 index 0000000000..4372cf0db1 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/SeriesValueFieldComboBoxPane.java @@ -0,0 +1,107 @@ +package com.fr.design.chartx.component; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.SeriesValueField; +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; +import com.fr.general.GeneralUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/5/17. + */ +public class SeriesValueFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { + + @Override + protected AbstractUseFieldValuePane createUseFieldValuePane() { + return new UseFieldValuePane(); + } + + @Override + protected AbstractCustomFieldNamePane createCustomFieldNamePane() { + return new CustomFieldNamePane(); + } + + @Override + public void populateBean(SeriesValueCorrelationDefinition ob) { + if (ob.isCustomFieldValue()) { + populateCustomFieldNamePane(ob); + jcb.setSelectedIndex(1); + } else { + populateUseFieldValuePane(ob); + jcb.setSelectedIndex(0); + } + } + + @Override + public void updateBean(SeriesValueCorrelationDefinition ob) { + if (jcb.getSelectedIndex() == 0) { + ob.setCustomFieldValue(false); + updateUseFieldValuePane(ob); + } else { + ob.setCustomFieldValue(true); + updateCustomFieldNamePane(ob); + } + } + + private class UseFieldValuePane extends AbstractUseFieldValuePane { + + @Override + public void populateBean(SeriesValueCorrelationDefinition ob) { + List list = ob.getSeriesValueFieldList(); + if (list != null && list.size() > 0) { + populateSeries(list.get(0).getSeries().getFieldName()); + populateValue(list.get(0).getValue().getFieldName()); + populateFunction((AbstractDataFunction) list.get(0).getValue().getDataFunction()); + } + } + + @Override + public void updateBean(SeriesValueCorrelationDefinition ob) { + List list = new ArrayList(); + SeriesValueField seriesValueField = new SeriesValueField(); + ColumnField series = new ColumnField(updateSeries()); + ColumnField value = new ColumnField(updateValue()); + value.setDataFunction(updateFunction()); + seriesValueField.setValue(value); + seriesValueField.setSeries(series); + list.add(seriesValueField); + ob.setSeriesValueFieldList(list); + } + } + + private class CustomFieldNamePane extends AbstractCustomFieldNamePane { + @Override + protected List covertTBeanToTableModelList(SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { + List list = new ArrayList(); + for (SeriesValueField seriesValueField : seriesValueCorrelationDefinition.getSeriesValueFieldList()) { + Object[] array = new Object[]{ + seriesValueField.getValue().getFieldName(), + seriesValueField.getSeries().getFieldName(), + DataPaneHelper.getFunctionString(seriesValueField.getValue().getDataFunction()) + }; + list.add(array); + } + return list; + } + + @Override + protected void setTableModelListToTBean(List tableValues, SeriesValueCorrelationDefinition seriesValueCorrelationDefinition) { + List seriesValueFields = new ArrayList(); + for (Object[] line : tableValues) { + ColumnField value = new ColumnField(GeneralUtils.objectToString(line[0])); + ColumnField series = new ColumnField(GeneralUtils.objectToString(line[1])); + value.setDataFunction(DataPaneHelper.getFunctionByName(GeneralUtils.objectToString(line[2]))); + SeriesValueField seriesValueField = new SeriesValueField(); + seriesValueField.setValue(value); + seriesValueField.setSeries(series); + seriesValueFields.add(seriesValueField); + } + seriesValueCorrelationDefinition.setSeriesValueFieldList(seriesValueFields); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java new file mode 100644 index 0000000000..5c468c424a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractCorrelationPane.java @@ -0,0 +1,130 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.gui.itable.UITable; +import com.fr.design.gui.itable.UITableEditor; +import com.fr.stable.StringUtils; + +import javax.swing.JTable; +import javax.swing.event.ChangeEvent; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +/** + * Created by shine on 2019/6/4. + * 自定义editorComponent + 支持多种数据格式 + */ +public abstract class AbstractCorrelationPane extends BasicBeanPane { + private FieldEditorComponentWrapper[] editorComponents; + + private UICorrelationPane correlationPane; + + public AbstractCorrelationPane() { + + this.editorComponents = createFieldEditorComponentWrappers(); + + String[] headers = new String[editorComponents.length]; + + for (int i = 0, len = editorComponents.length; i < len; i++) { + headers[i] = editorComponents[i].headerName(); + } + + initComps(headers); + } + + protected abstract FieldEditorComponentWrapper[] createFieldEditorComponentWrappers(); + + @Override + public void populateBean(T ob) { + correlationPane.populateBean(covertTBeanToTableModelList(ob)); + } + + @Override + public void updateBean(T ob) { + setTableModelListToTBean(correlationPane.updateBean(), ob); + } + + @Override + public T updateBean() { + return null; + } + + protected abstract List covertTBeanToTableModelList(T t); + + protected abstract void setTableModelListToTBean(List tableValues, T t); + + private void initComps(String[] headers) { + correlationPane = new UICorrelationPane(headers) { + public UITableEditor createUITableEditor() { + return new Editor(); + } + + protected UITable initUITable() { + return new UITable(columnCount) { + + public UITableEditor createTableEditor() { + return createUITableEditor(); + } + + public void tableCellEditingStopped(ChangeEvent e) { + stopPaneEditing(e); + } + }; + } + + protected ActionListener getAddButtonListener() { + return new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + tablePane.addLine(createLine()); + fireTargetChanged(); + } + }; + } + }; + + this.setLayout(new BorderLayout()); + this.add(correlationPane, BorderLayout.CENTER); + } + + protected Object[] createLine() { + return new Object[this.editorComponents.length]; + } + + + private class Editor extends UITableEditor { + + private Component currentComponent; + private FieldEditorComponentWrapper currentEditorWrapper; + + public Object getCellEditorValue() { + return currentEditorWrapper.getValue(currentComponent); + } + + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (column == table.getModel().getColumnCount()) { + return null; + } + + correlationPane.stopCellEditing(); + + currentEditorWrapper = AbstractCorrelationPane.this.editorComponents[column]; + + currentComponent = currentEditorWrapper.getTableCellEditorComponent(correlationPane, table, isSelected, row, column); + currentEditorWrapper.setValue(currentComponent, value); + + return currentComponent; + } + + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java new file mode 100644 index 0000000000..d906058309 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/AbstractEditorComponent.java @@ -0,0 +1,19 @@ +package com.fr.design.chartx.component.correlation; + +import java.awt.Component; + +/** + * Created by shine on 2019/6/10. + */ +public abstract class AbstractEditorComponent implements FieldEditorComponentWrapper { + private String header; + + public AbstractEditorComponent(String header) { + this.header = header; + } + + @Override + public String headerName() { + return this.header; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java new file mode 100644 index 0000000000..9b14fdf4d7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/CalculateComboBoxEditorComponent.java @@ -0,0 +1,45 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; + +import javax.swing.JTable; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +/** + * Created by shine on 2019/6/10. + */ +public class CalculateComboBoxEditorComponent extends AbstractEditorComponent { + + public CalculateComboBoxEditorComponent(String header) { + super(header); + } + + @Override + public CalculateComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { + + CalculateComboBox calculateComboBox = new CalculateComboBox(); + + calculateComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + parent.stopCellEditing(); + parent.fireTargetChanged(); + } + }); + return calculateComboBox; + } + + @Override + public Object getValue(CalculateComboBox calculateComboBox) { + return calculateComboBox.getSelectedItem(); + } + + @Override + public void setValue(CalculateComboBox calculateComboBox, Object o) { + + if (o != null) { + calculateComboBox.setSelectedItem(o); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java new file mode 100644 index 0000000000..af934c3256 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/FieldEditorComponentWrapper.java @@ -0,0 +1,20 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.design.gui.frpane.UICorrelationPane; + +import javax.swing.JTable; +import java.awt.Component; + +/** + * Created by shine on 2019/6/4. + */ +public interface FieldEditorComponentWrapper { + + String headerName(); + + T getTableCellEditorComponent(UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column); + + Object getValue(T t); + + void setValue(T t, Object o); +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java new file mode 100644 index 0000000000..7470ef62d2 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/TinyFormulaPaneEditorComponent.java @@ -0,0 +1,56 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.base.BaseFormula; +import com.fr.base.Utils; +import com.fr.design.constants.UIConstants; +import com.fr.design.event.UIObserverListener; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.frpane.UICorrelationPane; + +import javax.swing.JTable; + +/** + * Created by shine on 2019/6/4. + */ +public class TinyFormulaPaneEditorComponent extends AbstractEditorComponent { + + public TinyFormulaPaneEditorComponent(String header) { + super(header); + } + + @Override + public TinyFormulaPane getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) { + TinyFormulaPane editorComponent = new TinyFormulaPane() { + @Override + public void okEvent() { + parent.stopCellEditing(); + parent.fireTargetChanged(); + } + + @Override + protected void populateTextField(BaseFormula fm) { + formulaTextField.setText(fm.getContent()); + } + }; + editorComponent.setBackground(UIConstants.FLESH_BLUE); + + editorComponent.getUITextField().registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + parent.fireTargetChanged(); + } + }); + + return editorComponent; + } + + @Override + public Object getValue(TinyFormulaPane formulaPane) { + return formulaPane.getUITextField().getText(); + } + + @Override + public void setValue(TinyFormulaPane formulaPane, Object o) { + formulaPane.getUITextField().setText(Utils.objectToString(o)); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java new file mode 100644 index 0000000000..6dcf19fbaf --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UIComboBoxEditorComponent.java @@ -0,0 +1,55 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.itable.UITable; + +import javax.swing.JTable; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/6/10. + */ +public class UIComboBoxEditorComponent extends AbstractEditorComponent { + + public UIComboBoxEditorComponent(String header) { + super(header); + } + + protected List items() { + return new ArrayList(); + } + + @Override + public UIComboBox getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, final int row, int column) { + UIComboBox uiComboBox = new UIComboBox(items().toArray()); + + uiComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + parent.stopCellEditing(); + parent.fireTargetChanged(); + UITable table = parent.getTable(); + Object object = table.getValueAt(row, 0); + if (object != null) { + table.setValueAt(object, row, 1); + } + } + }); + + return uiComboBox; + } + + + @Override + public Object getValue(UIComboBox uiComboBox) { + return uiComboBox.getSelectedItem(); + } + + @Override + public void setValue(UIComboBox uiComboBox, Object o) { + uiComboBox.getModel().setSelectedItem(o); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java new file mode 100644 index 0000000000..142cfb12b7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/correlation/UITextFieldEditorComponent.java @@ -0,0 +1,41 @@ +package com.fr.design.chartx.component.correlation; + +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.frpane.UICorrelationPane; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.general.GeneralUtils; + +import javax.swing.JTable; + +/** + * Created by shine on 2019/6/10. + */ +public class UITextFieldEditorComponent extends AbstractEditorComponent { + public UITextFieldEditorComponent(String header) { + super(header); + } + + @Override + public UITextField getTableCellEditorComponent(final UICorrelationPane parent, JTable table, boolean isSelected, int row, int column) { + UITextField uiTextField = new UITextField(); + + uiTextField.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + parent.fireTargetChanged(); + } + }); + + return uiTextField; + } + + @Override + public Object getValue(UITextField uiTextField) { + return uiTextField.getText(); + } + + @Override + public void setValue(UITextField uiTextField, Object o) { + uiTextField.setText(GeneralUtils.objectToString(o)); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java new file mode 100644 index 0000000000..6b6408d937 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractCellDataFieldsPane.java @@ -0,0 +1,97 @@ +package com.fr.design.chartx.fields; + +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.ColumnField; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.Arrays; + +/** + * Created by shine on 2019/5/16. + * 单元格数据源 具体有哪些字段的一个抽象pane + */ +public abstract class AbstractCellDataFieldsPane extends BasicBeanPane { + + public AbstractCellDataFieldsPane() { + initComponents(); + } + + protected void initComponents() { + + this.setLayout(new BorderLayout(0, 6)); + + this.add(createNorthPane(), BorderLayout.NORTH); + this.add(createCenterPane(), BorderLayout.CENTER); + this.add(createSouthPane(), BorderLayout.SOUTH); + + this.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 8)); + } + + protected JPanel createCenterPane() { + String[] labels = fieldLabels(); + Component[] formulaPanes = fieldComponents(); + + int len = Math.min(labels.length, formulaPanes.length); + + if (len == 0) { + return null; + } + + Component[][] components = new Component[len][2]; + for (int i = 0; i < len; i++) { + components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), formulaPanes[i]}; + } + + + double p = TableLayout.PREFERRED; + double[] columnSize = {ChartDataPane.LABEL_WIDTH, 124}; + double[] rowSize = new double[len]; + Arrays.fill(rowSize, p); + + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); + } + + + protected JPanel createNorthPane() { + return new JPanel(); + } + + protected JPanel createSouthPane() { + return new JPanel(); + } + + protected Component[] fieldComponents() { + return formulaPanes(); + } + + protected abstract String[] fieldLabels(); + + protected abstract TinyFormulaPane[] formulaPanes(); + + @Override + public abstract T updateBean(); + + public static void populateField(TinyFormulaPane formulaPane, ColumnField field) { + formulaPane.populateBean(field.getFieldName()); + } + + public static void updateField(TinyFormulaPane formulaPane, ColumnField field) { + field.setFieldName(formulaPane.updateBean()); + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java new file mode 100644 index 0000000000..1b0efcd5c4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/AbstractDataSetFieldsPane.java @@ -0,0 +1,149 @@ +package com.fr.design.chartx.fields; + +import com.fr.chartx.data.field.AbstractColumnFieldCollection; +import com.fr.chartx.data.field.ColumnField; +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; +import com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper; +import com.fr.general.GeneralUtils; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.Arrays; +import java.util.List; + +import static com.fr.design.mainframe.chart.gui.data.table.DataPaneHelper.refreshBoxItems; + +/** + * Created by shine on 2019/5/16. + * 数据集数据源 具体有哪些字段的一个抽象pane + */ +public abstract class AbstractDataSetFieldsPane extends BasicBeanPane { + + public AbstractDataSetFieldsPane() { + initComponents(); + } + + protected void initComponents() { + + this.setLayout(new BorderLayout(0, 4)); + this.setBorder(BorderFactory.createEmptyBorder(2, 24, 0, 15)); + + JPanel north = createNorthPane(), + center = createCenterPane(), + south = createSouthPane(); + + if (north != null) { + this.add(north, BorderLayout.NORTH); + } + + if (center != null) { + this.add(center, BorderLayout.CENTER); + } + + if (south != null) { + this.add(south, BorderLayout.SOUTH); + } + } + + protected JPanel createNorthPane() { + return null; + } + + protected JPanel createCenterPane() { + String[] labels = fieldLabels(); + Component[] fieldComponents = fieldComponents(); + + int len = Math.min(labels.length, fieldComponents.length); + + if (len == 0) { + return null; + } + + Component[][] components = new Component[len][2]; + for (int i = 0; i < len; i++) { + components[i] = new Component[]{new UILabel(labels[i], SwingConstants.LEFT), fieldComponents[i]}; + } + + double p = TableLayout.PREFERRED; + double[] columnSize = {ChartDataPane.LABEL_WIDTH, 122}; + double[] rowSize = new double[len]; + Arrays.fill(rowSize, p); + + return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 6); + } + + protected JPanel createSouthPane() { + return null; + } + + protected Component[] fieldComponents() { + return filedComboBoxes(); + } + + protected abstract String[] fieldLabels(); + + protected abstract UIComboBox[] filedComboBoxes(); + + public void checkBoxUse(boolean hasUse) { + for (Component component : fieldComponents()) { + component.setEnabled(hasUse); + } + } + + public void clearAllBoxList() { + for (UIComboBox comboBox : filedComboBoxes()) { + DataPaneHelper.clearBoxItems(comboBox); + } + } + + public void refreshBoxListWithSelectTableData(List columnNameList) { + for (UIComboBox comboBox : filedComboBoxes()) { + refreshBoxItems(comboBox, columnNameList); + } + } + + @Override + public abstract T updateBean(); + + public static void populateField(UIComboBox comboBox, ColumnField field) { + populateFunctionField(comboBox, null, field); + } + + public static void updateField(UIComboBox comboBox, ColumnField field) { + updateFunctionField(comboBox, null, field); + } + + protected static void populateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { + comboBox.setSelectedItem(field.getFieldName()); + if (calculateComboBox != null) { + calculateComboBox.populateBean((AbstractDataFunction) field.getDataFunction()); + } + } + + protected static void updateFunctionField(UIComboBox comboBox, CalculateComboBox calculateComboBox, ColumnField field) { + field.setFieldName(GeneralUtils.objectToString(comboBox.getSelectedItem())); + if (calculateComboBox != null) { + field.setDataFunction(calculateComboBox.updateBean()); + } else { + field.setDataFunction(null); + } + } + + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java new file mode 100644 index 0000000000..dc0ce33ec3 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractCellDataFieldsWithSeriesValuePane.java @@ -0,0 +1,41 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.CellDataSeriesValueCorrelationPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * Created by shine on 2019/6/4. + */ +public abstract class AbstractCellDataFieldsWithSeriesValuePane + extends AbstractCellDataFieldsPane { + + private CellDataSeriesValueCorrelationPane seriesValueFieldsPane; + + @Override + protected JPanel createCenterPane() { + JPanel normalCenter = super.createCenterPane(); + seriesValueFieldsPane = new CellDataSeriesValueCorrelationPane(); + + if (normalCenter != null) { + JPanel panel = new JPanel(new BorderLayout()); + panel.add(normalCenter, BorderLayout.CENTER); + panel.add(seriesValueFieldsPane, BorderLayout.SOUTH); + return panel; + } else { + return seriesValueFieldsPane; + } + } + + protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { + seriesValueFieldsPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); + } + + protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { + seriesValueFieldsPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java new file mode 100644 index 0000000000..5e6100e2fb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/AbstractDataSetFieldsWithSeriesValuePane.java @@ -0,0 +1,60 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.AbstractColumnFieldCollectionWithSeriesValue; +import com.fr.design.chartx.component.SeriesValueFieldComboBoxPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.util.List; + +/** + * Created by shine on 2019/5/16. + * 带有 自定义系列名(fr表现为 系列名使用字段名) 的字段集合 的一个pane + */ +public abstract class AbstractDataSetFieldsWithSeriesValuePane + extends AbstractDataSetFieldsPane { + + private SeriesValueFieldComboBoxPane seriesValueFieldComboBoxPane; + + @Override + protected JPanel createCenterPane() { + JPanel normalCenter = super.createCenterPane(); + seriesValueFieldComboBoxPane = new SeriesValueFieldComboBoxPane(); + + if (normalCenter != null) { + JPanel panel = new JPanel(new BorderLayout()); + panel.add(normalCenter, BorderLayout.CENTER); + panel.add(seriesValueFieldComboBoxPane, BorderLayout.SOUTH); + return panel; + } else { + return seriesValueFieldComboBoxPane; + } + } + + @Override + public void checkBoxUse(boolean hasUse) { + super.checkBoxUse(hasUse); + seriesValueFieldComboBoxPane.checkBoxUse(hasUse); + } + + @Override + public void clearAllBoxList() { + super.clearAllBoxList(); + seriesValueFieldComboBoxPane.clearAllBoxList(); + } + + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + seriesValueFieldComboBoxPane.refreshBoxListWithSelectTableData(columnNameList); + } + + protected void populateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { + seriesValueFieldComboBoxPane.populateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); + } + + protected void updateSeriesValuePane(AbstractColumnFieldCollectionWithSeriesValue fieldCollectionWithSeriesValue) { + seriesValueFieldComboBoxPane.updateBean(fieldCollectionWithSeriesValue.getSeriesValueCorrelationDefinition()); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java new file mode 100644 index 0000000000..3645a08db7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryCellDataFieldsPane.java @@ -0,0 +1,115 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.component.MultiTinyFormulaPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.van.chart.map.designer.VanChartGroupPane; + +import javax.swing.JPanel; +import java.util.List; + +/** + * Created by shine on 2019/4/12. + */ +public class MultiCategoryCellDataFieldsPane extends AbstractCellDataFieldsWithSeriesValuePane { + + private MultiTinyFormulaPane multiCategoryPane; + + private AbstractSingleFilterPane seriesFilterPane; + private AbstractSingleFilterPane categoryFilterPane; + + private void createMultiFormulaPane() { + if (multiCategoryPane == null) { + multiCategoryPane = new MultiTinyFormulaPane(); + } + } + + @Override + protected JPanel createNorthPane() { + + createMultiFormulaPane(); + + return multiCategoryPane; + } + + @Override + protected JPanel createSouthPane() { + if (seriesFilterPane == null) { + seriesFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + //todo@shinerefactor + return "series"; + } + }; + categoryFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return "category"; + } + }; + } + return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} + , new JPanel[]{seriesFilterPane, categoryFilterPane}) { + }; + } + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + + createMultiFormulaPane(); + + List list = multiCategoryPane.componentList(); + return list.toArray(new TinyFormulaPane[list.size()]); + } + + @Override + public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { + + List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); + + multiCategoryPane.populate(categoryList); + + populateSeriesValuePane(multiCategoryColumnFieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); + } + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection fieldCollection = new MultiCategoryColumnFieldCollection(); + List categoryList = fieldCollection.getCategoryList(); + + multiCategoryPane.update(categoryList); + + updateSeriesValuePane(fieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = fieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); + } + + return fieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java new file mode 100644 index 0000000000..5b18d8ae83 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiCategoryDataSetFieldsPane.java @@ -0,0 +1,116 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.ColumnField; +import com.fr.chartx.data.field.SeriesValueCorrelationDefinition; +import com.fr.chartx.data.field.diff.MultiCategoryColumnFieldCollection; +import com.fr.design.chartx.component.AbstractSingleFilterPane; +import com.fr.design.chartx.component.MultiComboBoxPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.van.chart.map.designer.VanChartGroupPane; + +import javax.swing.JPanel; +import java.util.List; + + +/** + * Created by shine on 2019/4/10. + */ +public class MultiCategoryDataSetFieldsPane extends AbstractDataSetFieldsWithSeriesValuePane { + + private MultiComboBoxPane multiCategoryPane; + + private AbstractSingleFilterPane seriesFilterPane; + private AbstractSingleFilterPane categoryFilterPane; + + @Override + protected String[] fieldLabels() { + return new String[0]; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + List list = initMultiCategoryPane().componentList(); + return list.toArray(new UIComboBox[list.size()]); + } + + private MultiComboBoxPane initMultiCategoryPane() { + if (multiCategoryPane == null) { + multiCategoryPane = new MultiComboBoxPane(); + } + return multiCategoryPane; + } + + @Override + protected JPanel createNorthPane() { + return initMultiCategoryPane(); + } + + @Override + protected JPanel createSouthPane() { + if (seriesFilterPane == null) { + seriesFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + //todo@shinerefactor + return "series"; + } + }; + categoryFilterPane = new AbstractSingleFilterPane() { + @Override + public String title4PopupWindow() { + return "category"; + } + }; + } + return new VanChartGroupPane(new String[]{seriesFilterPane.title4PopupWindow(), categoryFilterPane.title4PopupWindow()} + , new JPanel[]{seriesFilterPane, categoryFilterPane}) { + }; + } + + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + multiCategoryPane.setCurrentBoxItems(columnNameList); + } + + @Override + public void populateBean(MultiCategoryColumnFieldCollection multiCategoryColumnFieldCollection) { + List categoryList = multiCategoryColumnFieldCollection.getCategoryList(); + + multiCategoryPane.populate(categoryList); + + populateSeriesValuePane(multiCategoryColumnFieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = multiCategoryColumnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesFilterPane.populateBean(seriesValueCorrelationDefinition.getFilterProperties()); + + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryFilterPane.populateBean(categoryList.get(0).getFilterProperties()); + } + } + + @Override + public MultiCategoryColumnFieldCollection updateBean() { + + MultiCategoryColumnFieldCollection columnFieldCollection = new MultiCategoryColumnFieldCollection(); + List categoryList = columnFieldCollection.getCategoryList(); + + multiCategoryPane.update(categoryList); + + updateSeriesValuePane(columnFieldCollection); + + SeriesValueCorrelationDefinition seriesValueCorrelationDefinition = columnFieldCollection.getSeriesValueCorrelationDefinition(); + if (seriesValueCorrelationDefinition != null) { + seriesValueCorrelationDefinition.setFilterProperties(seriesFilterPane.updateBean()); + } + + if (categoryList != null && !categoryList.isEmpty()) { + categoryList.get(0).setFilterProperties(categoryFilterPane.updateBean()); + } + + return columnFieldCollection; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java new file mode 100644 index 0000000000..950f49401a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieCellDataFieldsPane.java @@ -0,0 +1,67 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; +import com.fr.design.chartx.component.MultiTinyFormulaPaneWithUISpinner; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; + +import javax.swing.JPanel; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private UITextField nameField;//指标名称 + + private MultiTinyFormulaPaneWithUISpinner levelPane; + + private TinyFormulaPane value; + + @Override + protected void initComponents() { + nameField = new UITextField(); + levelPane = new MultiTinyFormulaPaneWithUISpinner(); + value = new TinyFormulaPane(); + super.initComponents(); + } + + @Override + protected JPanel createNorthPane() { + return levelPane; + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + value + }; + } + + @Override + public void populateBean(MultiPieColumnFieldCollection ob) { + nameField.setText(ob.getTargetName()); + levelPane.populate(ob.getLevels()); + populateField(value, ob.getValue()); + } + + @Override + public MultiPieColumnFieldCollection updateBean() { + MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); + + result.setTargetName(nameField.getText()); + levelPane.update(result.getLevels()); + updateField(value, result.getValue()); + + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java new file mode 100644 index 0000000000..2a299ba6e9 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MultiPieDataSetFieldsPane.java @@ -0,0 +1,94 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.MultiPieColumnFieldCollection; +import com.fr.design.chartx.component.MultiComboBoxPaneWithUISpinner; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; + +import javax.swing.JPanel; +import java.awt.Component; +import java.util.List; + +/** + * Created by shine on 2019/6/18. + */ +public class MultiPieDataSetFieldsPane extends AbstractDataSetFieldsPane { + private UITextField nameField; + + private MultiComboBoxPaneWithUISpinner levelComboBoxPane; + + private UIComboBox value; + + private CalculateComboBox function; + + @Override + protected void initComponents() { + nameField = new UITextField(); + levelComboBoxPane = new MultiComboBoxPaneWithUISpinner(); + value = new UIComboBox(); + function = new CalculateComboBox(); + super.initComponents(); + } + + @Override + protected JPanel createNorthPane() { + return levelComboBoxPane; + } + + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + Toolkit.i18nText("Fine-Design_Chart_Summary_Method") + }; + } + + @Override + protected Component[] fieldComponents() { + return new UIComboBox[]{ + value, + function + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + List list = levelComboBoxPane.getComponentList(); + + int len = list.size(); + UIComboBox[] result = new UIComboBox[len + 1]; + for (int i = 0; i < len; i++) { + result[i] = list.get(i); + } + result[len] = value; + + return result; + } + + @Override + public void refreshBoxListWithSelectTableData(List columnNameList) { + super.refreshBoxListWithSelectTableData(columnNameList); + levelComboBoxPane.setCurrentBoxList(columnNameList); + } + + @Override + public void populateBean(MultiPieColumnFieldCollection ob) { + levelComboBoxPane.populate(ob.getLevels()); + populateFunctionField(value, function, ob.getValue()); + } + + @Override + public MultiPieColumnFieldCollection updateBean() { + MultiPieColumnFieldCollection result = new MultiPieColumnFieldCollection(); + + levelComboBoxPane.update(result.getLevels()); + + updateFunctionField(value, function, result.getValue()); + + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java new file mode 100644 index 0000000000..46af0112ce --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudCellDataFieldsPane.java @@ -0,0 +1,70 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.formula.TinyFormulaPane; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; + +import java.awt.Component; + +/** + * Created by shine on 2019/6/18. + */ +public class WordCloudCellDataFieldsPane extends AbstractCellDataFieldsPane { + + private UITextField name; + private TinyFormulaPane wordName; + private TinyFormulaPane wordValue; + + @Override + protected void initComponents() { + name = new UITextField(); + wordName = new TinyFormulaPane(); + wordValue = new TinyFormulaPane(); + + super.initComponents(); + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Value") + }; + } + + @Override + protected TinyFormulaPane[] formulaPanes() { + return new TinyFormulaPane[]{ + wordName, + wordValue + }; + } + + @Override + protected Component[] fieldComponents() { + return new Component[]{ + name, + wordName, + wordValue + }; + } + + @Override + public void populateBean(WordCloudColumnFieldCollection ob) { + name.setText(ob.getTargetName()); + populateField(wordName, ob.getWordName()); + populateField(wordValue, ob.getWordValue()); + } + + @Override + public WordCloudColumnFieldCollection updateBean() { + WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection(); + result.setTargetName(name.getText()); + updateField(wordName, result.getWordName()); + populateField(wordValue, result.getWordValue()); + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java new file mode 100644 index 0000000000..77c529ea5a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/WordCloudDataSetFieldsPane.java @@ -0,0 +1,74 @@ +package com.fr.design.chartx.fields.diff; + +import com.fr.chartx.data.field.diff.WordCloudColumnFieldCollection; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; + +import java.awt.Component; + +/** + * Created by shine on 2019/6/18. + */ +public class WordCloudDataSetFieldsPane extends AbstractDataSetFieldsPane { + private UITextField name; + private UIComboBox wordName; + private UIComboBox wordValue; + private CalculateComboBox calculateCombox; + + @Override + protected void initComponents() { + name = new UITextField(); + wordName = new UIComboBox(); + wordValue = new UIComboBox(); + calculateCombox = new CalculateComboBox(); + + super.initComponents(); + } + + @Override + protected String[] fieldLabels() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Value"), + Toolkit.i18nText("Fine-Design_Chart_Summary_Method") + }; + } + + @Override + protected UIComboBox[] filedComboBoxes() { + return new UIComboBox[]{ + wordName, + wordValue + }; + } + + @Override + protected Component[] fieldComponents() { + return new Component[]{ + name, + wordName, + wordValue, + calculateCombox + }; + } + + @Override + public void populateBean(WordCloudColumnFieldCollection ob) { + name.setText(ob.getTargetName()); + populateField(wordName, ob.getWordName()); + populateFunctionField(wordValue, calculateCombox, ob.getWordValue()); + } + + @Override + public WordCloudColumnFieldCollection updateBean() { + WordCloudColumnFieldCollection result = new WordCloudColumnFieldCollection(); + result.setTargetName(name.getText()); + updateField(wordName, result.getWordName()); + updateFunctionField(wordValue, calculateCombox, result.getWordValue()); + return result; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java new file mode 100644 index 0000000000..f0a4ef0afd --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/CellDataPane.java @@ -0,0 +1,56 @@ +package com.fr.design.chartx.single; + +import com.fr.chartx.data.CellDataDefinition; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.i18n.Toolkit; + +import java.awt.BorderLayout; + +/** + * Created by shine on 2019/5/21. + */ +public class CellDataPane extends FurtherBasicBeanPane { + + private AbstractCellDataFieldsPane cellDataFieldsPane; + + public CellDataPane(AbstractCellDataFieldsPane cellDataFieldsPane) { + initComps(cellDataFieldsPane); + } + + private void initComps(AbstractCellDataFieldsPane cellDataFieldsPane) { + this.cellDataFieldsPane = cellDataFieldsPane; + + this.setLayout(new BorderLayout()); + this.add(cellDataFieldsPane, BorderLayout.CENTER); + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Cell_Data"); + } + + + @Override + public boolean accept(Object ob) { + return ob instanceof CellDataDefinition; + } + + @Override + public void reset() { + this.removeAll(); + } + + @Override + public void populateBean(CellDataDefinition ob) { + cellDataFieldsPane.populateBean(ob.getColumnFieldCollection()); + } + + @Override + public CellDataDefinition updateBean() { + CellDataDefinition cellDataDefinition = new CellDataDefinition(); + cellDataDefinition.setColumnFieldCollection(cellDataFieldsPane.updateBean()); + + return cellDataDefinition; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java new file mode 100644 index 0000000000..98394c31a0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/DataSetPane.java @@ -0,0 +1,121 @@ +package com.fr.design.chartx.single; + +import com.fr.chartx.data.DataSetDefinition; +import com.fr.data.impl.NameTableData; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; +import com.fr.design.utils.gui.UIComponentUtils; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.List; + +/** + * Created by shine on 2019/5/21. + */ +public class DataSetPane extends FurtherBasicBeanPane { + private static final int TABLE_DATA_LABEL_LINE_WRAP_WIDTH = 65; + private static final int TABLE_DATA_PANE_WIDTH = 246; + + private DatabaseTableDataPane tableDataPane; + + private AbstractDataSetFieldsPane dataSetFieldsPane; + + public DataSetPane(AbstractDataSetFieldsPane dataSetFieldsPane) { + initComps(dataSetFieldsPane); + } + + private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane) { + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data")); + UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH); + UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH); + + tableDataPane = new DatabaseTableDataPane(label) { + @Override + protected void userEvent() { + refreshBoxList(); + checkBoxUse(); + } + }; + tableDataPane.setPreferredSize(new Dimension(TABLE_DATA_PANE_WIDTH, tableDataPane.getPreferredSize().height)); + + this.dataSetFieldsPane = dataSetFieldsPane; + + this.setLayout(new BorderLayout()); + this.add(tableDataPane, BorderLayout.NORTH); + this.add(dataSetFieldsPane, BorderLayout.CENTER); + } + + /** + * 检查box是否可用. + */ + public void checkBoxUse() { + TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper(); + + if (dataSetFieldsPane != null) { + dataSetFieldsPane.checkBoxUse(dataWrap != null); + } + } + + /** + * 刷新字段下拉列表 + */ + private void refreshBoxList() { + TableDataWrapper dataWrap = tableDataPane.getTableDataWrapper(); + + if (dataWrap == null) { + return; + } + + List columnNameList = dataWrap.calculateColumnNameList(); + + if (dataSetFieldsPane != null) { + dataSetFieldsPane.refreshBoxListWithSelectTableData(columnNameList); + } + } + + @Override + public boolean accept(Object ob) { + return ob instanceof DataSetDefinition; + } + + @Override + public String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_TableData"); + } + + @Override + public void reset() { + this.removeAll(); + } + + @Override + public void populateBean(DataSetDefinition ob) { + refreshBoxList(); + checkBoxUse(); + + tableDataPane.populateBean(ob.getNameTableData()); + + dataSetFieldsPane.populateBean(ob.getColumnFieldCollection()); + } + + @Override + public DataSetDefinition updateBean() { + DataSetDefinition dataSetDefinition = new DataSetDefinition(); + + TableDataWrapper tableDataWrapper = tableDataPane.getTableDataWrapper(); + if (tableDataWrapper != null) { + dataSetDefinition.setNameTableData(new NameTableData(tableDataWrapper.getTableDataName())); + } + + dataSetDefinition.setColumnFieldCollection(dataSetFieldsPane.updateBean()); + + return dataSetDefinition; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java new file mode 100644 index 0000000000..a4e6949983 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/single/SingleDataPane.java @@ -0,0 +1,90 @@ +package com.fr.design.chartx.single; + +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.chartx.fields.AbstractCellDataFieldsPane; +import com.fr.design.chartx.fields.AbstractDataSetFieldsPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.mainframe.chart.gui.ChartDataPane; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by shine on 2019/5/21. + */ +public class SingleDataPane extends BasicBeanPane { + + private UIComboBoxPane comboBoxPane; + + private DataSetPane dataSetPane; + + private CellDataPane cellDataPane; + + public SingleDataPane(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { + initComps(dataSetFieldsPane, cellDataFieldsPane); + } + + private void initComps(AbstractDataSetFieldsPane dataSetFieldsPane, AbstractCellDataFieldsPane cellDataFieldsPane) { + + cellDataPane = new CellDataPane(cellDataFieldsPane); + dataSetPane = new DataSetPane(dataSetFieldsPane); + + comboBoxPane = new UIComboBoxPane() { + @Override + protected List> initPaneList() { + List> list = new ArrayList>(); + list.add(dataSetPane); + list.add(cellDataPane); + return list; + } + + protected void initLayout() { + this.setLayout(new BorderLayout(LayoutConstants.HGAP_LARGE, 6)); + JPanel northPane = new JPanel(new BorderLayout(LayoutConstants.HGAP_LARGE, 0)); + northPane.add(jcb, BorderLayout.CENTER); + UILabel label1 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Source")); + label1.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); + northPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{jcb, null, null, label1, null})); + northPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 8)); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + + } + + @Override + protected String title4PopupWindow() { + return null; + } + }; + + + this.setLayout(new BorderLayout()); + this.add(comboBoxPane, BorderLayout.CENTER); + + } + + @Override + public void populateBean(AbstractDataDefinition ob) { + comboBoxPane.populateBean(ob); + } + + @Override + public AbstractDataDefinition updateBean() { + return comboBoxPane.updateBean(); + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 5fce5c3669..6d6f73ea2d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe.chart; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.DesignTableDataManager; @@ -20,6 +20,7 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.ChartTypePane; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; @@ -109,12 +110,14 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 if (!ComparatorUtils.equals(collection, lastCollection)) { - //此处画图 - Chart chart = collection.getSelectedChart(); - chart.demoImgEvent(true); + VanChart vanChart = collection.getSelectedChart(VanChart.class); + if (vanChart != null) { + //此处画图 + vanChart.demoImgEvent(true); + } try { - lastCollection = (ChartCollection) collection.clone(); + lastCollection = collection.clone(); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("error in clone ChartEditPane"); } @@ -131,7 +134,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 * 重新构造面板 * @param currentChart 图表 */ - public void reLayout(Chart currentChart){ + public void reLayout(ChartProvider currentChart) { if(currentChart != null){ int chartIndex = getSelectedChartIndex(currentChart); this.removeAll(); @@ -139,12 +142,8 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 paneList = new ArrayList(); addTypePane(); - boolean isDefault = true; - String plotID = ""; - if(currentChart.getPlot() != null){ - plotID = currentChart.getPlot().getPlotID(); - isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - } + String chartID = currentChart.getID(); + boolean isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); if(isDefault){ paneList.add(dataPane4SupportCell); @@ -152,11 +151,11 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 paneList.add(otherPane); this.isDefaultPane = true; }else{ - ChartDataPane chartDataPane = createChartDataPane(plotID); + ChartDataPane chartDataPane = createChartDataPane(chartID); if (chartDataPane != null) { paneList.add(chartDataPane); } - AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(plotID, listener); + AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(chartID, listener); for(int i = 0; i < otherPaneList.length; i++){ otherPaneList[i].addAttributeChangeListener(listener); paneList.add(otherPaneList[i]); @@ -226,8 +225,8 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 return; } - if(checkNeedsReLayout(collection.getSelectedChart())){ - reLayout(collection.getSelectedChart()); + if (checkNeedsReLayout(collection.getSelectedChartProvider())) { + reLayout(collection.getSelectedChartProvider()); } this.collection = collection; @@ -253,7 +252,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } } - public int getSelectedChartIndex(Chart chart){ + public int getSelectedChartIndex(ChartProvider chart) { int index = 0; if(typePane != null){ FurtherBasicBeanPane[] paneList = typePane.getPaneList(); @@ -267,15 +266,13 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } //populate的时候看看要不要重构面板 - private boolean checkNeedsReLayout(Chart chart){ + private boolean checkNeedsReLayout(ChartProvider chart) { if(chart != null){ int lastIndex = typePane.getSelectedIndex(); int currentIndex = getSelectedChartIndex(chart); - boolean currentPane = true; - if(chart.getPlot() != null){ - String plotID = chart.getPlot().getPlotID(); - currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - } + String chartID = chart.getID(); + boolean currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); + return (currentPane != isDefaultPane) || (!currentPane && lastIndex != currentIndex); } return false; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java deleted file mode 100644 index 4f109bd557..0000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDesignerOtherPane.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.chart.gui; - -import com.fr.design.mainframe.chart.gui.other.ChartDesignerConditionAttrPane; -import com.fr.design.mainframe.chart.gui.other.ChartDesignerInteractivePane; -import com.fr.design.dialog.BasicPane; - - -import javax.swing.*; -import java.awt.*; -import java.util.*; - -/** - * 图表设计器的图标属性表高级tab - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-16 - * Time: 下午2:04 - */ -public class ChartDesignerOtherPane extends ChartOtherPane { - - @Override - protected JPanel createContentPane() { - JPanel content = new JPanel(new BorderLayout()); - otherPane = new ChartTabPane(); - content.add(otherPane, BorderLayout.CENTER); - return content; - } - - /** - * 界面标题 - * - * @return 返回标题. - */ - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Advanced"); - } - - private boolean isHaveCondition() { - return hasCondition; - } - - - private class ChartTabPane extends TabPane { - - @Override - protected java.util.List initPaneList() { - java.util.List paneList = new ArrayList(); - interactivePane = new ChartDesignerInteractivePane(ChartDesignerOtherPane.this); - - paneList.add(interactivePane); - - if (ChartDesignerOtherPane.this.isHaveCondition()) { - conditionAttrPane = new ChartDesignerConditionAttrPane(); - paneList.add(conditionAttrPane); - } - return paneList; - } - - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index cc049b4503..4d72211134 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -2,10 +2,10 @@ package com.fr.design.mainframe.chart.gui; import com.fr.base.BaseUtils; import com.fr.chart.base.AttrChangeConfig; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.SwitchState; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionListener; import com.fr.design.dialog.UIDialog; @@ -19,6 +19,7 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -42,6 +43,8 @@ import java.awt.event.MouseListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; /** * 图表 类型 增删 控制按钮界面. @@ -56,6 +59,12 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private static final int P_W = 300; private static final int P_H = 400; + private static Set> supportChangeConfigChartClassSet = new HashSet>(); + + static { + registerSupportChangeConfigChartClass(VanChart.class); + } + private UIButton addButton; private UIButton configButton; private ArrayList indexList = new ArrayList(); @@ -109,6 +118,10 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen // Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); } + public static void registerSupportChangeConfigChartClass(Class cls) { + supportChangeConfigChartClassSet.add(cls); + } + private void initConfigCreator() { configCreator = new UIMenuNameableCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"), new AttrChangeConfig(), ChangeConfigPane.class); } @@ -135,9 +148,9 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (editingCollection != null) { //点击添加按钮,则会触发切换状态 - Chart chart = editingCollection.getChangeStateNewChart(); + ChartProvider chart = getChangeStateNewChart(); try { - Chart newChart = (Chart) chart.clone(); + ChartProvider newChart = (ChartProvider) chart.clone(); editingCollection.addNamedChart(name, newChart); } catch (CloneNotSupportedException e1) { FineLoggerFactory.getLogger().error("Error in Clone"); @@ -150,12 +163,51 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen //获取图表收集器的状态 private void checkoutChange(){ - editingCollection.calculateMultiChartMode(); + calculateMultiChartMode(); if (parent != null){ parent.relayoutChartTypePane(editingCollection); } //检查是否可以配置切换 - configButton.setEnabled(editingCollection.changeEnable()); + configButton.setEnabled(changeEnable()); + } + + /** + * 获取切花状态下的图表 + * + * @return + */ + public ChartProvider getChangeStateNewChart() { + ChartProvider chart = editingCollection.getSelectedChartProvider(); + String priority = ChartTypeManager.VAN_CHART_PRIORITY; + //todo@shinerefactor + // chart.getPriority(); + return ChartTypeManager.getInstanceWithCheck().getFirstChart(priority); + } + + //图表收集器模式状态改变 + private void calculateMultiChartMode() { + //设置切换功能是否可用 + editingCollection.getChangeConfigAttr().setEnable(changeEnable()); + //多图表切换模式 + if (editingCollection.getChartCount() > 1) { + editingCollection.setState(SwitchState.CHANGE); + } else { + editingCollection.setState(SwitchState.DEFAULT); + } + } + + /** + * 是否支持图表切换的配置 + * + * @return + */ + private boolean changeEnable() { + return editingCollection.getChartCount() > 1 + && supportChange(); + } + + private boolean supportChange() { + return supportChangeConfigChartClassSet.contains(editingCollection.getSelectedChartProvider().getClass()); } ActionListener configListener = new ActionListener() { @@ -310,11 +362,11 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen } private void checkConfigButtonVisible() { - addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChart().getPlot().getPlotID())); + addButton.setVisible(ChartTypeManager.enabledChart(editingCollection.getSelectedChartProvider().getID())); //新建一个collection - if(editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChart() != null){ + if (editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChartProvider() != null) { //Chart 不支持图表切换 - configButton.setVisible(editingCollection.getSelectedChart().supportChange()); + configButton.setVisible(supportChange()); } } @@ -440,7 +492,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void deleteAButton() { //先重构属性,在重构面板,否则面板在重构过程中,会重新将属性中的切换图表加到indexList中,导致面板无法删除 //记录改变前的plotID - String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID(); + String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID(); if (editingCollection != null) { int count = editingCollection.getChartCount(); for (int i = 0; i < count; i++) { @@ -520,7 +572,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (isEnabled()) { noSelected(); //记录改变前的plotID - String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID(); + String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChartProvider().getID(); changeCollectionSelected(getButtonName()); setSelectedWithFireListener(true); fireSelectedChanged(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 33c9a41dcc..8ac031f754 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -2,9 +2,9 @@ package com.fr.design.mainframe.chart.gui; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.SwitchState; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.dialog.BasicScrollPane; @@ -41,30 +41,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ private ChartTypeButtonPane buttonPane; private ChartEditPane editPane; private ChartCollection editingCollection; - private PaneState paneState = new PaneState(); - - private class PaneState{ - //记录面板所处状态 - private SwitchState paneState = SwitchState.DEFAULT; - //记录当前面板是谁在使用切换状态 - private String chartID = StringUtils.EMPTY; - - public SwitchState getPaneState() { - return paneState; - } - - public void setPaneState(SwitchState paneState) { - this.paneState = paneState; - } - - public String getChartID() { - return chartID; - } - - public void setChartID(String chartID) { - this.chartID = chartID; - } - } @Override protected JPanel createContentPane() { @@ -122,14 +98,14 @@ public class ChartTypePane extends AbstractChartAttrPane{ public String title4PopupWindow() { return PaneTitleConstants.CHART_TYPE_TITLE; } - - class ComboBoxPane extends UIComboBoxPane{ - private Map>> allChartTypePane; + + class ComboBoxPane extends UIComboBoxPane { + private Map>> allChartTypePane; @Override - protected List> initPaneList() { - List> paneList = new ArrayList>(); - allChartTypePane = new LinkedHashMap>>(); + protected List> initPaneList() { + List> paneList = new ArrayList>(); + allChartTypePane = new LinkedHashMap>>(); ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(paneList, allChartTypePane); return paneList; } @@ -145,13 +121,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ * 如果是切换图表的不同图表之间切换,则collection的选择下标会改变 * @param chart */ - public void updateBean(Chart chart) { + public void updateBean(ChartProvider chart) { - Plot oldPlot = chart.getPlot(); - String lastPlotID = oldPlot == null ? StringUtils.EMPTY : oldPlot.getPlotID(); + String lastPlotID = chart.getID(); try{ - Chart newDefaultChart = (Chart)((AbstractChartTypePane)getSelectedPane()).getDefaultChart().clone(); + ChartProvider newDefaultChart = (ChartProvider) ((AbstractChartTypePane) getSelectedPane()).getDefaultChart().clone(); if (!ComparatorUtils.equals(chart.getClass(), newDefaultChart.getClass())) { //vanChart 和 chart 之间切换 //不同chart之间切换 @@ -166,20 +141,20 @@ public class ChartTypePane extends AbstractChartAttrPane{ //这一步会替换plot ((AbstractChartTypePane)getSelectedPane()).updateBean(chart); - Plot plot = chart.getPlot(); - - if(plot != null){ - String plotID = plot.getPlotID(); - - //plot改变的话图表类型就算改变了 + String chartID = chart.getID(); - chart.setWrapperName(ChartTypeManager.getInstanceWithCheck().getWrapperName(plotID)); + //chartID改变的话图表类型就算改变了 + if (StringUtils.isNotEmpty(chartID)) { - chart.setChartImagePath(ChartTypeManager.getInstanceWithCheck().getChartImagePath(plotID)); + if (chart instanceof Chart) { + //todo@shinerefactor: 这边看下是否可以删除 + ((Chart) chart).setWrapperName(ChartTypeManager.getInstanceWithCheck().getWrapperName(chartID)); + ((Chart) chart).setChartImagePath(ChartTypeManager.getInstanceWithCheck().getChartImagePath(chartID)); + } - boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); + boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(chartID); - if(editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ + if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, chartID))) { editPane.reLayout(chart); } } @@ -219,12 +194,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ private void addOnePriorityCards(String priority, boolean ignore) { - Map> map = allChartTypePane.get(priority); + Map> map = allChartTypePane.get(priority); - Iterator>> iterator = map.entrySet().iterator(); + Iterator>> iterator = map.entrySet().iterator(); while (iterator.hasNext()) { - Map.Entry> entry = iterator.next(); + Map.Entry> entry = iterator.next(); String plotID = entry.getKey(); if (ignore || ChartTypeManager.enabledChart(plotID)) { cards.add(entry.getValue()); @@ -241,9 +216,11 @@ public class ChartTypePane extends AbstractChartAttrPane{ //处理办法:这边除了重构 下拉项选项和cardNames 还需要把cards重构下(不需要init pane,只需要我需要的拿出来就好了) private void relayout(ChartCollection collection){ //重构需要重构下拉框选项和cardNames - Chart chart = collection.getSelectedChart(); - String priority = chart.getPriority(); - String plotID = chart.getPlot().getPlotID(); + ChartProvider chart = collection.getSelectedChartProvider(); + String priority = ChartTypeManager.VAN_CHART_PRIORITY; + //TODO@shinerefactor + // chart.getPriority(); + String plotID = chart.getID(); boolean enabledChart = ChartTypeManager.enabledChart(plotID); String item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(priority, plotID); @@ -286,7 +263,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ } @Override - public void populateBean(Chart ob) { + public void populateBean(ChartProvider ob) { for (int i = 0; i < this.cards.size(); i++) { FurtherBasicBeanPane pane = cards.get(i); if (pane.accept(ob)) { @@ -303,12 +280,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ } @Override - public Chart updateBean() { + public ChartProvider updateBean() { return getSelectedPane().updateBean(); } @Override - public FurtherBasicBeanPane getSelectedPane(){ + public FurtherBasicBeanPane getSelectedPane() { Object item = jcb.getSelectedItem(); for (int i = 0; i < cards.size(); i++){ if (ComparatorUtils.equals(item, cards.get(i).title4PopupWindow())){ @@ -327,8 +304,8 @@ public class ChartTypePane extends AbstractChartAttrPane{ * @param collection */ public void reLayoutEditPane(String lastPlotID, ChartCollection collection){ - Chart chart = collection.getSelectedChart(); - String plotID = chart.getPlot().getPlotID(); + ChartProvider chart = collection.getSelectedChartProvider(); + String plotID = chart.getID(); boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); if (editPane != null && editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ editPane.reLayout(chart); @@ -337,22 +314,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void relayoutChartTypePane(ChartCollection collection){ - if (needRelayout(collection)) { - chartTypeComBox.relayout(collection); - //设置面板切换状态 - updatePaneState(collection); - } - } - - private void updatePaneState(ChartCollection collection) { - paneState.setChartID(collection.getRepresentChartID()); - paneState.setPaneState(collection.getState()); - } - - // TODO: 2016/11/17 因为现在populate面板时会重新构造面板,所以每次都需要重构 - private boolean needRelayout(ChartCollection collection) { - /*return paneState.getChartID() != collection.getRepresentChartID() || paneState.getPaneState() != collection.getState();*/ - return true; + chartTypeComBox.relayout(collection); } /** @@ -361,7 +323,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void populate(ChartCollection collection) { editingCollection = collection; - Chart chart = collection.getSelectedChart(); + ChartProvider chart = collection.getSelectedChartProvider(); this.remove(leftContentPane); initContentPane(); @@ -379,7 +341,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void update(ChartCollection collection) { editingCollection = collection; buttonPane.update(collection);// 内部操作时 已经做过处理. - Chart chart = collection.getSelectedChart(); + ChartProvider chart = collection.getSelectedChartProvider(); chartTypeComBox.updateBean(chart); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java deleted file mode 100644 index 9ce3afd91d..0000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/StylePane4Chart.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.fr.design.mainframe.chart.gui; - -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; -import com.fr.design.mainframe.chart.gui.style.series.SeriesPane4ChartDesigner; - -/** - * 图表设计器的样式面板 - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-25 - * Time: 下午6:56 - */ -public class StylePane4Chart extends ChartStylePane { - - public StylePane4Chart(AttributeChangeListener listener, boolean isNeedFormula) { - super(listener, isNeedFormula); - } - - public void update(ChartCollection collection) { - int selectIndex = collection.getSelectedIndex(); - super.update(collection); - collection.getSelectedChart().setStyleGlobal(false); - collection.setChartName(selectIndex, collection.getSelectedChart().getTitle().getTextObject().toString()); - } - - protected ChartSeriesPane createChartSeriesPane(){ - return new SeriesPane4ChartDesigner(StylePane4Chart.this); - } - -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java index 780a70e57b..7f22a03a6b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java @@ -11,6 +11,7 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.utils.gui.UIComponentUtils; @@ -39,8 +40,9 @@ public class TableDataPane extends FurtherBasicBeanPane{ } private void initDataPane() { - UILabel label = new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TableData")); + UILabel label = new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data")); UIComponentUtils.setLineWrap(label, TABLE_DATA_LABEL_LINE_WRAP_WIDTH); + UIComponentUtils.setPreferedWidth(label, ChartDataPane.LABEL_WIDTH); tableDataPane = new DatabaseTableDataPane(label) { @Override @@ -85,7 +87,7 @@ public class TableDataPane extends FurtherBasicBeanPane{ * @return 返回标题. */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TableData"); + return Toolkit.i18nText("Fine-Design_Chart_TableData"); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java deleted file mode 100644 index 6288b7ecf4..0000000000 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.fr.design.mainframe.chart.gui.other; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import com.fr.design.chart.ChartControlPane; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.mainframe.chart.ChartEditPane; -import com.fr.design.mainframe.chart.PaneTitleConstants; -import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.DialogActionAdapter; - - -public class ChartSwitchPane extends AbstractAttrNoScrollPane{ - - private UIButton changeButton; - - private ChartCollection editingChartCollection; - - private ChartEditPane currentChartEditPane; - - public ChartSwitchPane() { - - } - - @Override - protected JPanel createContentPane() { - JPanel pane = new JPanel(); - pane.setLayout(new BorderLayout()); - - changeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch")); - - pane.add(changeButton, BorderLayout.NORTH); - - changeButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - final ChartControlPane chartTypeManager = new ChartControlPane(); - chartTypeManager.populate(editingChartCollection); - - BasicDialog dlg = chartTypeManager.showWindow4ChartType(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionAdapter() { - public void doOk() { - chartTypeManager.update(editingChartCollection);//kunsnat: 确定刷新"chartSelectIndex" - - if(currentChartEditPane != null) { - currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update. - currentChartEditPane.gotoPane(PaneTitleConstants.CHART_TYPE_TITLE); - currentChartEditPane.gotoPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE); - currentChartEditPane.fire(); - } - } - }); - - dlg.setVisible(true); - } - }); - - return pane; - } - - /** - * 注册 切换事件的改变 和超链不同. - * @param listener - */ - public void registerChartEditPane(ChartEditPane currentChartEditPane) { - this.currentChartEditPane = currentChartEditPane; - } - - public void populateBean(ChartCollection c) { - this.editingChartCollection = c; - } - - public void updateBean(ChartCollection c) { - - } - - /** - * 界面标题 - * @param 返回标题 - */ - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch_Chart"); - } - - @Override - public String getIconPath() { - return null; - } -} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java index 7a1567bf9e..c9a6caf80a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java @@ -531,12 +531,16 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { double forValue = Double.MAX_VALUE; double backValue = -Double.MAX_VALUE; for(int i = 0, size = textFieldList.size(); i < size; i++) {// check 是否合格, 然后检查 是否改变颜色, + //backNumber是否是公式形式 + boolean formulaBackNumber = false; if(i == size - 1) { backValue = -Double.MAX_VALUE; } else { Number backNumber = ChartBaseUtils.formula2Number(BaseFormula.createFormulaBuilder().build(getValue4Index(i+1))); if(backNumber != null){ backValue = backNumber.doubleValue(); + } else { + formulaBackNumber = true; } } @@ -544,7 +548,7 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { if(number != null) { double value = number.doubleValue(); - if(value < forValue && value > backValue) { + if ((value < forValue && value > backValue) || formulaBackNumber) { setBackgroundUIColor(i,Color.WHITE); } else { setBackgroundUIColor(i, Color.red); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java index 4561549d41..639a41e429 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractBarPane.java @@ -9,9 +9,9 @@ import com.fr.chart.chartattr.Chart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午04:55:05 */ -public abstract class AbstractBarPane extends AbstractChartTypePane { - - protected static final int COLOMN_CHART = 0; +public abstract class AbstractBarPane extends AbstractDeprecatedChartTypePane { + + protected static final int COLOMN_CHART = 0; protected static final int STACK_COLOMN_CHART = 1; protected static final int PERCENT_STACK_COLOMN_CHART = 2; protected static final int THREE_D_COLOMN_CHART = 3; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 27f4266820..2634247623 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -1,22 +1,11 @@ package com.fr.design.mainframe.chart.gui.type; -import com.fr.base.ChartColorMatching; -import com.fr.base.ChartPreStyleConfig; -import com.fr.base.background.ColorBackground; -import com.fr.chart.base.AttrContents; -import com.fr.chart.base.AttrFillStyle; import com.fr.chart.base.ChartConstants; -import com.fr.chart.base.ChartUtils; -import com.fr.chart.base.DataSeriesCondition; -import com.fr.chart.base.TextAttr; -import com.fr.chart.chartattr.Axis; -import com.fr.chart.chartattr.CategoryPlot; import com.fr.chart.chartattr.Chart; -import com.fr.chart.chartattr.Legend; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartattr.Title; -import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.charttypes.BarIndependentChart; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.gui.ilable.BoldFontTextLabel; @@ -24,9 +13,6 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; -import com.fr.general.FRFont; -import com.fr.js.NameJavaScriptGroup; -import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; import javax.swing.JPanel; @@ -34,12 +20,11 @@ import javax.swing.JSeparator; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -import java.awt.Font; import java.util.ArrayList; import java.util.List; -public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ +public abstract class AbstractChartTypePane extends FurtherBasicBeanPane { private static final int ONE_LINE_NUM = 4; @@ -162,50 +147,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ } } } - /** - * 更新界面属性 - */ - public void populateBean(Chart chart) { - for(ChartImagePane imagePane : typeDemo) { - imagePane.isPressing = false; - } - for(ChartImagePane imagePane : styleList) { - imagePane.isPressing = false; - } - - if(styleList != null && !styleList.isEmpty()){ - int plotStyle = chart.getPlot().getPlotStyle(); - String styleName = chart.getPlot().getPlotFillStyle().getFillStyleName(); - - switch (plotStyle){ - case ChartConstants.STYLE_SHADE: if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"), styleName)){ - styleList.get(STYLE_SHADE).isPressing = true; - lastStyleIndex = STYLE_SHADE; - } - break; - case ChartConstants.STYLE_TRANSPARENT:if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"), styleName)){ - styleList.get(STYLE_TRANSPARENT).isPressing = true; - lastStyleIndex = STYLE_TRANSPARENT; - } - break; - case ChartConstants.STYLE_3D: if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)){ - styleList.get(STYLE_PLANE3D).isPressing = true; - lastStyleIndex = STYLE_PLANE3D; - } - break; - case ChartConstants.STYLE_OUTER:if(ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)){ - styleList.get(STYLE_HIGHLIGHT).isPressing = true; - lastStyleIndex = STYLE_HIGHLIGHT; - } - break; - default: - lastStyleIndex = -1; - break; - } - stylePane.setVisible(!(chart.getPlot().isSupport3D())); - this.repaint(); - } - } protected void checkDemosBackground() { if(this.styleList != null && !styleList.isEmpty()){ @@ -221,119 +162,10 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ } } - private void setPlotFillStyle(Chart chart){ - ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); - Plot plot = chart.getPlot(); - Object preStyle = null; - String name = ""; - if(styleList.get(STYLE_SHADE).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"); - preStyle = manager.getPreStyle(name); - }else if(styleList.get(STYLE_TRANSPARENT).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"); - preStyle = manager.getPreStyle(name); - }else if(styleList.get(STYLE_PLANE3D).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); - preStyle = manager.getPreStyle(name); - }else if(styleList.get(STYLE_HIGHLIGHT).isPressing){ - name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); - preStyle = manager.getPreStyle(name); - } - if(preStyle == null){ - plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT); - }else{ - AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); - fillStyle.setFillStyleName(name); - plot.setPlotFillStyle(fillStyle); - } - } - - /** - * 保存风格,对选中的风格做设置 - */ - public void updateBean(Chart chart) { - Plot oldPlot = chart.getPlot(); - Plot newPlot = this.setSelectedClonedPlotWithCondition(oldPlot); - checkTypeChange(oldPlot);//判断图表的类型是否发生变化 - if(styleList != null && !styleList.isEmpty()){ - if(styleList.get(STYLE_SHADE).isPressing && lastStyleIndex != STYLE_SHADE){ - lastStyleIndex = STYLE_SHADE; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE); - resetChart(chart); - createCondition4Shade(chart); - setPlotFillStyle(chart); - }else if(styleList.get(STYLE_TRANSPARENT).isPressing && lastStyleIndex != STYLE_TRANSPARENT){ - lastStyleIndex = STYLE_TRANSPARENT; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT); - resetChart(chart); - createCondition4Transparent(chart); - setPlotFillStyle(chart); - }else if(styleList.get(STYLE_PLANE3D).isPressing && lastStyleIndex != STYLE_PLANE3D){ - lastStyleIndex = STYLE_PLANE3D; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D); - resetChart(chart); - createCondition4Plane3D(chart); - setPlotFillStyle(chart); - }else if(styleList.get(STYLE_HIGHLIGHT).isPressing && lastStyleIndex != STYLE_HIGHLIGHT){ - lastStyleIndex = STYLE_HIGHLIGHT; - chart.setPlot(newPlot); - chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER); - resetChart(chart); - createCondition4HighLight(chart); - setPlotFillStyle(chart); - }else if(lastStyleIndex >= STYLE_SHADE && lastStyleIndex <= STYLE_HIGHLIGHT){ - if(styleList.get(lastStyleIndex).isDoubleClicked || typeChanged){ - chart.setPlot(newPlot); - resetChart(chart); - styleList.get(lastStyleIndex).isPressing = false; - checkDemosBackground(); - lastStyleIndex = -1; - } - } - - stylePane.setVisible(!(chart.getPlot().isSupport3D())); - this.repaint(); - } - } - - private Plot setSelectedClonedPlotWithCondition(Plot oldPlot){ - Plot newPlot = getSelectedClonedPlot(); - if(oldPlot != null && ComparatorUtils.equals(newPlot.getClass(), oldPlot.getClass())){ - if(oldPlot.getHotHyperLink() != null){ - NameJavaScriptGroup hotHyper = oldPlot.getHotHyperLink(); - try { - newPlot.setHotHyperLink((NameJavaScriptGroup)hotHyper.clone()); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error("Error in Hyperlink, Please Check it.", e); - } - } - newPlot.setConditionCollection(oldPlot.getConditionCollection()); - newPlot.setSeriesDragEnable(oldPlot.isSeriesDragEnable()); - if(newPlot.isSupportZoomCategoryAxis() && newPlot.getxAxis() != null) { - newPlot.getxAxis().setZoom(oldPlot.getxAxis().isZoom()); - } - if(newPlot.isSupportTooltipInInteractivePane()) { - newPlot.setHotTooltipStyle(oldPlot.getHotTooltipStyle()); - } - - if(newPlot.isSupportAutoRefresh()) { - newPlot.setAutoRefreshPerSecond(oldPlot.getAutoRefreshPerSecond()); - } - - if (newPlot.isSupportAxisTip()) { - newPlot.setInteractiveAxisTooltip(oldPlot.isInteractiveAxisTooltip()); - } - } - return newPlot; - } - /** * 更新整个新的Chart类型 */ - public Chart updateBean() { + public T updateBean() { return null; } @@ -345,14 +177,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ chart.setBackground(null); } - protected void changePlotWithClone(Chart chart, Plot plot) { - try { - chart.switchPlot((Plot)plot.clone()); - } catch (CloneNotSupportedException e) { - FineLoggerFactory.getLogger().error("Error in change plot"); - } - } - /** * 重置 */ @@ -393,219 +217,6 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ return false; } - //高光渐变的默认属性设置 - private void createCondition4HighLight(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.LEFT); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138,140,139))); - legend.setPosition(Constants.RIGHT_TOP); - chart.getPlot().setLegend(legend); - - //分类轴,现在只有柱形图,条形图,面积图 - if(chart.getPlot() instanceof CategoryPlot){ - CategoryPlot plot = (CategoryPlot)chart.getPlot(); - - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(204, 220, 228)); - cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138,140,139))); - - //值轴 - Axis valueAxis = plot.getyAxis(); - valueAxis.setAxisStyle(Constants.NONE); - valueAxis.setAxisColor(null); - valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); - valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - valueAxis.setShowAxisLabel(true); - valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138,140,139))); - - //绘图区 - plot.setBorderStyle(Constants.LINE_THIN); - plot.setBorderColor(new Color(204, 220, 228)); - plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245))); - plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); - plot.getyAxis().setMainGridColor(new Color(192,192,192)); - } - - } - } - - //平面3D的默认属性设置 - private void createCondition4Plane3D(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.CENTER); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51,51,51))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128,128,128))); - legend.setPosition(Constants.TOP); - chart.getPlot().setLegend(legend); - - //分类轴,现在只有柱形图,条形图,面积图 - if(chart.getPlot() instanceof CategoryPlot){ - CategoryPlot plot = (CategoryPlot)chart.getPlot(); - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(57, 57, 57)); - cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57,57,57))); - - //值轴设置 - Axis valueAxis = plot.getyAxis(); - valueAxis.setAxisStyle(Constants.LINE_NONE); - valueAxis.setTickMarkType(Constants.TICK_MARK_NONE); - valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - valueAxis.setShowAxisLabel(false); - - //绘图区 - plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); - plot.getyAxis().setMainGridColor(new Color(192,192,192)); - chart.setBorderStyle(Constants.LINE_NONE); - - //数据标签 - ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr(); - DataSeriesCondition attr = attrList.getExisted(AttrContents.class); - if(attr != null) { - attrList.remove(attr); - } - AttrContents attrContents = new AttrContents(); - attrContents.setPosition(Constants.OUTSIDE); - attrContents.setSeriesLabel(ChartConstants.VALUE_PARA); - attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51,51,51)))); - attrList.addDataSeriesCondition(attrContents); - } - } - } - - //透明风格的默认属性设置 - private void createCondition4Transparent(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.LEFT); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192,192,192))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138,140,139))); - legend.setPosition(Constants.RIGHT_TOP); - chart.getPlot().setLegend(legend); - - Plot plot = chart.getPlot(); - //绘图区 - chart.setBackground(ColorBackground.getInstance(new Color(51,51,51))); - - //分类轴,现在只有柱形图,条形图,面积图 - if(plot instanceof CategoryPlot){ - //边框 - plot.setBorderStyle(Constants.LINE_THIN); - plot.setBorderColor(new Color(65,65,65)); - - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(192,192,192)); - cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150,150,150))); - - //值轴 - Axis valueAxis = plot.getyAxis(); - valueAxis.setShowAxisLabel(true); - valueAxis.setAxisStyle(Constants.LINE_NONE); - valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150,150,150))); - valueAxis.setMainGridStyle(Constants.LINE_THIN); - valueAxis.setMainGridColor(new Color(63, 62, 62)); - } - } - } - - //渐变的默认属性设置 - private void createCondition4Shade(Chart chart){ - if(chart != null){ - //标题 - Title title = new Title(chart.getTitle().getTextObject()); - chart.setTitle(title); - title.setTitleVisible(true); - TextAttr textAttr = title.getTextAttr(); - if (textAttr == null) { - textAttr = new TextAttr(); - title.setTextAttr(textAttr); - } - title.setPosition(Constants.CENTER); - textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0,51,102))); - - //图例 - Legend legend = new Legend(); - legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128,128,128))); - legend.setPosition(Constants.BOTTOM); - chart.getPlot().setLegend(legend); - - //分类轴,现在只有柱形图,条形图,面积图 - if(chart.getPlot() instanceof CategoryPlot){ - CategoryPlot plot = (CategoryPlot)chart.getPlot(); - - //分类轴设置 - Axis cateAxis = plot.getxAxis(); - cateAxis.setAxisStyle(Constants.LINE_THICK); - cateAxis.setAxisColor(new Color(73, 100, 117)); - cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); - cateAxis.setShowAxisLabel(true); - cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128,128,128))); - - //值轴 - Axis valueAxis = plot.getyAxis(); - valueAxis.setShowAxisLabel(true); - valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128,128,128))); - valueAxis.setAxisStyle(Constants.LINE_NONE); - - //绘图区 - plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); - plot.getyAxis().setMainGridColor(new Color(192,192,192)); - plot.setHorizontalIntervalBackgroundColor(new Color(243,243,243)); - } - } - } - protected boolean needsResetChart(Chart chart){ return chart != null &&chart.getPlot() != null @@ -616,7 +227,7 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ return typePane; } - public Chart getDefaultChart() { + public ChartProvider getDefaultChart() { return BarIndependentChart.barChartTypes[0]; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java new file mode 100644 index 0000000000..81578ded56 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AbstractDeprecatedChartTypePane.java @@ -0,0 +1,409 @@ +package com.fr.design.mainframe.chart.gui.type; + +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.base.background.ColorBackground; +import com.fr.chart.base.AttrContents; +import com.fr.chart.base.AttrFillStyle; +import com.fr.chart.base.ChartConstants; +import com.fr.chart.base.ChartUtils; +import com.fr.chart.base.DataSeriesCondition; +import com.fr.chart.base.TextAttr; +import com.fr.chart.chartattr.Axis; +import com.fr.chart.chartattr.CategoryPlot; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.Legend; +import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartattr.Title; +import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRFont; +import com.fr.js.NameJavaScriptGroup; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.Constants; + +import java.awt.Color; +import java.awt.Font; + +/** + * Created by shine on 2019/7/1. + */ +public abstract class AbstractDeprecatedChartTypePane extends AbstractChartTypePane { + + protected void changePlotWithClone(Chart chart, Plot plot) { + try { + chart.switchPlot((Plot) plot.clone()); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error("Error in change plot"); + } + } + + /** + * 更新界面属性 + */ + public void populateBean(Chart chart) { + for (ChartImagePane imagePane : typeDemo) { + imagePane.isPressing = false; + } + for (ChartImagePane imagePane : styleList) { + imagePane.isPressing = false; + } + + if (styleList != null && !styleList.isEmpty()) { + int plotStyle = chart.getPlot().getPlotStyle(); + String styleName = chart.getPlot().getPlotFillStyle().getFillStyleName(); + + switch (plotStyle) { + case ChartConstants.STYLE_SHADE: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"), styleName)) { + styleList.get(STYLE_SHADE).isPressing = true; + lastStyleIndex = STYLE_SHADE; + } + break; + case ChartConstants.STYLE_TRANSPARENT: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"), styleName)) { + styleList.get(STYLE_TRANSPARENT).isPressing = true; + lastStyleIndex = STYLE_TRANSPARENT; + } + break; + case ChartConstants.STYLE_3D: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) { + styleList.get(STYLE_PLANE3D).isPressing = true; + lastStyleIndex = STYLE_PLANE3D; + } + break; + case ChartConstants.STYLE_OUTER: + if (ComparatorUtils.equals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"), styleName)) { + styleList.get(STYLE_HIGHLIGHT).isPressing = true; + lastStyleIndex = STYLE_HIGHLIGHT; + } + break; + default: + lastStyleIndex = -1; + break; + } + stylePane.setVisible(!(chart.getPlot().isSupport3D())); + this.repaint(); + } + } + + public void updateBean(Chart chart) { + Plot oldPlot = chart.getPlot(); + Plot newPlot = this.setSelectedClonedPlotWithCondition(oldPlot); + checkTypeChange(oldPlot);//判断图表的类型是否发生变化 + if (styleList != null && !styleList.isEmpty()) { + if (styleList.get(STYLE_SHADE).isPressing && lastStyleIndex != STYLE_SHADE) { + lastStyleIndex = STYLE_SHADE; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_SHADE); + resetChart(chart); + createCondition4Shade(chart); + setPlotFillStyle(chart); + } else if (styleList.get(STYLE_TRANSPARENT).isPressing && lastStyleIndex != STYLE_TRANSPARENT) { + lastStyleIndex = STYLE_TRANSPARENT; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_TRANSPARENT); + resetChart(chart); + createCondition4Transparent(chart); + setPlotFillStyle(chart); + } else if (styleList.get(STYLE_PLANE3D).isPressing && lastStyleIndex != STYLE_PLANE3D) { + lastStyleIndex = STYLE_PLANE3D; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_3D); + resetChart(chart); + createCondition4Plane3D(chart); + setPlotFillStyle(chart); + } else if (styleList.get(STYLE_HIGHLIGHT).isPressing && lastStyleIndex != STYLE_HIGHLIGHT) { + lastStyleIndex = STYLE_HIGHLIGHT; + chart.setPlot(newPlot); + chart.getPlot().setPlotStyle(ChartConstants.STYLE_OUTER); + resetChart(chart); + createCondition4HighLight(chart); + setPlotFillStyle(chart); + } else if (lastStyleIndex >= STYLE_SHADE && lastStyleIndex <= STYLE_HIGHLIGHT) { + if (styleList.get(lastStyleIndex).isDoubleClicked || typeChanged) { + chart.setPlot(newPlot); + resetChart(chart); + styleList.get(lastStyleIndex).isPressing = false; + checkDemosBackground(); + lastStyleIndex = -1; + } + } + + stylePane.setVisible(!(chart.getPlot().isSupport3D())); + this.repaint(); + } + } + + private Plot setSelectedClonedPlotWithCondition(Plot oldPlot) { + Plot newPlot = getSelectedClonedPlot(); + if (oldPlot != null && ComparatorUtils.equals(newPlot.getClass(), oldPlot.getClass())) { + if (oldPlot.getHotHyperLink() != null) { + NameJavaScriptGroup hotHyper = oldPlot.getHotHyperLink(); + try { + newPlot.setHotHyperLink((NameJavaScriptGroup) hotHyper.clone()); + } catch (CloneNotSupportedException e) { + FineLoggerFactory.getLogger().error("Error in Hyperlink, Please Check it.", e); + } + } + newPlot.setConditionCollection(oldPlot.getConditionCollection()); + newPlot.setSeriesDragEnable(oldPlot.isSeriesDragEnable()); + if (newPlot.isSupportZoomCategoryAxis() && newPlot.getxAxis() != null) { + newPlot.getxAxis().setZoom(oldPlot.getxAxis().isZoom()); + } + if (newPlot.isSupportTooltipInInteractivePane()) { + newPlot.setHotTooltipStyle(oldPlot.getHotTooltipStyle()); + } + + if (newPlot.isSupportAutoRefresh()) { + newPlot.setAutoRefreshPerSecond(oldPlot.getAutoRefreshPerSecond()); + } + + if (newPlot.isSupportAxisTip()) { + newPlot.setInteractiveAxisTooltip(oldPlot.isInteractiveAxisTooltip()); + } + } + return newPlot; + } + + //平面3D的默认属性设置 + private void createCondition4Plane3D(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.CENTER); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 16f, new Color(51, 51, 51))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128))); + legend.setPosition(Constants.TOP); + chart.getPlot().setLegend(legend); + + //分类轴,现在只有柱形图,条形图,面积图 + if (chart.getPlot() instanceof CategoryPlot) { + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(57, 57, 57)); + cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(57, 57, 57))); + + //值轴设置 + Axis valueAxis = plot.getyAxis(); + valueAxis.setAxisStyle(Constants.LINE_NONE); + valueAxis.setTickMarkType(Constants.TICK_MARK_NONE); + valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + valueAxis.setShowAxisLabel(false); + + //绘图区 + plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); + plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); + chart.setBorderStyle(Constants.LINE_NONE); + + //数据标签 + ConditionAttr attrList = plot.getConditionCollection().getDefaultAttr(); + DataSeriesCondition attr = attrList.getExisted(AttrContents.class); + if (attr != null) { + attrList.remove(attr); + } + AttrContents attrContents = new AttrContents(); + attrContents.setPosition(Constants.OUTSIDE); + attrContents.setSeriesLabel(ChartConstants.VALUE_PARA); + attrContents.setTextAttr(new TextAttr(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(51, 51, 51)))); + attrList.addDataSeriesCondition(attrContents); + } + } + } + + //透明风格的默认属性设置 + private void createCondition4Transparent(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.LEFT); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(192, 192, 192))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139))); + legend.setPosition(Constants.RIGHT_TOP); + chart.getPlot().setLegend(legend); + + Plot plot = chart.getPlot(); + //绘图区 + chart.setBackground(ColorBackground.getInstance(new Color(51, 51, 51))); + + //分类轴,现在只有柱形图,条形图,面积图 + if (plot instanceof CategoryPlot) { + //边框 + plot.setBorderStyle(Constants.LINE_THIN); + plot.setBorderColor(new Color(65, 65, 65)); + + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(192, 192, 192)); + cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(150, 150, 150))); + + //值轴 + Axis valueAxis = plot.getyAxis(); + valueAxis.setShowAxisLabel(true); + valueAxis.setAxisStyle(Constants.LINE_NONE); + valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(150, 150, 150))); + valueAxis.setMainGridStyle(Constants.LINE_THIN); + valueAxis.setMainGridColor(new Color(63, 62, 62)); + } + } + } + + //渐变的默认属性设置 + private void createCondition4Shade(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.CENTER); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(0, 51, 102))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(128, 128, 128))); + legend.setPosition(Constants.BOTTOM); + chart.getPlot().setLegend(legend); + + //分类轴,现在只有柱形图,条形图,面积图 + if (chart.getPlot() instanceof CategoryPlot) { + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(73, 100, 117)); + cateAxis.setTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(128, 128, 128))); + + //值轴 + Axis valueAxis = plot.getyAxis(); + valueAxis.setShowAxisLabel(true); + valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(128, 128, 128))); + valueAxis.setAxisStyle(Constants.LINE_NONE); + + //绘图区 + plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); + plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); + plot.setHorizontalIntervalBackgroundColor(new Color(243, 243, 243)); + } + } + } + + //高光渐变的默认属性设置 + private void createCondition4HighLight(Chart chart) { + if (chart != null) { + //标题 + Title title = new Title(chart.getTitle().getTextObject()); + chart.setTitle(title); + title.setTitleVisible(true); + TextAttr textAttr = title.getTextAttr(); + if (textAttr == null) { + textAttr = new TextAttr(); + title.setTextAttr(textAttr); + } + title.setPosition(Constants.LEFT); + textAttr.setFRFont(FRFont.getInstance("Microsoft YaHei", Font.BOLD, 16f, new Color(51, 51, 51))); + + //图例 + Legend legend = new Legend(); + legend.setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 9f, new Color(138, 140, 139))); + legend.setPosition(Constants.RIGHT_TOP); + chart.getPlot().setLegend(legend); + + //分类轴,现在只有柱形图,条形图,面积图 + if (chart.getPlot() instanceof CategoryPlot) { + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + + //分类轴设置 + Axis cateAxis = plot.getxAxis(); + cateAxis.setAxisStyle(Constants.LINE_THICK); + cateAxis.setAxisColor(new Color(204, 220, 228)); + cateAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); + cateAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + cateAxis.setShowAxisLabel(true); + cateAxis.getTextAttr().setFRFont(FRFont.getInstance("Microsoft YaHei", Font.PLAIN, 10f, new Color(138, 140, 139))); + + //值轴 + Axis valueAxis = plot.getyAxis(); + valueAxis.setAxisStyle(Constants.NONE); + valueAxis.setAxisColor(null); + valueAxis.setTickMarkType(Constants.TICK_MARK_INSIDE); + valueAxis.setSecTickMarkType(Constants.TICK_MARK_NONE); + valueAxis.setShowAxisLabel(true); + valueAxis.getTextAttr().setFRFont(FRFont.getInstance("SimSun", Font.PLAIN, 10f, new Color(138, 140, 139))); + + //绘图区 + plot.setBorderStyle(Constants.LINE_THIN); + plot.setBorderColor(new Color(204, 220, 228)); + plot.setBackground(ColorBackground.getInstance(new Color(248, 247, 245))); + plot.getyAxis().setMainGridStyle(Constants.LINE_THIN); + plot.getyAxis().setMainGridColor(new Color(192, 192, 192)); + } + + } + } + + private void setPlotFillStyle(Chart chart) { + ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); + Plot plot = chart.getPlot(); + Object preStyle = null; + String name = ""; + if (styleList.get(STYLE_SHADE).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Retro"); + preStyle = manager.getPreStyle(name); + } else if (styleList.get(STYLE_TRANSPARENT).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Fresh"); + preStyle = manager.getPreStyle(name); + } else if (styleList.get(STYLE_PLANE3D).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); + preStyle = manager.getPreStyle(name); + } else if (styleList.get(STYLE_HIGHLIGHT).isPressing) { + name = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Bright"); + preStyle = manager.getPreStyle(name); + } + if (preStyle == null) { + plot.getPlotFillStyle().setColorStyle(ChartConstants.COLOR_DEFAULT); + } else { + AttrFillStyle fillStyle = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); + fillStyle.setFillStyleName(name); + plot.setPlotFillStyle(fillStyle); + } + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java index 42667ee9d9..a50bc52b5e 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/AreaPlotPane.java @@ -8,6 +8,8 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.charttypes.AreaIndependentChart; +import com.fr.design.i18n.Toolkit; +import com.fr.locale.InterProviderFactory; /** @@ -15,7 +17,7 @@ import com.fr.chart.charttypes.AreaIndependentChart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午06:57:36 */ -public class AreaPlotPane extends AbstractChartTypePane{ +public class AreaPlotPane extends AbstractDeprecatedChartTypePane { private static final int STACK_AREA_CHART = 0; private static final int PERCENT_AREA_LINE_CHART = 1; @@ -33,10 +35,10 @@ public class AreaPlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { - String area = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Area"); - String stack = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Stacked"); - String percent = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Percent"); - String td = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_3D"); + String area = InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Area"); + String stack = Toolkit.i18nText("Fine-Design_Chart_Stacked"); + String percent = Toolkit.i18nText("Fine-Design_Chart_Use_Percent"); + String td = Toolkit.i18nText("Fine-Design_Chart_3D"); return new String[]{ stack + area, percent + stack + area, @@ -139,7 +141,7 @@ public class AreaPlotPane extends AbstractChartTypePane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Area"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Area"); } public Chart getDefaultChart() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java index 280fca724c..cd5e1b4d66 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BarPlotPane.java @@ -6,6 +6,8 @@ import com.fr.chart.chartattr.BarPlot; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.BarIndependentChart; +import com.fr.design.i18n.Toolkit; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; @@ -31,16 +33,16 @@ public class BarPlotPane extends AbstractBarPane{ @Override protected String[] getTypeTipName() { - String bar = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Bar"); - String stack = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Stacked"); - String percent = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Percent"); - String td = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_3D"); + String bar = InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Bar"); + String stack = Toolkit.i18nText("Fine-Design_Chart_Stacked"); + String percent = Toolkit.i18nText("Fine-Design_Chart_Use_Percent"); + String td = Toolkit.i18nText("Fine-Design_Chart_3D"); return new String[]{ bar, stack + bar, percent + stack + bar, td + bar, - td + bar + "(" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal") + ")", + td + bar + "(" + Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal") + ")", td + stack + bar, td + percent + stack + bar }; @@ -65,8 +67,8 @@ public class BarPlotPane extends AbstractBarPane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Bar"); - } + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Bar"); + } protected Plot getSelectedClonedPlot(){ Chart[] barChart = BarIndependentChart.barChartTypes; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java index 103dbd1940..551a975235 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/BubblePlotPane.java @@ -4,6 +4,7 @@ import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.BubblePlot; import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.BubbleIndependentChart; +import com.fr.locale.InterProviderFactory; /** @@ -12,8 +13,8 @@ import com.fr.chart.charttypes.BubbleIndependentChart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午06:56:47 */ -public class BubblePlotPane extends AbstractChartTypePane { - private static final long serialVersionUID = -601566194238908115L; +public class BubblePlotPane extends AbstractDeprecatedChartTypePane { + private static final long serialVersionUID = -601566194238908115L; private static final int BUBBLE_CHART = 0; @@ -25,9 +26,9 @@ public class BubblePlotPane extends AbstractChartTypePane { @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Bubble_Chart") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Bubble_Chart") }; - } + } @Override protected String[] getTypeLayoutPath() { @@ -44,7 +45,7 @@ public class BubblePlotPane extends AbstractChartTypePane { * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Bubble_Chart"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Bubble_Chart"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java index 5f290d5926..55de24714b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/ColumnPlotPane.java @@ -5,6 +5,8 @@ import com.fr.chart.chartattr.BarPlot; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.ColumnIndependentChart; +import com.fr.design.i18n.Toolkit; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; @@ -30,16 +32,16 @@ public class ColumnPlotPane extends AbstractBarPane{ @Override protected String[] getTypeTipName() { - String column = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Column"); - String stack = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Stacked"); - String percent = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Percent"); - String td = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_3D"); + String column = InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Column"); + String stack = Toolkit.i18nText("Fine-Design_Chart_Stacked"); + String percent = Toolkit.i18nText("Fine-Design_Chart_Use_Percent"); + String td = Toolkit.i18nText("Fine-Design_Chart_3D"); return new String[]{ column, stack + column, percent + stack + column, td + column, - td + column + "(" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal") + ")", + td + column + "(" + Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal") + ")", td + stack + column, td + percent + stack + column }; @@ -63,8 +65,8 @@ public class ColumnPlotPane extends AbstractBarPane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Column"); - } + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Column"); + } protected Plot getSelectedClonedPlot(){ Chart[] barChart = ColumnIndependentChart.columnChartTypes; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java index d6a46df458..f81b1168ce 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/CustomPlotPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.CustomIndependentChart; +import com.fr.locale.InterProviderFactory; /** @@ -10,7 +11,7 @@ import com.fr.chart.charttypes.CustomIndependentChart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-21 下午06:17:40 */ -public class CustomPlotPane extends AbstractChartTypePane { +public class CustomPlotPane extends AbstractDeprecatedChartTypePane { @Override protected String getPlotTypeID() { @@ -26,9 +27,9 @@ public class CustomPlotPane extends AbstractChartTypePane { @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Combine_Chart") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Combine") }; - } + } @Override protected String[] getTypeLayoutPath() { @@ -45,7 +46,7 @@ public class CustomPlotPane extends AbstractChartTypePane { * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Combine_Chart"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Combine"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java index e8643c34ff..0b57d225df 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/DonutPlotPane.java @@ -10,10 +10,11 @@ import com.fr.chart.chartattr.Donut3DPlot; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.charttypes.DonutIndependentChart; - +import com.fr.design.i18n.Toolkit; +import com.fr.locale.InterProviderFactory; import com.fr.stable.Constants; -import java.awt.*; +import java.awt.Color; import java.text.DecimalFormat; /** @@ -21,10 +22,10 @@ import java.text.DecimalFormat; * @author eason * */ -public class DonutPlotPane extends AbstractChartTypePane{ - private static final long serialVersionUID = -7084314809934346710L; - private static final int DONUT_CHART = 0; //2d圆环图 - private static final int THREE_D_DONUT_CHART = 1; //3D圆环图 +public class DonutPlotPane extends AbstractDeprecatedChartTypePane { + private static final long serialVersionUID = -7084314809934346710L; + private static final int DONUT_CHART = 0; //2d圆环图 + private static final int THREE_D_DONUT_CHART = 1; //3D圆环图 @Override protected String[] getTypeIconPath() { @@ -35,10 +36,10 @@ public class DonutPlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { - String donut = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Donut_Chart"); + String donut = InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Donut"); return new String[]{ donut, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_3D") + donut + Toolkit.i18nText("Fine-Design_Chart_3D") + donut }; } @@ -103,8 +104,8 @@ public class DonutPlotPane extends AbstractChartTypePane{ * @return 标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Donut_Chart"); - } + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Donut"); + } /** * 是否有坐标轴 diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java index 8f31c8c555..1b00f7a2aa 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/FunnelPlotPane.java @@ -7,7 +7,7 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.FunnelPlot; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.FunnelIndependentChart; - +import com.fr.locale.InterProviderFactory; import java.text.DecimalFormat; @@ -18,7 +18,7 @@ import java.text.DecimalFormat; * Time: 下午2:50 * To change this template use File | Settings | File Templates. */ -public class FunnelPlotPane extends AbstractChartTypePane{ +public class FunnelPlotPane extends AbstractDeprecatedChartTypePane { private static final int FUNNEL_CHART = 0; @@ -31,7 +31,7 @@ public class FunnelPlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Funnel") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Funnel") }; } @@ -50,7 +50,7 @@ public class FunnelPlotPane extends AbstractChartTypePane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Funnel"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Funnel"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java index 537fa46289..1bae398b52 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GanttPlotPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.GanttIndependentChart; +import com.fr.locale.InterProviderFactory; /** @@ -10,7 +11,7 @@ import com.fr.chart.charttypes.GanttIndependentChart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:38:18 */ -public class GanttPlotPane extends AbstractChartTypePane{ +public class GanttPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int GANTT = 0; @@ -24,9 +25,9 @@ public class GanttPlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gantt_Chart") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Gantt") }; - } + } @Override protected String getPlotTypeID() { @@ -47,7 +48,7 @@ public class GanttPlotPane extends AbstractChartTypePane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gantt_Chart"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Gantt"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java index 25d2fa48f2..e62f2e5c51 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/GisMapPlotPane.java @@ -11,17 +11,18 @@ import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; -import javax.swing.*; -import java.awt.*; +public class GisMapPlotPane extends AbstractDeprecatedChartTypePane { -public class GisMapPlotPane extends AbstractChartTypePane{ - private static final long serialVersionUID = 2595221900000305396L; - + private static final int GISMAP = 0; private UITextField keyInput; @@ -72,9 +73,9 @@ public class GisMapPlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { return new String[]{ - "gis"+com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Map") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_GIS_Map") }; - } + } @Override protected String getPlotTypeID() { @@ -172,7 +173,7 @@ public class GisMapPlotPane extends AbstractChartTypePane{ * @return 标题 */ public String title4PopupWindow() { - return "gis"+com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Map"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_GIS_Map"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java index 5afd3e2177..e5e23d2bcf 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/LinePlotPane.java @@ -5,10 +5,11 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.LinePlot; import com.fr.chart.chartattr.Plot; import com.fr.chart.charttypes.LineIndependentChart; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; -public class LinePlotPane extends AbstractChartTypePane{ +public class LinePlotPane extends AbstractDeprecatedChartTypePane { private static final int LINE_CHART = 0; @@ -21,9 +22,9 @@ public class LinePlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Chart") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Line") }; - } + } @Override protected String[] getTypeLayoutPath() { @@ -83,7 +84,7 @@ public class LinePlotPane extends AbstractChartTypePane{ } public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Chart"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Line"); } public Chart getDefaultChart() { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java index 6f9a55ab56..2b606fc064 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MapPlotPane.java @@ -10,12 +10,13 @@ import com.fr.chart.charttypes.MapIndependentChart; import com.fr.design.chart.series.PlotSeries.MapGroupExtensionPane; import com.fr.design.chart.series.PlotStyle.ChartSelectDemoPane; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import javax.swing.JPanel; import java.awt.BorderLayout; -public class MapPlotPane extends AbstractChartTypePane { +public class MapPlotPane extends AbstractDeprecatedChartTypePane { private boolean isSvgMap = true; // 默认是svg地图 @@ -71,7 +72,7 @@ public class MapPlotPane extends AbstractChartTypePane { * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Map_Map"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_SVG_MAP"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java index 811053641a..a02bcf5d10 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/MeterPlotPane.java @@ -6,6 +6,8 @@ import com.fr.chart.chartattr.MeterPlot; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.MeterStyle; import com.fr.chart.charttypes.MeterIndependentChart; +import com.fr.design.i18n.Toolkit; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; @@ -14,9 +16,9 @@ import com.fr.log.FineLoggerFactory; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:48:57 */ -public class MeterPlotPane extends AbstractChartTypePane { - - private static final int METER = 0; +public class MeterPlotPane extends AbstractDeprecatedChartTypePane { + + private static final int METER = 0; private static final int BLUE_METER =1; private static final int SIMPLE_METER = 2; @@ -31,9 +33,9 @@ public class MeterPlotPane extends AbstractChartTypePane { @Override protected String[] getTypeTipName() { - String meter = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Gauge"); + String meter = InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Meter"); return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Mode_Custom") + meter, + Toolkit.i18nText("Fine-Design_Chart_Mode_Custom") + meter, meter + "1", meter + "2" }; @@ -77,13 +79,13 @@ public class MeterPlotPane extends AbstractChartTypePane { * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Gauge"); - } - - /** - * 保存界面属性 - */ - public void updateBean(Chart chart) { + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Meter"); + } + + /** + * 保存界面属性 + */ + public void updateBean(Chart chart) { if(needsResetChart(chart)){ resetChart(chart); } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java index 98ccb0e533..4212d76c48 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/PiePlotPane.java @@ -10,10 +10,10 @@ import com.fr.chart.chartattr.PiePlot; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.charttypes.PieIndependentChart; - +import com.fr.locale.InterProviderFactory; import com.fr.stable.Constants; -import java.awt.*; +import java.awt.Color; import java.text.DecimalFormat; /** @@ -21,8 +21,8 @@ import java.text.DecimalFormat; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午06:55:33 */ -public class PiePlotPane extends AbstractChartTypePane{ - private static final long serialVersionUID = -601566194238908115L; +public class PiePlotPane extends AbstractDeprecatedChartTypePane { + private static final long serialVersionUID = -601566194238908115L; private static final int PIE_CHART = 0; private static final int THREE_D_PIE_CHART = 1; @@ -36,11 +36,11 @@ public class PiePlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { - String pie = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Pie"); + String pie = InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Pie"); return new String[]{ - pie, - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_3D") + pie - }; + pie, + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_3D") + pie + }; } @Override @@ -63,7 +63,7 @@ public class PiePlotPane extends AbstractChartTypePane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_New_Pie"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Pie"); } private void createPieCondition(Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java index 631a4d9d46..e3e55cb853 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RadarPlotPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.RadarIndependentChart; +import com.fr.locale.InterProviderFactory; /** @@ -10,7 +11,7 @@ import com.fr.chart.charttypes.RadarIndependentChart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午09:55:01 */ -public class RadarPlotPane extends AbstractChartTypePane{ +public class RadarPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int RADAR = 0; @@ -24,9 +25,9 @@ public class RadarPlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radar_Chart") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Radar") }; - } + } @Override protected String getPlotTypeID() { @@ -48,7 +49,7 @@ public class RadarPlotPane extends AbstractChartTypePane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radar_Chart"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Radar"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java index 405f9aa4fc..c685b4c3be 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/RangePlotPane.java @@ -4,6 +4,7 @@ import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.RangePlot; import com.fr.chart.charttypes.RangeIndependentChart; +import com.fr.locale.InterProviderFactory; /** @@ -11,7 +12,7 @@ import com.fr.chart.charttypes.RangeIndependentChart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:43:50 */ -public class RangePlotPane extends AbstractChartTypePane{ +public class RangePlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int RANGE = 0; @@ -25,9 +26,9 @@ public class RangePlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Range_Chart") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Range") }; - } + } @Override protected String getPlotTypeID() { @@ -49,7 +50,7 @@ public class RangePlotPane extends AbstractChartTypePane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Range_Chart"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Range"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java index 567595703c..c8c88fae1b 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/StockPlotPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.StockIndependentChart; +import com.fr.locale.InterProviderFactory; /** @@ -10,8 +11,8 @@ import com.fr.chart.charttypes.StockIndependentChart; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-26 上午10:52:36 */ -public class StockPlotPane extends AbstractChartTypePane { - +public class StockPlotPane extends AbstractDeprecatedChartTypePane { + private static final int STOCK = 0; @@ -24,9 +25,9 @@ public class StockPlotPane extends AbstractChartTypePane { @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Stock_Chart") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Stock") }; - } + } @Override protected String getPlotTypeID() { @@ -48,7 +49,7 @@ public class StockPlotPane extends AbstractChartTypePane { * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Stock_Chart"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_Stock"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java index 1f40de8be2..473c16c370 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/UserDefinedChartTypePane.java @@ -1,12 +1,14 @@ package com.fr.design.mainframe.chart.gui.type; import com.fr.chart.chartattr.Chart; +import com.fr.common.annotations.Compatible; /** * Created by mengao on 2017/8/30. * 不能删掉这个类,echarts插件中用到 */ -public abstract class UserDefinedChartTypePane extends AbstractChartTypePane { +@Compatible +public abstract class UserDefinedChartTypePane extends AbstractDeprecatedChartTypePane { protected String[] getTypeLayoutPath() { return new String[0]; } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java index 0effae28e1..eab3a98378 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/type/XYScatterPlotPane.java @@ -6,7 +6,7 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.XYScatterPlot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.charttypes.XYScatterIndependentChart; - +import com.fr.locale.InterProviderFactory; import com.fr.stable.Constants; /** @@ -14,7 +14,7 @@ import com.fr.stable.Constants; * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2012-12-25 下午08:33:55 */ -public class XYScatterPlotPane extends AbstractChartTypePane{ +public class XYScatterPlotPane extends AbstractDeprecatedChartTypePane { private static final long serialVersionUID = -601566194238908115L; private static final int XYSCATTER_CHART = 0; @@ -28,9 +28,9 @@ public class XYScatterPlotPane extends AbstractChartTypePane{ @Override protected String[] getTypeTipName() { return new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_I_XYScatterStyle_Marker") + InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_XYScatter") }; - } + } @Override protected String[] getTypeLayoutPath() { @@ -47,7 +47,7 @@ public class XYScatterPlotPane extends AbstractChartTypePane{ * @return 界面标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_I_XYScatterStyle_Marker"); + return InterProviderFactory.getProvider().getLocText("Fine-Engine_Chart_Type_XYScatter"); } /** diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java index 4e50371099..1c4d927523 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartHyperlinkGroup.java @@ -19,6 +19,7 @@ import com.fr.js.JavaScript; import com.fr.stable.ArrayUtils; import com.fr.stable.Filter; import com.fr.stable.bridge.StableFactory; +import org.jetbrains.annotations.NotNull; /** * 图表的超级链接界面. 比一般的HyperlinkGroupPane多了图表的相关超级链接 @@ -33,6 +34,8 @@ public class ChartHyperlinkGroup extends BaseHyperlinkGroup { * * @return NameableCreator[] */ + @NotNull + @Override public NameableCreator[] getHyperlinkCreators() { FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java index 2b8f6ea321..5bd4c38978 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStylePane.java @@ -5,7 +5,6 @@ import com.fr.chart.base.ChartUtils; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.event.UIObserver; @@ -13,7 +12,6 @@ import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.FRGUIPaneFactory; - import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; @@ -30,7 +28,8 @@ public class ChartPreStylePane extends BasicBeanPane { private ChartPreFillStylePane fillStylePane; private ChartComponent chartComponent; - + private Bar2DPlot demoPlot; + public ChartPreStylePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -50,8 +49,9 @@ public class ChartPreStylePane extends BasicBeanPane { this.add(boxPane, BorderLayout.CENTER); ChartCollection cc = new ChartCollection(); - cc.addChart(new Chart(new Bar2DPlot())); - + demoPlot = new Bar2DPlot(); + cc.addChart(new Chart(demoPlot)); + chartComponent = new ChartComponent(); chartComponent.populate(cc); chartComponent.setPreferredSize(new Dimension(400, 300)); @@ -82,8 +82,7 @@ public class ChartPreStylePane extends BasicBeanPane { private void refreshWhenStyleChange(ChartColorMatching preStyle) { if(chartComponent != null) { - Plot plot = (Plot) chartComponent.getEditingChart().getBasePlot(); - plot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle)); + demoPlot.setPlotFillStyle(ChartUtils.chartColorMatching2AttrFillStyle(preStyle)); chartComponent.reset(); } } diff --git a/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java b/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java index f10964d4c8..65ad2594d0 100644 --- a/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java +++ b/designer-chart/src/main/java/com/fr/design/module/FormHyperlinkGroup.java @@ -11,6 +11,7 @@ import com.fr.design.gui.frpane.BaseHyperlinkGroup; import com.fr.js.FormHyperlinkProvider; import com.fr.stable.ArrayUtils; import com.fr.stable.bridge.StableFactory; +import org.jetbrains.annotations.NotNull; /** * Created with IntelliJ IDEA. @@ -25,6 +26,8 @@ public class FormHyperlinkGroup extends BaseHyperlinkGroup { * * @return NameableCreator[] */ + @NotNull + @Override public NameableCreator[] getHyperlinkCreators() { FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); NameableCreator[] related4ChartHyper = { diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java index e42707a62a..b8758b9f5e 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartReportDataPane.java @@ -12,8 +12,8 @@ import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPa import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.SwingConstants; -import java.awt.Component; import java.awt.BorderLayout; +import java.awt.Component; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -92,38 +92,53 @@ public abstract class AbstractExtendedChartReportDataPane fieldList = new ArrayList(); + if (hasCustomFieldPane()) { + fieldList.add(new ExtendedField(seriesPane.updateBean())); + fieldList.add(new ExtendedField(valuePane.updateBean())); + } + dataConfig.setCustomFields(fieldList); + + return dataSet; + } + @Override public void updateBean(ChartCollection ob) { if (ob != null) { Chart chart = ob.getSelectedChart(); if (chart != null) { - ExtendedReportDataSet dataSet = new ExtendedReportDataSet(); - - AbstractDataConfig dataConfig = update(); - dataSet.setDataConfig(dataConfig); - - List fieldList = new ArrayList(); - if (hasCustomFieldPane()) { - fieldList.add(new ExtendedField(seriesPane.updateBean())); - fieldList.add(new ExtendedField(valuePane.updateBean())); - } - dataConfig.setCustomFields(fieldList); - chart.setFilterDefinition(dataSet); + chart.setFilterDefinition(updateDataSet()); } } } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java index 0771b749a5..ac1799e745 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/AbstractExtendedChartTableDataPane.java @@ -93,17 +93,40 @@ public abstract class AbstractExtendedChartTableDataPane { - private static final String[] HEADS = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Field_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Summary_Method")}; - - private UseFieldValuePane useFieldValuePane; - - private CustomFieldNamePane customFieldNamePane; - - private List fieldList = new ArrayList(); - +public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBoxPane { @Override - protected void initLayout() { - this.setLayout(new BorderLayout(0, 6)); - JPanel northPane = new JPanel(new BorderLayout()); - northPane.add(jcb, BorderLayout.CENTER); - UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Name_From")); - label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, 20)); - northPane.add(label, BorderLayout.WEST); - this.add(northPane, BorderLayout.NORTH); - this.add(cardPane, BorderLayout.CENTER); + protected AbstractUseFieldValuePane createUseFieldValuePane() { + return new ExtendedUseFieldValuePane(); } @Override - protected List> initPaneList() { - useFieldValuePane = new UseFieldValuePane(); - customFieldNamePane = new CustomFieldNamePane(); - List> list = new ArrayList>(); - list.add(useFieldValuePane); - list.add(customFieldNamePane); - return list; + protected AbstractCustomFieldNamePane createCustomFieldNamePane() { + return new ExtendedCustomFieldNamePane(); } - @Override - protected String title4PopupWindow() { - return StringUtils.EMPTY; - } - - protected boolean valueComboBoxHasNone() { - return false; - } - - public void checkBoxUse(boolean hasUse) { - jcb.setEnabled(hasUse); - useFieldValuePane.checkBoxUse(hasUse); - } - - public void clearAllBoxList() { - useFieldValuePane.clearAllBoxList(); - fieldList.clear(); - } - - protected void refreshBoxListWithSelectTableData(List columnNameList) { - useFieldValuePane.refreshBoxListWithSelectTableData(columnNameList); - fieldList = columnNameList; - } @Override public void populateBean(AbstractDataConfig ob) { if (ob.isCustomName()) { - customFieldNamePane.populateBean(ob); + populateCustomFieldNamePane(ob); jcb.setSelectedIndex(1); } else { - useFieldValuePane.populateBean(ob); + populateUseFieldValuePane(ob); jcb.setSelectedIndex(0); } } @@ -105,68 +38,22 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane { - private UIComboBox series; - private UIComboBox value; - private CalculateComboBox function; - - private UseFieldValuePane() { - initComponents(); - } - - private void initComponents() { - - series = new UIComboBox(); - value = valueComboBoxHasNone() ? new UIComboBoxWithNone() : new UIComboBox(); - - function = new CalculateComboBox(); - - Component[][] components = new Component[][]{ - new Component[]{new UILabel(HEADS[1], SwingConstants.LEFT), series}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value"), SwingConstants.LEFT), value}, - new Component[]{new UILabel(HEADS[2], SwingConstants.LEFT), function}, - }; - - double p = TableLayout.PREFERRED; - double[] columnSize = {78, 122}; - double[] rowSize = {p, p, p}; - - JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); - - this.setLayout(new BorderLayout(0, 6)); - this.add(panel, BorderLayout.CENTER); - } - - public void checkBoxUse(boolean hasUse) { - series.setEnabled(hasUse); - value.setEnabled(hasUse); - function.setEnabled(hasUse); - } - - public void clearAllBoxList() { - DataPaneHelper.clearBoxItems(series); - DataPaneHelper.clearBoxItems(value); - } - - public void refreshBoxListWithSelectTableData(List columnNameList) { - DataPaneHelper.refreshBoxItems(series, columnNameList); - DataPaneHelper.refreshBoxItems(value, columnNameList); - } + private class ExtendedUseFieldValuePane extends AbstractUseFieldValuePane { @Override public void populateBean(AbstractDataConfig ob) { List list = ob.getCustomFields(); if (list.size() == 2) { - series.setSelectedItem(list.get(0).getFieldName()); - value.setSelectedItem(list.get(1).getFieldName()); - function.populateBean((AbstractDataFunction) list.get(1).getDataFunction()); + populateSeries(list.get(0).getFieldName()); + populateValue(list.get(1).getFieldName()); + populateFunction((AbstractDataFunction) list.get(1).getDataFunction()); } } @@ -174,90 +61,35 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane list = new ArrayList(); - list.add(new ExtendedField(Utils.objectToString(series.getSelectedItem()))); - ExtendedField field = new ExtendedField(Utils.objectToString(value.getSelectedItem())); - field.setDataFunction(function.updateBean()); + list.add(new ExtendedField(updateSeries())); + ExtendedField field = new ExtendedField(updateValue()); + field.setDataFunction(updateFunction()); list.add(field); ob.setCustomFields(list); } - @Override - public boolean accept(Object ob) { - return true; - } - - @Override - public void reset() { - } - - @Override - public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Enable_Field_Value"); - } - @Override - public AbstractDataConfig updateBean() { - return null; - } } - private class CustomFieldNamePane extends FurtherBasicBeanPane { - - private UICorrelationPane correlationPane; - - public CustomFieldNamePane() { - initComponents(); - } - - private void initComponents() { - - correlationPane = new UICorrelationPane(HEADS) { - @Override - protected ActionListener getAddButtonListener() { - return new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - tablePane.addLine(new String[]{StringUtils.EMPTY, StringUtils.EMPTY, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_None")}); - fireTargetChanged(); - } - }; - } - - public UITableEditor createUITableEditor() { - return new Editor() { - @Override - protected UICorrelationPane getParent() { - return correlationPane; - } - }; - } - }; - - this.setLayout(new BorderLayout()); - this.add(correlationPane, BorderLayout.CENTER); - - } + private class ExtendedCustomFieldNamePane extends AbstractCustomFieldNamePane { @Override - public void populateBean(AbstractDataConfig ob) { - List customFields = ob.getCustomFields(); + protected List covertTBeanToTableModelList(AbstractDataConfig dataConfig) { + List customFields = dataConfig.getCustomFields(); List list = new ArrayList(); for (ExtendedField field : customFields) { String[] array = {field.getFieldName(), field.getCustomName(), DataPaneHelper.getFunctionString(field.getDataFunction())}; list.add(array); } - correlationPane.populateBean(list); + return list; } - @Override - public void updateBean(AbstractDataConfig ob) { - List list = correlationPane.updateBean(); - + protected void setTableModelListToTBean(List tableValues, AbstractDataConfig dataConfig) { List customFields = new ArrayList(); - for (Object[] line : list) { + for (Object[] line : tableValues) { ExtendedField field = new ExtendedField(Utils.objectToString(line[0])); field.setCustomName(Utils.objectToString(line[1])); if (line.length > 2) { @@ -266,122 +98,9 @@ public class ExtendedCustomFieldComboBoxPane extends UIComboBoxPane extends AbstractChartAtt return PaneTitleConstants.CHART_OTHER_TITLE; } + @Override + protected void initContentPane() { + leftContentPane = createContentPane(); + leftContentPane.setBorder(BorderFactory.createMatteBorder(10, 3, 0, 10, original)); + this.add(leftContentPane, BorderLayout.CENTER); + } } diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java index 9e5ddd7b48..affc3a611a 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedTypePane.java @@ -1,14 +1,14 @@ package com.fr.extended.chart; -import com.fr.chart.chartattr.Chart; import com.fr.chart.charttypes.ChartTypeManager; +import com.fr.chartx.attr.ChartProvider; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; /** * Created by shine on 2018/3/5. */ -public class ExtendedTypePane extends AbstractChartTypePane { +public class ExtendedTypePane extends AbstractChartTypePane { @Override protected String[] getTypeIconPath() { @@ -34,7 +34,7 @@ public class ExtendedTypePane extends AbstractChartType } @Override - public void populateBean(Chart chart) { + public void populateBean(AbstractChart chart) { if (getTypeIconPath().length > 0) { for (ChartImagePane imagePane : typeDemo) { imagePane.isPressing = false; @@ -46,7 +46,7 @@ public class ExtendedTypePane extends AbstractChartType } @Override - public void updateBean(Chart chart) { + public void updateBean(AbstractChart chart) { update((T) chart); if (getTypeIconPath().length > 0) { @@ -65,7 +65,7 @@ public class ExtendedTypePane extends AbstractChartType } @Override - public Chart getDefaultChart() { + public ChartProvider getDefaultChart() { return ChartTypeManager.getInstance().getChartTypes(getPlotID())[0]; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java index d50a803446..5727678692 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/ColumnIndependentVanChartInterface.java @@ -2,7 +2,10 @@ package com.fr.van.chart.column; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.MultiCategoryChartDataPane; import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.van.chart.vanchart.AbstractMultiCategoryVanChartUI; @@ -33,4 +36,9 @@ public class ColumnIndependentVanChartInterface extends AbstractMultiCategoryVan public String getPlotTypeTitle4PopupWindow(){ return VanChartColumnPlotPane.TITLE; } + + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new MultiCategoryChartDataPane(listener); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java index 61aa49829f..db0d5c8641 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java @@ -1,12 +1,16 @@ package com.fr.van.chart.designer.style; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; +import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.BoldFontTextLabel; +import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; - import com.fr.plugin.chart.type.LegendType; +import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick; import com.fr.van.chart.range.component.GradualIntervalConfigPane; import com.fr.van.chart.range.component.GradualLegendPane; +import com.fr.van.chart.range.component.LegendGradientBar; import com.fr.van.chart.range.component.SectionIntervalConfigPaneWithOutNum; import com.fr.van.chart.range.component.SectionLegendPane; @@ -46,8 +50,12 @@ public class HeatMapRangeLegendPane extends VanChartRangeLegendPane { protected GradualIntervalConfigPane createGradualIntervalConfigPane() { return new GradualIntervalConfigPane(){ @Override - protected Component[][] getPaneComponents() { - return super.getPaneComponentsWithOutTheme(); + protected Component[][] getPaneComponents(MinMaxValuePaneWithOutTick minMaxValuePane, ColorSelectBoxWithOutTransparent colorSelectBox, UINumberDragPane numberDragPane, LegendGradientBar legendGradientBar) { + return new Component[][]{ + new Component[]{minMaxValuePane, null}, + new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), numberDragPane}, + new Component[]{null, legendGradientBar} + }; } }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 9a26a87116..012c410a89 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -143,7 +143,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ JPanel panel = TableLayoutHelper.createTableLayoutPane(comps,row,col); - return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout"), panel); + return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index b16c9237e1..9ae650d97f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -12,9 +12,8 @@ import com.fr.design.gui.ilable.MultilineLabel; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; import com.fr.design.mainframe.chart.gui.type.ChartImagePane; import com.fr.general.Background; -import com.fr.log.FineLoggerFactory; - import com.fr.js.NameJavaScriptGroup; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.base.VanChartZoom; @@ -25,7 +24,7 @@ import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; -public abstract class AbstractVanChartTypePane extends AbstractChartTypePane{ +public abstract class AbstractVanChartTypePane extends AbstractChartTypePane { private static final long serialVersionUID = 7743244512351499265L; private UICheckBox largeModelCheckBox; diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java index 642630f149..825634547f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/MapDataTree.java @@ -6,7 +6,6 @@ import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.map.designer.type.GEOJSONTreeHelper; 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.stable.StringUtils; import javax.swing.JTree; @@ -98,7 +97,8 @@ public class MapDataTree extends JTree { } String dirPath = el.getUserObject().toString(); String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath); - if (GEOJSONHelper.getInstance().isValidDirPath(dirPath) && ComparatorUtils.equals(jsonUrl, url)){ + //先equals再valid原因:valid 远程下实时去服务器看有没有json文件 + if (ComparatorUtils.equals(jsonUrl, url) && GEOJSONTreeHelper.isValidDirPath(dirPath)) { selectTreeNode(el, m_model); return el; } @@ -151,7 +151,7 @@ public class MapDataTree extends JTree { DefaultMutableTreeNode el = els.nextElement(); String path = el.getUserObject().toString(); String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path); - if (GEOJSONHelper.getInstance().isValidDirPath(path) && StringUtils.contains(fileName, text)) { + if (StringUtils.contains(fileName, text) && GEOJSONTreeHelper.isValidDirPath(path)) { selectTreeNode(el, m_model); return; } 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 5fa180ffe6..10664b3405 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-chart/src/main/java/com/fr/van/chart/map/server/ChartMapEditorAction.java b/designer-chart/src/main/java/com/fr/van/chart/map/server/ChartMapEditorAction.java index 2775a37dcb..dc64adef11 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/server/ChartMapEditorAction.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/server/ChartMapEditorAction.java @@ -25,7 +25,7 @@ public class ChartMapEditorAction extends UpdateAction { int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); String web = GeneralContext.getCurrentAppNameOfEnv(); String serverlet = ServerConfig.getInstance().getServletName(); - ServerStarter.browserURLWithLocalEnv(WorkContext.getCurrent().isLocal() ? String.format("http://localhost:%d/%s/%s/view/report?op=map", port, web, serverlet) : WorkContext.getCurrent().getPath() + "/view/report?op=map"); + ServerStarter.browserURLWithLocalEnv(WorkContext.getCurrent().isLocal() ? String.format("http://localhost:%d/%s/%s/map/edit", port, web, serverlet) : WorkContext.getCurrent().getPath() + "/map/edit"); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java index e25e55b064..06f0b0f75f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/MultiPieIndependentVanChartInterface.java @@ -2,14 +2,12 @@ package com.fr.van.chart.multilayer; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.MultiPieChartDataPane; import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; -import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; -import com.fr.van.chart.multilayer.data.MultiPiePlotReportDataContentPane; -import com.fr.van.chart.multilayer.data.MultiPiePlotTableDataContentPane; import com.fr.van.chart.multilayer.other.VanChartMultiPieConditionPane; import com.fr.van.chart.multilayer.style.VanChartMultiPieSeriesPane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; @@ -29,13 +27,8 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan } @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent){ - return new MultiPiePlotTableDataContentPane(parent); - } - - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent){ - return new MultiPiePlotReportDataContentPane(parent); + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new MultiPieChartDataPane(listener); } public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java index b930c689d0..1a0413ffaa 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualIntervalConfigPane.java @@ -4,7 +4,6 @@ import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.layout.TableLayout; import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; - import com.fr.plugin.chart.range.GradualIntervalConfig; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick; @@ -23,7 +22,7 @@ public class GradualIntervalConfigPane extends JPanel{ //主题颜色 private ColorSelectBoxWithOutTransparent colorSelectBox; //划分阶段 - UINumberDragPane numberDragPane; + private UINumberDragPane numberDragPane; //渐变色编辑器 private LegendGradientBar legendGradientBar; @@ -58,7 +57,7 @@ public class GradualIntervalConfigPane extends JPanel{ double[] col = new double[]{f, e}; double[] row = new double[]{p, p, p, p}; - Component[][] components = getPaneComponents(); + Component[][] components = getPaneComponents(minMaxValuePane, colorSelectBox, numberDragPane, legendGradientBar); //控件承载面板 JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components,row,col); @@ -70,7 +69,10 @@ public class GradualIntervalConfigPane extends JPanel{ return new LegendGradientBar(); } - protected Component[][] getPaneComponents(){ + protected Component[][] getPaneComponents(MinMaxValuePaneWithOutTick minMaxValuePane, + ColorSelectBoxWithOutTransparent colorSelectBox, + UINumberDragPane numberDragPane, + LegendGradientBar legendGradientBar) { return new Component[][]{ new Component[]{minMaxValuePane, null}, new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Subject_Color")), colorSelectBox}, @@ -79,14 +81,6 @@ public class GradualIntervalConfigPane extends JPanel{ }; } - protected Component[][] getPaneComponentsWithOutTheme(){ - return new Component[][]{ - new Component[]{minMaxValuePane, null}, - new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), numberDragPane}, - new Component[]{null, legendGradientBar}, - }; - } - public void populate(GradualIntervalConfig intervalConfig){ minMaxValuePane.populate(intervalConfig.getMinAndMaxValue()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java index e6e89c0d93..1b270b90b7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/WordCloudIndependentVanChartInterface.java @@ -3,23 +3,19 @@ package com.fr.van.chart.wordcloud.designer; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.WordCloudChartDataPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; -import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane; - import com.fr.plugin.chart.base.VanChartConstants; import com.fr.van.chart.designer.other.VanChartInteractivePaneWithOutSort; import com.fr.van.chart.designer.other.VanChartOtherPane; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.vanchart.AbstractIndependentVanChartUI; -import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotReportDataContentPane; -import com.fr.van.chart.wordcloud.designer.data.WordCloudPlotTableDataContentPane; import com.fr.van.chart.wordcloud.designer.other.VanChartWordCloudConditionPane; import com.fr.van.chart.wordcloud.designer.style.VanChartWordCloudSeriesPane; import com.fr.van.chart.wordcloud.designer.type.VanChartWordCloudTypePane; @@ -50,16 +46,6 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa return "com/fr/design/images/form/toolbar/wordcloud.png"; } - @Override - public AbstractReportDataContentPane getReportDataSourcePane(Plot plot, ChartDataPane parent) { - return new WordCloudPlotReportDataContentPane(); - } - - @Override - public AbstractTableDataContentPane getTableDataSourcePane(Plot plot, ChartDataPane parent) { - return new WordCloudPlotTableDataContentPane(); - } - @Override public BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot) { return new VanChartWordCloudSeriesPane(parent, plot); @@ -104,4 +90,9 @@ public class WordCloudIndependentVanChartInterface extends AbstractIndependentVa public String getPlotTypeTitle4PopupWindow(){ return VanChartWordCloudTypePane.TITLE; } + + @Override + public ChartDataPane getChartDataPane(AttributeChangeListener listener) { + return new WordCloudChartDataPane(listener); + } } diff --git a/designer-form/build.form.gradle b/designer-form/build.form.gradle index c489d5ca29..42b16b0208 100644 --- a/designer-form/build.form.gradle +++ b/designer-form/build.form.gradle @@ -41,6 +41,7 @@ ant{ mkdir(dir:"src/main/java") move(todir:"src/main/java"){ fileset(dir:"../designer-realize/src",includes:"com/**") + fileset(dir:"../designer-sdk/src",includes:"com/**") fileset(dir:"src",includes:"com/**") } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XTreeEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XTreeEditor.java index c5672b389f..bde83a176b 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XTreeEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XTreeEditor.java @@ -73,7 +73,7 @@ public class XTreeEditor extends XWidgetCreator { crp = (CRPropertyDescriptor[]) ArrayUtils.add(crp, new CRPropertyDescriptor("ajax", this.data.getClass()).setI18NName( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Load_By_Async")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, - "Advanced")); + "Fine-Design_Basic_Advanced")); crp = this.addAllowEdit(crp); crp = this.addCustomData(crp); 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 6f84aaa321..b66293cfcc 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 313b571470..051c7bd494 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/mainframe/FormHierarchyTreePane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java index 3346f7d14e..6822422b29 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -23,6 +23,7 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -122,7 +123,12 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree private void refreshComponentTree() { componentTree.setAndScrollSelectionPath(componentTree.getSelectedTreePath()); - componentTree.refreshUI(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + componentTree.refreshUI(); + } + }); } private JPanel getWidgetPane() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java b/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java index 670c2fa489..090969d348 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormModelAdapter.java @@ -78,6 +78,10 @@ public class FormModelAdapter extends DesignModelAdapter> list.add(new WidgetName(widget.getWidgetName())); } } + @Override + public boolean dealWithAllCards() { + return true; + } }); return list; } @@ -135,4 +139,4 @@ public class FormModelAdapter extends DesignModelAdapter> protected Parameter[] getLatestParameters() { return this.getBook().getParameters(); } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 65e2f66598..5e57557e7f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.widget.ui; -import com.fr.base.BaseUtils; import com.fr.design.data.DataCreatorUI; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; @@ -34,6 +33,7 @@ import com.fr.form.ui.container.WTitleLayout; import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -90,6 +90,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { return new WidgetBoundPane(xCreator); } + @Override protected JPanel createContentPane() { return null; } @@ -102,6 +103,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { /** * 后台初始化所有事件. */ + @Override public void initAllListeners() { } @@ -113,7 +115,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { initListener(this); } - + @Override protected void initContentPane() { } @@ -214,12 +216,16 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { Widget widget = currentEditorDefinePane.updateBean(); if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic")) && widgetPropertyPane != null) { UITextField widgetNameField = widgetPropertyPane.getWidgetNameField(); - if (designer.getTarget().isNameExist(widgetNameField.getText()) && !ComparatorUtils.equals(widgetNameField.getText(), widget.getWidgetName())) { - widgetNameField.setText(widget.getWidgetName()); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, BaseUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + String toSetWidgetName = widgetNameField.getText(); + String currentWidgetName = widget.getWidgetName(); + boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); + if (exist) { + widgetNameField.setText(currentWidgetName); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); return; } widgetPropertyPane.update(widget); + // 上面一行更新了组件 这里必须重新调用getWidgetName xCreator.resetCreatorName(widget.getWidgetName()); xCreator.resetVisible(widget.isVisible()); designer.getEditListenerTable().fireCreatorModified(xCreator, DesignerEvent.CREATOR_RENAMED); @@ -250,6 +256,7 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { creator.firePropertyChange(); } + @Override public String getIconPath() { return StringUtils.EMPTY; } 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 04864c98a6..ff8ef4411f 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/actions/insert/flot/ChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java index d7ab0f9b15..b8f05c2e4a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java @@ -15,10 +15,9 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; import com.fr.design.menu.MenuKeySet; import com.fr.design.module.DesignModuleFactory; -import com.fr.log.FineLoggerFactory; - import com.fr.grid.Grid; import com.fr.grid.selection.FloatSelection; +import com.fr.log.FineLoggerFactory; import com.fr.report.ReportHelper; import com.fr.report.cell.FloatElement; import com.fr.report.elementcase.TemplateElementCase; @@ -27,8 +26,8 @@ import com.fr.stable.bridge.StableFactory; import com.fr.stable.unit.FU; import com.fr.stable.unit.OLDPIX; -import javax.swing.*; -import java.awt.*; +import javax.swing.KeyStroke; +import java.awt.Color; /** * 图表插入悬浮元素的操作. @@ -80,7 +79,6 @@ public class ChartFloatAction extends ElementCaseAction { reportPane.stopEditing(); final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG); - cc.removeAllNameObject(); final MiddleChartDialog chartDialog = DesignModuleFactory.getChartDialog(DesignerContext.getDesignerFrame()); chartDialog.populate(cc); chartDialog.addDialogActionListener(new DialogActionAdapter() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java index 9ba3ee9961..d7f98a2122 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ImageFloatAction.java @@ -87,7 +87,7 @@ public class ImageFloatAction extends ElementCaseAction { if (selectedFile != null && selectedFile.isFile()) { CellImage cellImage = selectImagePane.update(); - Image image = cellImage.getImage(); + Image image = cellImage.getBufferImage(); JTemplate currentEditingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); currentEditingTemplate.setPictureElem(floatElement, cellImage); diff --git a/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java b/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java index 1011f8036c..02d46c82aa 100644 --- a/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java +++ b/designer-realize/src/main/java/com/fr/design/headerfooter/ImagePane.java @@ -78,7 +78,7 @@ public class ImagePane extends BasicPane { } public Image update() { - return this.imagePreviewPane.getImage(); + return this.imagePreviewPane.getImageWithSuffix(); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index db91d0a39e..b68a5f72ea 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java @@ -174,6 +174,7 @@ public abstract class ElementCasePane extends Tar private CellSelection cellNeedTOFormat = null; private FormatBrushAction formatBrushAction; private ActionListener keyListener = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { if (!formatBrush.isSelected()) { DesignerContext.setFormatState(DesignerContext.FORMAT_STATE_ONCE); @@ -188,6 +189,7 @@ public abstract class ElementCasePane extends Tar } }; private ActionListener escKey = new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { cancelFormatBrush(); } @@ -212,6 +214,7 @@ public abstract class ElementCasePane extends Tar /** * 取消格式化 */ + @Override public void cancelFormat() { return; } @@ -240,7 +243,6 @@ public abstract class ElementCasePane extends Tar verScrollBar = new DynamicScrollBar(Adjustable.VERTICAL, this, this.resolution); horScrollBar = new DynamicScrollBar(Adjustable.HORIZONTAL, this, this.resolution); this.add(RGridLayout.VerticalBar, this.verScrollBar); -// this.add(RGridLayout.HorizontalBar, this.horScrollBar); // Init input/action map defaultly. initInputActionMap(); @@ -253,7 +255,7 @@ public abstract class ElementCasePane extends Tar initFormatBrush(); } - + @Override public int getMenuState() { return DesignState.WORK_SHEET; } @@ -265,6 +267,7 @@ public abstract class ElementCasePane extends Tar formatBrush.setSelected(DesignerContext.getFormatState() != DesignerContext.FORMAT_STATE_NULL); formatBrush.removeActionListener(formatBrushAction); formatBrush.addMouseListener(new MouseAdapter() { + @Override public void mouseClicked(MouseEvent e) { //如果没有格式刷,点击时就是想使用格式刷 if (e.getClickCount() == 1) { @@ -523,13 +526,16 @@ public abstract class ElementCasePane extends Tar !ComparatorUtils.equals(EastRegionContainerPane.getInstance().getCellAttrPane(), CellElementPropertyPane.getInstance())) { try { //旧选中内容编辑器释放模板对象 - this.getCurrentEditor().release(); + QuickEditor editor = this.getCurrentEditor(); + if(editor != null){ + editor.release(); + } } catch (UnsupportedOperationException e) { FineLoggerFactory.getLogger().info("Nothing to release"); } this.selection = selection; - fireSelectionChanged(); } + fireSelectionChanged(); } @@ -1210,6 +1216,7 @@ public abstract class ElementCasePane extends Tar /** * 请求焦点 */ + @Override public void requestFocus() { super.requestFocus(); this.getGrid().requestFocus(); @@ -1338,6 +1345,7 @@ public abstract class ElementCasePane extends Tar * * @return 返回正在编辑的状态. */ + @Override public EditingState createEditingState() { return new ElementCaseEditingState(this.selection, this.verScrollBar.getValue(), this.horScrollBar.getValue(), this.resolution); } @@ -1380,7 +1388,6 @@ public abstract class ElementCasePane extends Tar ElementCasePane.this.getVerticalScrollBar().setValue(this.verticalValue); ElementCasePane.this.getHorizontalScrollBar().setValue(this.horizontalValue); -// ElementCasePane.this.setResolution(this.resolution); HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(this.resolution); // 重绘. ElementCasePane.this.repaint(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java index 61f39b81db..1489294953 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/InformationCollector.java @@ -4,6 +4,7 @@ package com.fr.design.mainframe; import com.fr.base.FRContext; +import com.fr.concurrent.NamedThreadFactory; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.errorinfo.ErrorInfoUploader; @@ -47,6 +48,10 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + /** * @author neil * @@ -192,23 +197,16 @@ public class InformationCollector implements XMLReadable, XMLWriter { return; } - Thread sendThread = new Thread(new Runnable() { - + ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("InformationCollector")); + service.schedule(new Runnable() { @Override public void run() { - try { - //读取XML的5分钟后开始发请求连接服务器. - Thread.sleep(SEND_DELAY); - } catch (InterruptedException e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } sendUserInfo(); FocusPointMessageUploader.getInstance().sendToCloudCenter(); TemplateInfoCollector.getInstance().sendTemplateInfo(); ErrorInfoUploader.getInstance().sendErrorInfo(); } - }); - sendThread.start(); + }, SEND_DELAY, TimeUnit.MILLISECONDS); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java index 09f1ff9e1b..9fdc9d5a8c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/SheetNameTabPane.java @@ -3,6 +3,8 @@ package com.fr.design.mainframe; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -24,7 +26,7 @@ import com.fr.base.GraphHelper; import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; -import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.menu.MenuDef; @@ -35,6 +37,7 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.main.impl.WorkBook; import com.fr.poly.PolyDesigner; import com.fr.report.poly.PolyWorkSheet; @@ -52,15 +55,15 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse private static final Color LINE_COLOR = new Color(0xababab); - private static final Icon ADD_WORK_SHEET = BaseUtils.readIcon("com/fr/base/images/oem/addworksheet.png"); - protected static final Icon ADD_POLY_SHEET = BaseUtils.readIcon("com/fr/design/images/sheet/addpolysheet.png"); - private static final Icon WORK_SHEET_ICON = BaseUtils.readIcon("com/fr/base/images/oem/worksheet.png"); - private static final Icon POLY_SHEET_ICON = BaseUtils.readIcon("com/fr/design/images/sheet/polysheet.png"); - private static final Image DESIGN_IMAGE = BaseUtils.readImage("com/fr/design/images/sheet/left_right_btn.png"); - private static final Icon LEFT_ICON = BaseUtils.readIcon("com/fr/design/images/sheet/left_normal@1x.png"); - private static final Icon RIGHT_ICON = BaseUtils.readIcon("com/fr/design/images/sheet/right_normal@1x.png"); - private static final Icon DISABLED_LEFT_ICON = BaseUtils.readIcon("com/fr/design/images/sheet/left_hover@1x.png"); - private static final Icon DISABLED_RIGHT_ICON = BaseUtils.readIcon("com/fr/design/images/sheet/right_hover@1x.png"); + private static final Icon ADD_WORK_SHEET = IOUtils.readIcon("com/fr/base/images/oem/addworksheet.png"); + protected static final Icon ADD_POLY_SHEET = IOUtils.readIcon("com/fr/design/images/sheet/addpolysheet.png"); + private static final Icon WORK_SHEET_ICON = IOUtils.readIcon("com/fr/base/images/oem/worksheet.png"); + private static final Icon POLY_SHEET_ICON = IOUtils.readIcon("com/fr/design/images/sheet/polysheet.png"); + private static final Icon LEFT_ICON = IOUtils.readIcon("com/fr/design/images/sheet/left_normal@1x.png"); + private static final Icon RIGHT_ICON = IOUtils.readIcon("com/fr/design/images/sheet/right_normal@1x.png"); + private static final Icon DISABLED_LEFT_ICON = IOUtils.readIcon("com/fr/design/images/sheet/left_hover@1x.png"); + private static final Icon DISABLED_RIGHT_ICON = IOUtils.readIcon("com/fr/design/images/sheet/right_hover@1x.png"); + private static final int NUM = 10; private static final int ICON_SEP_DISTANCE = 8; private static final int TOOLBAR_HEIGHT = 16; @@ -144,6 +147,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse this.setBorder(null); this.setForeground(new Color(99, 99, 99)); leftButton = new UIButton(LEFT_ICON) { + @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, TOOLBAR_HEIGHT); } @@ -163,6 +167,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse leftButton.set4ToolbarButton(); leftButton.setDisabledIcon(DISABLED_LEFT_ICON); rightButton = new UIButton(RIGHT_ICON) { + @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, TOOLBAR_HEIGHT); } @@ -197,7 +202,14 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse } } }); - + + DesignerContext.getDesignerFrame().addComponentListener(new ComponentAdapter(){ + @Override public void componentResized(ComponentEvent e) { + for (int i = 0; i < lastOneIndex * NUM; i++) { + moveLeft(); + } + } + }); } private ActionListener createLeftButtonActionListener() { @@ -205,27 +217,31 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse @Override public void actionPerformed(ActionEvent e) { - int s = scrollIndex; - if (s == lastOneIndex && s != 0) { - scrollIndex--; - lastOneIndex--; - repaint(); - } else { - while (s > lastOneIndex && showCount != 0) { - scrollIndex++; - lastOneIndex++; - repaint(); - } - while (s < lastOneIndex && scrollIndex > 0) { - scrollIndex--; - lastOneIndex--; - repaint(); - } - } + moveLeft(); } }; } + private void moveLeft() { + int s = scrollIndex; + if (s == lastOneIndex && s != 0) { + scrollIndex--; + lastOneIndex--; + repaint(); + } else { + while (s > lastOneIndex && showCount != 0) { + scrollIndex++; + lastOneIndex++; + repaint(); + } + while (s < lastOneIndex && scrollIndex > 0) { + scrollIndex--; + lastOneIndex--; + repaint(); + } + } + } + /** * 设置选择index * @@ -282,6 +298,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse * * @param e 鼠标事件 */ + @Override public void mouseDragged(MouseEvent e) { if (isAuthorityEditing) { return; @@ -295,6 +312,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse * * @param e 鼠标事件 */ + @Override public void mouseMoved(MouseEvent e) { } @@ -423,15 +441,6 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse } generalPath.closePath(); g2d.fill(generalPath); -// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); -// g2d.setPaint(UIConstants.LINE_COLOR); -// if (selectedIndex == scrollIndex) { -// g2d.draw(new Line2D.Double(x[0], y[0], x[1], y[1])); -// } -// g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); -// g2d.draw(new Line2D.Double(x[2], y[2], x[3], y[3])); -// g2d.draw(new Line2D.Double(x[3], y[3], x[4], y[4])); -// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); sheeticon.paintIcon(this, g2d, (int) textX + charWidth, 2); // peter:画字符 g2d.setPaint(getForeground()); @@ -470,13 +479,6 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse g2d.fill(generalPath); g2d.setPaint(LINE_COLOR); -// if (i == scrollIndex) { -// g2d.draw(new Line2D.Double(x[0], y[0], x[1], y[1])); -// } -// g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); -// g2d.draw(new Line2D.Double(x[2], y[2], x[3], y[3])); -// g2d.draw(new Line2D.Double(x[3], y[3], x[4], y[4])); -// g2d.draw(new Line2D.Double(x[4], y[4], x[5], y[5])); double startX = textX > 0 ? textX - 1 : textX; g2d.drawRect((int)startX, 0, width, (int)textHeight); @@ -560,6 +562,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse * * @param e 鼠标事件 */ + @Override public void mouseClicked(MouseEvent e) { } @@ -568,6 +571,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse * * @param evt 鼠标事件 */ + @Override public void mousePressed(MouseEvent evt) { isReleased = false; int reportcount = reportComposite.getEditingWorkBook().getReportCount(); @@ -586,7 +590,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse boolean needRefreshPropertiesPane = getSelectedIndex() != i; setSelectedIndex(i); if (needRefreshPropertiesPane) { - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().refreshEastPropertiesPane(); } isBlank = false; @@ -629,11 +633,11 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse } } - + protected void addInsertGridShortCut(MenuDef def){ def.addShortCut(new GridReportInsertAction()); } - + protected void firstInsertActionPerformed(){ new GridReportInsertAction().actionPerformed(null); } @@ -644,6 +648,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse * * @param e 鼠标事件 */ + @Override public void mouseReleased(MouseEvent e) { this.isReleased = true; this.setReleasedXY(e.getX(), e.getY()); @@ -737,6 +742,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse * * @param e 鼠标事件 */ + @Override public void mouseEntered(MouseEvent e) { } @@ -745,6 +751,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse * * @param e 鼠标事件 */ + @Override public void mouseExited(MouseEvent e) { } @@ -772,7 +779,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse protected abstract class SheetInsertAction extends UpdateAction { SheetInsertAction() { this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Insert") + getTemplateReportType()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/base/images/cell/control/add.png")); } @Override @@ -945,7 +952,7 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse private class CopySheetAction extends UpdateAction { CopySheetAction() { this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Copy")); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); + this.setSmallIcon(IOUtils.readIcon("/com/fr/design/images/m_edit/copy.png")); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java index 6f329c39d2..7fe8b8ff87 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -16,8 +16,12 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.upm.event.CertificateEvent; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.DateUtils; @@ -208,6 +212,18 @@ public class UserInfoLabel extends UILabel { updateInfoPane(); } }); + EventDispatcher.listen(CertificateEvent.LOGIN, new Listener() { + @Override + public void on(Event event, String text) { + setText(text); + } + }); + EventDispatcher.listen(CertificateEvent.LOGOUT, new Listener() { + @Override + public void on(Event event, String text) { + setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_UnSignIn")); + } + }); } private void clearLoginInformation() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java index 629839a298..24ae13edaf 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/UserInfoPane.java @@ -4,6 +4,7 @@ package com.fr.design.mainframe.bbs; import com.fr.base.FRContext; +import com.fr.concurrent.NamedThreadFactory; import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; @@ -20,6 +21,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** @@ -111,7 +114,7 @@ public class UserInfoPane extends BasicPane { return StringUtils.EMPTY; } - public void updateBBSUserInfo(){ + public void updateBBSUserInfo() { String username = MarketConfig.getInstance().getBbsUsername(); if (StringUtils.isEmpty(username)) { markUnSignIn(); @@ -149,7 +152,8 @@ public class UserInfoPane extends BasicPane { } private void autoPushLoginDialog() { - Thread showBBSThread = new Thread(new Runnable() { + ExecutorService executorService = Executors.newSingleThreadExecutor(new NamedThreadFactory("BBSAutoPushLogin")); + executorService.execute(new Runnable() { @Override public void run() { @@ -185,7 +189,7 @@ public class UserInfoPane extends BasicPane { } }); - showBBSThread.start(); + executorService.shutdown(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/QuickEditorRegion.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/QuickEditorRegion.java index 77dcebef19..6291c5ddfc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/QuickEditorRegion.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/QuickEditorRegion.java @@ -46,7 +46,7 @@ public class QuickEditorRegion extends JPanel { */ public void populate(final QuickEditor currentEditor) { this.removeAll(); - if (currentEditor.getComponentCount() == 0) { + if (currentEditor == null || currentEditor.getComponentCount() == 0) { this.add(getEmptyEditor(), BorderLayout.CENTER); } else { this.add(currentEditor, BorderLayout.CENTER); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java index cecd400423..cbe37764de 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java @@ -17,6 +17,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.JTemplate; +import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; import com.fr.report.cell.DefaultTemplateCellElement; @@ -51,6 +52,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private static final int HEAD_WDITH = 290; private static final int HEAD_HEIGTH = 24; private static final int COMBO_WIDTH = 154; + private static final int BUTTON_GROUP_WIDTH = 140; // normal private UIButtonGroup autoshrik; @@ -81,7 +83,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private UIRadioButton[] adjustRadioButtons; // 插入行策略 - private UIButtonGroup insertRowPolicy; + private UIButtonGroup insertRowPolicyButtonGroup; private ValueEditorPane valueEditor; private CardLayout insertRowLayout; private JPanel insertRowPane; @@ -147,7 +149,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { private void initInsertRowPolicyPane() { // 插入行策略 - insertRowPolicy = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_NULL"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Estate_Default_Text"), + insertRowPolicyButtonGroup = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_NULL"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Estate_Default_Text"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_COPY")}); defaultValuePane = new JPanel(new BorderLayout(4, 0)); valueEditor = ValueEditorPaneFactory.createBasicValueEditorPane(); @@ -157,10 +159,10 @@ public class CellOtherSetPane extends AbstractCellAttrPane { insertRowPane.add(new JPanel(), "none"); insertRowPane.add(defaultValuePane, "content"); insertRowPane.setPreferredSize(new Dimension(0, 0)); - insertRowPolicy.addChangeListener(new ChangeListener() { + insertRowPolicyButtonGroup.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - if (insertRowPolicy.getSelectedIndex() == 1) { + if (insertRowPolicyButtonGroup.getSelectedIndex() == 1) { insertRowPane.setPreferredSize(new Dimension(100, 20)); insertRowLayout.show(insertRowPane, "content"); } else { @@ -169,16 +171,33 @@ public class CellOtherSetPane extends AbstractCellAttrPane { } } }); + + double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - double[] rowSize1 = {p, p}; - double[] columnSize1 = {p, f}; - int[][] rowCount1 = {{1, 1}, {1, 1}}; - Component[][] components1 = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy"), SwingConstants.LEFT), insertRowPolicy}, - new Component[]{null, insertRowPane}, - }; - insertRowPolicyPane = TableLayoutHelper.createGapTableLayoutPane(components1, rowSize1, columnSize1, rowCount1, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); + UILabel insertRowPolicyLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy", SwingConstants.LEFT)); + UIComponentUtils.setLineWrap(insertRowPolicyLabel); + + // 如果右侧需要很宽的空间,就用3行1列的布局 + if (insertRowPolicyButtonGroup.getPreferredSize().getWidth() > BUTTON_GROUP_WIDTH) { + double[] rowSize = {p, p, p}; + double[] columnSize = {f}; + + Component[][] components = new Component[][] { + new Component[]{insertRowPolicyLabel}, + new Component[]{insertRowPolicyButtonGroup}, + new Component[]{insertRowPane}, + }; + insertRowPolicyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); + } else { + double[] rowSize = {p, p}; + double[] columnSize = {f, BUTTON_GROUP_WIDTH}; + Component[][] components = new Component[][] { + new Component[]{insertRowPolicyLabel, insertRowPolicyButtonGroup}, + new Component[]{null, insertRowPane}, + }; + insertRowPolicyPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); + } } private JPanel seniorUpPane() { @@ -200,13 +219,14 @@ public class CellOtherSetPane extends AbstractCellAttrPane { fileNamePane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); UILabel showContentLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Content"), SwingConstants.LEFT); + UIComponentUtils.setLineWrap(showContentLabel); UILabel toolTipLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip")); JPanel toolTipTextFieldWrapper = new JPanel(new BorderLayout()); toolTipTextFieldWrapper.add(tooltipTextField, BorderLayout.NORTH); Component[][] components = new Component[][]{ - new Component[]{showContentLabel, showContent}, + new Component[]{showContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(showContent)}, new Component[]{fileNamePane, null}, // 选择"用下载连接显示二进制内容"时,会显示这一行的面板 new Component[]{toolTipLabel, toolTipTextFieldWrapper} }; @@ -323,7 +343,7 @@ public class CellOtherSetPane extends AbstractCellAttrPane { pageAfterColumnCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_Page_After_Column")); canBreakOnPaginateCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellPage_Can_Break_On_Paginate")); repeatCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellPage_Repeat_Content_When_Paging")); - insertRowPolicy.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy")); + insertRowPolicyButtonGroup.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy")); valueEditor.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy")); } @@ -395,16 +415,16 @@ public class CellOtherSetPane extends AbstractCellAttrPane { cellInsertPolicyAttr = new CellInsertPolicyAttr(); } if (ComparatorUtils.equals(CellInsertPolicyAttr.INSERT_POLICY_COPY, cellInsertPolicyAttr.getInsertPolicy())) { - insertRowPolicy.setSelectedIndex(2); + insertRowPolicyButtonGroup.setSelectedIndex(2); } else if (ComparatorUtils.equals(CellInsertPolicyAttr.INSERT_POLICY_DEFAULT, cellInsertPolicyAttr.getInsertPolicy())) { - insertRowPolicy.setSelectedIndex(1); + insertRowPolicyButtonGroup.setSelectedIndex(1); Object defaultValue = cellInsertPolicyAttr.getDefaultInsertValue(); this.valueEditor.populate(defaultValue); } else { - insertRowPolicy.setSelectedIndex(0); + insertRowPolicyButtonGroup.setSelectedIndex(0); this.valueEditor.populate(StringUtils.EMPTY); } - if (insertRowPolicy.getSelectedIndex() == 1) { + if (insertRowPolicyButtonGroup.getSelectedIndex() == 1) { insertRowPane.setPreferredSize(new Dimension(100, 20)); insertRowLayout.show(insertRowPane, "content"); } else { @@ -521,9 +541,9 @@ public class CellOtherSetPane extends AbstractCellAttrPane { // 插入 CellInsertPolicyAttr cellInsertPolicyAttr = new CellInsertPolicyAttr(); - if (insertRowPolicy.getSelectedIndex() == 2) { + if (insertRowPolicyButtonGroup.getSelectedIndex() == 2) { cellInsertPolicyAttr.setInsertPolicy(CellInsertPolicyAttr.INSERT_POLICY_COPY); - } else if (insertRowPolicy.getSelectedIndex() == 1) { + } else if (insertRowPolicyButtonGroup.getSelectedIndex() == 1) { cellInsertPolicyAttr.setInsertPolicy(CellInsertPolicyAttr.INSERT_POLICY_DEFAULT); Object value = valueEditor.update(); cellInsertPolicyAttr.setDefaultInsertValue(value); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java index 2555a26329..4497a0b28f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/FileEntityBuilder.java @@ -1,47 +1,34 @@ package com.fr.design.mainframe.messagecollect.entity; -import com.fr.general.CloudCenter; +import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; +import com.fr.general.CloudClient; import com.fr.general.IOUtils; -import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; -import com.fr.json.JSONException; -import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.CommonUtils; +import com.fr.stable.CoreConstants; import com.fr.stable.EncodeConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.third.jodd.datetime.JDateTime; -import com.fr.third.org.apache.http.HttpEntity; -import com.fr.third.org.apache.http.HttpResponse; -import com.fr.third.org.apache.http.client.HttpClient; -import com.fr.third.org.apache.http.client.methods.HttpPut; -import com.fr.third.org.apache.http.entity.FileEntity; -import com.fr.third.org.apache.http.impl.client.DefaultHttpClient; -import com.fr.third.org.apache.http.util.EntityUtils; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; +import java.net.URLEncoder; import java.util.UUID; -import static com.fr.third.org.apache.http.HttpStatus.SC_OK; - /** * @author alex sung * @date 2019/4/8 */ public class FileEntityBuilder { - private static final String INTELLI_OPERATION_URL = "intelli.operation.url"; - private static final String OPERATION_URL = "https://cloud.fanruan.com/config/protect/operation"; - private static final String ATTR_SIGNATURE = "signature"; - private static final String ATTR_KEY = "key"; private static final String FOCUS_POINT_FILE_ROOT_PATH = "FocusPoint"; + private static final String FILE_FROM = "design"; /** * 文件夹路径 @@ -61,6 +48,9 @@ public class FileEntityBuilder { } public File generateZipFile(String pathName) { + if (pathName == null) { + return null; + } File zipFile = null; try { zipFile = new File(pathName + ".zip"); @@ -100,53 +90,19 @@ public class FileEntityBuilder { /** * 上传文件到云中心 - * @param file 待上传文件 + * + * @param file 待上传文件 * @param keyFileName 目标文件 * @throws IOException */ public static void uploadFile(File file, String keyFileName) throws IOException { + CloudClient client = CloudClient.getInstance(); String today = new JDateTime().toString("YYYY-MM-DD"); - HttpClient httpclient = new DefaultHttpClient(); - try { - String signedUrl = generateSignedUploadUrl(FOCUS_POINT_FILE_ROOT_PATH + File.separator + today + File.separator +keyFileName); - if(StringUtils.isEmpty(signedUrl)){ - FineLoggerFactory.getLogger().error("signedUrl is null."); - return; - } - HttpPut httpPost = new HttpPut(signedUrl); - httpPost.addHeader("Content-Type","application/octet-stream"); - FileEntity fileEntity = new FileEntity(file); - httpPost.setEntity(fileEntity); - HttpResponse response = httpclient.execute(httpPost); - - int statusCode = response.getStatusLine().getStatusCode(); - if (statusCode == SC_OK) { - HttpEntity resEntity = response.getEntity(); - EntityUtils.consume(resEntity); - } else { - HttpEntity entity = response.getEntity(); - String result = EntityUtils.toString(entity, "utf-8"); - FineLoggerFactory.getLogger().info("upload file result:" + result); - } - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } + String filePath = FOCUS_POINT_FILE_ROOT_PATH + CoreConstants.SEPARATOR + today + CoreConstants.SEPARATOR + keyFileName; + String bbsUserName = MarketConfig.getInstance().getBbsUsername(); + String uuid = DesignerEnvManager.getEnvManager().getUUID(); + String name = StringUtils.isEmpty(bbsUserName) ? uuid : bbsUserName; - private static String generateSignedUploadUrl(String fileKeyName) throws IOException { - String url = CloudCenter.getInstance().acquireUrlByKind(INTELLI_OPERATION_URL, OPERATION_URL); - Map parameters = new HashMap(); - parameters.put(ATTR_KEY, fileKeyName); - parameters.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); - String responseText = HttpToolbox.get(url, parameters); - try { - JSONObject data = new JSONObject(responseText); - if ("success".equals(data.optString("status"))) { - return data.optString("url"); - } - } catch (JSONException e) { - FineLoggerFactory.getLogger().error("Illegal response text."+e, e.getMessage()); - } - return null; + client.uploadFile(file, filePath, URLEncoder.encode(name, EncodeConstants.ENCODING_UTF_8), FILE_FROM); } } 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 da98e47784..77f370d9d0 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 33adf8e2de..62f822af58 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 @@ -1,7 +1,5 @@ package com.fr.design.mainframe.messagecollect.impl; -import com.fr.config.MarketConfig; -import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.messagecollect.entity.FileEntityBuilder; import com.fr.design.mainframe.messagecollect.utils.MessageCollectUtils; import com.fr.intelli.record.FocusPoint; @@ -24,8 +22,6 @@ import java.util.UUID; public class FocusPointMessageUploader extends AbstractSendDataToCloud { private static final String TAG = "FocusPointMessageTag"; - private static final String SEPARATOR = "_"; - private static final String FOCUS_POINT = "FocusPoint"; private static final long DELTA = 24 * 3600 * 1000L; private static volatile FocusPointMessageUploader instance; @@ -42,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; @@ -91,17 +90,8 @@ public class FocusPointMessageUploader extends AbstractSendDataToCloud { } private void generatePath() { - DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); - String bbsUserName = MarketConfig.getInstance().getBbsUsername(); - String uuid = envManager.getUUID(); - //文件夹名称的格式是: "FocusPoint" + 大版本号 + 小版本号 + uuid + bbsUserName + randomUuid,均以下划线分隔 - StringBuilder sb = new StringBuilder(); - sb.append(FOCUS_POINT).append(SEPARATOR). - append(ProductConstants.MAIN_VERSION).append(SEPARATOR). - append(ProductConstants.MINOR_VERSION).append(SEPARATOR). - append(uuid).append(SEPARATOR).append(bbsUserName).append(SEPARATOR). - append(UUID.randomUUID()); - String folderName = StableUtils.pathJoin(ProductConstants.getEnvHome(), sb.toString()); + //文件夹名称是uuid.zip,版本信息已经在edition中体现了 + String folderName = StableUtils.pathJoin(ProductConstants.getEnvHome(), String.valueOf(UUID.randomUUID())); setFileEntityBuilder(new FileEntityBuilder(folderName)); } } 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 dac28a627a..10a1ee0bdf 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 77a662d6d1..bcad15c76c 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 @@ -1,22 +1,18 @@ 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.frpane.ImgChooseWrapper; 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.gui.GUICoreUtils; - import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.painter.CellImagePainter; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; @@ -44,13 +40,6 @@ public class SelectImagePane extends BasicPane { private Style imageStyle = null; - private Image previewImage = null; - - /** - * 默认格式 - */ - private String suffix = PictureCollection.DEFAULT_SUFFIX; - private File imageFile; public SelectImagePane() { @@ -124,22 +113,8 @@ public class SelectImagePane extends BasicPane { .showOpenDialog(SelectImagePane.this); if (returnVal != JFileChooser.CANCEL_OPTION) { File selectedFile = imageFileChooser.getSelectedFile(); - - if (selectedFile != null && selectedFile.isFile()) { - String filePath = selectedFile.getPath(); - suffix = ImageIOHelper.getSuffix(filePath); - Image image = BaseUtils.readImage(filePath); - CoreGraphHelper.waitForImage(image); - - imageFile = selectedFile; - setImageStyle(); - previewPane.setImage(image); - previewPane.setImageStyle(imageStyle); - previewImage = image; - } else { - previewPane.setImage(null); - } - previewPane.repaint(); + imageFile = selectedFile; + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, null).dealWithImageFile(returnVal); } } }; @@ -184,7 +159,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(); @@ -209,16 +183,12 @@ public class SelectImagePane extends BasicPane { public void setImage(Image image) { previewPane.setImage(image); - this.previewImage = image; } 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/report/freeze/RepeatColPane.java b/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatColPane.java index 100b306d8e..b4ff4f9efd 100644 --- a/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatColPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatColPane.java @@ -21,8 +21,10 @@ public class RepeatColPane extends FreezeAndRepeatPane { @Override public void populateBean(FT ob) { - ((ColSpinner)start).setValue((ob.getFrom() + 1)); - ((ColSpinner)end).setValue((ob.getTo() + 1)); + if (ob.getFrom() <= ob.getTo()) { + ((ColSpinner)start).setValue((ob.getFrom() + 1)); + ((ColSpinner)end).setValue((ob.getTo() + 1)); + } } @Override diff --git a/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatRowPane.java b/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatRowPane.java index e46a59a6e9..5ae39ec25c 100644 --- a/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatRowPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/freeze/RepeatRowPane.java @@ -21,8 +21,10 @@ public class RepeatRowPane extends FreezeAndRepeatPane { @Override public void populateBean(FT ob) { - ((RowSpinner)start).setValue((ob.getFrom() + 1)); - ((RowSpinner)end).setValue((ob.getTo() + 1)); + if (ob.getFrom() <= ob.getTo()) { + ((RowSpinner)start).setValue((ob.getFrom() + 1)); + ((RowSpinner)end).setValue((ob.getTo() + 1)); + } } @Override diff --git a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java index b6683337fd..0a2c627668 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/EditToolBar.java @@ -679,12 +679,10 @@ public class EditToolBar extends BasicPane { private void updateCustomToolBarButton() { CustomToolBarButton customToolBarButton = (CustomToolBarButton) widget; - if (customToolBarButton.getJSImpl() != null) { - customToolBarButton.setJSImpl(this.javaScriptPane.updateBean()); - } else { - customToolBarButton.setJSImpl(JavaScriptActionPane.createDefault().updateBean()); + if (customToolBarButton.getJSImpl() == null) { + this.javaScriptPane = JavaScriptActionPane.createDefault(); } - + customToolBarButton.setJSImpl(this.javaScriptPane.updateBean()); } } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java b/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java index 8f7e4b8475..c396538dd4 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/ViewToolBarPane.java @@ -52,9 +52,10 @@ public class ViewToolBarPane extends AbstractEditToolBarPane { editToolBarButton.setEnabled(isUseToolBarCheckBox.isSelected()); } }); - sortCheckBox.setSelected(true); - conditonFilterBox.setSelected(true); - listFilterBox.setSelected(true); + // 切换BI工程目录 webView未设置 默认false + sortCheckBox.setSelected(false); + conditonFilterBox.setSelected(false); + listFilterBox.setSelected(false); northPane.add(GUICoreUtils.createFlowPane(new Component[]{sortCheckBox, conditonFilterBox, listFilterBox}, FlowLayout.LEFT, 6)); northPane.add(GUICoreUtils.createFlowPane(new Component[] {isUseToolBarCheckBox, editToolBarButton}, FlowLayout.LEFT)); northPane.add(GUICoreUtils.createFlowPane(showListenersLabel, FlowLayout.LEFT)); 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 e7db157a97..0383b83b7e 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/Grid.java b/designer-realize/src/main/java/com/fr/grid/Grid.java index 16b8924731..19e68a9139 100644 --- a/designer-realize/src/main/java/com/fr/grid/Grid.java +++ b/designer-realize/src/main/java/com/fr/grid/Grid.java @@ -961,7 +961,6 @@ public class Grid extends BaseGridComponent { if (!ComparatorUtils.equals_exactly(oldValue, newValue)) { if (newValue instanceof CellImage) { CellImage cellImage = (CellImage) newValue; - newValue = cellImage.getImage(); JTemplate currentEditingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); currentEditingTemplate.setPictureElem(selectedFloatElement, cellImage); 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 4c4342291b..e68bd907b9 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/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 1bb88c7b09..c7ea413687 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -26,6 +26,7 @@ import com.fr.main.FineBook; import com.fr.page.PaperSettingProvider; import com.fr.page.ReportSettingsProvider; import com.fr.page.WatermarkPainter; +import com.fr.page.stable.PaperSetting; import com.fr.report.ReportHelper; import com.fr.report.cell.CellElement; import com.fr.report.cell.FloatElement; @@ -118,7 +119,7 @@ public class GridUI extends ComponentUI { protected ReportSettingsProvider getReportSettings(ElementCase elementCase) { if (elementCase instanceof Report) { return ReportUtils.getReportSettings((Report) elementCase); - } else if(elementCase instanceof FormElementCase){ + } else if (elementCase instanceof FormElementCase) { return ((FormElementCase) elementCase).getReportSettings(); } else { return new ReportSettings(); @@ -141,6 +142,9 @@ public class GridUI extends ComponentUI { // richer;聚合报表设计中,最初的ElementCase还没有加到Report中,所以elementCase.getReport()可能为空 ReportSettingsProvider reportSettings = getReportSettings(elementCase); PaperSettingProvider psetting = reportSettings.getPaperSetting(); + if (psetting == null) { + psetting = new PaperSetting(); + } if (grid.getPaginateLineShowType() != Grid.NO_PAGINATE_LINE) {// paint paper margin line. PaperSize paperSize = psetting.getPaperSize(); Margin margin = psetting.getMargin(); diff --git a/designer-realize/src/main/java/com/fr/grid/GridUtils.java b/designer-realize/src/main/java/com/fr/grid/GridUtils.java index dfe7a5f2d2..11e907fc64 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUtils.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUtils.java @@ -12,6 +12,7 @@ import com.fr.general.ComparatorUtils; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; import com.fr.grid.selection.Selection; +import com.fr.poly.creator.ECBlockPane; import com.fr.report.ReportHelper; import com.fr.report.cell.CellElement; import com.fr.report.cell.FloatElement; @@ -48,8 +49,7 @@ public class GridUtils { //peter:下面这几个量是在Drag列的时候用. public final static int DRAG_CELL_SIZE = 1; //peter:drag的时候改变格子的宽度. - public final static int DRAG_SELECT_UNITS = 2; //peter:drag的时候,选中单元格. -// public static int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes); + public final static int DRAG_SELECT_UNITS = 2; //peter:drag的时候,选中单元格.// public static int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes); /** * Is above float element.(the return may be null).
@@ -125,7 +125,6 @@ public class GridUtils { */ public static double[] caculateFloatElementLocations(FloatElement floatElement, DynamicUnitList columnWidthList, DynamicUnitList rowHeightList, int verticalValue, int horizentalValue) { -// int resolution = ScreenResolution.getScreenResolution(); int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes); double floatX = columnWidthList.getRangeValue(horizentalValue, 0).toPixD(resolution) + floatElement.getLeftDistance().toPixD(resolution); @@ -180,7 +179,6 @@ public class GridUtils { private static int cc_selected_column_or_row(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList) { double tmpIntIndex = 0; int selectedCellIndex = 0; -// int resolution = ScreenResolution.getScreenResolution(); int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes); if (mouseEvtPosition < 0) { selectedCellIndex = value; @@ -239,7 +237,6 @@ public class GridUtils { private static int cc_selected_column_or_row_withresolution(double mouseEvtPosition, int beginValue, int value, DynamicUnitList sizeList, int resolution) { double tmpIntIndex = 0; int selectedCellIndex = 0; -// int resolution = ScreenResolution.getScreenResolution(); if (mouseEvtPosition < 0) { selectedCellIndex = value; for (; true; selectedCellIndex--) { @@ -311,6 +308,7 @@ public class GridUtils { public static boolean canMove(ElementCasePane reportPane, int cellColumn, int cellRow) { if (reportPane.mustInVisibleRange()) { Grid grid = reportPane.getGrid(); + checkGridCount(reportPane); int verticalEndValue = grid.getVerticalValue() + grid.getVerticalExtent() - 1; int horizontalEndValue = grid.getHorizontalValue() + grid.getHorizontalExtent() - 1; if (cellColumn > horizontalEndValue) { @@ -323,6 +321,16 @@ public class GridUtils { return true; } + /** + *聚合报表的报表块增加单元格的数量时 当单元格拉动一半会自动扩展成完整的单元格 + * 该单元格不被记录 check下重新计算下单元格数量 + */ + private static void checkGridCount(Object obj) { + if (obj instanceof ECBlockPane) { + ((ECBlockPane) obj).getTarget().firePropertyChange(); + } + } + /** * 选择一个Cell, 支持Merge. */ diff --git a/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java b/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java index 3130a4b864..d06f77af41 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyComponentsBar.java @@ -1,7 +1,7 @@ package com.fr.poly; import com.fr.base.BaseUtils; -import com.fr.base.chart.BaseChart; +import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartGetter; import com.fr.base.chart.BaseChartNameID; import com.fr.base.vcs.DesignerMode; @@ -12,6 +12,7 @@ import com.fr.design.gui.itooltip.MultiLineToolTip; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.dnd.SerializableTransferable; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.report.poly.PolyECBlock; import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; @@ -63,9 +64,10 @@ public class PolyComponentsBar extends JToolBar { ); this.add(serIcons[0]); for (int i = 0; i < typeLen; i++) { - BaseChart[] rowChart = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID()); - String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(typeName[i].getPlotID()); - serIcons[i + 1] = new SerIcon(rowChart[0], Toolkit.i18nText(typeName[i].getName()), iconPath); + String chartID = typeName[i].getChartID(); + String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID); + BaseChartCollection chartCollection = BaseChartGetter.createChartCollection(chartID); + serIcons[i + 1] = new SerIcon(chartCollection, InterProviderFactory.getProvider().getLocText(typeName[i].getName()), iconPath); this.add(serIcons[i + 1]); } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyUtils.java b/designer-realize/src/main/java/com/fr/poly/PolyUtils.java index 330949fb34..e297a69ad4 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyUtils.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyUtils.java @@ -4,9 +4,7 @@ package com.fr.poly; import com.fr.base.ScreenResolution; -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; -import com.fr.base.chart.BasePlot; import com.fr.log.FineLoggerFactory; import com.fr.poly.creator.BlockCreator; import com.fr.poly.creator.ChartBlockCreator; @@ -15,7 +13,6 @@ import com.fr.poly.model.AddedData; import com.fr.report.poly.PolyChartBlock; import com.fr.report.poly.PolyECBlock; import com.fr.report.poly.TemplateBlock; -import com.fr.stable.bridge.StableFactory; import java.awt.Point; import java.lang.reflect.Constructor; @@ -53,10 +50,8 @@ public class PolyUtils { public static BlockCreator createCreator(Class clazz) { return createCreator(blockGenerate(clazz)); } - - public static BlockCreator createCreator(BaseChart chart) { - BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); - cc.addChart(chart); + + public static BlockCreator createCreator(BaseChartCollection cc) { TemplateBlock block = new PolyChartBlock(cc); return createCreator(block); } @@ -66,20 +61,7 @@ public class PolyUtils { try { block = (TemplateBlock) clazz.newInstance(); } catch (Exception e) { - try { - BasePlot plot = (BasePlot)clazz.newInstance(); - BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG); - - BaseChart chart = (BaseChart)StableFactory.createXmlObject(BaseChart.XML_TAG); - chart.initChart(plot); - cc.addChart(chart); - - block = new PolyChartBlock(cc); - } catch (InstantiationException e1) { - FineLoggerFactory.getLogger().error(e1.getMessage(), e1); - } catch (IllegalAccessException e1) { - FineLoggerFactory.getLogger().error(e1.getMessage(), e1); - } + FineLoggerFactory.getLogger().error(e.getMessage(), e); } return block; } diff --git a/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java b/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java index 006c7e48db..bf72884bcb 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/ChartBlockEditor.java @@ -3,25 +3,15 @@ */ package com.fr.poly.creator; -import com.fr.base.BaseUtils; -import com.fr.base.ScreenResolution; -import com.fr.base.chart.BaseChart; import com.fr.base.chart.BaseChartCollection; -import com.fr.base.chart.BaseChartGetter; -import com.fr.base.chart.BaseChartNameID; import com.fr.base.vcs.DesignerMode; -import com.fr.design.border.UIRoundedBorder; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.mainframe.EastRegionContainerPane; -import com.fr.design.mainframe.JSliderPane; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.NoSupportAuthorityEdit; import com.fr.design.mainframe.cell.QuickEditorRegion; import com.fr.design.module.DesignModuleFactory; -import com.fr.design.utils.gui.LayoutUtils; -import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.poly.PolyConstants; import com.fr.poly.PolyDesigner; import com.fr.poly.PolyDesigner.SelectionType; @@ -31,13 +21,8 @@ import com.fr.report.poly.PolyChartBlock; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JPanel; -import javax.swing.JToggleButton; -import javax.swing.border.Border; import java.awt.Color; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -48,31 +33,10 @@ import java.awt.event.MouseEvent; */ // 图片的命名必须符合下面的代码规范(chart类别+序号的方式) 不然读取不到指定图片 public class ChartBlockEditor extends BlockEditor { - private static final int BOUND_OFF = 21; - private static Border buttonBorder; - private static String[][] chartsNames; - private static BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames(); - private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes); - - static { - buttonBorder = new UIRoundedBorder(new Color(149, 149, 149), 1, 5); - chartsNames = new String[typeName.length][]; - for (int i = 0; i < typeName.length; i++) { - BaseChart[] rowCharts = BaseChartGetter.getStaticChartTypes(typeName[i].getPlotID()); - chartsNames[i] = new String[rowCharts.length]; - for (int j = 0; j < rowCharts.length; j++) { - chartsNames[i][j] = rowCharts[j].getChartName(); - } - } - } - - private ChartButton[] chartButtons = null; public ChartBlockEditor(PolyDesigner designer, ChartBlockCreator creator) { super(designer, creator); this.resolution = creator.resolution; - //shine:和产品商量后决定把最上面一排切换按钮去掉 -// this.initNorthBarComponent(); } @@ -80,33 +44,6 @@ public class ChartBlockEditor extends BlockEditor localeMark = LocaleCenter.getMark(UserInfoMark.class); try { - Desktop.getDesktop().browse(new URI(url)); + Desktop.getDesktop().browse(new URI(localeMark.getValue())); } catch (Exception ignored) { } diff --git a/designer-realize/src/main/java/com/fr/start/Designer.java b/designer-realize/src/main/java/com/fr/start/Designer.java index 5c81ee258b..654f396c84 100644 --- a/designer-realize/src/main/java/com/fr/start/Designer.java +++ b/designer-realize/src/main/java/com/fr/start/Designer.java @@ -3,7 +3,6 @@ package com.fr.start; import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; -import com.fr.design.RestartHelper; import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.file.WebPreviewUtils; import com.fr.design.actions.file.newReport.NewPolyReportAction; @@ -22,6 +21,7 @@ import com.fr.design.gui.ibutton.UIPreviewButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.itoolbar.UILargeToolbar; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.ActiveKeyGenerator; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.InformationCollector; @@ -30,14 +30,12 @@ import com.fr.design.mainframe.JWorkBook; import com.fr.design.mainframe.alphafine.component.AlphaFinePane; import com.fr.design.mainframe.bbs.UserInfoLabel; import com.fr.design.mainframe.bbs.UserInfoPane; -import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.module.DesignModuleFactory; -import com.fr.design.utils.DesignUtils; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; @@ -45,18 +43,14 @@ import com.fr.log.FineLoggerFactory; import com.fr.module.Module; import com.fr.module.ModuleContext; import com.fr.runtime.FineRuntime; -import com.fr.stable.BuildContext; -import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.lifecycle.LifecycleFatalError; import com.fr.stable.xml.XMLTools; -import com.fr.start.fx.SplashFx; -import com.fr.start.jni.SplashMac; import com.fr.start.module.StartupArgs; -import com.fr.start.preload.ImagePreLoader; import com.fr.start.server.ServerTray; +import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.workspace.WorkContext; import javax.swing.JComponent; @@ -71,8 +65,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; @@ -102,24 +94,11 @@ public class Designer extends BaseDesigner { * @param args 参数 */ public static void main(String[] args) { - + + StopWatch watch = new StopWatch(); + watch.start(); //启动运行时 FineRuntime.start(); - BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); - // 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了 - if (DesignUtils.isStarted()) { - DesignUtils.clientSend(args); - FineLoggerFactory.getLogger().error("Designer port not available."); - System.exit(0); - return; - } - RestartHelper.deleteRecordFilesWhenStart(); - - preloadResource(); - - SplashContext.getInstance().registerSplash(createSplash()); - - SplashContext.getInstance().show(); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); //传递启动参数 designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); @@ -127,7 +106,7 @@ public class Designer extends BaseDesigner { designerRoot.start(); } catch (LifecycleFatalError fatal) { SplashContext.getInstance().hide(); - JOptionPane.showMessageDialog(null, fatal.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(null, fatal.getMessage(), Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); FineLoggerFactory.getLogger().error(fatal.getMessage(), fatal); System.exit(0); } @@ -136,36 +115,8 @@ public class Designer extends BaseDesigner { //初始化一下serverTray ServerTray.init(); } - - } - - private static void preloadResource() { - ExecutorService service = Executors.newCachedThreadPool(); - - service.submit(new Runnable() { - @Override - public void run() { - new ImagePreLoader(); - } - }); - - service.submit(new Runnable() { - @Override - public void run() { - TemplateInfoCollector.getInstance(); - } - }); - service.shutdown(); - } - - private static SplashStrategy createSplash() { - // 这里可以开接口加载自定义启动画面 - if (OperatingSystem.isWindows()) { - return new SplashFx(); - } else if (OperatingSystem.isMacOS()) { - return new SplashMac(); - } - return new SplashFx(); + FineLoggerFactory.getLogger().info("Designer started.Time used {} ms", watch.getTime()); + watch.stop(); } /** @@ -327,7 +278,7 @@ public class Designer extends BaseDesigner { ) { @Override protected void upButtonClickEvent() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null) { return; } @@ -336,7 +287,7 @@ public class Designer extends BaseDesigner { @Override protected void downButtonClickEvent() { - final JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + final JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (jt == null) { return; } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerInitial.java b/designer-realize/src/main/java/com/fr/start/DesignerInitial.java new file mode 100644 index 0000000000..ea1faa321d --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/DesignerInitial.java @@ -0,0 +1,24 @@ +package com.fr.start; + +/** + * Created by juhaoyu on 2019-06-14. + * 设计器上下文 + */ +public class DesignerInitial { + + private static volatile Designer designer; + + public synchronized static void init(String... args) { + + designer = new Designer(args); + } + + public synchronized static void show() { + + if (designer != null) { + designer.show(); + } + //启动画面结束 + SplashContext.getInstance().hide(); + } +} 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 f40403a4d0..e45eee48f1 100644 --- a/designer-realize/src/main/java/com/fr/start/SplashContext.java +++ b/designer-realize/src/main/java/com/fr/start/SplashContext.java @@ -1,11 +1,15 @@ package com.fr.start; -import com.fr.design.DesignerEnvManager; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.i18n.Toolkit; +import com.fr.design.locale.impl.SplashMark; import com.fr.design.mainframe.bbs.BBSConstants; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.general.GeneralContext; +import com.fr.general.locale.LocaleCenter; +import com.fr.general.locale.LocaleMark; import com.fr.module.ModuleEvent; import com.fr.stable.StringUtils; @@ -24,8 +28,9 @@ import java.util.concurrent.TimeUnit; public class SplashContext { public static final String SPLASH_PATH = getSplashPath(); - public static final String SPLASH_CACHE_NAME = getSplashCacheName(); + 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(); @@ -38,7 +43,7 @@ public class SplashContext { private int fetchOnlineTimes = 0; private String guest = StringUtils.EMPTY; - private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + private ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory("SplashContext")); private Listener listener; @@ -147,7 +152,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); } } } @@ -166,18 +171,7 @@ public class SplashContext { } private static String getSplashPath() { - if (DesignerEnvManager.getEnvManager().getLanguage().equals(Locale.JAPAN)) { - return "/com/fr/design/images/splash_10_jp.gif"; - } else { - return "/com/fr/design/images/splash_10.gif"; - } - } - - private static String getSplashCacheName() { - if (DesignerEnvManager.getEnvManager().getLanguage().equals(Locale.JAPAN)) { - return "splash_10_jp.gif"; - } else { - return "splash_10.gif"; - } + LocaleMark localeMark = LocaleCenter.getMark(SplashMark.class); + return localeMark.getValue(); } -} +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java index 99066e964e..470b382c93 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java +++ b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java @@ -1,5 +1,6 @@ package com.fr.start.fx; +import com.fr.concurrent.NamedThreadFactory; import com.sun.javafx.iio.ImageFrame; import com.sun.javafx.iio.ImageLoadListener; import com.sun.javafx.iio.ImageLoader; @@ -14,6 +15,8 @@ import com.sun.prism.impl.PrismSettings; import java.io.IOException; import java.io.InputStream; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * 边加载边播放的gif加载器 @@ -36,7 +39,8 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { delayTimes = new int[gifCount]; this.width = width; this.height = height; - new Thread() { + ExecutorService es = Executors.newSingleThreadExecutor(new NamedThreadFactory("PrismImageLoader2")); + es.execute(new Runnable() { @Override public void run() { InputStream inputStream = null; @@ -47,14 +51,16 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { e.printStackTrace(); } finally { try { - inputStream.close(); + if (inputStream != null) { + inputStream.close(); + } } catch (IOException e) { e.printStackTrace(); } } } - }.start(); - + }); + es.shutdown(); } @Override @@ -108,6 +114,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { return 40; } + @Override public int getLoopCount() { return 0; } diff --git a/designer-realize/src/main/java/com/fr/start/fx/SplashFx.java b/designer-realize/src/main/java/com/fr/start/fx/SplashFx.java index fc657f6596..f5c64bf792 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/SplashFx.java +++ b/designer-realize/src/main/java/com/fr/start/fx/SplashFx.java @@ -1,5 +1,6 @@ package com.fr.start.fx; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.start.SplashFxActionListener; import com.fr.start.SplashStrategy; @@ -21,7 +22,7 @@ import java.util.concurrent.Executors; public class SplashFx implements SplashStrategy { private SplashFxWindow fxWindow; - private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(); + private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("SplashFx")); @Override public void show() { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index f360f24b9b..ff0f9221e6 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -3,8 +3,12 @@ package com.fr.start.module; import com.fr.base.BaseFormula; import com.fr.base.Formula; import com.fr.base.MultiFieldParameter; +import com.fr.base.passport.FinePassportListenerAdapter; +import com.fr.base.passport.FinePassportManager; import com.fr.base.process.ProcessOperator; import com.fr.chart.chartattr.ChartCollection; +import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; import com.fr.design.actions.core.ActionFactory; @@ -21,7 +25,6 @@ import com.fr.design.actions.insert.flot.FormulaFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction; import com.fr.design.actions.insert.flot.TextBoxFloatAction; import com.fr.design.bridge.DesignToolbarProvider; -import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.form.parameter.FormParaDesigner; import com.fr.design.fun.ElementUIProvider; import com.fr.design.gui.controlpane.NameObjectCreator; @@ -34,9 +37,6 @@ import com.fr.design.javascript.JavaScriptImplPane; import com.fr.design.javascript.ParameterJavaScriptPane; import com.fr.design.javascript.ProcessTransitionAdapter; import com.fr.design.mainframe.BaseJForm; -import com.fr.design.mainframe.CellElementPropertyPane; -import com.fr.design.mainframe.DesignerFrameFileDealerPane; -import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.ElementCaseThumbnail; import com.fr.design.mainframe.FormHierarchyTreePane; import com.fr.design.mainframe.InformationCollector; @@ -50,7 +50,6 @@ import com.fr.design.mainframe.form.FormECDesignerProvider; import com.fr.design.mainframe.form.FormElementCaseDesigner; import com.fr.design.mainframe.form.FormReportComponentComposite; import com.fr.design.mainframe.loghandler.DesignerLogAppender; -import com.fr.design.mainframe.loghandler.LogMessageBar; import com.fr.design.mainframe.socketio.DesignerSocketIO; import com.fr.design.module.DesignModuleFactory; import com.fr.design.parameter.FormParameterReader; @@ -58,7 +57,6 @@ import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.parameter.WorkBookParameterReader; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; import com.fr.form.stable.ElementCaseThumbnailProcessor; -import com.fr.form.ui.WidgetInfoConfig; import com.fr.general.xml.GeneralXMLTools; import com.fr.js.EmailJavaScript; import com.fr.js.JavaScriptImpl; @@ -104,8 +102,6 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; /** * Created by juhaoyu on 2018/1/31. @@ -125,10 +121,10 @@ public class DesignerActivator extends Activator { } } designerModuleStart(); - preLoadPane(); loadLogAppender(); DesignerSocketIO.update(); UserInfoPane.getInstance().updateBBSUserInfo(); + storePassport(); } private void loadLogAppender() { @@ -168,49 +164,6 @@ public class DesignerActivator extends Activator { InformationCollector.getInstance().collectStartTime(); } - private static void preLoadPane() { - ExecutorService service = Executors.newCachedThreadPool(); - service.submit(new Runnable() { - @Override - public void run() { - LogMessageBar.getInstance(); - } - }); - - service.submit(new Runnable() { - @Override - public void run() { - HistoryTemplateListPane.getInstance(); - } - }); - service.submit(new Runnable() { - @Override - public void run() { - WidgetInfoConfig.getInstance(); - } - }); - service.submit(new Runnable() { - @Override - public void run() { - CellElementPropertyPane.getInstance(); - } - }); - service.submit(new Runnable() { - @Override - public void run() { - DesignerFrameFileDealerPane.getInstance();//这边会涉及到TemplateTreePane - } - }); - - service.submit(new Runnable() { - @Override - public void run() { - EastRegionContainerPane.getInstance(); - } - }); - service.shutdown(); - } - private static Class[] actionsForInsertCellElement() { List> classes = new ArrayList<>(); Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); @@ -392,6 +345,16 @@ public class DesignerActivator extends Activator { StableFactory.registerMarkedObject(ElementCaseThumbnailProcessor.MARK_STRING, new ElementCaseThumbnail()); } + private static void storePassport() { + FinePassportManager.getInstance().storePassport(MarketConfig.getInstance().getBbsUsername(), DesignerEnvManager.getEnvManager().getActivationKey()); + FinePassportManager.getInstance().addPassportListener(new FinePassportListenerAdapter() { + @Override + public void onLoginSuccess() { + FinePassportManager.getInstance().storePassport(MarketConfig.getInstance().getBbsUsername(), DesignerEnvManager.getEnvManager().getActivationKey()); + } + }); + } + @Override public void stop() { unloadLogAppender(); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java new file mode 100644 index 0000000000..e9bea26922 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java @@ -0,0 +1,21 @@ +package com.fr.start.module; + +import com.fr.module.Activator; +import com.fr.start.DesignerInitial; + +/** + * Created by juhaoyu on 2019-06-14. + */ +public class DesignerInitActivator extends Activator { + + @Override + public void start() { + + DesignerInitial.init(upFindSingleton(StartupArgs.class).get()); + } + + @Override + public void stop() { + + } +} diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerShowActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerShowActivator.java new file mode 100644 index 0000000000..33ef015c1f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerShowActivator.java @@ -0,0 +1,25 @@ +package com.fr.start.module; + +import com.fr.design.i18n.Toolkit; +import com.fr.event.EventDispatcher; +import com.fr.module.Activator; +import com.fr.module.ModuleEvent; +import com.fr.start.DesignerInitial; + +/** + * Created by juhaoyu on 2019-06-14. + */ +public class DesignerShowActivator extends Activator { + + @Override + public void start() { + + EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Module_Name_Designer")); + DesignerInitial.show(); + } + + @Override + public void stop() { + + } +} diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java index 4a3db7b2cc..b1ad722519 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java @@ -1,24 +1,11 @@ package com.fr.start.module; -import com.fr.design.file.HistoryTemplateListCache; -import com.fr.design.mainframe.DesignerContext; -import com.fr.event.Event; -import com.fr.event.Listener; import com.fr.module.Activator; import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.Metrics; import com.fr.runtime.FineRuntime; -import com.fr.start.Designer; import com.fr.start.ServerStarter; -import com.fr.start.SplashContext; -import com.fr.start.server.FineEmbedServer; -import com.fr.startup.activators.BasicActivator; -import com.fr.workspace.Workspace; -import com.fr.workspace.WorkspaceEvent; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; /** * Created by juhaoyu on 2018/1/8. @@ -31,41 +18,10 @@ public class DesignerStartup extends Activator { public void start() { startSub(PreStartActivator.class); - //启动基础部分 - startSub(BasicActivator.class); - final String[] args = getModule().upFindSingleton(StartupArgs.class).get(); - final Designer designer = new Designer(args); - - startSub(DesignerWorkspaceProvider.class); - registerEnvListener(); - //启动env - startSub(EnvBasedModule.class); + getSub("parallel").start(); //designer模块启动好后,查看demo browserDemo(); - ExecutorService service = Executors.newFixedThreadPool(2); - service.submit(new Runnable() { - @Override - public void run() { - FineEmbedServer.start(); - } - }); - service.submit(new Runnable() { - - @Override - public void run() { - try { - designer.show(args); - } finally { - DesignerContext.getDesignerFrame().getProgressDialog().dispose(); - } - } - }); - service.shutdown(); - DesignerContext.getDesignerFrame().setVisible(true); - //启动画面结束 - SplashContext.getInstance().hide(); - - DesignerContext.getDesignerFrame().getProgressDialog().setVisible(true); + startSub(DesignerShowActivator.class); startSub(StartFinishActivator.class); FineRuntime.startFinish(); } @@ -77,55 +33,6 @@ public class DesignerStartup extends Activator { } } - /** - * 注册切换环境前后事件监听 - */ - private void registerEnvListener() { - - /*切换环境前,关闭所有相关模块,最后执行*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MIN_VALUE) { - - @Override - public void on(Event event, Workspace current) { - getSub(EnvBasedModule.class).stop(); - } - }); - /*切换环境后,重新启动所有相关模块,最先执行*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MAX_VALUE) { - - @Override - public void on(Event event, Workspace current) { - getSub(EnvBasedModule.class).start(); - // 切换后的环境是本地环境才启动内置服务器 - if (current.isLocal()) { - ExecutorService service = Executors.newSingleThreadExecutor(); - service.submit(new Runnable() { - @Override - public void run() { - FineEmbedServer.start(); - } - }); - service.shutdown(); - } - } - }); - /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MAX_VALUE) { - @Override - public void on(Event event, Workspace workspace) { - HistoryTemplateListCache.getInstance().stash(); - } - }); - - /*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/ - listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MIN_VALUE) { - @Override - public void on(Event event, Workspace workspace) { - HistoryTemplateListCache.getInstance().load(); - } - }); - } - @Override public void stop() { diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java new file mode 100644 index 0000000000..e652cda6f8 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceActivator.java @@ -0,0 +1,93 @@ +package com.fr.start.module; + +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.event.Event; +import com.fr.event.Listener; +import com.fr.module.Activator; +import com.fr.start.server.FineEmbedServer; +import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.WorkspaceEvent; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * Created by juhaoyu on 2019-06-14. + */ +public class DesignerWorkspaceActivator extends Activator { + + @Override + public void start() { + + registerEnvListener(); + startServer(WorkContext.getCurrent()); + } + + /** + * 注册切换环境前后事件监听 + */ + private void registerEnvListener() { + + /*切换环境前,关闭所有相关模块,最后执行*/ + listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MIN_VALUE) { + + @Override + public void on(Event event, Workspace current) { + + getSub(EnvBasedModule.class).stop(); + } + }); + /*切换环境后,重新启动所有相关模块,最先执行*/ + listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MAX_VALUE) { + + @Override + public void on(Event event, Workspace current) { + + getSub(EnvBasedModule.class).start(); + startServer(current); + } + }); + /*切换环境前,存储一下打开的所有文件对象,要先于 关闭相关模块部分 被触发*/ + listenEvent(WorkspaceEvent.BeforeSwitch, new Listener(Integer.MAX_VALUE) { + + @Override + public void on(Event event, Workspace workspace) { + + HistoryTemplateListCache.getInstance().stash(); + } + }); + + /*切换环境后,装载一下打开的所有文件对象,优先级低于默认优先级,要后于 启动相关模块部分 被触发*/ + listenEvent(WorkspaceEvent.AfterSwitch, new Listener(Integer.MIN_VALUE) { + + @Override + public void on(Event event, Workspace workspace) { + + HistoryTemplateListCache.getInstance().load(); + } + }); + } + + private void startServer(Workspace current) { + + // 切换后的环境是本地环境才启动内置服务器 + if (current.isLocal()) { + ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("DesignerWorkspaceActivator")); + service.submit(new Runnable() { + + @Override + public void run() { + FineEmbedServer.start(); + } + }); + service.shutdown(); + } + } + + @Override + public void stop() { + + } +} diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index a6ba2c0095..e1779c3e24 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -2,6 +2,7 @@ package com.fr.start.module; import com.fr.design.DesignerEnvManager; import com.fr.design.EnvChangeEntrance; +import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.log.FineLoggerFactory; @@ -15,12 +16,12 @@ import com.fr.workspace.Workspace; * 设计器启动时的环境相关模块activator */ public class DesignerWorkspaceProvider extends Activator { - + @Override public void start() { //检查环境 DesignerEnvManager.checkNameEnvMap(); - + if (getModule().leftFindSingleton(StartupArgs.class) != null && getModule().leftFindSingleton(StartupArgs.class).isDemo()) { DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); } else { @@ -39,13 +40,12 @@ public class DesignerWorkspaceProvider extends Activator { EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(); } } + DesignerLaunchStatus.setStatus(DesignerLaunchStatus.WORKSPACE_INIT_COMPLETE); } - - + @Override public void stop() { - + } - - + } diff --git a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java index c4eea3bada..630f96b20e 100644 --- a/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/PreStartActivator.java @@ -2,12 +2,26 @@ package com.fr.start.module; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; +import com.fr.design.fun.OemProcessor; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.DesignUtils; +import com.fr.design.utils.DesignerPort; +import com.fr.event.EventDispatcher; import com.fr.general.CloudCenter; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; +import com.fr.module.ModuleEvent; +import com.fr.stable.BuildContext; +import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; +import com.fr.stable.StableUtils; +import com.fr.start.OemHandler; +import com.fr.start.SplashContext; +import com.fr.start.SplashStrategy; +import com.fr.start.fx.SplashFx; +import com.fr.start.jni.SplashMac; import java.io.File; @@ -16,38 +30,56 @@ import java.io.File; */ public class PreStartActivator extends Activator { - private static final int MESSAGE_PORT = 51462; - - private static final int DEBUG_PORT = 51463; - @Override public void start() { - CloudCenter.getInstance(); - if (checkMultiStart()) { + BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); + // 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了 + final String[] args = getModule().upFindSingleton(StartupArgs.class).get(); + // 检查是否是-Ddebug = true 启动 并切换对应的端口以及环境配置文件 + checkDebugStart(); + if (DesignUtils.isStarted()) { + DesignUtils.clientSend(args); + FineLoggerFactory.getLogger().info("The Designer Has Been Started"); + System.exit(0); return; } + + RestartHelper.deleteRecordFilesWhenStart(); + + SplashContext.getInstance().registerSplash(createSplash()); + + SplashContext.getInstance().show(); + //初始化 + EventDispatcher.fire(ModuleEvent.MajorModuleStarting, Toolkit.i18nText("Fine-Design_Basic_Initializing")); + // 完成初始化 + //noinspection ResultOfMethodCallIgnored + CloudCenter.getInstance(); + + // 创建监听服务 + DesignUtils.createListeningServer(DesignUtils.getPort(), startFileSuffix()); + initLanguage(); } - private boolean checkMultiStart() { - - if (isDebug()) { - setDebugEnv(); - } else { - DesignUtils.setPort(getStartPort()); - } + @Override + public void stop() { - return false; } - private int getStartPort() { + private void checkDebugStart() { - return MESSAGE_PORT; + if (isDebug()) { + setDebugEnv(); + } } - //在VM options里加入-Ddebug=true激活 + /** + * 在VM options里加入-Ddebug=true激活 + * + * @return isDebug + */ private boolean isDebug() { return ComparatorUtils.equals("true", System.getProperty("debug")); @@ -57,8 +89,13 @@ public class PreStartActivator extends Activator { //端口改一下,环境配置文件改一下。便于启动两个设计器,进行对比调试 private void setDebugEnv() { - DesignUtils.setPort(DEBUG_PORT); - DesignerEnvManager.setEnvFile(new File(ProductConstants.getEnvHome() + File.separator + ProductConstants.APP_NAME + "Env_debug.xml")); + DesignUtils.setPort(DesignerPort.DEBUG_MESSAGE_PORT); + String debugXMlFilePath = StableUtils.pathJoin( + ProductConstants.getEnvHome(), + ProductConstants.APP_NAME + "Env_debug.xml" + ); + DesignerEnvManager.setEnvFile( + new File(debugXMlFilePath)); } private void initLanguage() { @@ -66,8 +103,31 @@ public class PreStartActivator extends Activator { GeneralContext.setLocale(DesignerEnvManager.getEnvManager(false).getLanguage()); } - @Override - public void stop() { + private String[] startFileSuffix() { + + return new String[]{".cpt", ".xls", ".xlsx", ".frm", ".form", ".cht", ".chart"}; + } + private SplashStrategy createSplash() { + + OemProcessor oemProcessor = OemHandler.findOem(); + if (oemProcessor != null) { + SplashStrategy splashStrategy = null; + try { + splashStrategy = oemProcessor.createSplashStrategy(); + } catch (Throwable e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (splashStrategy != null) { + return splashStrategy; + } + } + // 这里可以开接口加载自定义启动画面 + if (OperatingSystem.isWindows()) { + return new SplashFx(); + } else if (OperatingSystem.isMacOS()) { + return new SplashMac(); + } + return new SplashFx(); } } diff --git a/designer-realize/src/main/java/com/fr/start/module/StartFinishActivator.java b/designer-realize/src/main/java/com/fr/start/module/StartFinishActivator.java index b9e165b264..41f662a880 100644 --- a/designer-realize/src/main/java/com/fr/start/module/StartFinishActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/StartFinishActivator.java @@ -1,36 +1,19 @@ package com.fr.start.module; import com.fr.design.fun.impl.GlobalListenerProviderManager; -import com.fr.design.utils.DesignUtils; import com.fr.module.Activator; /** * Created by juhaoyu on 2018/1/8. */ public class StartFinishActivator extends Activator { - - private static final int MESSAGE_PORT = 51462; - + @Override public void start() { - - DesignUtils.creatListeningServer(getStartPort(), startFileSuffix()); GlobalListenerProviderManager.getInstance().init(); } - - private int getStartPort() { - - return MESSAGE_PORT; - } - - - private String[] startFileSuffix() { - - return new String[]{".cpt", ".xls", ".xlsx", ".frm", ".form", ".cht", ".chart"}; - } - + @Override public void stop() { - } } diff --git a/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java b/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java index c53bbb6db0..1204f9a882 100644 --- a/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java +++ b/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java @@ -1,5 +1,6 @@ package com.fr.start.preload; +import com.fr.concurrent.NamedThreadFactory; import com.fr.general.IOUtils; import java.util.concurrent.ExecutorService; @@ -13,7 +14,7 @@ public class ImagePreLoader { public static final int THRESHOLD = 50; public ImagePreLoader() { - ExecutorService service = Executors.newCachedThreadPool(); + ExecutorService service = Executors.newCachedThreadPool(new NamedThreadFactory("ImagePreLoader")); int len = preLoadImages.length; int start = 0; diff --git a/designer-realize/src/main/resources/com/fr/design/images/splash_10_en.gif b/designer-realize/src/main/resources/com/fr/design/images/splash_10_en.gif new file mode 100644 index 0000000000..00b98250d3 Binary files /dev/null and b/designer-realize/src/main/resources/com/fr/design/images/splash_10_en.gif differ diff --git a/designer-realize/src/main/resources/com/fr/design/images/splash_10_jp.gif b/designer-realize/src/main/resources/com/fr/design/images/splash_10_jp.gif index 4f5d4ce0a8..860963c956 100644 Binary files a/designer-realize/src/main/resources/com/fr/design/images/splash_10_jp.gif and b/designer-realize/src/main/resources/com/fr/design/images/splash_10_jp.gif differ diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java new file mode 100644 index 0000000000..3b5bd1a14e --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/JFileTest.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe; + +import com.fr.config.dao.DaoContext; +import com.fr.config.dao.impl.LocalClassHelperDao; +import com.fr.config.dao.impl.LocalEntityDao; +import com.fr.config.dao.impl.LocalXmlEntityDao; +import com.fr.form.main.Form; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.general.ImageWithSuffix; +import com.fr.general.ModuleContext; +import com.fr.main.impl.WorkBook; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellImage; +import com.fr.report.restriction.CellCountRestriction; +import com.fr.report.restriction.ReportRestrictionScene; +import com.fr.report.worksheet.FormElementCase; +import com.fr.report.worksheet.WorkSheet; +import com.fr.restriction.Restrictions; +import com.fr.stable.module.Module; +import com.fr.start.Designer; +import junit.framework.TestCase; +import org.junit.Assert; + +import java.awt.image.BufferedImage; + +public class JFileTest extends TestCase { + @Override + protected void setUp() throws Exception { + DaoContext.setEntityDao(new LocalEntityDao()); + DaoContext.setClassHelperDao(new LocalClassHelperDao()); + DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); + Restrictions.register(ReportRestrictionScene.CELL_COUNT, new CellCountRestriction()); + ModuleContext.startModule(Module.PAGE_MODULE); + ModuleContext.startModule(Module.VIEW_MODULE); + Designer designer = new Designer(new String[0]); + } + + public void testJWorkBookSetPicture() { + WorkBook workBook = new WorkBook(); + WorkSheet workSheet = new WorkSheet(); + workBook.addReport("sheet1", workSheet); + TemplateCellElement cellElement = new DefaultTemplateCellElement(); + workSheet.addCellElement(cellElement); + ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); + CellImage cellImage = new CellImage(); + cellImage.setImage(imageWithSuffix); + JWorkBook jWorkBook = new JWorkBook(workBook, "text"); + jWorkBook.setPictureElem(cellElement, cellImage); + Assert.assertEquals(imageWithSuffix, cellElement.getValue()); + } + + public void testJFormSetPicture() { + Form form = new Form(); + ElementCaseEditor editor = new ElementCaseEditor(); + FormElementCase elementCase = new FormElementCase(); + TemplateCellElement cellElement = new DefaultTemplateCellElement(); + elementCase.addCellElement(cellElement); + editor.setElementCase(elementCase); + form.getContainer().addWidget(editor); + ImageWithSuffix imageWithSuffix = ImageWithSuffix.build(new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB), "jpg"); + CellImage cellImage = new CellImage(); + cellImage.setImage(imageWithSuffix); + JForm jForm = new JForm(); + jForm.setTarget(form); + jForm.setPictureElem(cellElement, cellImage); + Assert.assertEquals(imageWithSuffix, cellElement.getValue()); + } +} \ No newline at end of file diff --git a/designer-sdk/.gitignore b/designer-sdk/.gitignore new file mode 100644 index 0000000000..85184fbc39 --- /dev/null +++ b/designer-sdk/.gitignore @@ -0,0 +1,5 @@ +*.iml +.idea/ +.DS_Store +.classpath +.project \ No newline at end of file diff --git a/designer-sdk/pom.xml b/designer-sdk/pom.xml new file mode 100644 index 0000000000..9702536e22 --- /dev/null +++ b/designer-sdk/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + com.fr.report + design + 10.0 + + com.fr.report + designer-sdk + 10.0 + + + com.fr.report + designer-realize + 10.0 + + + com.fr.report + sdk-base + 10.0 + + + \ No newline at end of file diff --git a/designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java b/designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java new file mode 100644 index 0000000000..ea60edf74f --- /dev/null +++ b/designer-sdk/src/main/java/com/fr/sdk/designer/FineDesignUtils.java @@ -0,0 +1,80 @@ +package com.fr.sdk.designer; + +import com.fr.config.activator.ConfigurationActivator; +import com.fr.design.env.DesignerWorkspaceGenerator; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; +import com.fr.log.FineLoggerFactory; +import com.fr.module.Activator; +import com.fr.module.Module; +import com.fr.module.tool.ActivatorToolBox; +import com.fr.report.ReportActivator; +import com.fr.report.RestrictionActivator; +import com.fr.report.module.ReportBaseActivator; +import com.fr.scheduler.SchedulerActivator; +import com.fr.sdk.server.shell.ModuleShell; +import com.fr.serialization.SerializationActivator; +import com.fr.stable.StringUtils; +import com.fr.startup.WorkspaceRegister; +import com.fr.store.StateServerActivator; +import com.fr.workspace.WorkContext; +import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.WorkspaceActivator; +import com.fr.workspace.server.ServerWorkspaceRegister; + +/** + * 设计器SDK模块工具类,用来放一些设计器相关插件开发过程中常用的工具函数 + */ +public class FineDesignUtils { + + /** + * 创建一个连接远程服务器的模块 + * @param remoteUrl 远程服务器地址 + * @param username 用户名 + * @param password 密码 + * @return 模块代理对象 使用ModuleShell的start和stop控制模块启停 + */ + public static ModuleShell createRemoteServerModule(String remoteUrl, String username, String password) { + return createRemoteServerModule(remoteUrl, username, password, StringUtils.EMPTY, StringUtils.EMPTY); + } + + /** + * 创建一个连接远程服务器的模块 + * @param remoteUrl 远程服务器地址 + * @param username 用户名 + * @param password 密码 + * @param certPath https证书路径 + * @param certSecretKey 证书秘钥 + * @return 模块代理对象 使用ModuleShell的start和stop控制模块启停 + */ + public static ModuleShell createRemoteServerModule(final String remoteUrl, final String username, final String password, final String certPath, final String certSecretKey) { + Module module = ActivatorToolBox.simpleLink( + new WorkspaceActivator(), + new SerializationActivator(), + new Activator() { + @Override + public void start() { + WorkspaceConnectionInfo connectionInfo = new WorkspaceConnectionInfo(remoteUrl, username, password, certPath, certSecretKey); + try { + WorkContext.switchTo(DesignerWorkspaceGenerator.generate(RemoteDesignerWorkspaceInfo.create(connectionInfo))); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(),e); + } + } + + @Override + public void stop() { + + } + }, + new ConfigurationActivator(), + new StateServerActivator(), + new SchedulerActivator(), + new ReportBaseActivator(), + new RestrictionActivator(), + new ReportActivator(), + new WorkspaceRegister(), + new ServerWorkspaceRegister() + ); + return new ModuleShell(module); + } +} \ No newline at end of file diff --git a/designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java b/designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java new file mode 100644 index 0000000000..ec210321b9 --- /dev/null +++ b/designer-sdk/src/test/java/com/fr/sdk/FineDesignUtilsTest.java @@ -0,0 +1,7 @@ +package com.fr.sdk; + +import junit.framework.TestCase; + +public class FineDesignUtilsTest extends TestCase { + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 408bc7be85..407f1fd17b 100644 --- a/pom.xml +++ b/pom.xml @@ -16,6 +16,7 @@ designer-chart designer-form designer-realize + designer-sdk com.fr.report design