diff --git a/designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java b/designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java new file mode 100644 index 0000000000..310e75dce0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/common/detect/CommonPortDetector.java @@ -0,0 +1,59 @@ +package com.fr.common.detect; + +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.DesignerEnvManager; +import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleContext; +import com.fr.web.WebSocketConfig; + +import java.net.Socket; +import java.util.concurrent.ExecutorService; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/10 + */ +public class CommonPortDetector { + + private static final CommonPortDetector INSTANCE = new CommonPortDetector(); + private ExecutorService service = ModuleContext.getExecutor().newSingleThreadExecutor(new NamedThreadFactory("CommonPortDetector")); + + public static CommonPortDetector getInstance() { + return INSTANCE; + } + + public void execute() { + service.submit(new Runnable() { + @Override + public void run() { + detectTomcatPort(); + detectWebSocketPort(); + } + }); + } + + private void detectTomcatPort() { + int port = DesignerEnvManager.getEnvManager().getEmbedServerPort(); + if (checkPort(port)) { + FineLoggerFactory.getLogger().error("EmbedTomcat Port: {} is not available, maybe occupied by other programs, please check it!", port); + } + } + + private void detectWebSocketPort() { + Integer[] ports = WebSocketConfig.getInstance().getPort(); + for (int port : ports) { + if (checkPort(port)) { + FineLoggerFactory.getLogger().error("WebSocKet Port: {} is not available, maybe occupied by other programs, please check it!", port); + } + } + } + + private boolean checkPort(int port) { + try (Socket socket = new Socket("localhost", port)) { + return true; + } catch (Exception e) { + return false; + } + } +} diff --git a/designer-base/src/main/java/com/fr/common/report/ReportState.java b/designer-base/src/main/java/com/fr/common/report/ReportState.java new file mode 100644 index 0000000000..cc32e439cf --- /dev/null +++ b/designer-base/src/main/java/com/fr/common/report/ReportState.java @@ -0,0 +1,21 @@ +package com.fr.common.report; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/27 + */ +public enum ReportState { + + STOP("stop"), ACTIVE("active"); + + private String value; + + ReportState(String value) { + this.value = value; + } + + public String getValue() { + return this.value; + } +} \ No newline at end of file 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 48c5576bcc..9d59ef187a 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -1,5 +1,6 @@ package com.fr.design; +import com.fr.common.report.ReportState; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -14,7 +15,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.DesignUtils; -import com.fr.design.write.submit.CheckServiceDialog; +import com.fr.env.CheckServiceDialog; import com.fr.env.EnvListPane; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralContext; @@ -24,9 +25,13 @@ import com.fr.json.JSONArray; import com.fr.license.exception.RegistEditionException; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; import com.fr.rpc.Result; import com.fr.stable.AssistUtils; import com.fr.stable.EnvChangedListener; +import com.fr.stable.StringUtils; import com.fr.start.server.ServerTray; import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContextCallback; @@ -43,7 +48,11 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.lang.reflect.Method; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Set; @@ -127,6 +136,11 @@ public class EnvChangeEntrance { } } }); + // REPORT-25688如果是war包部署的服务器,给与提示 + if (WorkContext.getCurrent().isWarDeploy()) { + FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Message"), JOptionPane.INFORMATION_MESSAGE); + } //REPORT-13810如果只是添加了工作目录,没有切换,这里ToolArea也是要显示新建的工作目录 JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); if (template != null) { @@ -209,6 +223,53 @@ public class EnvChangeEntrance { return true; } + /** + * 对选择的环境做服务检测 + * @param selectedEnv 选择的工作环境 + */ + public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { + //是否需要做服务校验 + if(needCheckBranch(selectedEnv)) { + String localBranch; + String remoteBranch; + WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); + localBranch = GeneralUtils.readFullBuildNO(); + try { + remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch(); + } catch (WorkspaceConnectionException e) { + remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(localBranch); + } + //通过是否包含#来避免当前版本为非安装版本(主要是内部开发版本) + if (localBranch.contains("#") && localBranch.equals(remoteBranch)) { + //说明版本一致,仅做日志记录 + FineLoggerFactory.getLogger().info("Remote Designer version consistency"); + } else { + localBranch = formatBranch(localBranch); + remoteBranch = formatBranch(remoteBranch); + Set noExistServiceSet = getNoExistServiceSet(connectionInfo); + StringBuilder textBuilder = new StringBuilder(); + for (Class clazz : noExistServiceSet) { + WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); + if(workspaceAPI == null){ + FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz); + continue; + } + if(workspaceAPI.ignore()){ + continue; + } + String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); + textBuilder.append(descriptionOfCN).append("\n"); + } + String areaText = textBuilder.toString(); + if(StringUtils.isEmpty(areaText)){ + return; + } + CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch); + dialog.setVisible(true); + } + } + } + /** * 对选择的环境做服务检测 * @param selectedEnv 选择的工作环境 @@ -249,12 +310,32 @@ public class EnvChangeEntrance { /** * 判断是否需要做版本验证,判断依据为 * 1、选择的环境为远程环境 - * 2、一个月内不弹出是否勾选(这里预留,还未实际增加) + * 2、一个月内不弹出是否勾选 * @param selectedEnv 选择的环境 * @return */ private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv){ - return selectedEnv.getType() == DesignerWorkspaceType.Remote; + if(selectedEnv.getType() == DesignerWorkspaceType.Remote){ + try { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar calendar = Calendar.getInstance(); + if(StringUtils.isEmpty(selectedEnv.getRemindTime())){ + return true; + } + //获取记录的时间 + Date remindTime = format.parse(selectedEnv.getRemindTime()); + calendar.setTime(remindTime); + //获取一个月后的时间 + calendar.add(Calendar.MONTH,1); + //与当前时间作对比,然后判断是否提示 + if(new Date().after(calendar.getTime())){ + return true; + } + } catch (ParseException e) { + return true; + } + } + return false; } /** @@ -304,7 +385,7 @@ public class EnvChangeEntrance { return noExistServiceSet; } catch (Exception e){ FineLoggerFactory.getLogger().error(e.getMessage(),e); - return null; + return noExistServiceSet; } } @@ -315,7 +396,7 @@ public class EnvChangeEntrance { */ private String formatBranch(String branch){ if(branch.contains("#")){ - return branch.substring(branch.lastIndexOf("#") + 1, branch.length() - 13); + return branch.substring(branch.lastIndexOf("-") + 1, branch.length() - 13); } return branch; } @@ -360,6 +441,10 @@ public class EnvChangeEntrance { * 处理异常 */ public void dealEvnExceptionWhenStartDesigner() { + ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); + if (eventPipe != null) { + eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); + } final EnvListPane envListPane = new EnvListPane(); envListPane.populateEnvManager(currentEnvName); BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame())); @@ -367,6 +452,7 @@ public class EnvChangeEntrance { @Override public void doOk() { + FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue())); if (!envListOkAction(envListPane, PopTipStrategy.NOW)) { DesignerExiter.getInstance().execute(); } @@ -374,7 +460,8 @@ public class EnvChangeEntrance { @Override public void doCancel() { - DesignerExiter.getInstance().execute(); } + DesignerExiter.getInstance().execute(); + } }); envListDialog.setVisible(true); } diff --git a/designer-base/src/main/java/com/fr/design/RestartHelper.java b/designer-base/src/main/java/com/fr/design/RestartHelper.java index 596257d70c..64fdda7baa 100644 --- a/designer-base/src/main/java/com/fr/design/RestartHelper.java +++ b/designer-base/src/main/java/com/fr/design/RestartHelper.java @@ -153,7 +153,14 @@ public class RestartHelper { } finally { WorkContext.getCurrent().close(); frame.dispose(); - DesignerExiter.getInstance().execute(); + try { + // 更新升级过渡用 供当前测试 后面可删除 + Class.forName("com.fr.exit.DesignerExiter"); + DesignerExiter.getInstance().execute(); + } catch (Exception ignore) { + } finally { + System.exit(0); + } } } @@ -195,7 +202,11 @@ public class RestartHelper { } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } - DesignerContext.getDesignerFrame().exit(); + if (DesignerContext.getDesignerFrame() != null) { + DesignerContext.getDesignerFrame().exit(); + } else { + DesignerExiter.getInstance().execute(); + } } } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java b/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java index ff62c6fb81..600f9721ed 100644 --- a/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java @@ -42,11 +42,15 @@ public class TableDataSourceAction extends TemplateComponentAction[] cls) { + if (cls != null) { + actionClasses.clear(); + Collections.addAll(actionClasses, cls); + } + } + /** * 生成单元格插入相关的Action * 表单中报表块编辑需要屏蔽掉"插入子报表" @@ -318,6 +325,13 @@ public class ActionFactory { } } + public static void referFloatInsertActionClass(Class[] cls) { + if (cls != null) { + floatActionClasses.clear(); + Collections.addAll(floatActionClasses, cls); + } + } + /** * 生成悬浮元素插入相关的Action * 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 207bdf36dd..57d9bbcb9a 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 @@ -28,6 +28,7 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.common.VcsHelper; import com.fr.design.os.impl.SupportOSImpl; +import com.fr.design.unit.UnitConvertUtil; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.general.ComparatorUtils; @@ -38,6 +39,7 @@ import com.fr.general.log.Log4jConfig; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; +import com.fr.stable.os.OperatingSystem; import com.fr.third.apache.log4j.Level; import com.fr.transaction.Configurations; import com.fr.transaction.Worker; @@ -148,9 +150,6 @@ public class PreferencePane extends BasicPane { private UIColorButton paginationLineColorTBButton; - private UICheckBox supportCellEditorDefCheckBox; - private UICheckBox isDragPermitedCheckBox; - private UITextField logExportDirectoryField; private UIComboBox logLevelComboBox, pageLengthComboBox, reportLengthComboBox; @@ -198,7 +197,6 @@ public class PreferencePane extends BasicPane { createFunctionPane(generalPane); createEditPane(generalPane); - createGuiOfGridPane(generalPane); createColorSettingPane(generalPane); createVcsSettingPane(generalPane); @@ -218,15 +216,17 @@ public class PreferencePane extends BasicPane { oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oraclePane.add(oracleSpace); - JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); - useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); - upmSelectorPane.add(useOptimizedUPMCheckbox); - advancePane.add(upmSelectorPane); + if (!OperatingSystem.isLinux()) { + JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); + useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); + upmSelectorPane.add(useOptimizedUPMCheckbox); + advancePane.add(upmSelectorPane); + } JPanel dbmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Database_Manager")); useUniverseDBMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_Universe_Database_Manager")); - dbmSelectorPane.add(useUniverseDBMCheckbox); - advancePane.add(dbmSelectorPane); + //dbmSelectorPane.add(useUniverseDBMCheckbox); + //advancePane.add(dbmSelectorPane); JPanel improvePane = FRGUIPaneFactory.createVerticalTitledBorderPane(i18nText("Fine-Design_Basic_Product_Improve")); joinProductImproveCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Join_Product_Improve")); @@ -444,18 +444,6 @@ public class PreferencePane extends BasicPane { } - private void createGuiOfGridPane(JPanel generalPane) { - // GridPane - JPanel guiOfGridPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Grid")); - generalPane.add(guiOfGridPane); - - supportCellEditorDefCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Support_Cell_Editor_Definition")); - guiOfGridPane.add(supportCellEditorDefCheckBox); - - isDragPermitedCheckBox = new UICheckBox(i18nText("Fine-Design_Basic_Preference_Is_Drag_Permited")); - guiOfGridPane.add(isDragPermitedCheckBox); - } - private void createColorSettingPane(JPanel generalPane) { // Color Setting Pane JPanel colorSettingPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Preference_Setting_Colors")); @@ -588,7 +576,7 @@ public class PreferencePane extends BasicPane { pageLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH")}); pageLengthComboBox.setPreferredSize(new Dimension(80, 20)); pageLengthComboBox.setMinimumSize(new Dimension(80, 20)); - reportLengthComboBox = new UIComboBox(new String[]{i18nText("Fine-Design_Basic_Page_Setup_MM"), i18nText("Fine-Design_Report_Unit_CM"), i18nText("Fine-Design_Report_Unit_INCH"), i18nText("Fine-Design_Report_Unit_PT_Duplicate")}); + reportLengthComboBox = new UIComboBox(UnitConvertUtil.getUnitItems()); reportLengthComboBox.setPreferredSize(new Dimension(80, 20)); reportLengthComboBox.setMinimumSize(new Dimension(80, 20)); UILabel pagelengthLabel = new UILabel(i18nText("Fine-Design_Basic_Page_Setup_Scale_Units") + ":"); @@ -693,9 +681,6 @@ public class PreferencePane extends BasicPane { useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval()); gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable()); gcButton.setEnabled(gcEnableCheckBox.isSelected()); - supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef()); - - isDragPermitedCheckBox.setSelected(designerEnvManager.isDragPermited()); gridLineColorTBButton.setColor(designerEnvManager.getGridLineColor()); paginationLineColorTBButton.setColor(designerEnvManager.getPaginationLineColor()); @@ -711,7 +696,9 @@ public class PreferencePane extends BasicPane { this.portEditor.setValue(new Integer(designerEnvManager.getEmbedServerPort())); - useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); + if (useOptimizedUPMCheckbox != null) { + useOptimizedUPMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseOptimizedUPM()); + } useUniverseDBMCheckbox.setSelected(ServerPreferenceConfig.getInstance().isUseUniverseDBM()); @@ -763,12 +750,8 @@ public class PreferencePane extends BasicPane { designerEnvManager.setDefaultStringToFormula(defaultStringToFormulaBox.isSelected()); - designerEnvManager.setSupportCellEditorDef(supportCellEditorDefCheckBox.isSelected()); - designerEnvManager.setAutoCompleteShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : shortCutLabel.getText()); - designerEnvManager.setDragPermited(isDragPermitedCheckBox.isSelected()); - designerEnvManager.setGridLineColor(gridLineColorTBButton.getColor()); designerEnvManager.setPaginationLineColor(paginationLineColorTBButton.getColor()); @@ -832,7 +815,9 @@ public class PreferencePane extends BasicPane { Configurations.update(new Worker() { @Override public void run() { - ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected()); + if (useOptimizedUPMCheckbox != null) { + ServerPreferenceConfig.getInstance().setUseOptimizedUPM(useOptimizedUPMCheckbox.isSelected()); + } ServerPreferenceConfig.getInstance().setUseUniverseDBM(useUniverseDBMCheckbox.isSelected()); } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java index b8acba9fe2..3ede159504 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/AboutPane.java @@ -72,11 +72,11 @@ public class AboutPane extends JPanel { addPhoneAndQQPane(contentPane); // 官网 - JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), CloudCenter.getInstance().acquireUrlByKind("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL)); + JPanel urlActionPane = getURLActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Official_Website"), CloudCenter.getInstance().acquireConf("website." + GeneralContext.getLocale(), ProductConstants.WEBSITE_URL)); // 支持邮箱 - String defaultEmail = CloudCenter.getInstance().acquireUrlByKind("support.email", ProductConstants.SUPPORT_EMAIL); - JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Email"), CloudCenter.getInstance().acquireUrlByKind("support.email." + GeneralContext.getLocale(), defaultEmail)); + String defaultEmail = CloudCenter.getInstance().acquireConf("support.email", ProductConstants.SUPPORT_EMAIL); + JPanel emailPane = getEmailActionPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Support_Email"), CloudCenter.getInstance().acquireConf("support.email." + GeneralContext.getLocale(), defaultEmail)); contentPane.add(urlActionPane); contentPane.add(emailPane); @@ -96,7 +96,7 @@ public class AboutPane extends JPanel { if (GeneralContext.getLocale().equals(Locale.US)) { return; } - boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Service_Phone") + CloudCenter.getInstance().acquireUrlByKind("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE)); + boxCenterAlignmentPane = new BoxCenterAligmentPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Service_Phone") + CloudCenter.getInstance().acquireConf("service.phone." + FRContext.getLocale(), COMPANY_TELEPHONE)); contentPane.add(boxCenterAlignmentPane); // 繁体版不显示QQ if (GeneralContext.getLocale().equals(Locale.TAIWAN)) { @@ -176,7 +176,7 @@ public class AboutPane extends JPanel { private String getCopyRight() { return append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_About_CopyRight"), COPYRIGHT_LABEL, - ProductConstants.HISTORY, StringUtils.BLANK, CloudCenter.getInstance().acquireUrlByKind("company.name", ProductConstants.COMPANY_NAME)); + ProductConstants.HISTORY, StringUtils.BLANK, CloudCenter.getInstance().acquireConf("company.name", ProductConstants.COMPANY_NAME)); } private String getBuildTitle() { diff --git a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java index deef91f0c7..0e9db97c7a 100644 --- a/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java @@ -27,6 +27,7 @@ import com.fr.transaction.Worker; import com.fr.transaction.WorkerFacade; import javax.swing.KeyStroke; +import java.awt.*; import java.awt.event.ActionEvent; import java.util.HashMap; import java.util.Map; @@ -35,7 +36,8 @@ import java.util.Map; * Global TableData. */ public class GlobalTableDataAction extends UpdateAction implements ResponseDataSourceChange { - //private static TableDataManagerPane globalTableDataPane = new TableDataManagerPane(); + + private static final Dimension DEFAULT_DIMENSION = new Dimension(1000, 600); public GlobalTableDataAction() { this.setMenuKeySet(SERVER_TABLEDATA); @@ -77,20 +79,10 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS } protected void renameConnection(final String oldName, final String newName) { - Configurations.update(new Worker() { - @Override - public void run() { - tableDataConfig.renameTableData(oldName, newName); - } - - @Override - public Class[] targets() { - return new Class[]{TableDataConfig.class, ProcedureConfig.class}; - } - }); + tableDataConfig.renameTableData(oldName, newName); } }; - final BasicDialog globalTableDataDialog = globalTableDataPane.showLargeWindow(designerFrame, null); + final BasicDialog globalTableDataDialog = globalTableDataPane.showWindowWithCustomSize(designerFrame, null, DEFAULT_DIMENSION); globalTableDataDialog.addDialogActionListener(new DialogActionAdapter() { diff --git a/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java b/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java new file mode 100644 index 0000000000..e9b6b3e0f3 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/base/clipboard/ClipboardFilter.java @@ -0,0 +1,50 @@ +package com.fr.design.base.clipboard; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.ClipboardHandlerProvider; +import com.fr.plugin.injectable.PluginModule; + +import java.util.Set; + +/** + * created by Harrison on 2020/05/14 + **/ +@SuppressWarnings({"rawtypes", "unchecked"}) +public abstract class ClipboardFilter { + + public static T cut(T selection) { + + ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); + for (ClipboardHandlerProvider provider : providers) { + if (provider.support(selection)) { + selection = ((ClipboardHandlerProvider) provider).cut(selection); + } + } + return selection; + } + + public static T copy(T selection) { + + ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); + for (ClipboardHandlerProvider provider : providers) { + if (provider.support(selection)) { + selection = ((ClipboardHandlerProvider) provider).copy(selection); + } + } + return selection; + } + + public static T paste(T selection) { + + ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = manager.getArray(ClipboardHandlerProvider.XML_TAG); + for (ClipboardHandlerProvider provider : providers) { + if (provider.support(selection)) { + selection = ((ClipboardHandlerProvider) provider).paste(selection); + } + } + return selection; + } +} diff --git a/designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java b/designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java new file mode 100644 index 0000000000..76ae081d7b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/base/clipboard/DesignerClipboard.java @@ -0,0 +1,68 @@ +package com.fr.design.base.clipboard; + +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.ClipboardOwner; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.FlavorListener; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; + +/** + * created by Harrison on 2020/05/11 + **/ +public class DesignerClipboard extends Clipboard { + + private Clipboard clipboard; + + public DesignerClipboard(Clipboard clipboard) { + super(clipboard.getName()); + this.clipboard = clipboard; + } + + @Override + public synchronized void setContents(Transferable contents, ClipboardOwner owner) { + //处理 contents/owner + Transferable filtered = ClipboardFilter.copy(contents); + clipboard.setContents(filtered, owner); + } + + @Override + public synchronized Transferable getContents(Object requestor) { + Transferable contents = clipboard.getContents(requestor); + //处理 contents + Transferable filtered = ClipboardFilter.paste(contents); + return filtered; + } + + @Override + public DataFlavor[] getAvailableDataFlavors() { + return clipboard.getAvailableDataFlavors(); + } + + @Override + public boolean isDataFlavorAvailable(DataFlavor flavor) { + return clipboard.isDataFlavorAvailable(flavor); + } + + @Override + public Object getData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { + return clipboard.getData(flavor); + } + + @Override + public synchronized void addFlavorListener(FlavorListener listener) { + clipboard.addFlavorListener(listener); + } + + @Override + public synchronized void removeFlavorListener(FlavorListener listener) { + clipboard.removeFlavorListener(listener); + } + + @Override + public synchronized FlavorListener[] getFlavorListeners() { + return clipboard.getFlavorListeners(); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index 1e119d27ed..15a7c87c08 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -145,7 +145,6 @@ public interface UIConstants { public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3); - public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); public static final BufferedImage ARROW_NORTH = IOUtils.readImage("com/fr/design/images/control/up_arrow.png"); @@ -196,6 +195,7 @@ public interface UIConstants { public static final Icon ANA_SMALL_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/anas.png"); public static final Icon REFRESH_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/refresh.png"); public static final Icon FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/foreground.png"); + public static final Icon AUTO_FONT_ICON = IOUtils.readIcon("/com/fr/design/images/gui/color/autoForeground.png"); public static final Icon HISTORY_ICON = IOUtils.readIcon("com/fr/design/images/buttonicon/history.png"); public static final Icon DELETE_ICON = IOUtils.readIcon("com/fr/design/images/m_file/close.png"); public static final Icon EDIT_ICON = IOUtils.readIcon("com/fr/design/images/m_file/edit.png"); 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 45b3ac6a2a..e8bc8e39ab 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 @@ -137,6 +137,8 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp nPanel.setShowText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Stored_Procedure_Name_Tips")); dg.setButtonEnabled(false); } + } else if (!BasicTableDataUtils.checkName(tempName)) { + dg.setButtonEnabled(false); } else { nPanel.setShowText(StringUtils.BLANK); dg.setButtonEnabled(true); diff --git a/designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java b/designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java new file mode 100644 index 0000000000..27724450bb --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java @@ -0,0 +1,36 @@ +package com.fr.design.data; + +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.StringUtils; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/4/27 + */ +public abstract class BasicTableDataUtils { + + private static final int LEN = 2; + + + public static boolean checkName(String name) { + if (isInValidName(name)) { + FineJOptionPane.showMessageDialog(null, + Toolkit.i18nText("Fine-Design_Basic_DataSet_Rename_Warning", name), + Toolkit.i18nText("Fine-Design_Basic_Alert"), + FineJOptionPane.WARNING_MESSAGE); + return false; + } + return true; + } + + public static boolean isInValidName(String name) { + String[] values = name.split("\\."); + if (values.length == LEN) { + return (StringUtils.isNotEmpty(values[0]) && StringUtils.isNotEmpty(values[1])) + || (StringUtils.isEmpty(values[0]) && StringUtils.isNotEmpty(values[1])); + } + return false; + } +} 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 25492c55ed..dc7002fa85 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 @@ -114,6 +114,7 @@ public abstract class DesignTableDataManager { public static void closeTemplate(JTemplate template) { if (template != null) { + template.whenClose(); columnCache.remove(getEditingTableDataSource()); dsListenersMap.remove(template.getPath()); } @@ -247,6 +248,15 @@ public abstract class DesignTableDataManager { } } + public static String[] getDsColumnNames(String dsName) { + TableDataSource dataSource = getEditingTableDataSource(); + Map map = columnCache.get(dataSource); + if (map == null) { + return new String[0]; + } + return map.get(dsName); + } + /** * august:返回当前正在编辑的具有报表数据源的模板(基本报表、聚合报表) 包括 : 图表模板 * 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 eda6414671..52ed6861b1 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 @@ -1,12 +1,10 @@ package com.fr.design.data.datapane; -import com.fr.base.BaseUtils; import com.fr.base.TableData; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.dialect.DialectFactory; -import com.fr.data.impl.Connection; import com.fr.data.impl.DBTableData; import com.fr.data.operator.DataOperator; import com.fr.design.DesignerEnvManager; @@ -37,6 +35,7 @@ import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; +import com.fr.workspace.server.connection.DBConnectAuth; import javax.swing.JList; import javax.swing.JOptionPane; @@ -61,9 +60,10 @@ import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; +import java.util.Collection; import java.util.Enumeration; import java.util.List; -import java.util.Map; +import java.util.Set; /** * @author zhou @@ -210,10 +210,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha @SuppressWarnings("unchecked") protected void initDsNameComboBox() { dsNameComboBox.setRefreshingModel(true); - ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); - List dsList = new ArrayList<>(); - dsList.addAll(connectionConfig.getConnections().keySet()); - FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(dsList); + FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections()); dsNameComboBox.setModel(dsNameComboBoxModel); dsNameComboBox.setRefreshingModel(false); } @@ -322,14 +319,31 @@ public class ChoosePane extends BasicBeanPane implements Refresha return null; // peter:选中了当前的零长度的节点,直接返回. } ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); - for (Map.Entry entry : connectionConfig.getConnections().entrySet()) { - if (ComparatorUtils.equals(selectedDSName, entry.getKey())) { - return entry.getValue(); + List authConnections = getHasAuthConnections(); + for (String name : authConnections) { + if (ComparatorUtils.equals(selectedDSName, name)) { + return connectionConfig.getConnection(name); } } return null; } + private List getHasAuthConnections() { + List authConnections = new ArrayList<>(); + Set allConnections = ConnectionConfig.getInstance().getConnections().keySet(); + Collection noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections(); + if (noAuthConnections == null) { + return authConnections; + } + + for (String name : allConnections) { + if (!noAuthConnections.contains(name)) { + authConnections.add(name); + } + } + return authConnections; + } + /** * 刷新没多大用。而且要刷新也不是这儿刷新。 */ diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java index b480e168c4..79c160489b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ReportTableDataPane.java @@ -59,4 +59,8 @@ public class ReportTableDataPane extends LoadingBasicPane { public Map getDsNameChangedMap() { return tdPane.getDsNameChangedMap(); } + + public boolean isNamePermitted() { + return tdPane.isNamePermitted(); + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java index 533139b376..dcb38c14ee 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java @@ -35,6 +35,7 @@ public class TableDataCreatorProducer { "ds", "/com/fr/design/images/data/database.png", DBTableData.class, DBTableDataPane.class); TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), + "Class", "/com/fr/design/images/data/source/classTableData.png", ClassTableData.class, ClassTableDataPane.class); TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), "Embedded", @@ -60,6 +61,7 @@ public class TableDataCreatorProducer { "Proc", "/com/fr/design/images/data/store_procedure.png", StoreProcedure.class, ProcedureDataPane.class) { + @Override public boolean shouldInsertSeparator() { return true; } @@ -92,6 +94,7 @@ public class TableDataCreatorProducer { }; TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png", StoreProcedure.class, ProcedureDataPane.class) { + @Override public boolean shouldInsertSeparator() { return true; } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java index a90f7a1263..3f0f08f35c 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataNameObjectCreator.java @@ -5,10 +5,13 @@ import com.fr.data.impl.DBTableData; import com.fr.design.actions.tabledata.TableDataAction; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.controlpane.NameObjectCreator; +import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.icon.WarningIcon; import com.fr.general.ComparatorUtils; +import com.fr.general.NameObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; +import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import javax.swing.Icon; @@ -95,6 +98,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator { * * @return 图片 */ + @Override public Icon menuIcon() { return createMenuIcon(); } @@ -112,6 +116,7 @@ public class TableDataNameObjectCreator extends NameObjectCreator { * * @return 提示 */ + @Override public String createTooltip() { return b ? com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Connect_SQL_Cannot_Null") : null; } @@ -166,11 +171,21 @@ public class TableDataNameObjectCreator extends NameObjectCreator { return false; } + @Override public boolean equals(Object obj) { return obj instanceof TableDataNameObjectCreator && ComparatorUtils.equals(menuName, ((TableDataNameObjectCreator) obj).menuName); } + @Override + public Nameable createNameable(UnrepeatedNameHelper helper) { + try { + return new NameObject(helper.createUnrepeatedName(this.getPrefix()), clazzOfInitCase.newInstance()); + } catch (InstantiationException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + @Override public int hashCode() { return menuName == null ? 0 : menuName.hashCode(); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java index 437334c530..1dd1f00aa0 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -4,6 +4,7 @@ import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.api.StoreProcedureAssist; import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; @@ -14,6 +15,7 @@ import com.fr.file.ProcedureConfig; import com.fr.file.TableDataConfig; import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; +import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; @@ -47,6 +49,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; String tempName = getEditingName(); Object editingType = getEditingType(); + + if (!BasicTableDataUtils.checkName(tempName)) { + isNamePermitted = false; + nameableList.stopEditing(); + setIllegalIndex(editingIndex); + return; + } + if (StringUtils.isEmpty(tempName)) { isNamePermitted = false; nameableList.stopEditing(); @@ -69,7 +79,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } if (nameableList.getSelectedValue() instanceof ListModelElement) { Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; - if (!ComparatorUtils.equals(tempName, selected.getName())) { + if (!ComparatorUtils.equals(tempName, selected.getName()) && !isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { rename(selected.getName(), tempName); } @@ -133,36 +143,28 @@ public class TableDataPaneListPane extends JListControlPane implements TableData return super.createUnrepeatedName(prefix); } String[] allDsNames = DesignTableDataManager.getAllDSNames(source); + + // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. + int count = 1; + while (isDsNameRepeated(prefix + count, allDsNames)) { + count++; + } + return prefix + count; + } + + private boolean isDsNameRepeated(String name, String[] allDsNames) { DefaultListModel model = this.getModel(); Nameable[] all = new Nameable[model.getSize()]; for (int i = 0; i < model.size(); i++) { all[i] = ((ListModelElement) model.get(i)).wrapper; } - // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. - int count = all.length + 1; - while (true) { - String name_test = prefix + count; - boolean repeated = false; - for (int i = 0, len = model.size(); i < len; i++) { - Nameable nameable = all[i]; - if (ComparatorUtils.equals(nameable.getName(), name_test)) { - repeated = true; - break; - } - } - for (String dsname : allDsNames) { - if (ComparatorUtils.equals(dsname, name_test)) { - repeated = true; - break; - } - } - - if (!repeated) { - return name_test; + for (int i = 0, len = model.size(); i < len; i++) { + Nameable nameable = all[i]; + if (ComparatorUtils.equals(nameable.getName(), name)) { + return true; } - - count++; } + return ArrayUtils.contains(allDsNames, name); } @Override diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java index 1e0d2c77e4..8b5c626571 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java @@ -2,6 +2,7 @@ package com.fr.design.data.datapane; import com.fr.data.TableDataSource; import com.fr.data.impl.RecursionTableData; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; @@ -70,8 +71,14 @@ public class TreeTableDataComboBox extends UIComboBox { } public void setSelectedTableDataByName(String name) { - TableDataWrapper tableDataWrappe = res_map.get(name); - this.getModel().setSelectedItem(tableDataWrappe); + TableDataWrapper tableDataWrapper; + if (res_map.get(name) != null) { + tableDataWrapper = res_map.get(name); + } else { + String changeName = DesignTableDataManager.getChangedDsNameByOldDsName(name); + tableDataWrapper = res_map.get(changeName); + } + this.getModel().setSelectedItem(tableDataWrapper); } @Override 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 e7be5bf338..6ad281e268 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 @@ -238,13 +238,10 @@ 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(wrapMaxPanel); + editToolBar.add(maxPanel); return editToolBar; } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java index 6a3b707ab0..ba5d42bd88 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataDefinedPane.java @@ -25,7 +25,7 @@ import java.util.Date; public class EmbeddedTableDataDefinedPane extends BasicPane{ - + private static final int MIN_CELL_WIDTH = 30; private EmbeddedTableData tableData; private JTable dataJTable; private UIButton add; @@ -64,7 +64,7 @@ public class EmbeddedTableDataDefinedPane extends BasicPane{ // 行号显示 TableColumn tableColumn = dataJTable.getColumnModel().getColumn(0); tableColumn.setCellRenderer(new CellRenderer()); - tableColumn.setMaxWidth(dataJTable.getColumnCount()); + tableColumn.setMaxWidth(Math.max(dataJTable.getColumnCount(), MIN_CELL_WIDTH)); // 控制按钮 add = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Add")); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java index afefe7264a..8b47b222d6 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/EmbeddedTableDataPane.java @@ -34,6 +34,7 @@ import java.util.Date; public class EmbeddedTableDataPane extends AbstractTableDataPane { + private static final int MIN_CELL_WIDTH = 30; private JTable dataJTable ; private JScrollPane scrollPane; private UILabel coordinatelabel; @@ -220,7 +221,7 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane 200 ? 350 : 250; + + private static int getMaxComBoBoxWidth() { + int maxWidth = GraphHelper.getWidth(CACHE_LIST[0]); + for (int i = 1; i < CACHE_LIST.length; i++) { + int width = GraphHelper.getWidth(CACHE_LIST[i]); + if (width > maxWidth) { + maxWidth = width; + } + } + return maxWidth; + } private UISpinner numberSpinner; private UIComboBox switchCache; @@ -44,7 +59,7 @@ public class MaxMemRowCountPanel extends UIToolbar { @Override public Dimension getPreferredSize() { Dimension dim = super.getPreferredSize(); - dim.width = 340; + dim.width = MAX_WIDTH; return dim; }; @@ -52,8 +67,7 @@ public class MaxMemRowCountPanel extends UIToolbar { this.setFloatable(false); this.setRollover(true); this.setBackground(UIConstants.NORMAL_BACKGROUND); - String[] cacheList = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Save_All_Records_In_Memory"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Max_Mem_Row_Count") }; - switchCache = new UIComboBox(cacheList); + switchCache = new UIComboBox(CACHE_LIST); switchCache.addActionListener(switchStateL); numberSpinner = new UISpinner(0, Integer.MAX_VALUE, 1); } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java index 7c484c7b29..c55e5871ee 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/TableDataManagerPane.java @@ -33,9 +33,16 @@ public class TableDataManagerPane extends LoadingBasicPane { ); } tableDataPane = pane == null ? new TableDataPaneListPane() { - public void rename(String oldName, String newName) { + @Override + public void rename(final String oldName, final String newName) { super.rename(oldName, newName); - renameConnection(oldName, newName); + new SwingWorker() { + @Override + protected Void doInBackground() { + renameConnection(oldName, newName); + return null; + } + }.execute(); } } : pane; container.add(tableDataPane.getPanel(), BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java index 812eb25af3..82022bea60 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java @@ -50,10 +50,11 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); TableDataSource tds = adapter == null ? null : adapter.getBook(); String[] colNames = tabledata.getColumnNames(tds); + String[] colNamesInCache = DesignTableDataManager.getDsColumnNames(name); if(ArrayUtils.isNotEmpty(colNames)){ - columnNameList = new ArrayList(); - columnNameList.addAll(Arrays.asList(colNames)); - return columnNameList; + return toColumnNameList(colNames); + } else if (ArrayUtils.isNotEmpty(colNamesInCache)) { + return toColumnNameList(colNamesInCache); } EmbeddedTableData embeddedTableData = null; @@ -69,6 +70,12 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper { return columnNameList; } + private List toColumnNameList(String[] colNames) { + columnNameList = new ArrayList<>(); + columnNameList.addAll(Arrays.asList(colNames)); + return columnNameList; + } + /** * 生成子节点 * diff --git a/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java b/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java index e4cf0c8e71..35f9c3c0fb 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/TipDialog.java @@ -6,6 +6,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.IOUtils; +import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.BorderLayout; @@ -39,7 +40,14 @@ public abstract class TipDialog extends JDialog implements ActionListener { northPane.add(iconPane, BorderLayout.WEST); northPane.add(tipPane, BorderLayout.CENTER); - JTextArea area = new JTextArea(type); + JTextPane area = new JTextPane(); + UILabel typeLabel = new UILabel(type); + area.insertComponent(typeLabel); + if (StringUtils.isNotEmpty(type)) { + UILabel logoIconLabel = new UILabel(); + logoIconLabel.setIcon(IOUtils.readIcon("com/fr/base/images/oem/logo.png")); + area.insertComponent(logoIconLabel); + } area.setPreferredSize(new Dimension(400, 100)); area.setEnabled(true); area.setEditable(false); diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java index a885c51883..8f2021c696 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java @@ -123,8 +123,11 @@ public abstract class UIDialog extends JDialog { // transfer focus to CurrentEditor inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "dialogOK"); actionMap.put("dialogOK", new AbstractAction() { - + @Override public void actionPerformed(ActionEvent evt) { + if (!okButton.isEnabled()) { + return; + } doOK(); } }); diff --git a/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java b/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java index 80c545e922..bb5353f133 100644 --- a/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java +++ b/designer-base/src/main/java/com/fr/design/editor/editor/WidgetNameEditor.java @@ -4,6 +4,7 @@ import com.fr.design.DesignModelAdapter; import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.stable.StringUtils; import com.fr.stable.js.WidgetName; import javax.swing.JList; @@ -19,6 +20,8 @@ import java.awt.Component; * @since 2012-3-29下午6:04:37 */ public class WidgetNameEditor extends Editor { + static final WidgetName EMPTY_WIDGET_NAME = new WidgetName(StringUtils.EMPTY); + private FilterComboBox comb; @@ -79,7 +82,8 @@ public class WidgetNameEditor extends Editor { @Override public WidgetName getValue() { - return (WidgetName) comb.getSelectedItem(); + WidgetName widgetName = (WidgetName) comb.getSelectedItem(); + return widgetName == null ? EMPTY_WIDGET_NAME : widgetName; } @Override diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java index 1174a8a73b..15b0e191e0 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceGenerator.java @@ -1,15 +1,40 @@ package com.fr.design.env; +import com.fr.common.report.ReportState; +import com.fr.concurrent.NamedThreadFactory; +import com.fr.design.EnvChangeEntrance; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; +import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; +import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; +import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceClient; +import javax.swing.*; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + /** * 根据配置生成运行环境 */ public class DesignerWorkspaceGenerator { - public static Workspace generate(DesignerWorkspaceInfo config) throws Exception { + private static final int WAIT_FREQ = 60; + private static ExecutorService service = Executors.newCachedThreadPool( + new NamedThreadFactory("DesignerWorkspaceGenerator")); + + public static Workspace generate(final DesignerWorkspaceInfo config) throws Exception { if (config == null || config.getType() == null) { return null; @@ -22,7 +47,19 @@ public class DesignerWorkspaceGenerator { break; } case Remote: { - WorkspaceClient client = WorkContext.getConnector().connect(config.getConnection()); + Future future = service.submit(new Callable() { + @Override + public WorkspaceClient call() throws Exception { + return WorkContext.getConnector().connect(config.getConnection()); + } + }); + WorkspaceClient client = null; + try { + client = future.get(WAIT_FREQ, TimeUnit.SECONDS); + } catch (TimeoutException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + RemoteHandler.handle(config); + } if (client != null) { workspace = new RemoteWorkspace(client, config.getConnection()); } @@ -31,4 +68,33 @@ public class DesignerWorkspaceGenerator { } return workspace; } + + enum RemoteHandler { + SELF; + public static void handle(DesignerWorkspaceInfo config) { + FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue())); + StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getId(), + DesignerErrorMessage.REMOTE_DESIGN_NO_RESPONSE.getMessage(), + StringUtils.EMPTY); + int result = FineJOptionPane.showOptionDialog(null, + Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"), + JOptionPane.YES_NO_OPTION, + JOptionPane.ERROR_MESSAGE, + IOUtils.readIcon("com/fr/design/images/error/error2.png"), + new Object[] {Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Wait"), Toolkit.i18nText("Fine-Design_Error_Remote_No_Response_Switch")}, + null); + if (result == JOptionPane.YES_OPTION) { + try { + generate(config); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + } + + public static void stop() { + service.shutdown(); + } } diff --git a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java index 2e5cc9f8c0..ccc98bfe37 100644 --- a/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/DesignerWorkspaceInfo.java @@ -10,6 +10,9 @@ public interface DesignerWorkspaceInfo extends XMLable { String getPath(); + //获取提醒时间,用于判断是否做服务检测 + String getRemindTime(); + WorkspaceConnectionInfo getConnection(); boolean checkValid(); diff --git a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java index 19b0857818..ef1f420d62 100644 --- a/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/LocalDesignerWorkspaceInfo.java @@ -43,6 +43,11 @@ public class LocalDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return path; } + @Override + public String getRemindTime() { + return null; + } + @Override public WorkspaceConnectionInfo getConnection() { return null; diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 9d2af66cf1..af0b8a01c0 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -13,6 +13,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private String name; + private String remindTime; + private WorkspaceConnectionInfo connection; public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { @@ -45,11 +47,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return connection; } + public void setRemindTime(String remindTime){ + this.remindTime = remindTime; + } + + @Override + public String getRemindTime(){ + return remindTime; + } + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); + this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); } if (reader.isChildNode()) { String tagName = reader.getTagName(); @@ -69,6 +81,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { public void writeXML(XMLPrintWriter writer) { writer.attr("name", name); + writer.attr("remindTime", remindTime); if (this.connection != null) { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index cc7b02c7b6..3d96ea1efc 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -1,8 +1,10 @@ package com.fr.design.env; -import com.fr.cluster.engine.base.FineClusterConfig; +import com.fr.cluster.engine.remote.ClusterOperator; import com.fr.design.i18n.Toolkit; +import com.fr.base.operator.common.CommonOperator; import com.fr.rpc.ExceptionHandler; +import com.fr.rpc.RPCInvokerExceptionInfo; import com.fr.stable.AssistUtils; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; @@ -48,8 +50,12 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isWarDeploy() { - - return false; + return WorkContext.getCurrent().get(CommonOperator.class, new ExceptionHandler() { + @Override + public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { + return false; + } + }).isWarDeploy(); } @Override @@ -73,7 +79,12 @@ public class RemoteWorkspace implements Workspace { @Override public boolean isCluster() { - return FineClusterConfig.getInstance().isCluster(); + return WorkContext.getCurrent().get(ClusterOperator.class, new ExceptionHandler() { + @Override + public Boolean callHandler(RPCInvokerExceptionInfo rpcInvokerExceptionInfo) { + return false; + } + }).isCluster(); } @Override diff --git a/designer-base/src/main/java/com/fr/design/event/RemoveListener.java b/designer-base/src/main/java/com/fr/design/event/RemoveListener.java new file mode 100644 index 0000000000..ff3eae3055 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/event/RemoveListener.java @@ -0,0 +1,11 @@ +package com.fr.design.event; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/19 + */ +public interface RemoveListener { + + void doRemoveAction(); +} 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 4b0edb979f..801b4e369a 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 @@ -1,10 +1,10 @@ package com.fr.design.extra; import com.fr.config.MarketConfig; +import com.fr.design.bridge.exec.JSCallback; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.exe.callback.InstallFromDiskCallback; import com.fr.design.extra.exe.callback.InstallOnlineCallback; -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; @@ -13,6 +13,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.general.CloudCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; +import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -25,9 +26,9 @@ import com.fr.plugin.manage.control.PluginTaskResult; import com.fr.plugin.view.PluginView; import com.fr.stable.StringUtils; -import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; +import javax.swing.*; import java.io.File; +import java.net.HttpURLConnection; import java.util.List; @@ -110,13 +111,18 @@ public class PluginOperateUtils { public static String getRecommendPlugins() { String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.feature"); JSONArray resultArray = JSONArray.create(); + if (StringUtils.isBlank(plistUrl)) { + return resultArray.toString(); + } try { HttpClient httpClient = new HttpClient(plistUrl); - String result = httpClient.getResponseText(); - JSONArray jsonArray = new JSONArray(result); - resultArray = PluginUtils.filterPluginsFromVersion(jsonArray); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); + if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { + String result = httpClient.getResponseText(); + JSONArray jsonArray = new JSONArray(result); + resultArray = PluginUtils.filterPluginsFromVersion(jsonArray); + } + } catch (JSONException e) { + FineLoggerFactory.getLogger().info(e.getMessage(), e); } return resultArray.toString(); } 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 d1997684f6..bec02a200e 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 @@ -2,6 +2,7 @@ package com.fr.design.extra; import com.fr.base.TemplateUtils; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.i18n.Toolkit; import com.fr.general.CloudCenter; import com.fr.general.http.HttpClient; import com.fr.json.JSONArray; @@ -12,8 +13,8 @@ import com.fr.plugin.basic.version.Version; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.error.PluginBaseErrorCode; +import com.fr.plugin.error.PluginErrorCode; import com.fr.plugin.manage.PluginManager; import com.fr.plugin.view.PluginView; import com.fr.stable.EncodeConstants; @@ -21,11 +22,12 @@ import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import javax.swing.JOptionPane; +import javax.swing.*; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URLDecoder; import java.text.SimpleDateFormat; @@ -38,7 +40,7 @@ import java.util.Map; * Created by ibm on 2017/5/25. */ public class PluginUtils { - + private static final String ERROR_CODE_I18N_PREFIX = "FR-Plugin_Error_"; public static final String FR_VERSION = "fr_version"; @@ -46,8 +48,7 @@ public class PluginUtils { public static PluginMarker createPluginMarker(String pluginInfo) { //todo 判空 String[] plugin = pluginInfo.split("_"); - PluginMarker pluginMarker = PluginMarker.create(plugin[0], plugin[1]); - return pluginMarker; + return PluginMarker.create(plugin[0], plugin[1]); } public static JSONObject getLatestPluginInfo(String pluginID) throws Exception { @@ -90,7 +91,11 @@ public class PluginUtils { InputStream reader = null; FileOutputStream writer = null; try { - HttpClient httpClient = new HttpClient(getDownloadPath(id)); + String downloadPath = getDownloadPath(id); + if (StringUtils.isBlank(downloadPath)) { + throw new PluginVerifyException(Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error")); + } + HttpClient httpClient = new HttpClient(downloadPath); if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { int totalSize = httpClient.getContentLength(); reader = httpClient.getResponseStream(); @@ -108,12 +113,12 @@ public class PluginUtils { p.process(totalBytesRead / (double) totalSize); } } else { - throw new com.fr.plugin.PluginVerifyException(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error")); + throw new PluginVerifyException(Toolkit.i18nText("Fine-Design_Basic_Plugin_Connect_Server_Error")); } } catch (PluginVerifyException e) { FineJOptionPane.showMessageDialog(null, e.getMessage(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Plugin_Warning"), JOptionPane.ERROR_MESSAGE); return false; - } catch (Exception e) { + } catch (IOException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); return false; } finally { @@ -122,7 +127,7 @@ public class PluginUtils { return true; } - private static void closeStream(InputStream reader, FileOutputStream writer){ + private static void closeStream(InputStream reader, FileOutputStream writer) { try { if (null != reader) { reader.close(); @@ -136,18 +141,26 @@ public class PluginUtils { } } - private static String getDownloadPath(String id) throws Exception { - HashMap map = new HashMap(); - map.put("id", id); - HttpClient httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("shop.script.download")+ "?" + FR_VERSION + "=" + ProductConstants.VERSION); + private static String getDownloadPath(String id) { + String url = CloudCenter.getInstance().acquireUrlByKind("shop.script.download"); + if (StringUtils.isBlank(url)) { + return StringUtils.EMPTY; + } + HttpClient httpClient = new HttpClient(url + "?" + FR_VERSION + "=" + ProductConstants.VERSION); httpClient.asGet(); - String resText = httpClient.getResponseText(); - JSONObject resultJSONObject = new JSONObject(resText); - String scriptUrl = resultJSONObject.optString("result"); - String charSet = EncodeConstants.ENCODING_UTF_8; - scriptUrl = URLDecoder.decode(URLDecoder.decode(scriptUrl, charSet), charSet); - - return scriptUrl; + if (httpClient.getResponseCode() == HttpURLConnection.HTTP_OK) { + String resText = httpClient.getResponseText(); + JSONObject resultJSONObject = new JSONObject(resText); + String scriptUrl = resultJSONObject.optString("result"); + String charSet = EncodeConstants.ENCODING_UTF_8; + try { + scriptUrl = URLDecoder.decode(URLDecoder.decode(scriptUrl, charSet), charSet); + } catch (UnsupportedEncodingException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + return scriptUrl; + } + return StringUtils.EMPTY; } public static boolean isPluginMatch(PluginView pluginView, String text) { @@ -194,22 +207,22 @@ public class PluginUtils { return StringUtils.EMPTY; } } - + public static String getMessageByErrorCode(PluginBaseErrorCode errorCode) { - if(errorCode == PluginErrorCode.None){ + if (errorCode == PluginErrorCode.None) { return ""; } - + return com.fr.design.i18n.Toolkit.i18nCompatibleServerText(getInterKeyByErrorCode(errorCode)); } - + private static String getInterKeyByErrorCode(PluginBaseErrorCode errorCode) { - - return errorCode.getDescription(); + + return errorCode.getDescription(); } - + public static PluginMarker getInstalledPluginMarkerByID(String pluginID) { - + PluginContext context = PluginManager.getContext(pluginID); if (context != null) { return context.getMarker(); @@ -219,29 +232,30 @@ public class PluginUtils { /** * 在不同设计器版本下展示不同插件 + * * @return 插件 */ - public static JSONArray filterPluginsFromVersion(JSONArray oriJSONArray) throws Exception{ - JSONArray resultJSONArray = JSONArray.create(); - for(int i = 0; i < oriJSONArray.length(); i++){ + public static JSONArray filterPluginsFromVersion(JSONArray oriJSONArray) { + JSONArray resultJSONArray = JSONArray.create(); + for (int i = 0; i < oriJSONArray.length(); i++) { JSONObject jo = oriJSONArray.getJSONObject(i); String envVersion = jo.optString("envversion"); - if(isCompatibleCurrentEnv(envVersion)){ + if (isCompatibleCurrentEnv(envVersion)) { resultJSONArray.put(jo); } } return resultJSONArray; } - private static boolean isCompatibleCurrentEnv(String envVersion){ + private static boolean isCompatibleCurrentEnv(String envVersion) { return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); } - public static JSONArray transferStorePluginToJson(PluginContext [] pluginContexts){ + public static JSONArray transferStorePluginToJson(PluginContext[] pluginContexts) { JSONArray ja = JSONArray.create(); try { - for(PluginContext pluginContext : pluginContexts){ + for (PluginContext pluginContext : pluginContexts) { JSONObject jo = JSONObject.create(); jo.put("id", pluginContext.getID()); jo.put("name", pluginContext.getName()); @@ -265,7 +279,7 @@ public class PluginUtils { jo.put("switchedReason", pluginContext.getSwitchedReason()); ja.put(jo); } - }catch (Exception e){ + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } return ja; diff --git a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java index 3abcfc0a4f..47d1541461 100644 --- a/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java +++ b/designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java @@ -75,7 +75,7 @@ public class WebViewDlgHelper { } return; } - String jar_version = PluginStoreConstants.getInstance().getProps(ENV_VERSION, StringUtils.EMPTY); + String jar_version = PluginStoreConstants.getProps(ENV_VERSION, StringUtils.EMPTY); if (ComparatorUtils.equals(jar_version, ProductConstants.VERSION)) { updateShopScripts(SHOP_SCRIPTS); showPluginDlg(); @@ -297,7 +297,7 @@ public class WebViewDlgHelper { protected Void doInBackground() throws Exception { String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.update"); if (url != null) { - String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getInstance().getProps("VERSION")); + String text = HttpToolbox.get(url + "?" + PluginUtils.FR_VERSION + "=" + ProductConstants.VERSION + "&version=" + PluginStoreConstants.getProps("VERSION")); JSONObject resultJSONObject = new JSONObject(text); String isLatest = resultJSONObject.optString("result"); if (!ComparatorUtils.equals(isLatest, LATEST)) { diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java index 0a3b76211d..1d6e8c4836 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginCategoriesExecutor.java @@ -4,6 +4,7 @@ import com.fr.design.extra.PluginConstants; import com.fr.design.extra.Process; import com.fr.general.CloudCenter; import com.fr.general.http.HttpClient; +import com.fr.stable.StringUtils; /** * Created by vito on 16/5/16. @@ -28,7 +29,7 @@ public class GetPluginCategoriesExecutor implements Executor { @Override public void run(Process process) { String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.category"); - if (url != null) { + if (StringUtils.isNotEmpty(url)) { HttpClient httpClient = new HttpClient(url); result = httpClient.getResponseText(); } else { diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java index 4a1168734e..3bf7b2cb32 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/GetPluginFromStoreExecutor.java @@ -52,7 +52,7 @@ public class GetPluginFromStoreExecutor implements Executor { @Override public void run(Process process) { - String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.plist") + "?"; + String plistUrl = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.plist"); boolean getRecommend = StringUtils.isEmpty(category) && StringUtils.isEmpty(seller) && StringUtils.isEmpty(fee) && StringUtils.isEmpty(scope); if (getRecommend) { result = PluginOperateUtils.getRecommendPlugins(); @@ -61,7 +61,7 @@ public class GetPluginFromStoreExecutor implements Executor { if (StringUtils.isNotBlank(plistUrl)) { StringBuilder url = new StringBuilder(); - url.append(plistUrl); + url.append(plistUrl).append("?"); PluginOperateUtils.dealParams(url, category, seller, fee, scope); try { HttpClient httpClient = new HttpClient(url.toString()); diff --git a/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java b/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java index fdbd8562f4..1a84519eee 100644 --- a/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java +++ b/designer-base/src/main/java/com/fr/design/extra/exe/SearchOnlineExecutor.java @@ -14,8 +14,8 @@ import com.fr.stable.StringUtils; * Created by vito on 16/4/18. */ public class SearchOnlineExecutor implements Executor { - private String result = StringUtils.EMPTY; - private String keyword; + private String result = JSONArray.create().toString(); + private final String keyword; public SearchOnlineExecutor(String keyword) { this.keyword = keyword; @@ -42,7 +42,11 @@ public class SearchOnlineExecutor implements Executor { result = PluginOperateUtils.getRecommendPlugins(); return; } - HttpClient httpClient = new HttpClient(CloudCenter.getInstance().acquireUrlByKind("shop.plugin.store") + "&keyword=" + keyword); + String url = CloudCenter.getInstance().acquireUrlByKind("shop.plugin.store"); + if (StringUtils.isEmpty(url)) { + return; + } + HttpClient httpClient = new HttpClient(url + "&keyword=" + keyword); httpClient.asGet(); String responseText = httpClient.getResponseText(); JSONObject jsonObject = new JSONObject(responseText); 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 2f9a69b313..cb68bb6e47 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 @@ -2,6 +2,7 @@ package com.fr.design.file; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.base.io.BaseBook; +import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.data.DesignTableDataManager; @@ -178,15 +179,28 @@ public class HistoryTemplateListCache implements CallbackEvent { * @return 位置 */ public int contains(JTemplate jt) { + return contains(jt, null); + } + + public int contains(FILE file) { + return contains(null, file); + } + + private int contains(JTemplate jt, FILE file) { + FILE item = null; + if (jt != null) { + item = jt.getEditingFILE(); + } else { + item = file; + } for (int i = 0; i < historyList.size(); i++) { - if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), jt.getEditingFILE())) { + if (ComparatorUtils.equals(historyList.get(i).getEditingFILE(), item)) { return i; } } return -1; } - /** * 判断是否打开过该模板 * 由于切换环境不会关闭模板,可能存在同名的模板,所以该方法不能准确找到所选的模板, @@ -371,9 +385,14 @@ public class HistoryTemplateListCache implements CallbackEvent { historyList.set(i, template); // 替换当前正在编辑的模板,使用添加并激活的方式,以便使用统一的入口来处理监听事件 if (isCurrentEditingFile(template.getPath())) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(template); - setCurrentEditingTemplate(template); - FineLoggerFactory.getLogger().info("Env Change Current Editing Template."); + loadCurrentTemplate(template); + } + } else { + // 当模板为空时 说明是一个新建的未保存模板 但是内存中保存了该模板 可以从中获取 + JTemplate jt = historyList.get(i); + // 另外如果该模板是正在编辑的模板,需要要激活 + if (jt != null && isCurrentEditingFile(jt.getPath())) { + loadCurrentTemplate(jt); } } } catch (Exception e) { @@ -387,6 +406,12 @@ public class HistoryTemplateListCache implements CallbackEvent { FineLoggerFactory.getLogger().info("Env Change Template Loaded."); } + private void loadCurrentTemplate(JTemplate template) { + DesignerContext.getDesignerFrame().addAndActivateJTemplate(template); + setCurrentEditingTemplate(template); + FineLoggerFactory.getLogger().info("Env Change Current Editing Template " + template.getTemplateName()); + } + /** * 重新载入当前模板,刷新数据/对象 */ @@ -394,8 +419,7 @@ public class HistoryTemplateListCache implements CallbackEvent { JTemplate jt = getCurrentEditingTemplate(); boolean access = jt != null && jt.getEditingFILE() != null && jt.getEditingFILE().exists(); if (access) { - closeSelectedReport(jt); - DesignerContext.getDesignerFrame().openTemplate(jt.getEditingFILE()); + jt.refreshResource(); } } diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 32e7030bb6..9259248ac6 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -2,7 +2,6 @@ package com.fr.design.formula; import com.fr.base.BaseFormula; import com.fr.base.BaseUtils; -import com.fr.base.FRContext; import com.fr.design.actions.UpdateAction; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; @@ -25,7 +24,6 @@ import com.fr.log.FineLoggerFactory; import com.fr.parser.FRLexer; import com.fr.parser.FRParser; import com.fr.stable.EncodeConstants; -import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.script.Expression; @@ -54,7 +52,10 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; -import java.util.Locale; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; /** * 公式编辑面板 @@ -413,14 +414,19 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { if (keyWord.length() != 0) { NameAndDescription[] descriptions = FunctionConstants.ALL.getDescriptions(); int lengthOfDes = descriptions.length; + List list = new ArrayList<>(); for (int i = 0; i < lengthOfDes; i++) { NameAndDescription and = descriptions[i]; String functionName = and.searchResult(keyWord, findDescription); if (StringUtils.isNotBlank(functionName)) { - listModel.addElement(functionName); + list.add(functionName); } } + Collections.sort(list, new SimilarComparator(keyWord)); + for (String name : list) { + listModel.addElement(name); + } if (!listModel.isEmpty()) { tipsList.setSelectedIndex(0); @@ -969,6 +975,26 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { } } + public static class SimilarComparator implements Comparator { + + private String searchKey; + + public SimilarComparator(String searchKey) { + this.searchKey = searchKey.toLowerCase(); + } + + @Override + public int compare(String o1, String o2) { + if (o1.toLowerCase().startsWith(searchKey)) { + return -1; + } + if (o2.toLowerCase().startsWith(searchKey)) { + return 1; + } + return o2.compareTo(o1); + } + } + public static class TextFolderUserObject { private String text; diff --git a/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java b/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java index 3d56dd925e..c40a917e39 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FunctionManagerPane.java @@ -142,8 +142,10 @@ public class FunctionManagerPane extends BasicPane { editorButton.setPreferredSize(new Dimension(editorButton.getPreferredSize().width, classNameTextField.getPreferredSize().height)); reportletNamePane.add(editorButton); editorButton.addActionListener(createEditorButtonActionListener()); - northPane.add(GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), - reportletNamePane}, FlowLayout.LEFT)); + JPanel classNamePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + classNamePane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Class_Name") + ":"), BorderLayout.NORTH); + classNamePane.add(reportletNamePane, BorderLayout.CENTER); + northPane.add(classNamePane); DescriptionTextArea descriptionArea = new DescriptionTextArea(); descriptionArea.setWrapStyleWord(true); descriptionArea.setLineWrap(true); diff --git a/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java b/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java index 9b5a95a431..a34762a1fd 100644 --- a/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/JavaEditorPane.java @@ -220,8 +220,8 @@ public class JavaEditorPane extends BasicPane { " }\n" + "\n" + " /**\n" + - " * 获取数据集的列数\n" + - " * @return 数据集的列\n" + + " * Get the number of columns in a dataset\n" + + " * @return Dataset columns\n" + " * @throws TableDataException\n" + " */\n" + " public int getColumnCount() throws TableDataException {\n" + @@ -229,9 +229,9 @@ public class JavaEditorPane extends BasicPane { " }\n" + "\n" + " /**\n" + - " * 获取数据集指定列的列名\n" + - " * @param columnIndex 指定列的索引\n" + - " * @return 指定列的列名\n" + + " * Get the column name of the specified column of the dataset\n" + + " * @param columnIndex The index of the specified column\n" + + " * @return The column name of the specified column\n" + " * @throws TableDataException\n" + " */\n" + " public String getColumnName(int columnIndex) throws TableDataException {\n" + @@ -239,8 +239,8 @@ public class JavaEditorPane extends BasicPane { " }\n" + "\n" + " /**\n" + - " * 获取数据集的行数\n" + - " * @return 数据集数据行数\n" + + " * Get the number of rows in the dataset\n" + + " * @return Dataset rows\n" + " * @throws TableDataException\n" + " */\n" + " public int getRowCount() throws TableDataException {\n" + @@ -248,10 +248,10 @@ public class JavaEditorPane extends BasicPane { " }\n" + "\n" + " /**\n" + - " * 获取数据集指定位置上的值\n" + - " * @param rowIndex 指定的行索引\n" + - " * @param columnIndex 指定的列索引\n" + - " * @return 指定位置的值\n" + + " * Get the value at the specified position in the dataset\n" + + " * @param rowIndex The specified row index\n" + + " * @param columnIndex The specified column index\n" + + " * @return The value of the specified location\n" + " */\n" + " public Object getValueAt(int rowIndex, int columnIndex) {\n" + " return null;\n" + @@ -263,12 +263,12 @@ public class JavaEditorPane extends BasicPane { "import com.fr.script.AbstractFunction;\n" + "\n" + "/**\n" + - " * 自定义函数\n" + + " * Custom function\n" + " */\n" + "public class CustomFun extends AbstractFunction {\n" + " /**\n" + - " * @param args 函数的参数,是经过了算子处理了其中特殊参数的\n" + - " * @return 经过函数处理的值,用于参与最终计算\n" + + " * @param args The parameters of the function are processed by calculator with special parameters\n" + + " * @return The value processed by the function is used to participate in the final calculation\n" + " */\n" + " public Object run(Object[] args) {\n" + " return null;\n" + diff --git a/designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java b/designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java new file mode 100644 index 0000000000..ec37e16007 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/CellExpandAttrPanelProvider.java @@ -0,0 +1,21 @@ +package com.fr.design.fun; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.report.cell.TemplateCellElement; +import com.fr.stable.fun.mark.Mutable; + +/** + * @author yaohwu + * created by yaohwu at 2020/4/26 15:50 + */ +public interface CellExpandAttrPanelProvider extends Mutable { + + String MARK_STRING = "CellExpandAttrPanelProvider"; + + int CURRENT_LEVEL = 1; + + /** + * @return 创建单元格属性-扩展设置中的额外面板 + */ + BasicBeanPane createPanel(); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java b/designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java new file mode 100644 index 0000000000..fbbdacaad8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/ClipboardHandlerProvider.java @@ -0,0 +1,45 @@ +package com.fr.design.fun; + +import com.fr.stable.fun.mark.Mutable; + +/** + * created by Harrison on 2020/05/14 + **/ +public interface ClipboardHandlerProvider extends Mutable { + + String XML_TAG = "ClipboardHandlerProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 剪切 + * + * @param selection 选中 + * @return 处理后的内容 + */ + T cut(T selection); + + /** + * 复制 + * + * @param selection 选中 + * @return 处理后的内容 + */ + T copy(T selection); + + /** + * 粘贴 + * + * @param selection 选中 + * @return 处理后的内容 + */ + T paste(T selection); + + /** + * 支持的类型 + * + * @param selection 内容 + * @return 是否 + */ + boolean support(Object selection); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java b/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java new file mode 100644 index 0000000000..7b484b156d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/ComponentLibraryPaneProcessor.java @@ -0,0 +1,57 @@ +package com.fr.design.fun; + +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.mainframe.DockingView; +import com.fr.stable.fun.mark.Immutable; + +import javax.swing.JPanel; + +/** + * 组件库面板处理器 + * + * created by Harrison on 2020/03/16 + **/ +public interface ComponentLibraryPaneProcessor extends Immutable { + + String XML_TAG = "ComponentLibraryPaneProcessor"; + + int CURRENT_LEVEL = 1; + + /** + * 创建展示面板 + * + * @param isEdit 是否可以编辑 + * @return 展示面板 + */ + UIScrollPane createShowPanel(boolean isEdit); + + /** + * 创建菜单的上部面板 + * + * @return 面板 + */ + JPanel createMenuNorthPane(); + + /** + * 创建复选框 + * + * @return 复选框 + */ + UIComboBox createMenuComBox(); + + void parentView(DockingView dockingView); + + /** + * 父面板 + * + * @param panel 面板 + */ + void parentPane(JPanel panel); + + /** + * 创建完成 + */ + void complete(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/DesignerStartClassProcessor.java b/designer-base/src/main/java/com/fr/design/fun/DesignerStartClassProcessor.java new file mode 100644 index 0000000000..4874be8029 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/DesignerStartClassProcessor.java @@ -0,0 +1,23 @@ +package com.fr.design.fun; + +import com.fr.stable.fun.mark.Mutable; +import com.fr.start.BaseDesigner; + +/** + * 设计器启动类替换接口 + * + * @author hades + * @version 10.0 + * Created by hades on 2020/5/7 + */ + +public interface DesignerStartClassProcessor extends Mutable { + + String MARK_STRING = "DesignerStartClassProcessor"; + + int CURRENT_LEVEL = 1; + + + Class transform(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java b/designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java new file mode 100644 index 0000000000..ebe0e8c3d4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java @@ -0,0 +1,43 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.JTemplate; +import com.fr.design.menu.ShortCut; +import com.fr.stable.fun.mark.Immutable; + +import javax.swing.JComponent; +import java.awt.Dimension; +import java.awt.image.BufferedImage; + + +/** + * Created by kerry on 2020-04-09 + * 临时接口,后续自适应内置后删除 + */ +public interface FormAdaptiveConfigUIProcessor extends Immutable { + + String MARK_STRING = "FormAdaptiveConfigUIProcessor"; + int CURRENT_LEVEL = 1; + + /** + * 获取表单自适应配置菜单 + * @return 表单自适应配置菜单 + */ + ShortCut getConfigShortCut(JTemplate jTemplate); + + /** + * 绘制自适应下报表块在表单界面中显示图片 + * @param size 绘制尺寸 + * @param elementCasePane 报表块内容对象 + * @return 自适应下报表块在表单界面中显示的图片 + */ + BufferedImage paintFormElementCaseImage(Dimension size, JComponent elementCasePane); + + + /** + * 获取新自适应下字体显示的dpi + * @return dpi + */ + int fontResolution(); + +} + diff --git a/designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java new file mode 100644 index 0000000000..770e65a9ee --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/MobileTemplateStyleProvider.java @@ -0,0 +1,25 @@ +package com.fr.design.fun; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.general.cardtag.mobile.MobileTemplateStyle; +import com.fr.stable.fun.mark.Mutable; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/31 + */ +public interface MobileTemplateStyleProvider extends Mutable { + + String XML_TAG = "MobileTemplateStyleProvider"; + + int CURRENT_LEVEL = 1; + + Class classFroMobileTemplateStyle(); + + + Class> classFroMobileTemplateStyleAppearance(); + + String displayName(); + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/ReportLengthUNITProvider.java b/designer-base/src/main/java/com/fr/design/fun/ReportLengthUNITProvider.java new file mode 100644 index 0000000000..af97950cf8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/ReportLengthUNITProvider.java @@ -0,0 +1,39 @@ +package com.fr.design.fun; + +import com.fr.stable.fun.mark.Mutable; +import com.fr.stable.unit.UNIT; + +/** + * Created by kerry on 2020-04-09 + */ +public interface ReportLengthUNITProvider extends Mutable { + String MARK_STRING = "ReportLengthUNITProvider"; + + int CURRENT_LEVEL = 1; + + /** + * 标尺单位显示字符 + * @return 标尺单位字符 + */ + String unitText(); + + /** + * 标尺单位类型(之前是将int类型的值直接保存在数据库里面的) + * @return 返回标尺单位类型 + */ + int unitType(); + + /** + * UNIT转标尺单位值 + * @param value UNIT + * @return 标尺单位值 + */ + float unit2Value4Scale(UNIT value); + + /** + * 标尺单位值转UNIT + * @param value 标尺单位值 + * @return UNIT + */ + UNIT float2UNIT(float value); +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java new file mode 100644 index 0000000000..3ec730862c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractCellExpandAttrPanelProvider.java @@ -0,0 +1,39 @@ +package com.fr.design.fun.impl; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.CellExpandAttrPanelProvider; +import com.fr.report.cell.TemplateCellElement; +import com.fr.stable.fun.mark.API; + +/** + * @author yaohwu + * created by yaohwu at 2020/4/26 16:08 + */ +@API(level = CellExpandAttrPanelProvider.CURRENT_LEVEL) +public class AbstractCellExpandAttrPanelProvider implements CellExpandAttrPanelProvider { + + /** + * 当前接口的API等级,用于判断是否需要升级插件 + * + * @return API等级 + */ + @Override + public int currentAPILevel() { + return CellExpandAttrPanelProvider.CURRENT_LEVEL; + } + + /** + * 获取当前provider的标记(可以使用类路径保证唯一)以避免provider的重复加载 + * + * @return 当前provider的标记 + */ + @Override + public String mark4Provider() { + return null; + } + + @Override + public BasicBeanPane createPanel() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java new file mode 100644 index 0000000000..da1861916f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractClipboardHandlerProvider.java @@ -0,0 +1,17 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.ClipboardHandlerProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * created by Harrison on 2020/05/14 + **/ +@API(level = ClipboardHandlerProvider.CURRENT_LEVEL) +public abstract class AbstractClipboardHandlerProvider extends AbstractProvider implements ClipboardHandlerProvider { + + @Override + public int currentAPILevel() { + return ClipboardHandlerProvider.CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerStartClassProcessorProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerStartClassProcessorProcessor.java new file mode 100644 index 0000000000..7c94ffe37a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractDesignerStartClassProcessorProcessor.java @@ -0,0 +1,23 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.DesignerStartClassProcessor; +import com.fr.stable.fun.mark.API; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/5/7 + */ +@API(level = DesignerStartClassProcessor.CURRENT_LEVEL) +public abstract class AbstractDesignerStartClassProcessorProcessor implements DesignerStartClassProcessor { + + @Override + public String mark4Provider() { + return getClass().getName(); + } + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormAdaptiveConfigUIProcessor.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormAdaptiveConfigUIProcessor.java new file mode 100644 index 0000000000..1fc76077c1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractFormAdaptiveConfigUIProcessor.java @@ -0,0 +1,23 @@ +package com.fr.design.fun.impl; + + +import com.fr.design.fun.FormAdaptiveConfigUIProcessor; +import com.fr.stable.fun.mark.API; + +/** + * Created by kerry on 2020-04-09 + */ +@API(level = FormAdaptiveConfigUIProcessor.CURRENT_LEVEL) +public abstract class AbstractFormAdaptiveConfigUIProcessor implements FormAdaptiveConfigUIProcessor { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public int layerIndex() { + return DEFAULT_LAYER_INDEX; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java new file mode 100644 index 0000000000..54c947c57a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractMobileTemplateStyleProvider.java @@ -0,0 +1,25 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.MobileTemplateStyleProvider; +import com.fr.design.fun.MobileWidgetStyleProvider; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/31 + */ +@API(level = MobileWidgetStyleProvider.CURRENT_LEVEL) +public abstract class AbstractMobileTemplateStyleProvider extends AbstractProvider implements MobileTemplateStyleProvider { + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String mark4Provider() { + return getClass().getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportLengthUNITProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportLengthUNITProvider.java new file mode 100644 index 0000000000..da77c947f9 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractReportLengthUNITProvider.java @@ -0,0 +1,42 @@ +package com.fr.design.fun.impl; + + +import com.fr.design.fun.ReportLengthUNITProvider; +import com.fr.stable.StringUtils; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; +import com.fr.stable.unit.UNIT; + +/** + * Created by kerry on 2020-04-09 + */ +@API(level = ReportLengthUNITProvider.CURRENT_LEVEL) +public abstract class AbstractReportLengthUNITProvider extends AbstractProvider implements ReportLengthUNITProvider { + + + @Override + public int currentAPILevel() { + return CURRENT_LEVEL; + } + + @Override + public String unitText() { + return StringUtils.EMPTY; + } + + @Override + public int unitType() { + return 0; + } + + @Override + public float unit2Value4Scale(UNIT value) { + return 0; + } + + @Override + public UNIT float2UNIT(float value) { + return UNIT.ZERO; + } +} + diff --git a/designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java b/designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java index f027157169..dc9cea2bdc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java +++ b/designer-base/src/main/java/com/fr/design/gui/UILookAndFeel.java @@ -29,11 +29,11 @@ import com.fr.design.gui.itoolbar.UIToolBarBorder; import com.fr.design.gui.itoolbar.UIToolBarSeparatorUI; import com.fr.design.gui.itooltip.UIToolTipBorder; import com.fr.design.gui.itree.UITreeUI; +import com.fr.design.i18n.Toolkit; import com.fr.log.FineLoggerFactory; import com.fr.general.IOUtils; -import javax.swing.ImageIcon; -import javax.swing.UIDefaults; +import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.plaf.BorderUIResource; @@ -52,6 +52,12 @@ import java.net.URL; */ public class UILookAndFeel extends MetalLookAndFeel { + + static { + UIManager.put("ProgressMonitor.progressText", Toolkit.i18nText("Fine-Design_Basic_ProgressBar_Title")); + UIManager.put("OptionPane.cancelButtonText", Toolkit.i18nText("Fine-Design_Basic_Cancel")); + } + public static boolean CONTROL_PANEL_INSTANTIATED = false; 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 4bb286dbc0..ebe41b2bc7 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 @@ -1,10 +1,13 @@ package com.fr.design.gui.controlpane; +import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.general.ComparatorUtils; @@ -99,6 +102,15 @@ class JControlUpdatePane extends JPanel { if (pane != null && pane.isVisible()) { Object bean = pane.updateBean(); + try { + if (bean instanceof RemoteDesignerWorkspaceInfo) { + DesignerWorkspaceInfo info = DesignerEnvManager.getEnvManager().getWorkspaceInfo(elEditing.wrapper.getName()); + String remindTime = info.getRemindTime(); + ((RemoteDesignerWorkspaceInfo) bean).setRemindTime(remindTime); + } + }catch (Exception e){ + FineLoggerFactory.getLogger().info("remindTime is not exist"); + } if (i < creators.length) { creators[i].saveUpdatedBean(elEditing, bean); } diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java index c67dd08d9e..3ba2e025fe 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/tree/layer/config/LayerDataConfigPane.java @@ -7,6 +7,7 @@ import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.present.dict.TableDataDictPane; import com.fr.form.ui.tree.LayerConfig; import com.fr.form.ui.tree.LayerDependence; +import com.fr.stable.StringUtils; import java.awt.*; import java.util.*; @@ -73,13 +74,19 @@ public class LayerDataConfigPane extends BasicBeanPane { if (wrapper != null) { columnNames = wrapper.calculateColumnNameList(); } else { - columnNames = new ArrayList(); + columnNames = new ArrayList<>(); } - String viewColStr = tableDataDictPane.updateBean().getValueColumnName(); - String modelColStr = tableDataDictPane.updateBean().getKeyColumnName(); TableDataDictionary dictionary = tableDataDictPane.updateBean(); + String viewColStr = dictionary.getValueColumnName(); + String modelColStr = dictionary.getKeyColumnName(); int viewCol = columnNames.indexOf(viewColStr); int modelCol = columnNames.indexOf(modelColStr); + if (StringUtils.EMPTY.equals(viewColStr)) { + viewCol = dictionary.getValueColumnIndex(); + } + if (StringUtils.EMPTY.equals(modelColStr)) { + modelCol = dictionary.getKeyColumnIndex(); + } //将数据设置到当前正在修改的layerData中 this.layerConfig.setDictionary(dictionary); this.layerConfig.setModelColumn(modelCol); diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java index 86fc564384..28f5830619 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButton.java @@ -24,10 +24,10 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class UIColorButton extends UIButton implements PopupHider, UIObserver, GlobalNameObserver { - private static final int SIZE = 16; - private static final int SIZE_2 = 2; - private static final int SIZE_4 = 4; - private static final int SIZE_6 = 6; + public static final int SIZE = 16; + public static final int SIZE_2 = 2; + public static final int SIZE_4 = 4; + public static final int SIZE_6 = 6; private static final int POPUP_MENU_SHIFT = -70; private Color color = Color.BLACK; private ColorControlWindow popupWin; @@ -53,6 +53,14 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G iniListener(); } + public ColorControlWindow getPopupWin() { + return popupWin; + } + + public void setPopupWin(ColorControlWindow popupWin) { + this.popupWin = popupWin; + } + private void iniListener() { if (shouldResponseChangeListener()) { this.addColorChangeListener(new ChangeListener() { @@ -103,8 +111,12 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G if (ComparatorUtils.equals(this.color, color)) { return; } - + Color oldColor = this.color; this.color = color; + checkColorChange(oldColor, this.color); + } + + protected void checkColorChange(Color oldColor, Color newColor) { hidePopupMenu(); fireColorStateChanged(); } @@ -139,7 +151,7 @@ public class UIColorButton extends UIButton implements PopupHider, UIObserver, G repaint(); } - private ColorControlWindow getColorControlWindow() { + protected ColorControlWindow getColorControlWindow() { //find parant. if (this.popupWin == null) { this.popupWin = new ColorControlWindow(UIColorButton.this) { diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java new file mode 100644 index 0000000000..a7dcad008a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIColorButtonWithAuto.java @@ -0,0 +1,38 @@ +package com.fr.design.gui.ibutton; + +import com.fr.chart.base.ChartConstants; +import com.fr.design.constants.UIConstants; +import com.fr.design.style.color.ColorControlWindow; +import com.fr.design.style.color.ColorControlWindowWithAuto; +import com.fr.general.ComparatorUtils; + +import java.awt.Color; + +public class UIColorButtonWithAuto extends UIColorButton { + + protected void checkColorChange(Color oldColor, Color newColor) { + if (ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && !ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { + setIcon(UIConstants.FONT_ICON); + } + + if (!ComparatorUtils.equals(oldColor, ChartConstants.AUTO_FONT_COLOR) && ComparatorUtils.equals(newColor, ChartConstants.AUTO_FONT_COLOR)) { + setIcon(UIConstants.AUTO_FONT_ICON); + } + + super.checkColorChange(oldColor, newColor); + } + + protected ColorControlWindow getColorControlWindow() { + if (getPopupWin() == null) { + ColorControlWindowWithAuto colorControlWindowWithAuto = new ColorControlWindowWithAuto(UIColorButtonWithAuto.this) { + protected void colorChanged() { + UIColorButtonWithAuto.this.setColor(this.getColor()); + } + }; + + setPopupWin(colorControlWindowWithAuto); + } + + return getPopupWin(); + } +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java index 1c2aef38a7..7112e5d657 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButton.java @@ -22,6 +22,8 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam private GlobalNameListener globalNameListener = null; private String radioButtonName = StringUtils.EMPTY; + private boolean markMnemonic = true; + public UIRadioButton() { super(); initListener(); @@ -58,6 +60,13 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam initComponent(); } + public UIRadioButton(String text, boolean selected, boolean markMnemonic) { + super(text, selected); + initListener(); + initComponent(); + this.markMnemonic = markMnemonic; + } + public UIRadioButton(String text, Icon icon) { super(text, icon); initListener(); @@ -70,6 +79,13 @@ public class UIRadioButton extends JRadioButton implements UIObserver, GlobalNam initListener(); } + public void setMnemonic(char mnemonic) { + super.setMnemonic(mnemonic); + if (!markMnemonic) { + setDisplayedMnemonicIndex(-1); + } + } + private void initListener() { if (shouldResponseChangeListener()) { this.addItemListener(new ItemListener() { diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButtonUI.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButtonUI.java index 0e054b6938..811c1c2bdf 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButtonUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIRadioButtonUI.java @@ -5,9 +5,12 @@ import com.fr.design.utils.ThemeUtils; import javax.swing.*; import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicHTML; import javax.swing.plaf.metal.MetalRadioButtonUI; import java.awt.*; import java.awt.event.KeyEvent; +import javax.swing.text.View; +import sun.swing.SwingUtilities2; /** * Created by IntelliJ IDEA. @@ -84,6 +87,124 @@ public class UIRadioButtonUI extends MetalRadioButtonUI { return radioButton; } + // ******************************** + // Paint Methods + // ******************************** + public synchronized void paint(Graphics g, JComponent c) { + + AbstractButton b = (AbstractButton) c; + ButtonModel model = b.getModel(); + + Dimension size = c.getSize(); + + int w = size.width; + int h = size.height; + + Font f = c.getFont(); + g.setFont(f); + FontMetrics fm = SwingUtilities2.getFontMetrics(c, g, f); + + Rectangle viewRect = new Rectangle(size); + Rectangle iconRect = new Rectangle(); + Rectangle textRect = new Rectangle(); + + Insets i = c.getInsets(); + viewRect.x += i.left; + viewRect.y += i.top; + viewRect.width -= (i.right + viewRect.x); + viewRect.height -= (i.bottom + viewRect.y); + + Icon altIcon = b.getIcon(); + Icon selectedIcon = null; + Icon disabledIcon = null; + + String text = SwingUtilities.layoutCompoundLabel( + c, fm, b.getText(), altIcon != null ? altIcon : getDefaultIcon(), + b.getVerticalAlignment(), b.getHorizontalAlignment(), + b.getVerticalTextPosition(), b.getHorizontalTextPosition(), + viewRect, iconRect, textRect, b.getIconTextGap()); + + // fill background + if (c.isOpaque()) { + g.setColor(b.getBackground()); + g.fillRect(0, 0, size.width, size.height); + } + + + // Paint the radio button + if (altIcon != null) { + + if (!model.isEnabled()) { + if (model.isSelected()) { + altIcon = b.getDisabledSelectedIcon(); + } else { + altIcon = b.getDisabledIcon(); + } + } else if (model.isPressed() && model.isArmed()) { + altIcon = b.getPressedIcon(); + if (altIcon == null) { + // Use selected icon + altIcon = b.getSelectedIcon(); + } + } else if (model.isSelected()) { + if (b.isRolloverEnabled() && model.isRollover()) { + altIcon = b.getRolloverSelectedIcon(); + if (altIcon == null) { + altIcon = b.getSelectedIcon(); + } + } else { + altIcon = b.getSelectedIcon(); + } + } else if (b.isRolloverEnabled() && model.isRollover()) { + altIcon = b.getRolloverIcon(); + } + + if (altIcon == null) { + altIcon = b.getIcon(); + } + + altIcon.paintIcon(c, g, iconRect.x, iconRect.y); + + } else { + getDefaultIcon().paintIcon(c, g, iconRect.x, iconRect.y); + } + + // Draw the Text + if (text != null) { + View v = (View) c.getClientProperty(BasicHTML.propertyKey); + if (v != null) { + v.paint(g, textRect); + } else { + int mnemIndex = b.getDisplayedMnemonicIndex(); + if (model.isEnabled()) { + // *** paint the text normally + g.setColor(b.getForeground()); + } else { + // *** paint the text disabled + g.setColor(getDisabledTextColor()); + } + if (markMnemonic(text, mnemIndex)) { + SwingUtilities2.drawStringUnderlineCharAt(c, g, text, + mnemIndex, textRect.x, textRect.y + fm.getAscent()); + } else { + SwingUtilities2.drawString(c, g, text, textRect.x, textRect.y + fm.getAscent()); + } + } + if (b.hasFocus() && b.isFocusPainted() && + textRect.width > 0 && textRect.height > 0) { + paintFocus(g, textRect, size); + } + } + } + + /** + * @param text + * @param mnemIndex 助记符在text中的索引 + * @return true:需要给助记符画一个下划线 + */ + private boolean markMnemonic(String text, int mnemIndex) { + return mnemIndex > 0 && text != null && text.length() > 0 && text.length() > mnemIndex; + } /** * Paints the focus for the radiobutton diff --git a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java index 379274b90b..e294d80220 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java @@ -34,6 +34,7 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser private UIObserverListener uiObserverListener; private GlobalNameListener globalNameListener = null; private String checkboxName = ""; + private boolean markMnemonic = true; public UICheckBox(String string) { super(string); @@ -53,6 +54,13 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser initListener(); } + public UICheckBox(String locText, boolean b, boolean markMnemonic) { + super(locText, b); + setUI(new UICheckBoxUI()); + initListener(); + this.markMnemonic=markMnemonic; + } + public UICheckBox(String text, Icon icon) { super(text, icon); setUI(new UICheckBoxUI()); @@ -189,14 +197,18 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser if (v != null) { v.paint(g, textRect); } else { - int mnemIndex = b.getDisplayedMnemonicIndex(); + if (model.isEnabled()) { g.setColor(b.getForeground()); } else { g.setColor(getDisabledTextColor()); } - SwingUtilities2.drawStringUnderlineCharAt(c, g, text, - mnemIndex, textRect.x, textRect.y + fm.getAscent()); + if (markMnemonic) { + SwingUtilities2.drawStringUnderlineCharAt(c, g, text, + b.getDisplayedMnemonicIndex(), textRect.x, textRect.y + fm.getAscent()); + } else { + SwingUtilities2.drawString(c, g, text, textRect.x, textRect.y + fm.getAscent()); + } } } } diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java index c3dd64c9d4..a7a9133351 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java @@ -1,22 +1,14 @@ package com.fr.design.gui.icombobox; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.IllegalComponentStateException; -import java.awt.RenderingHints; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseMotionListener; -import java.util.Enumeration; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.NameObject; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -38,16 +30,23 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; - -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.general.ComparatorUtils; -import com.fr.general.NameObject; -import com.fr.stable.Constants; -import com.fr.stable.StringUtils; +import java.util.Enumeration; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.IllegalComponentStateException; +import java.awt.RenderingHints; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionAdapter; +import java.awt.event.MouseMotionListener; public class FRTreeComboBox extends UIComboBox { @@ -79,7 +78,7 @@ public class FRTreeComboBox extends UIComboBox { boolean showRoot, boolean editable) { this.setTree(tree); this.tree.setCellRenderer(renderer); - this.setEditor(new FrTreeSearchComboBoxEditor(this)); + this.setEditor(createEditor()); if (!showRoot) { tree.expandPath(new TreePath(tree.getModel().getRoot())); tree.setRootVisible(false); @@ -101,6 +100,10 @@ public class FRTreeComboBox extends UIComboBox { return true; } + protected UIComboBoxEditor createEditor() { + return new FrTreeSearchComboBoxEditor(this); + } + public void setTree(JTree tree) { this.tree = tree; if (tree != null) { @@ -529,7 +532,7 @@ public class FRTreeComboBox extends UIComboBox { } } - class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { + public class FrTreeSearchComboBoxEditor extends UIComboBoxEditor implements DocumentListener { private volatile boolean setting = false; private FRTreeComboBox comboBox; private Object item; diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java index 6eba4a6da0..2d9f354ab8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java @@ -371,6 +371,14 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam popup.setSelectedValue(map); } + @Override + public void setEnabled(boolean enabled) { + super.setEnabled(enabled); + this.popup.setEnabled(enabled); + this.editor.setEnabled(enabled); + this.arrowButton.setEnabled(enabled); + } + /** * 简单的测试demo * @param args diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java index 06a4f54800..cccf64e26d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java @@ -91,10 +91,10 @@ public class TableViewList extends UIList { if (refreshList != null) { refreshList.cancel(true); } - refreshList = new SwingWorker() { + refreshList = new SwingWorker() { @Override - protected Void doInBackground() throws Exception { + protected DefaultListModel doInBackground() throws Exception { Connection datasource = ConnectionConfig.getInstance().getConnection(databaseName); boolean status = false; int count = 3; @@ -106,13 +106,13 @@ public class TableViewList extends UIList { if (!status) { throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); } - TableViewList.this.setModel(processDataInAnotherThread(databaseName, searchFilter, typesFilter)); - return null; + return processDataInAnotherThread(databaseName, searchFilter, typesFilter); } + @Override public void done() { try { - get(); + TableViewList.this.setModel(get()); } catch (Exception e) { if (!(e instanceof InterruptedException) && !(e instanceof CancellationException)) { TableViewList.this.setModel(failed); diff --git a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java index fc219a30bc..7d04113078 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java +++ b/designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java @@ -235,7 +235,7 @@ public abstract class UITableModelAdapter extends AbstractTabl public void actionPerformed(ActionEvent e) { int[] selectedRow = table.getSelectedRows(); if (ismultiSelected()) { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Multiple_Select_Warn_Text")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Multiple_Select_Warn_Text")); return; } if (table.getCellEditor() != null) { diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index da0cd32ed5..0dcfe4c217 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java @@ -229,6 +229,16 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse cellBorderStyle.setVerticalStyle(verticalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); cellBorderStyle.setHorizontalColor(lineColor); cellBorderStyle.setHorizontalStyle(horizontalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); + if (leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected()) { + outerToggleButton.setSelected(true); + } else { + outerToggleButton.setSelected(false); + } + if (verticalToggleButton.isSelected() && horizontalToggleButton.isSelected()) { + innerToggleButton.setSelected(true); + } else { + innerToggleButton.setSelected(false); + } return cellBorderStyle; } diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java index 795c6d455a..0b33b7adfc 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java @@ -6,6 +6,8 @@ import com.fr.base.Style; import com.fr.base.TextFormat; import com.fr.data.core.FormatField; import com.fr.data.core.FormatField.FormatContents; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.i18n.Toolkit; import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; @@ -21,6 +23,8 @@ import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; +import java.math.BigDecimal; +import java.math.RoundingMode; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.TitledBorder; @@ -36,20 +40,23 @@ import java.text.SimpleDateFormat; * @author zhou * @since 2012-5-24上午10:57:00 */ -public class FormatPane extends AbstractBasicStylePane implements GlobalNameObserver { +public class FormatPane extends AbstractBasicStylePane implements GlobalNameObserver { private static final long serialVersionUID = 724330854437726751L; - private static final int LABLE_X = 4; - private static final int LABLE_Y = 18; - private static final int LABLE_DELTA_WIDTH = 8; - private static final int LABLE_HEIGHT = 15; //标签背景的范围 + private static final int LABEL_X = 4; + private static final int LABEL_Y = 18; + private static final int LABEL_DELTA_WIDTH = 8; + private static final int LABEL_HEIGHT = 15; //标签背景的范围 private static final int CURRENCY_FLAG_POINT = 6; - private static final Border LEFT_BORDER = BorderFactory.createEmptyBorder(0,30,0,0); + private static final Border LEFT_BORDER = BorderFactory.createEmptyBorder(0, 30, 0, 0); - private static final Integer[] TYPES = new Integer[]{FormatContents.NULL, FormatContents.NUMBER, FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.SCIENTIFIC, - FormatContents.DATE, FormatContents.TIME, FormatContents.TEXT}; + private static final Integer[] TYPES = new Integer[]{ + FormatContents.NULL, FormatContents.NUMBER, + FormatContents.CURRENCY, FormatContents.PERCENT, + FormatContents.SCIENTIFIC, FormatContents.DATE, + FormatContents.TIME, FormatContents.TEXT}; - private static final Integer[] DATETYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME,}; + private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME}; private Format format; @@ -59,9 +66,11 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs private JPanel contentPane; private JPanel txtCenterPane; private JPanel centerPane; + private JPanel optionPane; + private UICheckBox roundingBox; private JPanel formatFontPane; private FRFontPane frFontPane; - private boolean isRightFormate; + private boolean isRightFormat; private boolean isDate = false; private GlobalNameListener globalNameListener = null; @@ -78,7 +87,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs protected void initComponents(Integer[] types) { this.setLayout(new BorderLayout(0, 4)); - iniSampleLable(); + initSampleLabel(); contentPane = new JPanel(new BorderLayout(0, 4)) { @Override public Dimension getPreferredSize() { @@ -108,7 +117,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs frFontPane = new FRFontPane(); - UILabel font = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FR_Font"), SwingConstants.LEFT); + UILabel font = new UILabel(Toolkit.i18nText("Fine-Design_Form_FR_Font"), SwingConstants.LEFT); JPanel fontPane = new JPanel(new BorderLayout()); fontPane.add(font, BorderLayout.NORTH); @@ -119,6 +128,22 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs // centerPane.setBorder(LEFT_BORDER); frFontPane.setBorder(LEFT_BORDER); + JPanel option = new JPanel(new BorderLayout()); + option.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"), SwingConstants.LEFT), BorderLayout.WEST); + roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up")); + roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 40, 0, 0)); + roundingBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + } + }); + roundingBox.setGlobalName("roundingBox"); + option.add(roundingBox, BorderLayout.CENTER); + optionPane = new JPanel(new CardLayout()); + optionPane.add(new JPanel(), "hide"); + optionPane.setPreferredSize(new Dimension(0, 0)); + optionPane.add(option, "show"); + Component[][] components = getComponent(fontPane, centerPane, typePane); this.add(createContentPane(components), BorderLayout.CENTER); } @@ -136,8 +161,9 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { return new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, new Component[]{centerPane, null}, + new Component[]{optionPane, null}, new Component[]{fontPane, frFontPane}, }; } @@ -155,24 +181,24 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs }; } - private void iniSampleLable() { - Border innterborder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); - Font tmpFont = null; - Border border = BorderFactory.createTitledBorder(innterborder, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"), TitledBorder.LEFT, 0, tmpFont, UIConstants.LINE_COLOR); + private void initSampleLabel() { + Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); + String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); + Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR); sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { @Override public void paint(Graphics g) { super.paint(g); int width = getWidth(); - Color orignal = g.getColor(); + Color original = g.getColor(); g.setColor(getBackground()); - g.fillRect(LABLE_X, LABLE_Y, width - LABLE_DELTA_WIDTH, LABLE_HEIGHT); + g.fillRect(LABEL_X, LABEL_Y, width - LABEL_DELTA_WIDTH, LABEL_HEIGHT); g.setColor(UIConstants.LINE_COLOR); FontMetrics cellFM = g.getFontMetrics(); int textWidth = cellFM.stringWidth(getText()); GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); - g.setColor(orignal); + g.setColor(original); } }; sampleLabel.setHorizontalAlignment(UILabel.CENTER); @@ -197,7 +223,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs * @return 标题 */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text"); + return Toolkit.i18nText("Fine-Design_Report_Text"); } /** @@ -212,14 +238,11 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs if (format instanceof CoreDecimalFormat) { // check all value String pattern = ((CoreDecimalFormat) format).toPattern(); - boolean isCurrency1 = (pattern.length() > 0 && pattern.charAt(0) == '¤'); - boolean isCurrency2 = (pattern.length() > 0 && pattern.charAt(0) == '$'); - boolean isCurrency = isCurrency1 || isCurrency2; - boolean isCurrency4 = (pattern.length() > CURRENCY_FLAG_POINT && ComparatorUtils.equals(pattern.substring(0, CURRENCY_FLAG_POINT), "#,##0;")); - if (isCurrency || isCurrency4) { + if (isCurrencyFormatStyle(pattern)) { setPatternComboBoxAndList(FormatContents.CURRENCY, pattern); - } else if (pattern.endsWith("%")) { + } else if (pattern.indexOf("%") > 0) { setPatternComboBoxAndList(FormatContents.PERCENT, pattern); + this.roundingBox.setSelected(((CoreDecimalFormat) format).getRoundingMode().equals(RoundingMode.HALF_UP)); } else if (pattern.indexOf("E") > 0) { setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern); } else { @@ -238,6 +261,17 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs } } + private boolean isCurrencyFormatStyle(String pattern) { + if (pattern.length() == 0) { + return false; + } + + if (pattern.charAt(0) == '¤' || pattern.charAt(0) == '$') { + return true; + } + + return pattern.length() > CURRENCY_FLAG_POINT && pattern.startsWith("#,##0;"); + } /** * 判断是否是数组有模式 @@ -273,9 +307,10 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs if (getFormatContents() == FormatContents.TEXT) { return FormatField.getInstance().getFormat(getFormatContents(), patternString); } - if (isRightFormate) { + if (isRightFormat) { if (StringUtils.isNotEmpty(patternString)) { - return FormatField.getInstance().getFormat(getFormatContents(), patternString); + RoundingMode roundingMode = roundingBox.isSelected() ? RoundingMode.HALF_UP : RoundingMode.HALF_EVEN; + return FormatField.getInstance().getFormat(getFormatContents(), patternString, roundingMode); } } return null; @@ -292,7 +327,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); try { - isRightFormate = true; + isRightFormat = true; if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { return; } @@ -300,7 +335,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs } catch (Exception e) { this.sampleLabel.setForeground(Color.red); this.sampleLabel.setText(e.getMessage()); - isRightFormate = false; + isRightFormat = false; } } @@ -331,6 +366,15 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs centerPane.setPreferredSize(new Dimension(270, 65)); cardLayout.show(centerPane, "show"); } + CardLayout optionLayout = ((CardLayout) optionPane.getLayout()); + if (getFormatContents() == FormatContents.PERCENT) { + optionPane.setPreferredSize(new Dimension(100, 20)); + optionLayout.show(optionPane, "show"); + } else { + optionPane.setPreferredSize(new Dimension(0, 0)); + optionLayout.show(optionPane, "hide"); + roundingBox.setSelected(false); + } } } @@ -359,7 +403,9 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs * update */ public Style update(Style style) { - if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField") || ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox")) { + if (ComparatorUtils.equals(globalNameListener.getGlobalName(), "textField") + || ComparatorUtils.equals(globalNameListener.getGlobalName(), "typeComboBox") + || ComparatorUtils.equals(globalNameListener.getGlobalName(), "roundingBox")) { return style.deriveFormat(this.update()); } else { return style.deriveFRFont(this.frFontPane.update(style.getFRFont())); @@ -401,8 +447,8 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs this.isDate = isDate; this.typeComboBox.setSelectedIndex(0); if (isDate) { - for (int i = 0; i < DATETYPES.length; i++) { - this.typeComboBox.addItem(DATETYPES[i]); + for (int i = 0; i < DATE_TYPES.length; i++) { + this.typeComboBox.addItem(DATE_TYPES[i]); } for (int i = 0; i < TYPES.length; i++) { this.typeComboBox.removeItemAt(1); @@ -411,7 +457,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObs for (int i = 0; i < TYPES.length; i++) { this.typeComboBox.addItem(TYPES[i]); } - for (int i = 0; i < DATETYPES.length; i++) { + for (int i = 0; i < DATE_TYPES.length; i++) { this.typeComboBox.removeItemAt(1); } } diff --git a/designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java b/designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java index 176d6ec3c1..7d57708642 100644 --- a/designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java +++ b/designer-base/src/main/java/com/fr/design/i18n/DesignI18nImpl.java @@ -1,5 +1,6 @@ package com.fr.design.i18n; +import com.fr.design.DesignerEnvManager; import com.fr.general.GeneralContext; import com.fr.general.log.MessageFormatter; import com.fr.locale.DesignI18nProvider; @@ -14,6 +15,11 @@ import java.util.Locale; public class DesignI18nImpl implements DesignI18nProvider { + static { + // GeneralContext上下文 存储本次启动的语言环境 直接使用DesignerEnvManager 会在设置语言环境后 不重启 立即生效 存在问题 + GeneralContext.setLocale(DesignerEnvManager.getEnvManager().getLanguage()); + } + private static DesignI18nImpl instance = new DesignI18nImpl(); public static DesignI18nImpl getInstance() { diff --git a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java index 8806d6853c..158c05d1e1 100644 --- a/designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java +++ b/designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java @@ -2,6 +2,7 @@ package com.fr.design.javascript; import com.fr.base.Parameter; import com.fr.design.data.tabledata.tabledatapane.OneListTableModel; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.frpane.ReportletParameterViewPane; import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itableeditorpane.UITableEditAction; @@ -62,7 +63,7 @@ public class JavaScriptImplPane extends AbstractHyperLinkPane { } if (tempSet.contains(list.get(i).toString())) { list.remove(i); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!"); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameter_Duplicate_Name") + "!"); parameterChanger(list); return; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java index 9362f37c5a..49fffa6cef 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerContext.java @@ -4,6 +4,7 @@ package com.fr.design.mainframe; import com.fr.base.Style; +import com.fr.design.base.clipboard.DesignerClipboard; import com.fr.design.designer.TargetComponent; import com.fr.design.dialog.BasicDialog; import com.fr.log.FineLoggerFactory; @@ -56,41 +57,53 @@ public class DesignerContext { public static DesignerBean getDesignerBean(String name) { return beans.get(name) == null ? DesignerBean.NULL : beans.get(name); } - - public static void setDesignerBean(String name, DesignerBean bean) { - beans.put(name, bean); - } - - /** - * Gets the Clipboard. - */ - public static Clipboard getClipboard(JComponent comp) { - if (DesignerContext.clipboard == null) { - try { - Action transferAction = TransferHandler.getCutAction(); - Method clipMethod = StableUtils.getDeclaredMethod(transferAction.getClass(), "getClipboard", new Class[]{JComponent.class}); - clipMethod.setAccessible(true); - - return (Clipboard) clipMethod.invoke(transferAction, new Object[]{comp}); - } catch (Exception securityException) { - FineLoggerFactory.getLogger().error(securityException.getMessage(), securityException); - //用反射机制,获得TransferHandler的getClipboard - //这样可以保证和TextField直接的copy paste - try { - //控件的Clipboard. - DesignerContext.clipboard = comp.getToolkit().getSystemClipboard(); - } catch (Exception exp) { - FineLoggerFactory.getLogger().error(exp.getMessage(), exp); - DesignerContext.clipboard = new Clipboard("FR"); - } - } - } - - return DesignerContext.clipboard; - } - - - public static void setFormatState(int setformatState) { + + public static void setDesignerBean(String name, DesignerBean bean) { + beans.put(name, bean); + } + + /** + * get this custom clipboard + */ + public static Clipboard getClipboard(JComponent comp) { + + if (DesignerContext.clipboard == null) { + + Clipboard clipboard = getClipboard0(comp); + return new DesignerClipboard(clipboard); + } + return DesignerContext.clipboard; + } + + /** + * Gets the system Clipboard. + */ + private static Clipboard getClipboard0(JComponent comp) { + + Clipboard clipboard = null; + try { + Action transferAction = TransferHandler.getCutAction(); + Method clipMethod = StableUtils.getDeclaredMethod(transferAction.getClass(), "getClipboard", new Class[]{JComponent.class}); + clipMethod.setAccessible(true); + + return (Clipboard) clipMethod.invoke(transferAction, new Object[]{comp}); + } catch (Exception securityException) { + FineLoggerFactory.getLogger().error(securityException.getMessage(), securityException); + //用反射机制,获得TransferHandler的getClipboard + //这样可以保证和TextField直接的copy paste + try { + //控件的Clipboard. + clipboard = comp.getToolkit().getSystemClipboard(); + } catch (Exception exp) { + FineLoggerFactory.getLogger().error(exp.getMessage(), exp); + clipboard = new Clipboard("FR"); + } + } + return clipboard; + } + + + public static void setFormatState(int setformatState) { formatState = setformatState; } 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 4d37d75390..2cf8d8c350 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 @@ -40,6 +40,7 @@ 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.os.impl.MacOsAddListenerAction; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.event.EventDispatcher; @@ -50,16 +51,18 @@ import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; +import com.fr.general.IOUtils; +import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; -import com.fr.stable.OperatingSystem; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.image4j.codec.ico.ICODecoder; +import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; import com.fr.stable.project.ProjectConstants; @@ -314,6 +317,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta // window close listener. this.addWindowListeners(getFrameListeners()); + addMacOsListener(); + this.addComponentListener(new ComponentAdapter() { @Override @@ -466,7 +471,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta OSSupportCenter.buildAction(new OSBasedAction() { @Override public void execute(Object... objects) { - bbsLoginPane[0] = ad.createBBSLoginPane(); + bbsLoginPane[0] = ad.createBBSLoginPane(); } }, SupportOSImpl.USERINFOPANE); processor.hold(northEastPane, LogMessageBar.getInstance(), bbsLoginPane[0]); @@ -478,7 +483,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta OSSupportCenter.buildAction(new OSBasedAction() { @Override public void execute(Object... objects) { - northEastPane.add(ad.createBBSLoginPane()); + northEastPane.add(ad.createBBSLoginPane()); } }, SupportOSImpl.USERINFOPANE); @@ -501,8 +506,14 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta image = ICODecoder.read(DesignerFrame.class .getResourceAsStream("/com/fr/base/images/oem/logo.ico")); } - this.setIconImages(image); - } catch (IOException e) { + if (OperatingSystem.isMacos()) { + Class clazz = Class.forName("com.apple.eawt.Application"); + BufferedImage icon = image.isEmpty() ? IOUtils.readImage("/com/fr/base/images/oem/logo.png") : image.get(image.size() - 1); + Reflect.on(Reflect.on(clazz).call("getApplication").get()).call("setDockIconImage", icon); + } else { + this.setIconImages(image); + } + } catch (IOException | ClassNotFoundException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); this.setIconImage(BaseUtils.readImage("/com/fr/base/images/oem/logo.png")); } @@ -515,6 +526,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } + private void addMacOsListener() { + OSSupportCenter.buildAction(new MacOsAddListenerAction(), SupportOSImpl.DOCK_QUIT); + } + protected ArrayList getFrameListeners() { ArrayList arrayList = new ArrayList<>(); @@ -1086,6 +1101,17 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta */ private void openFile(FILE tplFile) { + if (tplFile != null) { + int index = HistoryTemplateListCache.getInstance().contains(tplFile); + if (index != -1) { + JTemplate jt = HistoryTemplateListCache.getInstance().getHistoryList().get(index); + if (!(jt instanceof JVirtualTemplate)) { + jt.activeOldJTemplate(); + return; + } + } + } + JTemplate jt = JTemplateFactory.createJTemplate(tplFile); if (jt == null) { return; @@ -1095,23 +1121,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.addAndActivateJTemplate(); MutilTempalteTabPane.getInstance().setTemTemplate( HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()); - } else { - activeTemplate(jt); - } - } - - /** - * 激活指定的模板 - * - * @param jt 当前报表 - * @date 2014-10-14-下午6:31:23 - */ - private void activeTemplate(JTemplate jt) { - // 如果该模板已经打开,则进行激活就可以了 - int index = HistoryTemplateListCache.getInstance().contains(jt); - List> historyList = HistoryTemplateListCache.getInstance().getHistoryList(); - if (index != -1) { - historyList.get(index).activeJTemplate(index, jt); } else { this.addAndActivateJTemplate(jt); } @@ -1135,8 +1144,10 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta Thread.currentThread().interrupt(); } - DesignerEnvManager.getEnvManager().setLastOpenFile( - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath()); + JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jt != null) { + DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); + } DesignerEnvManager.getEnvManager().setLastWestRegionToolPaneY( WestRegionContainerPane.getInstance().getToolPaneY()); @@ -1269,4 +1280,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta progressDialog.dispose(); } + + /** + * 设计器是否已经打开 + * + * @return 设计器是否已经打开 + */ + public boolean isDesignerOpened() { + return designerOpened; + } } 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 b4b469e10a..bcac7f946c 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 @@ -684,21 +684,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt this.dispose(); //模版重命名 - boolean success = false; - - // 提醒保存文件 - SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(true); - // 只有一个文件未保存时 - if (HistoryTemplateListCache.getInstance().getHistoryCount() == 1) { - int choose = saveSomeTempaltePane.saveLastOneTemplate(); - if (choose != JOptionPane.CANCEL_OPTION) { - success = selectedOperation.rename(fnf, path, newPath); - } - } else { - if (saveSomeTempaltePane.showSavePane()) { - success = selectedOperation.rename(fnf, path, newPath); - } - } + boolean success = selectedOperation.rename(fnf, path, newPath); if (success) { HistoryTemplateListCache.getInstance().rename(fnf, path, newPath); 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 482b0d3375..66d7216c91 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 @@ -93,10 +93,11 @@ public abstract class JTemplate> protected U authorityUndoState = null; protected T template; // 当前模板 protected TemplateProcessInfo processInfo; // 模板过程的相关信息 + private JComponent centerPane; private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private DesignModelAdapter designModel; private PreviewProvider previewType; - private TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); + protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); public int resolution = ScreenResolution.getScreenResolution(); public JTemplate() { @@ -123,7 +124,7 @@ public abstract class JTemplate> this.editingFILE = file; this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder()); - this.add(createCenterPane(), BorderLayout.CENTER); + addCenterPane(); this.undoState = createUndoState(); designModel = createDesignModel(); @@ -246,19 +247,47 @@ public abstract class JTemplate> } + /** + * 模板关闭时 + */ + public void whenClose() { + // do nothing + } + /** * 刷新内部资源 + * + * 刷新资源的同时。 + * CenterPane 负责监听改动。 + * 所以需要同步处理 */ public void refreshResource() { try { this.template = JTemplateFactory.asIOFile(this.editingFILE); setTarget(this.template); + + // 先移除旧的。 + removeCenterPane(); + // 加入新的 + addCenterPane(); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + private void addCenterPane() { + + this.centerPane = createCenterPane(); + this.add(centerPane, BorderLayout.CENTER); + } + + private void removeCenterPane() { + + JComponent centerPane = this.centerPane; + this.remove(centerPane); + } + /** * 刷新容器 */ diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java index a3665b77bd..15291211cb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointCollector.java @@ -5,6 +5,8 @@ import com.fr.base.io.XMLReadHelper; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.template.info.SendHelper; import com.fr.log.FineLoggerFactory; +import com.fr.stable.ProductConstants; +import com.fr.stable.StableUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLableReader; @@ -121,10 +123,23 @@ public abstract class AbstractPointCollector implem } } + + private File getInfoFile() { + File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), getInfoFilePath())); + try { + if (!file.exists()) { + StableUtils.makesureFileExist(file); + } + } catch (Exception ex) { + FineLoggerFactory.getLogger().error(ex.getMessage(), ex); + } + return file; + } + /** * 获取缓存文件存放路径 */ - protected abstract File getInfoFile(); + protected abstract String getInfoFilePath(); protected abstract void addIdleDayCount(); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java index 6646bfd09a..11058af5cb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java @@ -11,6 +11,9 @@ public abstract class AbstractPointInfo implements BasePointInfo { protected int idleDayCount; // 到现在为止,埋点闲置的天数 + //是否是测试模板 + protected boolean testTemplate; + @Override public void resetIdleDayCount() { this.idleDayCount = 0; @@ -38,10 +41,14 @@ public abstract class AbstractPointInfo implements BasePointInfo { } } + public void setTestTemplate(boolean testTemplate) { + this.testTemplate = testTemplate; + } + /** * 是否为测试模板 */ - protected abstract boolean isTestTemplate(); + public abstract boolean isTestTemplate(); /** * 是否已经制作完成 diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java index 9d305ef1da..4c546c4cd9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java @@ -1,6 +1,10 @@ package com.fr.design.mainframe.chart.info; import com.fr.base.io.BaseBook; +import com.fr.chartx.attr.ChartProvider; +import com.fr.chartx.config.info.AbstractConfig; +import com.fr.chartx.config.info.ChartConfigInfo; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.config.MarketConfig; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; @@ -26,10 +30,11 @@ import java.util.Map; public class ChartInfo extends AbstractPointInfo { public static final String XML_TAG = "ChartInfo"; private static final String CHART_CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("chartinfo.consuming") + "/single"; - + private static final String CHART_FUNCTION_URL = CloudCenter.getInstance().acquireUrlByKind("chart.info.function") + "/single"; private static final String XML_CHART_CONSUMING_MAP = "chartConsumingMap"; private static final String ATTR_TEST_TEMPLATE = "testTemplate"; + private static final String ATTR_TEST_CHART = "testChart"; private static final String ATTR_DAY_COUNT = "day_count"; private static final String ATTR_USERNAME = "username"; private static final String ATTR_UUID = "uuid"; @@ -44,6 +49,11 @@ public class ChartInfo extends AbstractPointInfo { private static final String ATTR_CHART_PROPERTY_END_TIME = "chartPropertyEndTime"; private static final String ATTR_JAR_TIME = "jarTime"; private static final String ATTR_VERSION = "version"; + private static final String ATTR_USER_ID = "userId"; + private static final String ATTR_FIRST_CHART_TYPE = "firstChartType"; + private static final String ATTR_OVER_CHART_TYPE_COUNT = "overChartTypeCount"; + private static final String ATTR_IS_NEW = "isNew"; + private static final String ATTR_IS_REUSE = "isReuse"; private static final int COMPLETE_DAY_COUNT = 3; // 判断图表是否可以上传的天数 @@ -53,9 +63,12 @@ public class ChartInfo extends AbstractPointInfo { private Map chartConsumingMap = new HashMap<>(); + private ChartConfigInfo chartConfigInfo = new ChartConfigInfo(); + private BaseBook book; - private boolean testTemplate; + + private boolean testChart; private ChartInfo() { } @@ -64,6 +77,7 @@ public class ChartInfo extends AbstractPointInfo { this.chartId = chartId; this.templateId = templateId; this.book = book; + this.testChart = true; } public String getChartId() { @@ -84,36 +98,42 @@ public class ChartInfo extends AbstractPointInfo { this.chartConsumingMap.put(ATTR_TEMPLATE_ID, templateId); } - public BaseBook getBook() { return book; } @Override public boolean isTestTemplate() { - return testTemplate; + return testTemplate || testChart; } public void setTestTemplate(boolean testTemplate) { this.testTemplate = testTemplate; } + public void setTestChart(boolean testChart) { + this.testChart = testChart; + } + static ChartInfo newInstanceByRead(XMLableReader reader) { ChartInfo chartInfo = new ChartInfo(); reader.readXMLObject(chartInfo); return chartInfo; } - public static ChartInfo newInstance(String chartId, String chartType) { - return newInstance(chartId, chartType, null); + public static ChartInfo newInstance(ChartProvider chartProvider) { + return newInstance(chartProvider, null, false, false); } - public static ChartInfo newInstance(String chartId, String chartType, String createTime) { + public static ChartInfo newInstance(ChartProvider chartProvider, String createTime, boolean isNew, boolean isReuse) { HashMap chartConsumingMap = new HashMap<>(); String username = MarketConfig.getInstance().getBbsUsername(); + String userId = String.valueOf(MarketConfig.getInstance().getBbsUid()); String uuid = DesignerEnvManager.getEnvManager().getUUID(); String activityKey = DesignerEnvManager.getEnvManager().getActivationKey(); + String chartId = chartProvider.getChartUuid(); + String chartType = chartProvider.getID(); BaseBook book = DesignModelAdapter.getCurrentModelAdapter().getBook(); String templateId = book.getTemplateID(); @@ -138,9 +158,15 @@ public class ChartInfo extends AbstractPointInfo { chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); chartConsumingMap.put(ATTR_JAR_TIME, jarTime); chartConsumingMap.put(ATTR_VERSION, version); + chartConsumingMap.put(ATTR_USER_ID, userId); + chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType); + chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, "0"); + chartConsumingMap.put(ATTR_IS_NEW, String.valueOf(isNew)); + chartConsumingMap.put(ATTR_IS_REUSE, String.valueOf(isReuse)); ChartInfo chartInfo = new ChartInfo(chartId, templateId, book); chartInfo.chartConsumingMap = chartConsumingMap; + chartProvider.initChartConfigInfo(chartInfo.chartConfigInfo); return chartInfo; } @@ -158,6 +184,7 @@ public class ChartInfo extends AbstractPointInfo { writer.attr(ATTR_DAY_COUNT, this.idleDayCount); } writer.attr(ATTR_TEST_TEMPLATE, this.testTemplate); + writer.attr(ATTR_TEST_CHART, this.testChart); writer.startTAG(XML_CHART_CONSUMING_MAP); writer.attr(ATTR_USERNAME, chartConsumingMap.get(ATTR_USERNAME)); writer.attr(ATTR_UUID, chartConsumingMap.get(ATTR_UUID)); @@ -170,7 +197,14 @@ public class ChartInfo extends AbstractPointInfo { writer.attr(ATTR_CHART_PROPERTY_END_TIME, chartConsumingMap.get(ATTR_CHART_PROPERTY_END_TIME)); writer.attr(ATTR_JAR_TIME, chartConsumingMap.get(ATTR_JAR_TIME)); writer.attr(ATTR_VERSION, chartConsumingMap.get(ATTR_VERSION)); + writer.attr(ATTR_USER_ID, chartConsumingMap.get(ATTR_USER_ID)); + writer.attr(ATTR_FIRST_CHART_TYPE, chartConsumingMap.get(ATTR_FIRST_CHART_TYPE)); + writer.attr(ATTR_OVER_CHART_TYPE_COUNT, chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT)); + writer.attr(ATTR_IS_NEW, chartConsumingMap.get(ATTR_IS_NEW)); + writer.attr(ATTR_IS_REUSE, chartConsumingMap.get(ATTR_IS_REUSE)); writer.end(); + + chartConfigInfo.writeXML(writer); writer.end(); } @@ -182,6 +216,7 @@ public class ChartInfo extends AbstractPointInfo { chartId = reader.getAttrAsString(ATTR_CHART_ID, StringUtils.EMPTY); templateId = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY); testTemplate = reader.getAttrAsBoolean(ATTR_TEST_TEMPLATE, true); + testChart = reader.getAttrAsBoolean(ATTR_TEST_CHART, false); } else { String name = reader.getTagName(); if (XML_CHART_CONSUMING_MAP.equals(name)) { @@ -198,6 +233,14 @@ public class ChartInfo extends AbstractPointInfo { chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, reader.getAttrAsString(ATTR_CHART_PROPERTY_END_TIME, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY)); chartConsumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0")); + chartConsumingMap.put(ATTR_USER_ID, reader.getAttrAsString(ATTR_USER_ID, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, reader.getAttrAsString(ATTR_FIRST_CHART_TYPE, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, reader.getAttrAsString(ATTR_OVER_CHART_TYPE_COUNT, "0")); + chartConsumingMap.put(ATTR_IS_NEW, reader.getAttrAsString(ATTR_IS_NEW, StringUtils.EMPTY)); + chartConsumingMap.put(ATTR_IS_REUSE, reader.getAttrAsString(ATTR_IS_REUSE, StringUtils.EMPTY)); + } + if (ChartConfigInfo.XML_TAG.equals(name)) { + this.chartConfigInfo = (ChartConfigInfo) reader.readXMLObject(new ChartConfigInfo()); } } } @@ -212,9 +255,17 @@ public class ChartInfo extends AbstractPointInfo { public Map getSendInfo() { Map sendMap = new HashMap<>(); sendMap.put(CHART_CONSUMING_URL, new JSONObject(chartConsumingMap).toString()); + sendMap.put(CHART_FUNCTION_URL, getFunctionJson()); return sendMap; } + private String getFunctionJson() { + JSONObject jsonObject = JSONObject.create(); + jsonObject.put("chartID", this.chartId); + chartConfigInfo.toJSONObject(jsonObject); + return jsonObject.toString(); + } + public void updatePropertyTime() { String propertyTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); @@ -224,13 +275,31 @@ public class ChartInfo extends AbstractPointInfo { chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, propertyTime); } - public void updateChartType(String chartType) { + public void updateChartType(ChartProvider chartProvider) { String typeTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); chartConsumingMap.put(ATTR_CHART_TYPE_TIME, typeTime); - chartConsumingMap.put(ATTR_CHART_TYPE, chartType); + chartConsumingMap.put(ATTR_CHART_TYPE, chartProvider.getID()); chartConsumingMap.put(ATTR_CHART_PROPERTY_FIRST_TIME, ""); chartConsumingMap.put(ATTR_CHART_PROPERTY_END_TIME, ""); + String count = chartConsumingMap.get(ATTR_OVER_CHART_TYPE_COUNT); + count = StringUtils.isEmpty(count) ? "1" : String.valueOf(Integer.parseInt(count) + 1); + chartConsumingMap.put(ATTR_OVER_CHART_TYPE_COUNT, count); + + resetChartConfigInfo(chartProvider); + } + + public void resetChartConfigInfo(ChartProvider chartProvider) { + chartConfigInfo.reset(); + chartProvider.initChartConfigInfo(chartConfigInfo); + } + + public void updateFirstType(String chartType) { + chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType); + } + + public void updateChartConfig(ConfigType configType, AbstractConfig config) { + chartConfigInfo.updateChartConfig(configType, config); } @Override @@ -245,6 +314,7 @@ public class ChartInfo extends AbstractPointInfo { chartConsumingMap.put(entry.getKey(), entry.getValue()); } chartInfo.chartConsumingMap = chartConsumingMap; + chartInfo.chartConfigInfo = chartConfigInfo.clone(); return chartInfo; } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java index d622c688a5..87dc8ca40f 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfoCollector.java @@ -2,20 +2,16 @@ package com.fr.design.mainframe.chart.info; import com.fr.base.io.BaseBook; import com.fr.chartx.attr.ChartProvider; +import com.fr.chartx.config.info.AbstractConfig; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.design.mainframe.template.info.TemplateInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; -import com.fr.plugin.chart.vanchart.VanChart; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; import com.fr.third.joda.time.DateTime; - -import java.io.File; import java.util.HashMap; import java.util.Map; @@ -53,72 +49,92 @@ public class ChartInfoCollector extends AbstractPointCollector { } public void collection(ChartProvider chartProvider, String createTime) { - if (chartProvider instanceof VanChart) { - VanChart vanChart = (VanChart) chartProvider; - collection(vanChart.getUuid(), vanChart.getID(), createTime); - } + collection(chartProvider, createTime, false); } /** * 新建图表,保存状态 */ - public void collection(String chartId, String chartType, String createTime) { - if (!shouldCollectInfo()) { + public void collection(ChartProvider chartProvider, String createTime, boolean isReuse) { + String chartId = chartProvider.getChartUuid(); + if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) { return; } - - ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime); + ChartInfo chartInfo = ChartInfo.newInstance(chartProvider, createTime, true, isReuse); chartInfoCacheMap.put(chartId, chartInfo); } + /** + * 图表编辑,更新编辑时间 + */ public void updateChartPropertyTime(ChartProvider chartProvider) { - if (chartProvider instanceof VanChart) { - VanChart vanChart = (VanChart) chartProvider; - updateChartPropertyTime(vanChart.getUuid(), vanChart.getID()); + if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) { + return; } + ChartInfo chartInfo = getOrCreateChartInfo(chartProvider); + + //更新编辑时间 + chartInfo.updatePropertyTime(); + + //重置计数 + chartInfo.resetIdleDayCount(); } /** * 图表编辑,更新编辑时间 */ - public void updateChartPropertyTime(String chartId, String chartType) { - if (!shouldCollectInfo()) { + public void updateChartConfig(ChartProvider chartProvider, ConfigType configType, AbstractConfig config) { + if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) { return; } - ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); + ChartInfo chartInfo = getOrCreateChartInfo(chartProvider); - //更新编辑时间 - chartInfo.updatePropertyTime(); + //更新对应的配置 + chartInfo.updateChartConfig(configType, config); //重置计数 chartInfo.resetIdleDayCount(); } - public void updateChartTypeTime(ChartProvider chartProvider) { - if (chartProvider instanceof VanChart) { - VanChart vanChart = (VanChart) chartProvider; - updateChartTypeTime(vanChart.getUuid(), vanChart.getID()); + /** + * 图表子类型更新 + */ + public void updateChartMiniType(ChartProvider chartProvider) { + if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) { + return; } + ChartInfo chartInfo = getOrCreateChartInfo(chartProvider); + + //图表子类型更新 + chartInfo.resetChartConfigInfo(chartProvider); + + //重置计数 + chartInfo.resetIdleDayCount(); } /** * 图表类型变化,更新类型和类型确认时间 */ - public void updateChartTypeTime(String chartId, String chartType) { - if (!shouldCollectInfo()) { + public void updateChartTypeTime(ChartProvider chartProvider, String oldType) { + if (!shouldCollectInfo() || StringUtils.isEmpty(chartProvider.getChartUuid())) { return; } - ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); + ChartInfo chartInfo = getOrCreateChartInfo(chartProvider, oldType); //更新类型确认时间和类型 - chartInfo.updateChartType(chartType); + chartInfo.updateChartType(chartProvider); //重置计数 chartInfo.resetIdleDayCount(); } - private ChartInfo getOrCreateChartInfo(String chartId, String chartType) { + private ChartInfo getOrCreateChartInfo(ChartProvider chartProvider) { + return getOrCreateChartInfo(chartProvider, null); + } + + private ChartInfo getOrCreateChartInfo(ChartProvider chartProvider, String oldType) { + String chartId = chartProvider.getChartUuid(); //缓存中有从缓存中拿 if (chartInfoCacheMap.containsKey(chartId)) { return chartInfoCacheMap.get(chartId); @@ -129,12 +145,26 @@ public class ChartInfoCollector extends AbstractPointCollector { chartInfoCacheMap.put(chartId, chartInfo); return chartInfo; } - //都有的话创建一个并加入到缓存中 - ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType); + //都没有的话创建一个并加入到缓存中 + ChartInfo chartInfo = ChartInfo.newInstance(chartProvider); + if (StringUtils.isNotEmpty(oldType)) { + chartInfo.updateFirstType(oldType); + } chartInfoCacheMap.put(chartId, chartInfo); return chartInfo; } + public void checkTestChart(ChartProvider chartProvider) { + if (!shouldCollectInfo()) { + return; + } + ChartInfo chartInfo = chartInfoCacheMap.get(chartProvider.getChartUuid()); + if (chartInfo != null) { + boolean testChart = chartProvider.isTestChart(); + chartInfo.setTestChart(testChart); + } + } + /** * 保存模板的时候将该模板中的图表埋点信息保存 */ @@ -200,16 +230,8 @@ public class ChartInfoCollector extends AbstractPointCollector { * 获取缓存文件存放路径 */ @Override - protected File getInfoFile() { - File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); - try { - if (!file.exists()) { - file.createNewFile(); - } - } catch (Exception ex) { - FineLoggerFactory.getLogger().error(ex.getMessage(), ex); - } - return file; + protected String getInfoFilePath() { + return XML_FILE_NAME; } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java similarity index 94% rename from designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java rename to designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java index 9bfd729dd4..99950edae7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfo.java @@ -21,6 +21,9 @@ import java.util.Date; */ public class ErrorInfo { + private static final String SUFFIX = ".json"; + private static final String FOLDER_NAME = "errorInfo"; + private String username; private String uuid; private String activekey; @@ -128,8 +131,8 @@ public class ErrorInfo { public void saveFileToCache(JSONObject jo) { String content = jo.toString(); - String fileName = UUID.randomUUID() + ErrorInfoUploader.SUFFIX; - File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), ErrorInfoUploader.FOLDER_NAME, fileName)); + String fileName = UUID.randomUUID() + SUFFIX; + File file = new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), FOLDER_NAME, fileName)); FileOutputStream out = null; try (InputStream in = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8))) { StableUtils.makesureFileExist(file); 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 57d1d457f6..b935eb11ea 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 @@ -45,7 +45,7 @@ public class DesignerLogHandler { private final SimpleDateFormat LOG_SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - private static final int GAP_X = -150; + private static final int GAP_X = -75; private static final int INFO_GAP_Y = -60; @@ -53,6 +53,12 @@ public class DesignerLogHandler { private static final int SERVER_GAP_Y = -20; + private static final String ERROR_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":"; + + private static final String WARN_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":"; + + private static final String NORMAL_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":"; + public static DesignerLogHandler getInstance() { return HOLDER.singleton; @@ -310,11 +316,11 @@ public class DesignerLogHandler { private String appendLocaleMark(String str, int style) { if (style == DesignerLogger.ERROR_INT) { - str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + ":" + str + "\n"; + str = ERROR_MARK + str + "\n"; } else if (style == DesignerLogger.WARN_INT) { - str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + ":" + str + "\n"; + str = WARN_MARK + str + "\n"; } else { - str = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Normal") + ":" + str + "\n"; + str = NORMAL_MARK + str + "\n"; } return str; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java index 5ea260f469..0ed6386168 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogDetailPane.java @@ -6,6 +6,7 @@ import javax.swing.JFrame; import javax.swing.JPanel; import com.fr.base.BaseUtils; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; public class LogDetailPane extends JPanel{ @@ -20,7 +21,7 @@ public class LogDetailPane extends JPanel{ fr.setSize(600, 400); GUICoreUtils.centerWindow(fr); fr.setResizable(false); - fr.setTitle("日志"); + fr.setTitle(Toolkit.i18nText("Fine-Design_Basic_Log")); fr.setIconImage(BaseUtils.readImageWithCache("com/fr/design/images/buttonicon/history.png")); fr.getContentPane().setLayout(new BorderLayout()); fr.getContentPane().add(this, BorderLayout.CENTER); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java index ddb16de04c..433d601c0c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBar.java @@ -2,183 +2,170 @@ package com.fr.design.mainframe.loghandler; import com.fr.base.BaseUtils; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.ui.util.UIUtil; import javax.swing.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.concurrent.atomic.AtomicBoolean; -public class LogHandlerBar extends JPanel implements ItemSelectable { - - private static final long serialVersionUID = 1L; - private ItemListener listeners; - private UIButton clear; - private UIButton selectedall; - private UIButton set; - - private String text; - private int INFONUM = 0; - private int ERRORNUM = 0; - private int SERVERNUM = 0; - - private boolean isWithSerious; - - public LogHandlerBar() { - this(null); - } - - public LogHandlerBar(String text) { - this.setLayout(new CaptionLayout()); - this.setUI(new LogHandlerBarUI()); - this.text = text; - clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png")); - clear.setMargin(null); - clear.setOpaque(false); - clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - clear.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Clear_All")); - selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png")); - selectedall.setMargin(null); - selectedall.setOpaque(false); - selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - selectedall.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Select_All")); - set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png")); - set.setMargin(null); - set.setOpaque(false); - set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); - set.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Set")); - - this.add(clear); - this.add(selectedall); - this.add(set); - } - - public void clearMessage() { - INFONUM = ERRORNUM = SERVERNUM = 0; - repaint(); - } - - public boolean IsWithSerious() { - return isWithSerious; - } - - public void setWithSerious(boolean b) { - this.isWithSerious = b; - } - - public void infoAdd() { - INFONUM++; - repaint(); - } - - public void errorAdd() { - ERRORNUM++; - timerPaint(); - } - - public void serverAdd() { - SERVERNUM++; - timerPaint(); - } - - private AtomicBoolean painting = new AtomicBoolean(false); - - public void timerPaint() { - if(!painting.get()) { - painting.set(true); - repaint(); - painting.set(false); - } - } - - public int getInfo() { - return INFONUM; - } - - public int getError() { - return ERRORNUM; - } - - public int getServer() { - return SERVERNUM; - } - - public void addItemListener(ItemListener l) { - listeners = l; - } - - public void removeItemListener(ItemListener l) { - listeners = null; - } - - protected void fireItemStateChanged(ItemEvent e) { - listeners.itemStateChanged(e); - } - - public Object[] getSelectedObjects() { - return new Object[] { text }; - } - - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - repaint(); - } - - public void addClearListener(ActionListener l) { - clear.addActionListener(l); - } - - public void addSelectedListener(ActionListener l) { - selectedall.addActionListener(l); - } - - public void addSetListener(ActionListener l) { - set.addActionListener(l); - } - - private class CaptionLayout implements LayoutManager { - - @Override - public void addLayoutComponent(String name, Component comp) { - - } - - @Override - public void removeLayoutComponent(Component comp) { - - } - - @Override - public Dimension preferredLayoutSize(Container parent) { - return new Dimension(120, 24); - } +import static com.fr.design.i18n.Toolkit.i18nText; - @Override - public Dimension minimumLayoutSize(Container parent) { - return new Dimension(0, 0); - } - - @Override - public void layoutContainer(Container target) { - Insets insets = target.getInsets(); - int top = insets.top; - int right = target.getWidth() - insets.right; - clear.setBounds(right - CLEAR_OFFSET, top + TOP_OFFSET, clear.getPreferredSize().width, clear.getPreferredSize().height); - selectedall.setBounds(right - SELECT_OFFSET, top + TOP_OFFSET, selectedall.getPreferredSize().width, selectedall.getPreferredSize().height); - set.setBounds(right - SET_OFFSET, top + TOP_OFFSET, set.getPreferredSize().width, set.getPreferredSize().height); - - } - - private static final int CLEAR_OFFSET = 130; - private static final int TOP_OFFSET = 4; - private static final int SELECT_OFFSET = 100; - private static final int SET_OFFSET = 70; - } +public class LogHandlerBar extends JPanel implements ItemSelectable { + // 可以作为常量 提前初始化 不用每次都去实时频繁的读取 + private static final String NORMAL_MARK = i18nText("Fine-Design_Basic_NNormal"); + private static final String ALERT_MARK = i18nText("Fine-Design_Basic_Alert"); + private static final String SERIOUSLY_MARK = i18nText("Fine-Design_Basic_Seriously"); + + private static final long serialVersionUID = 1L; + private ItemListener listeners; + private UIButton clear; + private UIButton selectedall; + private UIButton set; + private UILabel normalLabel; + private UILabel alertLabel; + private UILabel seriouslyLabel; + + private String text; + private int INFONUM = 0; + private int ERRORNUM = 0; + private int SERVERNUM = 0; + private static final int FLOW_LAYOUT_HGAP = 10; + private static final int FLOW_LAYOUT_VGAP = 5; + + private boolean isWithSerious; + + public LogHandlerBar() { + this(null); + } + + public LogHandlerBar(String text) { + this.setLayout(new FlowLayout(FlowLayout.RIGHT, FLOW_LAYOUT_HGAP, FLOW_LAYOUT_VGAP)); + this.setUI(new LogHandlerBarUI()); + this.text = text; + clear = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/clear.png")); + clear.setMargin(null); + clear.setOpaque(false); + clear.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + clear.setToolTipText(i18nText("Fine-Design_Basic_Clear_All")); + selectedall = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/selectedall.png")); + selectedall.setMargin(null); + selectedall.setOpaque(false); + selectedall.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + selectedall.setToolTipText(i18nText("Fine-Design_Basic_Select_All")); + set = new UIButton(BaseUtils.readIcon("com/fr/design/images/log/setting.png")); + set.setMargin(null); + set.setOpaque(false); + set.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + set.setToolTipText(i18nText("Fine-Design_Report_Set")); + normalLabel = new UILabel(i18nText("Fine-Design_Basic_NNormal") + "(0)"); + alertLabel = new UILabel(i18nText("Fine-Design_Basic_Alert") + "(0)"); + seriouslyLabel = new UILabel(i18nText("Fine-Design_Basic_Seriously") + "(0)"); + + this.add(normalLabel); + this.add(alertLabel); + this.add(seriouslyLabel); + this.add(clear); + this.add(selectedall); + this.add(set); + } + + /** + * 更新日志数量统计标签 + */ + private void changeLabel() { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + // 这块逻辑执行地很频繁 + // 容易造成 AWT 与 FinePluginController 发生死锁 + // in18Text每次读取 资源的时候 都会走下插件引擎逻辑去读取下插件的资源 + // 应该避免每次都去读取 可以作为常量提前初始化好 避免与FinePluginController的竞争 + normalLabel.setText(NORMAL_MARK + '(' + getInfo() + ')'); + alertLabel.setText(ALERT_MARK + '(' + getError() + ')'); + seriouslyLabel.setText(SERIOUSLY_MARK + '(' + getServer() + ')'); + } + }); + } + + public void clearMessage() { + INFONUM = ERRORNUM = SERVERNUM = 0; + changeLabel(); + } + + public boolean IsWithSerious() { + return isWithSerious; + } + + public void setWithSerious(boolean b) { + this.isWithSerious = b; + } + + public void infoAdd() { + INFONUM++; + changeLabel(); + } + + public void errorAdd() { + ERRORNUM++; + changeLabel(); + } + + public void serverAdd() { + SERVERNUM++; + changeLabel(); + } + + public int getInfo() { + return INFONUM; + } + + public int getError() { + return ERRORNUM; + } + + public int getServer() { + return SERVERNUM; + } + + public void addItemListener(ItemListener l) { + listeners = l; + } + + public void removeItemListener(ItemListener l) { + listeners = null; + } + + protected void fireItemStateChanged(ItemEvent e) { + listeners.itemStateChanged(e); + } + + public Object[] getSelectedObjects() { + return new Object[]{text}; + } + + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + repaint(); + } + + public void addClearListener(ActionListener l) { + clear.addActionListener(l); + } + + public void addSelectedListener(ActionListener l) { + selectedall.addActionListener(l); + } + + public void addSetListener(ActionListener l) { + set.addActionListener(l); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java index bbb9eed346..d118817081 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogHandlerBarUI.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.loghandler; +import javax.swing.JComponent; +import javax.swing.plaf.ComponentUI; import java.awt.Color; import java.awt.Cursor; import java.awt.FontMetrics; @@ -11,9 +13,6 @@ import java.awt.event.FocusListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import javax.swing.JComponent; -import javax.swing.plaf.ComponentUI; - public class LogHandlerBarUI extends ComponentUI implements MouseListener, FocusListener { @@ -99,10 +98,6 @@ public class LogHandlerBarUI extends ComponentUI implements MouseListener, Focus if (button.getText() != null) { g.drawString(button.getText(), textLeadingGap, y); } - - g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_NNormal") + '(' + button.getInfo() + ')', button.getWidth() - 310, y); - g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Alert") + '(' + button.getError() + ')', button.getWidth() - 250, y); - g.drawString(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Seriously") + '(' + button.getServer() + ')', button.getWidth() - 190, y); } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java index 54bb4addc3..8b3cedeef6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/loghandler/LogMessageBar.java @@ -12,6 +12,9 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; public class LogMessageBar extends JPanel { + + private static final String LOG_MARK = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log"); + private UILabel messageLabel; private int width = 600; private static volatile LogMessageBar THIS; @@ -56,7 +59,7 @@ public class LogMessageBar extends JPanel { if (message == null) { return; } - messageLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Log") + " | " + message); + messageLabel.setText(LOG_MARK + " | " + message); repaint(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java similarity index 90% rename from designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java rename to designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java index 0b6a6b0e4c..ca3fd13ccc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/StartErrorMessageCollector.java @@ -1,8 +1,8 @@ package com.fr.design.mainframe.messagecollect; -import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.errorinfo.ErrorInfo; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; /** @@ -30,6 +30,7 @@ public class StartErrorMessageCollector { } public void record(String id, String msg, String detail) { + FineLoggerFactory.getLogger().error(id + ": " + msg + ", detail: " + detail); ErrorInfo errorInfo = new ErrorInfo(StringUtils.EMPTY, uuid, activeKey); errorInfo.setLogid(id); errorInfo.setLog(msg); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java b/designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java similarity index 100% rename from designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java rename to designer-base/src/main/java/com/fr/design/mainframe/messagecollect/entity/DesignerErrorMessage.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java index 0a480d99a0..7812e8f32a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileBookMarkStyleDefinePane.java @@ -30,11 +30,15 @@ public class MobileBookMarkStyleDefinePane extends BasicBeanPane { + public static final int LEFT_PANEL_WIDTH = 140; + public static final int LEFT_PANEL_HEIGHT = 565; + public static final int RIGHT_PANEL_WIDTH = 510; + public static final int RIGHT_PANEL_HEIGHT = 565; + public static ListCellRenderer renderer = new DefaultListCellRenderer() { @Override @@ -48,6 +55,7 @@ public class MobileBookMarkStylePane extends BasicBeanPane private void initComponent() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.listModel = new DefaultListModel<>(); this.card = new CardLayout(); this.rightPane = FRGUIPaneFactory.createCardLayout_S_Pane(); @@ -79,14 +87,16 @@ public class MobileBookMarkStylePane extends BasicBeanPane } }); JPanel leftPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + leftPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); leftPanel.add(bookMarkList, BorderLayout.CENTER); - leftPanel.setPreferredSize(new Dimension(100, 500)); + leftPanel.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, LEFT_PANEL_HEIGHT)); this.add(leftPanel, BorderLayout.WEST); } private void initRightPanel() { JPanel centerPane = FRGUIPaneFactory.createBorderLayout_L_Pane(); - centerPane.setPreferredSize(new Dimension(500, 500)); + centerPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + centerPane.setPreferredSize(new Dimension(RIGHT_PANEL_WIDTH, RIGHT_PANEL_HEIGHT)); centerPane.add(rightPane, BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER); } @@ -94,10 +104,12 @@ public class MobileBookMarkStylePane extends BasicBeanPane private List getMobileBookMarkStyleProvider() { DefaultMobileBookMarkStyleProvider defaultMobileBookMarkStyleProvider = new DefaultMobileBookMarkStyleProvider(); + SidebarMobileBookMarkStyleProvider sidebarMobileBookMarkStyleProvider = new SidebarMobileBookMarkStyleProvider(); Set mobileBookMarkStyleProviders = ExtraDesignClassManager.getInstance().getArray( MobileBookMarkStyleProvider.XML_TAG); List list = new ArrayList<>(); list.add(defaultMobileBookMarkStyleProvider); + list.add(sidebarMobileBookMarkStyleProvider); list.addAll(mobileBookMarkStyleProviders); return Collections.unmodifiableList(list); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java index 766f06d511..8fd34d4524 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStyleExpandPane.java @@ -6,13 +6,12 @@ import com.fr.design.gui.itextfield.UIIntNumberField; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.widget.UITitleSplitLine; +import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.mobile.MobileCollapsedStyle; import com.fr.form.ui.mobile.MobileFormCollapsedStyle; -import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.Dimension; +import javax.swing.*; +import java.awt.*; /** * @author hades @@ -21,34 +20,45 @@ import java.awt.Dimension; */ public class MobileCollapsedStyleExpandPane extends MobileCollapsedStylePane { - private static final Dimension DEFAULT_SPINNER_SIZE = new Dimension(60, 24); - private UISpinner rowSpinner; public MobileCollapsedStyleExpandPane() { } - @Override - protected JPanel createLinePane() { - UITitleSplitLine splitLine = new UITitleSplitLine(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number"), 520); - splitLine.setPreferredSize(new Dimension(520, 20)); + protected void createConfigPanes(JPanel settingPane) { + JPanel lineNumberConfigPane = this.createLineNumberConfigPane(); + settingPane.add(lineNumberConfigPane); + super.createConfigPanes(settingPane); + } + + protected JPanel createLineNumberConfigPane() { + JPanel configPane = super.createTitleConfigPane(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Line_Number")); + + UILabel collapseLocationLabel = createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Show_Button")); this.rowSpinner = new UISpinner(1, Integer.MAX_VALUE, 1, 1) { @Override protected UINumberField initNumberField(){ return new UIIntNumberField(); } }; - rowSpinner.setPreferredSize(DEFAULT_SPINNER_SIZE); - JPanel panel = new JPanel(); - panel.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); - panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From"))); - panel.add(rowSpinner); - panel.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold"))); - JPanel linePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - linePane.add(splitLine, BorderLayout.NORTH); - linePane.add(panel, BorderLayout.CENTER); - return linePane; + this.rowSpinner.setPreferredSize(new Dimension(62, COMPONENT_HEIGHT)); + JPanel defaultCollapsedStatePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + defaultCollapsedStatePanel.add(createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Start_From") + " ")); + defaultCollapsedStatePanel.add(rowSpinner); + defaultCollapsedStatePanel.add(createLabel(" " + Toolkit.i18nText("Fine-Design_Mobile_Collapse_Row_To_Fold"))); + + double[] rowSize = {COMPONENT_HEIGHT}; + double[] columnSize = {LABEL_WIDTH, COMPONENT_WIDTH}; + double[] verticalGaps = {0}; + JPanel navButtonSettingsPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{ + {collapseLocationLabel, defaultCollapsedStatePanel}, + }, rowSize, columnSize, 5, verticalGaps); + navButtonSettingsPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0)); + + configPane.add(navButtonSettingsPanel); + + return configPane; } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java index 74538e77c5..ae86e90ca3 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileCollapsedStylePane.java @@ -1,8 +1,6 @@ package com.fr.design.mainframe.mobile.ui; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.designer.IntervalConstants; import com.fr.design.gui.ibutton.ModeButtonGroup; import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; @@ -10,9 +8,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; 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.layout.VerticalFlowLayout; import com.fr.design.mainframe.widget.UITitleSplitLine; import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; @@ -21,13 +17,7 @@ import com.fr.form.ui.mobile.MobileChartCollapsedStyle; import com.fr.form.ui.mobile.MobileCollapsedStyle; import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; +import java.awt.*; /** * @author hades @@ -36,6 +26,13 @@ import java.awt.FlowLayout; */ public class MobileCollapsedStylePane extends BasicBeanPane { + public final static Color THEME_COLOR = Color.decode("#2F8EF1"); + public final static Font TEXT_FONT = new Font("Default", Font.PLAIN, 12); + public final static Color TEXT_FONT_COLOR = Color.decode("#333334"); + public final static int LABEL_WIDTH = 96; + public final static int COMPONENT_HEIGHT = 20; + public final static int COMPONENT_WIDTH = 160; + private UICheckBox showButtonCheck; private NewColorSelectBox buttonColorBox; private UITextField foldedTextFiled; @@ -44,74 +41,94 @@ public class MobileCollapsedStylePane extends BasicBeanPane(); + + UILabel defaultCollapsedStateLabel = this.createLabel(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Default_State")); + JPanel defaultCollapsedStatePanel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); UIRadioButton foldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Fold")); foldedButton.setSelected(true); + foldedButton.setPreferredSize(new Dimension(COMPONENT_WIDTH / 2, COMPONENT_HEIGHT)); + foldedButton.setForeground(TEXT_FONT_COLOR); + foldedButton.setFont(TEXT_FONT); UIRadioButton unfoldedButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Mobile_Collapse_Unfold")); + unfoldedButton.setPreferredSize(new Dimension(COMPONENT_WIDTH / 2, COMPONENT_HEIGHT)); + unfoldedButton.setForeground(TEXT_FONT_COLOR); + unfoldedButton.setFont(TEXT_FONT); + defaultCollapsedStatePanel.add(foldedButton); + defaultCollapsedStatePanel.add(unfoldedButton); + + buttonGroup = new ModeButtonGroup<>(); buttonGroup.put(CollapseState.FOLDED, foldedButton); buttonGroup.put(CollapseState.UNFOLDED, unfoldedButton); - JPanel flowLeftPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - flowLeftPane.add(foldedButton); - flowLeftPane.add(unfoldedButton); - Component[][] northComponents = new Component[][] { - new Component[] {showButtonLabel, showButtonCheck} - }; - Component[][] southComponents = new Component[][] { - new Component[] {defaultStateLabel, flowLeftPane} - }; - double f = TableLayout.FILL; - double p = TableLayout.PREFERRED; - double[] rowSize = {p, p, p, p, p}; - double[] colSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; - Component[][] centerComponents = new Component[][] { - new Component[] {buttonColorLabel, buttonColorBox}, - new Component[] {foldedLabel, foldedTextFiled}, - new Component[] {unfoldedLabel, unfoldedTextFiled}, - }; - JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(northComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W2, IntervalConstants.INTERVAL_L1); - JPanel southPane = TableLayoutHelper.createGapTableLayoutPane(southComponents, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); - final JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(centerComponents, rowSize, colSize, rowCount, LayoutConstants.HGAP_LARGE, LayoutConstants.VGAP_SMALL); - JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - panel.add(northPane, BorderLayout.NORTH); - panel.add(centerPane, BorderLayout.CENTER); - panel.add(southPane, BorderLayout.SOUTH); - settingPane.add(splitLine); - settingPane.add(panel); - showButtonCheck.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - centerPane.setVisible(showButtonCheck.isSelected()); - } - }); - return settingPane; - } - protected JPanel createLinePane() { - return FRGUIPaneFactory.createBorderLayout_S_Pane(); + double[] rowSize = {COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT, COMPONENT_HEIGHT}; + double[] columnSize = {LABEL_WIDTH, COMPONENT_WIDTH}; + double[] verticalGaps = {10, 10, 10, 10, 10}; + JPanel contentPane = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{ + {showButtonLabel, showButtonCheck}, + {buttonColorLabel, buttonColorBox}, + {foldedLabel, foldedTextFiled}, + {unfoldedLabel, unfoldedTextFiled}, + {defaultCollapsedStateLabel, defaultCollapsedStatePanel} + }, rowSize, columnSize, 5, verticalGaps); + contentPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 15, 0)); + + configPane.add(contentPane); + + return configPane; } @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java index 6e9b74a1dd..7a8b823724 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileComboBoxDialogEditor.java @@ -9,8 +9,8 @@ import com.fr.design.i18n.Toolkit; import com.fr.form.ui.mobile.MobileCollapsedStyle; import com.fr.general.ComparatorUtils; -import javax.swing.SwingUtilities; -import java.awt.Dimension; +import javax.swing.*; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -33,6 +33,7 @@ public class MobileComboBoxDialogEditor extends BasicPane { private ActionListener listener; public MobileComboBoxDialogEditor(MobileCollapsedStylePane stylePane) { + this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); this.stylePane = stylePane; this.comboBox = new UIComboBox(new Object[] {NONE, CUSTOM}); this.comboBox.setPreferredSize(COMBOX_DIMENSION); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java index 93c24ad699..5f11e46db0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java @@ -2,29 +2,54 @@ package com.fr.design.mainframe.mobile.ui; import com.fr.base.background.ColorBackground; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.icombobox.LineComboBox; 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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.mobile.MobileStyle; import com.fr.general.FRFont; import com.fr.invoke.Reflect; +import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.JPanel; import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; -public class MobileStyleDefinePane extends BasicBeanPane { +public class MobileStyleDefinePane extends BasicBeanPane { + private final static int[] BORDER_LINE_STYLE_ARRAY = new int[]{ + Constants.LINE_NONE, + Constants.LINE_THIN, //1px + Constants.LINE_MEDIUM, //2px + Constants.LINE_THICK, //3px + }; + private static final int NORMAL_COMBO_WIDTH = 152; private Widget widget; private MobileStyleCustomDefinePane customBeanPane; private Class mobileStyleClazz; private ColorSelectBox colorSelectBox; private Color titleColor = new Color(47, 142, 241); + private JPanel commomPane; + private LineComboBox borderType; + private NewColorSelectBox borderColor; + private UISpinner borderRadius; + private NewColorSelectBox iconColor; + private MobileStyleFontConfigPane fontConfigPane; MobileStyleDefinePane(Widget widget, Class customBeanPaneClass, Class mobileStyleClazz) { @@ -40,6 +65,17 @@ public class MobileStyleDefinePane extends BasicBeanPane { if(ob.getBackground() != null) { colorSelectBox.setSelectObject(((ColorBackground)ob.getBackground()).getColor()); } + borderType.setSelectedLineStyle(ob.getBorderType()); + if (ob.getBorderColor() != null) { + borderColor.setSelectObject(ob.getBorderColor()); + } + borderRadius.setValue(ob.getBorderRadius()); + if (ob.getIconColor() != null) { + iconColor.setSelectObject(ob.getIconColor()); + } + if (ob.getFont() != null) { + fontConfigPane.populateBean(ob.getFont()); + } } @Override @@ -48,6 +84,11 @@ public class MobileStyleDefinePane extends BasicBeanPane { this.widget.setMobileStyle(mobileStyle); this.customBeanPane.updateBean(); mobileStyle.setBackground(ColorBackground.getInstance(colorSelectBox.getSelectObject())); + mobileStyle.setBorderType(borderType.getSelectedLineStyle()); + mobileStyle.setBorderColor(borderColor.getSelectObject()); + mobileStyle.setBorderRadius(borderRadius.getValue()); + mobileStyle.setIconColor(iconColor.getSelectObject()); + mobileStyle.setFont(fontConfigPane.updateBean()); return mobileStyle; } @@ -64,7 +105,7 @@ public class MobileStyleDefinePane extends BasicBeanPane { private void createGeneralPane() { createPreviewPane(); - createBackgroundPane(); + createCommonPane(); } private void createPreviewPane() { @@ -79,29 +120,45 @@ public class MobileStyleDefinePane extends BasicBeanPane { } } - private void createBackgroundPane() { + private void createCommonPane() { + TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute")); + commomPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); + commomPane.setBorder(titledBorder); + this.add(commomPane, BorderLayout.NORTH); - JPanel backgroundPane = new JPanel(); - backgroundPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5)); - backgroundPane.setPreferredSize(new Dimension(500, 65)); + createBackgroundPane(); + createBorderPane(); + createIconSettingPane(); + createFontPane(); + } - TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_Common_Attribute")); - backgroundPane.setBorder(titledBorder); + private void createBackgroundPane() { + colorSelectBox = new ColorSelectBox(NORMAL_COMBO_WIDTH); - UILabel colorSelectLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Widget_Background"), UILabel.RIGHT); - colorSelectLabel.setPreferredSize(new Dimension(65, 20)); + JPanel backgroundPane = createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Background")), colorSelectBox); + commomPane.add(backgroundPane); + } - colorSelectBox = new ColorSelectBox(152); - colorSelectBox.addSelectChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - } - }); + private void createBorderPane() { + borderType = new LineComboBox(BORDER_LINE_STYLE_ARRAY); + borderType.setSelectedLineStyle(Constants.LINE_THIN); + borderType.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 15, 20)); + borderColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH); + borderRadius = new UISpinner(0, Integer.MAX_VALUE, 1, 2); + borderRadius.setPreferredSize(new Dimension(NORMAL_COMBO_WIDTH + 20, 20)); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderType")), borderType)); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderColor")), borderColor)); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius)); + } - backgroundPane.add(colorSelectLabel); - backgroundPane.add(colorSelectBox); + private void createIconSettingPane() { + iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor)); + } - this.add(backgroundPane, BorderLayout.NORTH); + private void createFontPane() { + fontConfigPane = new MobileStyleFontConfigPane(); + commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane)); } private void createCustomPane() { @@ -109,6 +166,7 @@ public class MobileStyleDefinePane extends BasicBeanPane { TitledBorder titledBorder = createTitledBorder(Toolkit.i18nText("Fine-Design_Report_Set")); configPane.setBorder(titledBorder); + JPanel container = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 10); configPane.add(this.customBeanPane, BorderLayout.CENTER); this.add(configPane, BorderLayout.CENTER); @@ -119,4 +177,14 @@ public class MobileStyleDefinePane extends BasicBeanPane { titledBorder.setTitleFont(FRFont.getInstance("PingFangSC-Regular", Font.PLAIN, 12)); return titledBorder; } + + private UILabel createConfigLabel(String title) { + UILabel label = new UILabel(title + ":", UILabel.RIGHT); + label.setPreferredSize(new Dimension(75, 20)); + return label; + } + + private JPanel createLeftRightComponentsPane(Component... components) { + return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{components}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java new file mode 100644 index 0000000000..f765e25845 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java @@ -0,0 +1,123 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icombobox.UIComboBoxRenderer; +import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.util.Vector; + +public class MobileStyleFontConfigPane extends JPanel { + public static final int FONT_NONE = 0; + private static final int MAX_FONT_SIZE = 18; + private static final int MIN_FONT_SIZE = 12; + private static final Dimension BUTTON_SIZE = new Dimension(20, 18); + + public static Vector getFontSizes() { + Vector FONT_SIZES = new Vector(); + FONT_SIZES.add(FONT_NONE); + for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { + FONT_SIZES.add(i); + } + return FONT_SIZES; + } + + private UIComboBox fontSizeComboBox; + private UIToggleButton underline; + private UIToggleButton italic; + private UIToggleButton bold; + + public MobileStyleFontConfigPane() { + this.initComponent(); + } + + private void initComponent() { + + fontSizeComboBox = new UIComboBox(); + fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes())); + fontSizeComboBox.setSelectedItem(0); + fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); + fontSizeComboBox.setRenderer(new LineCellRenderer()); + underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); + italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + + this.setButtonsTips(); + this.setButtonsSize(BUTTON_SIZE); + + Component[] components_font = new Component[]{ + fontSizeComboBox, underline, italic, bold + }; + + JPanel buttonPane = new JPanel(new BorderLayout()); + buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE)); + + this.setLayout(new BorderLayout(0,0)); + this.add(buttonPane, BorderLayout.CENTER); + } + + private void setButtonsTips() { + underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); + italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic")); + bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold")); + } + + private void setButtonsSize(Dimension size) { + underline.setPreferredSize(size); + italic.setPreferredSize(size); + bold.setPreferredSize(size); + } + + + public void populateBean(FRFont frFont) { + fontSizeComboBox.setSelectedItem(frFont.getSize()); + bold.setSelected(frFont.isBold()); + italic.setSelected(frFont.isItalic()); + underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE); + } + + public FRFont updateBean() { + int style = Font.PLAIN; + style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; + style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; + return FRFont.getInstance( + FRFont.DEFAULT_FONTNAME, + style, + Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), + Color.BLACK, + underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE + ); + } + + private class LineCellRenderer extends UIComboBoxRenderer { + public LineCellRenderer() { + super(); + } + + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + int currentValue = ((Integer) value).intValue(); + if (currentValue == MobileStyleFontConfigPane.FONT_NONE) { + renderer.setText(StringUtils.BLANK + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None")); + } + return renderer; + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java index feb19463da..7c07aee6fc 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileTemplateStyleDefinePane.java @@ -63,14 +63,16 @@ public abstract class MobileTemplateStyleDefinePane extends BasicBeanPane { + private static final long serialVersionUID = 1L; + + private static final int COLUMN_HEIGHT = 20; + private static final int COLUMN_WIDTH = 160; + + private UnsignedIntUISpinner buttonWidthSpinner; + private UnsignedIntUISpinner buttonHeightSpinner; + private UnsignedIntUISpinner buttonGapSpinner; + private UnsignedIntUISpinner buttonBorderRadiusSpinner; + + private ColorSelectBox normalBackgroundColorBox; + private NumberDragBar normalOpacityDragBar; + private UnsignedIntUISpinner normalOpacitySpinner; + private LineComboBox normalBorderWidthComBox; + private ColorSelectBox normalBorderColorBox; + private UIComboBox normalFontNameComboBox; + private UIComboBox normalFontSizeComboBox; + private UIColorButton normalFontColorButton; + private UIToggleButton normalFontItalicButton; + private UIToggleButton normalFontBoldButton; + + private ColorSelectBox selectedBackgroundColorBox; + private NumberDragBar selectedOpacityDragBar; + private UnsignedIntUISpinner selectedOpacitySpinner; + private LineComboBox selectedBorderWidthComBox; + private ColorSelectBox selectedBorderColorBox; + private UIComboBox selectedFontNameComboBox; + private UIComboBox selectedFontSizeComboBox; + private UIColorButton selectedFontColorButton; + private UIToggleButton selectedFontItalicButton; + private UIToggleButton selectedFontBoldButton; + + private SidebarMobileBookMarkStyle DEFAULT_STYLE = new SidebarMobileBookMarkStyle(); + + public SidebarMobileBookMarkStyleCustomDefinePane() { + this.initComponent(); + } + + private void initComponent() { + this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + + final JPanel contentPanel = FRGUIPaneFactory.createYBoxEmptyBorderPane(); + + contentPanel.add(this.createNavButtonStylePanel()); + contentPanel.add(this.createNormalStateStylePanel()); + contentPanel.add(this.createSelectedStateStylePanel()); + + JPanel scrollPanel = new AttrScrollPane() { + @Override + protected JPanel createContentPane() { + return contentPanel; + } + }; + scrollPanel.setPreferredSize(new Dimension(-2, -2)); + this.add(scrollPanel, BorderLayout.CENTER); + } + + private JPanel createNavButtonStylePanel() { + + buttonWidthSpinner = new UnsignedIntUISpinner(20, 150, 1, DEFAULT_STYLE.getWidth()); + buttonHeightSpinner = new UnsignedIntUISpinner(20, 100, 1, DEFAULT_STYLE.getHeight()); + buttonGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getGap()); + buttonBorderRadiusSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, DEFAULT_STYLE.getBorderRadius()); + + UILabel sizeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Size") + ":", + SwingConstants.RIGHT); + JPanel sizePane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 4, 0); + sizePane.add(buttonWidthSpinner); + sizePane.add(buttonHeightSpinner); + + JPanel sizeTipsPane = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 4, 0); + sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Width"), + SwingConstants.CENTER)); + sizeTipsPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Height"), + SwingConstants.CENTER)); + + UILabel gapLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Gap") + ":", + SwingConstants.RIGHT); + UILabel borderRadiusLabel = new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Border_Radius") + ":", + SwingConstants.RIGHT); + + double p = TableLayout.PREFERRED; + double[] rowSize = {COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT}; + double[] columnSize = {p, COLUMN_WIDTH}; + double[] verticalGaps = {0, 10, 10}; + + JPanel navButtonSettingsPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{ + {sizeLabel, sizePane}, + {null, sizeTipsPane}, + {gapLabel, buttonGapSpinner}, + {borderRadiusLabel, buttonBorderRadiusSpinner}, + }, rowSize, columnSize, 5, verticalGaps); + + navButtonSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Button_Style"), + Color.decode("#2F8EF1"))); + containerPane.add(navButtonSettingsPanel); + + return containerPane; + } + + private JPanel createNormalStateStylePanel() { + double p = TableLayout.PREFERRED; + + normalBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH); + normalBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getBackgroundColor()); + normalOpacityDragBar = new NumberDragBar(0, 100); + normalOpacityDragBar.setValue(DEFAULT_STYLE.getOpacity()); + normalOpacityDragBar.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + normalOpacitySpinner.setValue(normalOpacityDragBar.getValue()); + } + }); + normalOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getOpacity()); + normalOpacitySpinner.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + normalOpacityDragBar.setValue((int) normalOpacitySpinner.getValue()); + } + }); + normalBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); + normalBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getBorderLineStyle()); + normalBorderColorBox = new ColorSelectBox(COLUMN_WIDTH); + normalBorderColorBox.setSelectObject(DEFAULT_STYLE.getBorderColor()); + normalFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + normalFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily()); + normalFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + normalFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getFontSize()); + normalFontColorButton = new UIColorButton(); + normalFontColorButton.setColor(DEFAULT_STYLE.getFontColor()); + normalFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + normalFontItalicButton.setSelected(DEFAULT_STYLE.isFontItalic()); + normalFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + normalFontBoldButton.setSelected(DEFAULT_STYLE.isFontBold()); + + JPanel opacityPane = new JPanel(new BorderLayout(0, 0)); + JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + jp.add(normalOpacityDragBar); + jp.add(normalOpacitySpinner); + opacityPane.add(jp, BorderLayout.CENTER); + + JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{normalFontSizeComboBox, normalFontColorButton, normalFontItalicButton, normalFontBoldButton}}, + new double[]{COLUMN_HEIGHT}, + new double[]{p, p, p, p}, + 7, 0 + ); + + double[] rowSize = {COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT}; + double[] columnSize = {p, COLUMN_WIDTH, p}; + + JPanel normalStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT), + normalBackgroundColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT), + opacityPane, + new UILabel("%") + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT), + normalBorderWidthComBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT), + normalBorderColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT), + normalFontNameComboBox, + fontExtraPane + } + }, rowSize, columnSize, 5, 10); + normalStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder( + GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Normal_Style"), + Color.decode("#2F8EF1")) + ); + containerPane.add(normalStateStyleSettingsPanel); + + return containerPane; + } + + private JPanel createSelectedStateStylePanel() { + double p = TableLayout.PREFERRED; + + selectedBackgroundColorBox = new ColorSelectBox(COLUMN_WIDTH); + selectedBackgroundColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBackgroundColor()); + selectedOpacityDragBar = new NumberDragBar(0, 100); + selectedOpacityDragBar.setValue(DEFAULT_STYLE.getSelectedOpacity()); + selectedOpacityDragBar.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + selectedOpacitySpinner.setValue(selectedOpacityDragBar.getValue()); + } + }); + selectedOpacitySpinner = new UnsignedIntUISpinner(0, 100, 1, DEFAULT_STYLE.getSelectedOpacity()); + selectedOpacitySpinner.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + selectedOpacityDragBar.setValue((int) selectedOpacitySpinner.getValue()); + } + }); + selectedBorderWidthComBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); + selectedBorderWidthComBox.setSelectedLineStyle(DEFAULT_STYLE.getSelectedBorderLineStyle()); + selectedBorderColorBox = new ColorSelectBox(COLUMN_WIDTH); + selectedBorderColorBox.setSelectObject(DEFAULT_STYLE.getSelectedBorderColor()); + selectedFontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); + selectedFontNameComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontFamily()); + selectedFontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); + selectedFontSizeComboBox.setSelectedItem(DEFAULT_STYLE.getSelectedFontSize()); + selectedFontColorButton = new UIColorButton(); + selectedFontColorButton.setColor(DEFAULT_STYLE.getSelectedFontColor()); + selectedFontItalicButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + selectedFontItalicButton.setSelected(DEFAULT_STYLE.isSelectedFontItalic()); + selectedFontBoldButton = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); + selectedFontBoldButton.setSelected(DEFAULT_STYLE.isSelectedFontBold()); + + JPanel opacityPane = new JPanel(new BorderLayout(0, 0)); + JPanel jp = FRGUIPaneFactory.createNColumnGridInnerContainer_Pane(2, 5, 0); + jp.add(selectedOpacityDragBar); + jp.add(selectedOpacitySpinner); + opacityPane.add(jp, BorderLayout.CENTER); + + JPanel fontExtraPane = TableLayoutHelper.createGapTableLayoutPane( + new JComponent[][]{{selectedFontSizeComboBox, selectedFontColorButton, selectedFontItalicButton, selectedFontBoldButton}}, + new double[]{COLUMN_HEIGHT}, + new double[]{p, p, p, p}, + 7, 0 + ); + + double[] rowSize = {COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT, COLUMN_HEIGHT}; + double[] columnSize = {p, COLUMN_WIDTH, p}; + + JPanel selectedStateStyleSettingsPanel = TableLayoutHelper.createGapTableLayoutPane(new JComponent[][]{ + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Background_Color") + ":", SwingConstants.RIGHT), + selectedBackgroundColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Opacity") + ":", SwingConstants.RIGHT), + opacityPane, + new UILabel("%") + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Width") + ":", SwingConstants.RIGHT), + selectedBorderWidthComBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Border_Color") + ":", SwingConstants.RIGHT), + selectedBorderColorBox + }, + { + new UILabel(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Font") + ":", SwingConstants.RIGHT), + selectedFontNameComboBox, + fontExtraPane + } + }, rowSize, columnSize, 5, 10); + selectedStateStyleSettingsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); + + JPanel containerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + containerPane.setBorder( + GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar_Selected_Style"), + Color.decode("#2F8EF1")) + ); + containerPane.add(selectedStateStyleSettingsPanel); + + return containerPane; + } + + @Override + public void populateBean(MobileBookMarkStyle ob) { + SidebarMobileBookMarkStyle style = null; + if (ob instanceof SidebarMobileBookMarkStyle) { + style = (SidebarMobileBookMarkStyle) ob; + } + if (style == null) { + return; + } + + buttonWidthSpinner.setValue(style.getWidth()); + buttonHeightSpinner.setValue(style.getHeight()); + buttonGapSpinner.setValue(style.getGap()); + buttonBorderRadiusSpinner.setValue(style.getBorderRadius()); + + normalBackgroundColorBox.setSelectObject(style.getBackgroundColor()); + normalOpacityDragBar.setValue(style.getOpacity()); + normalOpacitySpinner.setValue(style.getOpacity()); + normalBorderWidthComBox.setSelectedLineStyle(style.getBorderLineStyle()); + normalBorderColorBox.setSelectObject(style.getBorderColor()); + normalFontNameComboBox.setSelectedItem(style.getFontFamily()); + normalFontSizeComboBox.setSelectedItem(style.getFontSize()); + normalFontColorButton.setColor(style.getFontColor()); + normalFontItalicButton.setSelected(style.isFontItalic()); + normalFontBoldButton.setSelected(style.isFontBold()); + + selectedBackgroundColorBox.setSelectObject(style.getSelectedBackgroundColor()); + selectedOpacityDragBar.setValue(style.getSelectedOpacity()); + selectedOpacitySpinner.setValue(style.getSelectedOpacity()); + selectedBorderWidthComBox.setSelectedLineStyle(style.getSelectedBorderLineStyle()); + selectedBorderColorBox.setSelectObject(style.getSelectedBorderColor()); + selectedFontNameComboBox.setSelectedItem(style.getSelectedFontFamily()); + selectedFontSizeComboBox.setSelectedItem(style.getSelectedFontSize()); + selectedFontColorButton.setColor(style.getSelectedFontColor()); + selectedFontItalicButton.setSelected(style.isSelectedFontItalic()); + selectedFontBoldButton.setSelected(style.isSelectedFontBold()); + } + + @Override + public MobileBookMarkStyle updateBean() { + SidebarMobileBookMarkStyle style = new SidebarMobileBookMarkStyle(); + + style.setWidth((int) buttonWidthSpinner.getValue()); + style.setHeight((int) buttonHeightSpinner.getValue()); + style.setGap((int) buttonGapSpinner.getValue()); + style.setBorderRadius((int) buttonBorderRadiusSpinner.getValue()); + + style.setBackgroundColor(normalBackgroundColorBox.getSelectObject()); + style.setOpacity((int) normalOpacitySpinner.getValue()); + style.setBorderLineStyle(normalBorderWidthComBox.getSelectedLineStyle()); + style.setBorderColor(normalBorderColorBox.getSelectObject()); + if (normalFontNameComboBox.getSelectedItem() != null) { + style.setFontFamily((String) normalFontNameComboBox.getSelectedItem()); + } + if (normalFontSizeComboBox.getSelectedItem() != null) { + style.setFontSize((Integer) normalFontSizeComboBox.getSelectedItem()); + } + style.setFontColor(normalFontColorButton.getColor()); + style.setFontItalic(normalFontItalicButton.isSelected()); + style.setFontBold(normalFontBoldButton.isSelected()); + + style.setSelectedBackgroundColor(selectedBackgroundColorBox.getSelectObject()); + style.setSelectedOpacity((int) selectedOpacitySpinner.getValue()); + style.setSelectedBorderLineStyle(selectedBorderWidthComBox.getSelectedLineStyle()); + style.setSelectedBorderColor(selectedBorderColorBox.getSelectObject()); + if (selectedFontNameComboBox.getSelectedItem() != null) { + style.setSelectedFontFamily((String) selectedFontNameComboBox.getSelectedItem()); + } + if (selectedFontSizeComboBox.getSelectedItem() != null) { + style.setSelectedFontSize((Integer) selectedFontSizeComboBox.getSelectedItem()); + } + style.setSelectedFontColor(selectedFontColorButton.getColor()); + style.setSelectedFontItalic(selectedFontItalicButton.isSelected()); + style.setSelectedFontBold(selectedFontBoldButton.isSelected()); + + return style; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java new file mode 100644 index 0000000000..7c9202f3fd --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/SidebarMobileBookMarkStyleProvider.java @@ -0,0 +1,30 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.impl.AbstractMobileBookMarkStyleProvider; +import com.fr.design.i18n.Toolkit; +import com.fr.form.ui.mobile.MobileBookMarkStyle; +import com.fr.form.ui.mobile.impl.SidebarMobileBookMarkStyle; + +/** + * @author Starryi + * @version 10.0 + * Created by Starryi on 2020/02/28 + */ +public class SidebarMobileBookMarkStyleProvider extends AbstractMobileBookMarkStyleProvider { + + @Override + public Class classForMobileBookMarkStyle() { + return SidebarMobileBookMarkStyle.class; + } + + @Override + public Class> classForMobileBookMarkStyleAppearance() { + return SidebarMobileBookMarkStyleCustomDefinePane.class; + } + + @Override + public String displayName() { + return Toolkit.i18nText("Fine-Design_Mobile_BookMark_Style_Sidebar"); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TemplateStyleDefinePaneFactory.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TemplateStyleDefinePaneFactory.java index dab5a03ba7..16cfe4995d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TemplateStyleDefinePaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/TemplateStyleDefinePaneFactory.java @@ -7,6 +7,7 @@ import com.fr.general.cardtag.mobile.DownMenuStyle; import com.fr.general.cardtag.mobile.MobileTemplateStyle; import com.fr.general.cardtag.mobile.SliderStyle; import com.fr.general.cardtag.mobile.UpMenuStyle; +import com.fr.general.cardtag.mobile.UniteStyle; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; import java.util.HashMap; @@ -20,6 +21,7 @@ public class TemplateStyleDefinePaneFactory { defineMap.put(UpMenuStyle.STYLE_NAME, new StyleDefinePaneUI(UpMenuStyleDefinePane.class)); defineMap.put(DownMenuStyle.STYLE_NAME, new StyleDefinePaneUI(DownMenuStyleDefinePane.class)); defineMap.put(SliderStyle.STYLE_NAME, new StyleDefinePaneUI(SliderStyleDefinePane.class)); + defineMap.put(UniteStyle.STYLE_NAME, new StyleDefinePaneUI(UniteStyleDefinePane.class)); } public static BasicBeanPane createDefinePane(String style, WCardTagLayout tagLayout) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UniteStyleDefinePane.java b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UniteStyleDefinePane.java new file mode 100644 index 0000000000..527697501a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/UniteStyleDefinePane.java @@ -0,0 +1,233 @@ +package com.fr.design.mainframe.mobile.ui; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.icombobox.LineComboBox; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UnsignedIntUISpinner; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.widget.MobileTabFontConfPane; +import com.fr.design.mainframe.widget.UITitleSplitLine; +import com.fr.design.mainframe.widget.preview.MobileTemplatePreviewPane; +import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.style.color.NewColorSelectBox; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import com.fr.general.cardtag.mobile.MobileTemplateStyle; +import com.fr.general.cardtag.mobile.TabFontConfig; +import com.fr.general.cardtag.mobile.UniteStyle; +import com.fr.stable.CoreConstants; + +import javax.swing.*; +import java.awt.*; + +public class UniteStyleDefinePane extends MobileTemplateStyleDefinePane { + private static final int SPLIT_LINE_WIDTH = 520; + private static final int SPLIT_LINE_HEIGHT = 20; + + private static final int TOGGLE_BUTTON_WIDTH = 20; + private static final int LABEL_WIDTH = 75; + private static final int LINE_COMPONENT_WIDTH = 157; + private static final int LINE_COMPONENT_HEIGHT = 20; + + private UnsignedIntUISpinner paddingLeftSpinner; + private UnsignedIntUISpinner paddingRightSpinner; + + private NewColorSelectBox initialBackgroundColorBox; + private NewColorSelectBox selectedBackgroundColorBox; + + private LineComboBox borderWidthComboBox; + private ColorSelectBox borderColorBox; + private UnsignedIntUISpinner borderRadiusSpinner; + + private MobileTabFontConfPane tabFontConfPane; + private UIColorButton selectedFontColorButton; + + public UniteStyleDefinePane(WCardTagLayout tagLayout) { + super(tagLayout); + } + + @Override + protected void createBuiltinConfPane(JPanel centerPane) { + // ignore builtin conf pane + } + + @Override + protected void createExtraConfPane(JPanel centerPane) { + UITitleSplitLine paddingSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Button_Padding"), SPLIT_LINE_WIDTH); + paddingSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); + centerPane.add(paddingSplit); + centerPane.add(this.createPaddingConfPane()); + + UITitleSplitLine backgroundSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Button_Background"), SPLIT_LINE_WIDTH); + backgroundSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); + centerPane.add(backgroundSplit); + centerPane.add(this.createBackgroundColorConfPanel()); + + UITitleSplitLine borderSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Border"), SPLIT_LINE_WIDTH); + borderSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); + centerPane.add(borderSplit); + centerPane.add(this.createBorderConfPanel()); + + UITitleSplitLine fontSplit = new UITitleSplitLine(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Char"), SPLIT_LINE_WIDTH); + fontSplit.setPreferredSize(new Dimension(SPLIT_LINE_WIDTH, SPLIT_LINE_HEIGHT)); + centerPane.add(fontSplit); + centerPane.add(this.createFontConfPanel()); + } + + private JPanel createPaddingConfPane() { + + this.paddingLeftSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_PADDING_LEFT); + this.paddingLeftSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT)); + this.paddingRightSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_PADDING_RIGHT); + this.paddingRightSpinner.setPreferredSize(new Dimension(62, LINE_COMPONENT_HEIGHT)); + + UILabel paddingLeftLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Left") + ":", SwingConstants.RIGHT); + paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + UILabel paddingRightLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Right") + ":", SwingConstants.RIGHT); + paddingLeftLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + + JPanel paddingPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{ + paddingLeftLabel, paddingLeftSpinner, paddingRightLabel,paddingRightSpinner + }}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + paddingPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); + + return paddingPanel; + } + + private JPanel createBackgroundColorConfPanel() { + this.initialBackgroundColorBox = new NewColorSelectBox(LINE_COMPONENT_WIDTH); + this.initialBackgroundColorBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); + this.selectedBackgroundColorBox = new NewColorSelectBox(LINE_COMPONENT_WIDTH); + this.selectedBackgroundColorBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); + + UILabel initialBackgroundColorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Init_Fill") + ":", SwingConstants.RIGHT); + initialBackgroundColorLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + UILabel selectedBackgroundColorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Select_Fill") + ":", SwingConstants.RIGHT); + selectedBackgroundColorLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + + JPanel backgroundColorPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ + new Component[]{ initialBackgroundColorLabel, initialBackgroundColorBox }, + new Component[]{ selectedBackgroundColorLabel, selectedBackgroundColorBox } + }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + backgroundColorPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); + + return backgroundColorPanel; + } + + private JPanel createBorderConfPanel() { + this.borderWidthComboBox = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); + this.borderWidthComboBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); + this.borderColorBox = new ColorSelectBox(LINE_COMPONENT_WIDTH); + this.borderColorBox.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); + this.borderRadiusSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, UniteStyle.DEFAULT_BORDER_RADIUS); + this.borderRadiusSpinner.setPreferredSize(new Dimension(LINE_COMPONENT_WIDTH, LINE_COMPONENT_HEIGHT)); + + UILabel borderSizeLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Line_Style") + ":", SwingConstants.RIGHT); + borderSizeLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + UILabel borderColorLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Colors") + ":", SwingConstants.RIGHT); + borderColorLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + UILabel borderRadiusLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Radius") + ":", SwingConstants.RIGHT); + borderRadiusLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + + JPanel borderPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ + new Component[]{ borderSizeLabel, borderWidthComboBox}, + new Component[]{ borderColorLabel, borderColorBox }, + new Component[]{ borderRadiusLabel, borderRadiusSpinner } + }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + borderPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); + + return borderPanel; + } + + private JPanel createFontConfPanel() { + this.tabFontConfPane = new MobileTabFontConfPane(); + this.selectedFontColorButton = new UIColorButton(); + this.selectedFontColorButton.setPreferredSize(new Dimension(TOGGLE_BUTTON_WIDTH, LINE_COMPONENT_HEIGHT)); + JPanel selectedFontColorPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + selectedFontColorPanel.add(this.selectedFontColorButton); + + UILabel initialFontLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Init_Char") + ":", SwingConstants.RIGHT); + initialFontLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + UILabel selectedFontLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Tab_Select_Char") + ":", SwingConstants.RIGHT); + selectedFontLabel.setPreferredSize(new Dimension(LABEL_WIDTH, LINE_COMPONENT_HEIGHT)); + + JPanel fontPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ + new Component[]{ initialFontLabel, tabFontConfPane }, + new Component[]{ selectedFontLabel, selectedFontColorPanel } + }, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); + fontPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 20)); + + return fontPanel; + } + + @Override + protected void initDefaultConfig() { + this.paddingLeftSpinner.setValue(UniteStyle.DEFAULT_PADDING_LEFT); + this.paddingRightSpinner.setValue(UniteStyle.DEFAULT_PADDING_RIGHT); + + this.initialBackgroundColorBox.setSelectObject(UniteStyle.DEFAULT_INITIAL_BACKGROUND_COLOR); + this.selectedBackgroundColorBox.setSelectObject(UniteStyle.DEFAULT_SELECTED_BACKGROUND_COLOR); + + this.borderWidthComboBox.setSelectedLineStyle(UniteStyle.DEFAULT_BORDER_LINE.getLineStyle()); + this.borderColorBox.setSelectObject(UniteStyle.DEFAULT_BORDER_LINE.getColor()); + this.borderRadiusSpinner.setValue(UniteStyle.DEFAULT_BORDER_RADIUS); + + this.tabFontConfPane.populate(UniteStyle.DEFAULT_TAB_FONT.getFont()); + this.selectedFontColorButton.setColor(UniteStyle.DEFAULT_TAB_FONT.getSelectColor()); + } + + @Override + protected MobileTemplatePreviewPane createPreviewPane() { + return null; + } + + @Override + protected MobileTemplateStyle getDefaultTemplateStyle() { + return new UniteStyle(); + } + + @Override + public void populateSubStyle(MobileTemplateStyle ob) { + UniteStyle style = (UniteStyle) ob; + this.paddingLeftSpinner.setValue(style.getPaddingLeft()); + this.paddingRightSpinner.setValue(style.getPaddingRight()); + + this.initialBackgroundColorBox.setSelectObject(style.getInitialColor()); + this.selectedBackgroundColorBox.setSelectObject(style.getSelectColor()); + + this.borderWidthComboBox.setSelectedLineStyle(style.getBorderLineStyle()); + this.borderColorBox.setSelectObject(style.getBorderColor()); + this.borderRadiusSpinner.setValue(style.getBorderRadius()); + + this.tabFontConfPane.populate(style.getTabFontConfig().getFont()); + this.selectedFontColorButton.setColor(style.getTabFontConfig().getSelectColor()); + } + + @Override + public MobileTemplateStyle updateSubStyle() { + UniteStyle style = new UniteStyle(); + style.setPaddingLeft((int) this.paddingLeftSpinner.getValue()); + style.setPaddingRight((int) this.paddingRightSpinner.getValue()); + + style.setInitialColor(this.initialBackgroundColorBox.getSelectObject()); + style.setSelectColor(this.selectedBackgroundColorBox.getSelectObject()); + + style.setBorderLineStyle(this.borderWidthComboBox.getSelectedLineStyle()); + style.setBorderColor(this.borderColorBox.getSelectObject()); + style.setBorderRadius((int) this.borderRadiusSpinner.getValue()); + + TabFontConfig config = new TabFontConfig(); + config.setFont(this.tabFontConfPane.update()); + config.setSelectColor(this.selectedFontColorButton.getColor()); + style.setTabFontConfig(config); + + return style; + } + + @Override + protected String title4PopupWindow() { + return null; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java index e233bc6e53..78eddb00f4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java @@ -4,15 +4,14 @@ import com.fr.config.MarketConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.burying.point.AbstractPointInfo; import com.fr.general.CloudCenter; -import com.fr.general.GeneralUtils; +import com.fr.json.JSON; +import com.fr.json.JSONFactory; import com.fr.json.JSONObject; -import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; +import com.fr.third.joda.time.DateTime; -import java.text.SimpleDateFormat; -import java.util.Calendar; import java.util.HashMap; import java.util.Map; @@ -22,6 +21,7 @@ import java.util.Map; */ public class TemplateInfo extends AbstractPointInfo { static final String XML_TAG = "TemplateInfo"; + private static final String SIMPLE_DATE_PATTRN = "yyyy-MM-dd HH:mm"; private static final String CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single"; private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single"; @@ -37,18 +37,18 @@ public class TemplateInfo extends AbstractPointInfo { private static final String ATTR_CELL_COUNT = "cell_count"; private static final String ATTR_BLOCK_COUNT = "block_count"; private static final String ATTR_REPORT_TYPE = "report_type"; - private static final String ATTR_ACTIVITYKEY = "activitykey"; - private static final String ATTR_JAR_TIME = "jar_time"; private static final String ATTR_CREATE_TIME = "create_time"; private static final String ATTR_UUID = "uuid"; - private static final String ATTR_TIME_CONSUME = "time_consume"; - private static final String ATTR_ORIGIN_TIME = "originTime"; - private static final String ATTR_VERSION = "version"; - private static final String ATTR_USERNAME = "username"; + private static final String ATTR_UID = "uid"; + private static final String ATTR_SAVE_RECORD = "saveRecord"; + private static final String ATTR_PARA_APPLY = "paraApply"; + private static final String ATTR_COMPONENTS_INFO = "components_info"; + private static final String ATTR_REUSE_CMP_LIST = "reuseCmptList"; + + private static final String TEST_TEMPLATE_FLAG = "test_template"; private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数 private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 - private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数 private String templateID = StringUtils.EMPTY; private String originID = StringUtils.EMPTY; @@ -76,28 +76,25 @@ public class TemplateInfo extends AbstractPointInfo { } public static TemplateInfo newInstance(String templateID) { - return newInstance(templateID, StringUtils.EMPTY, 0); + return newInstance(templateID, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY); + } + + public static TemplateInfo newInstance(String templateID, String originID, String saveRecord) { + String createTime = DateTime.now().toString(SIMPLE_DATE_PATTRN); + return newInstance(templateID, originID, saveRecord, createTime); } - public static TemplateInfo newInstance(String templateID, String originID, int originTime) { + public static TemplateInfo newInstance(String templateID, String originID, String saveRecord, String createTime) { HashMap consumingMap = new HashMap<>(); - String username = MarketConfig.getInstance().getBbsUsername(); String uuid = DesignerEnvManager.getEnvManager().getUUID(); - String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); - String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime()); - String jarTime = GeneralUtils.readBuildNO(); - String version = ProductConstants.VERSION; - consumingMap.put(ATTR_USERNAME, username); + MarketConfig config = MarketConfig.getInstance(); consumingMap.put(ATTR_UUID, uuid); - consumingMap.put(ATTR_ACTIVITYKEY, activitykey); consumingMap.put(ATTR_TEMPLATE_ID, templateID); consumingMap.put(ATTR_ORIGIN_ID, originID); consumingMap.put(ATTR_CREATE_TIME, createTime); - consumingMap.put(ATTR_TIME_CONSUME, originTime); // timeConsume 在原来模版的基础上累加 - consumingMap.put(ATTR_ORIGIN_TIME, originTime); - consumingMap.put(ATTR_JAR_TIME, jarTime); - consumingMap.put(ATTR_VERSION, version); + consumingMap.put(ATTR_UID, config.getBBSAttr().getBbsUid()); + consumingMap.put(ATTR_SAVE_RECORD, saveRecord); TemplateInfo templateInfo = new TemplateInfo(templateID, originID); templateInfo.consumingMap = consumingMap; @@ -109,14 +106,21 @@ public class TemplateInfo extends AbstractPointInfo { return templateID; } - String getOriginID() { - return originID; + public String getTemplateInfoID() { + return templateID + "_" + getSaveTime(); } - int getTimeConsume() { - return (int) consumingMap.get(ATTR_TIME_CONSUME); + public long getSaveTime() { + String saveRecord = (String) consumingMap.get(ATTR_SAVE_RECORD); + JSONObject jo = JSONFactory.createJSON(JSON.OBJECT, saveRecord); + return jo.getLong("time"); } + public String getTemplateCreateTime() { + return (String) consumingMap.get(ATTR_CREATE_TIME); + } + + @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG(XML_TAG); @@ -129,6 +133,7 @@ public class TemplateInfo extends AbstractPointInfo { if (idleDayCount >= 0) { writer.attr(ATTR_DAY_COUNT, this.idleDayCount); } + writer.attr(TEST_TEMPLATE_FLAG, this.testTemplate); writeProcessMap(writer); writeConsumingMap(writer); @@ -143,19 +148,18 @@ public class TemplateInfo extends AbstractPointInfo { writer.attr(ATTR_CELL_COUNT, (int) processMap.get(ATTR_CELL_COUNT)); writer.attr(ATTR_BLOCK_COUNT, (int) processMap.get(ATTR_BLOCK_COUNT)); writer.attr(ATTR_REPORT_TYPE, (int) processMap.get(ATTR_REPORT_TYPE)); + writer.attr(ATTR_PARA_APPLY, (int) processMap.get(ATTR_PARA_APPLY)); + writer.attr(ATTR_COMPONENTS_INFO, (String) processMap.get(ATTR_COMPONENTS_INFO)); + writer.attr(ATTR_REUSE_CMP_LIST, (String) processMap.get(ATTR_REUSE_CMP_LIST)); writer.end(); } private void writeConsumingMap(XMLPrintWriter writer) { writer.startTAG(XML_CONSUMING_MAP); - writer.attr(ATTR_ACTIVITYKEY, (String) consumingMap.get(ATTR_ACTIVITYKEY)); - writer.attr(ATTR_JAR_TIME, (String) consumingMap.get(ATTR_JAR_TIME)); writer.attr(ATTR_CREATE_TIME, (String) consumingMap.get(ATTR_CREATE_TIME)); writer.attr(ATTR_UUID, (String) consumingMap.get(ATTR_UUID)); - writer.attr(ATTR_TIME_CONSUME, (int) consumingMap.get(ATTR_TIME_CONSUME)); - writer.attr(ATTR_ORIGIN_TIME, (int) consumingMap.get(ATTR_ORIGIN_TIME)); - writer.attr(ATTR_VERSION, (String) consumingMap.get(ATTR_VERSION)); - writer.attr(ATTR_USERNAME, (String) consumingMap.get(ATTR_USERNAME)); + writer.attr(ATTR_UID, (int) consumingMap.get(ATTR_UID)); + writer.attr(ATTR_SAVE_RECORD, (String) consumingMap.get(ATTR_SAVE_RECORD)); writer.end(); } @@ -163,6 +167,7 @@ public class TemplateInfo extends AbstractPointInfo { public void readXML(XMLableReader reader) { if (!reader.isChildNode()) { idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0); + testTemplate = reader.getAttrAsBoolean(TEST_TEMPLATE_FLAG, false); templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY); originID = reader.getAttrAsString(ATTR_ORIGIN_ID, StringUtils.EMPTY); } else { @@ -175,18 +180,17 @@ public class TemplateInfo extends AbstractPointInfo { processMap.put(ATTR_CELL_COUNT, reader.getAttrAsInt(ATTR_CELL_COUNT, 0)); processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0)); processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0)); + processMap.put(ATTR_PARA_APPLY, reader.getAttrAsInt(ATTR_PARA_APPLY, 0)); + processMap.put(ATTR_COMPONENTS_INFO, reader.getAttrAsString(ATTR_COMPONENTS_INFO, StringUtils.EMPTY)); + processMap.put(ATTR_REUSE_CMP_LIST, reader.getAttrAsString(ATTR_REUSE_CMP_LIST, StringUtils.EMPTY)); processMap.put(ATTR_TEMPLATE_ID, templateID); } else if (XML_CONSUMING_MAP.equals(name)) { - consumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY)); - consumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY)); consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY)); consumingMap.put(ATTR_TEMPLATE_ID, templateID); consumingMap.put(ATTR_ORIGIN_ID, originID); consumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY)); - consumingMap.put(ATTR_TIME_CONSUME, reader.getAttrAsInt(ATTR_TIME_CONSUME, 0)); - consumingMap.put(ATTR_ORIGIN_TIME, reader.getAttrAsInt(ATTR_ORIGIN_TIME, 0)); - consumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0")); - consumingMap.put(ATTR_USERNAME, reader.getAttrAsString(ATTR_USERNAME, StringUtils.EMPTY)); + consumingMap.put(ATTR_UID, reader.getAttrAsInt(ATTR_UID, 0)); + consumingMap.put(ATTR_SAVE_RECORD, reader.getAttrAsString(ATTR_SAVE_RECORD, StringUtils.EMPTY)); } } catch (Exception ex) { // 什么也不做,使用默认值 @@ -195,17 +199,8 @@ public class TemplateInfo extends AbstractPointInfo { } @Override - protected boolean isTestTemplate() { - if (!isComplete()) { - return false; - } - - int reportType = (int) processMap.get(ATTR_REPORT_TYPE); - int cellCount = (int) processMap.get(ATTR_CELL_COUNT); - int floatCount = (int) processMap.get(ATTR_FLOAT_COUNT); - int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT); - int widgetCount = (int) processMap.get(ATTR_WIDGET_COUNT); - return isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount); + public boolean isTestTemplate() { + return testTemplate; } public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount) { @@ -222,25 +217,17 @@ public class TemplateInfo extends AbstractPointInfo { @Override protected boolean isComplete() { - // 条件 1. 超过15天未编辑 - // 条件 2. 设计器在这段未编辑的时间内启动超过 X 次(目前定的 X = 3)。即"设计器最近 X 次启动的时间跨度" < "未编辑时间"; - - return idleDayCount > COMPLETE_DAY_COUNT - && DesignerOpenHistory.getInstance().isOpenEnoughTimesInPeriod(idleDayCount); + return true; } @Override public Map getSendInfo() { Map sendMap = new HashMap<>(); - sendMap.put(CONSUMING_URL, new JSONObject(consumingMap).toString()); - sendMap.put(PROCESS_URL, new JSONObject(processMap).toString()); + sendMap.put(CONSUMING_URL, JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString()); + sendMap.put(PROCESS_URL, JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); return sendMap; } - void addTimeConsume(int timeConsume) { - timeConsume += (int) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间 - consumingMap.put(ATTR_TIME_CONSUME, timeConsume); - } void updateProcessMap(TemplateProcessInfo processInfo) { HashMap processMap = new HashMap<>(); @@ -253,11 +240,14 @@ public class TemplateInfo extends AbstractPointInfo { processMap.put(ATTR_FLOAT_COUNT, processInfo.getFloatCount()); processMap.put(ATTR_BLOCK_COUNT, processInfo.getBlockCount()); processMap.put(ATTR_WIDGET_COUNT, processInfo.getWidgetCount()); - + processMap.put(ATTR_PARA_APPLY, processInfo.useParaPane() ? 1 : 0); + processMap.put(ATTR_COMPONENTS_INFO, processInfo.getComponentsInfo().toString()); + processMap.put(ATTR_REUSE_CMP_LIST, processInfo.getReuseCmpList().toString()); this.processMap = processMap; } + int getIdleDayCount() { return this.idleDayCount; } -} \ No newline at end of file +} 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 8c4e7f18d2..23c07ea3a5 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,13 +1,18 @@ package com.fr.design.mainframe.template.info; import com.fr.design.mainframe.burying.point.AbstractPointCollector; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; +import com.fr.design.mainframe.burying.point.AbstractPointInfo; +import com.fr.json.JSON; +import com.fr.json.JSONFactory; +import com.fr.json.JSONObject; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLableReader; -import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** * 做模板的过程和耗时收集,辅助类 @@ -18,9 +23,12 @@ public class TemplateInfoCollector extends AbstractPointCollector private static final String XML_TEMPLATE_INFO_LIST = "TemplateInfoList"; private static final String XML_FILE_NAME = "tpl.info"; private static TemplateInfoCollector instance; - private DesignerOpenHistory designerOpenHistory; + private DesignerOpenHistory designerOpenHistory = DesignerOpenHistory.getInstance(); + //记录指定模板最新的模板耗时信息ID + private Map latestTemplateInfo; private TemplateInfoCollector() { + super(); } public static TemplateInfoCollector getInstance() { @@ -34,7 +42,7 @@ public class TemplateInfoCollector extends AbstractPointCollector * 根据模板ID是否在收集列表中,判断是否需要收集当前模板的信息 */ public boolean contains(String templateID) { - return StringUtils.isNotEmpty(templateID) && pointInfoMap.containsKey(templateID); + return StringUtils.isNotEmpty(templateID) && latestTemplateInfo.containsKey(templateID); } /** @@ -51,42 +59,41 @@ public class TemplateInfoCollector extends AbstractPointCollector if (!shouldCollectInfo()) { return; } + long saveTime = System.currentTimeMillis(); - TemplateInfo templateInfo; - if (this.contains(templateID)) { - templateInfo = pointInfoMap.get(templateID); - } else { - int originTime = this.contains(originID) ? pointInfoMap.get(originID).getTimeConsume() : 0; - templateInfo = TemplateInfo.newInstance(templateID, originID, originTime); - pointInfoMap.put(templateID, templateInfo); - } + TemplateInfo templateInfo = createTemplateInfo(templateID, originID, saveTime, timeConsume); + + pointInfoMap.put(templateInfo.getTemplateInfoID(), templateInfo); + + //更新下此模板最新保存记录 + updateLatestTemplateInfo(templateID, saveTime); - // 收集制作耗时 - templateInfo.addTimeConsume(timeConsume); // 收集模版基本信息 templateInfo.updateProcessMap(processInfo); + //设置是否是测试模板 + templateInfo.setTestTemplate(processInfo.isTestTemplate()); // 刷新闲置日计数器 templateInfo.resetIdleDayCount(); + // 每次更新之后,都同步到暂存文件中 saveInfo(); } - /** - * 获取缓存文件存放路径 - */ - @Override - protected File getInfoFile() { - return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); + private TemplateInfo createTemplateInfo(String templateID, String originID, long saveTime, int timeConsume){ + JSONObject saveRecord = JSONFactory.createJSON(JSON.OBJECT); + saveRecord.put("time", saveTime); + saveRecord.put("consume", timeConsume); + if (this.contains(templateID)){ + return TemplateInfo.newInstance(templateID, originID, saveRecord.toString(), getTemplateCreateTime(templateID)); + } + return TemplateInfo.newInstance(templateID, originID, saveRecord.toString()); } - TemplateInfo getOrCreateTemplateInfoByID(String templateID) { - if (pointInfoMap.containsKey(templateID)) { - return pointInfoMap.get(templateID); - } - TemplateInfo templateInfo = TemplateInfo.newInstance(templateID); - pointInfoMap.put(templateID, templateInfo); - return templateInfo; + private String getTemplateCreateTime(String templateID) { + long latestSaveTime = latestTemplateInfo.get(templateID); + TemplateInfo latestTemplateInfo = pointInfoMap.get(templateID + "_" + latestSaveTime); + return latestTemplateInfo.getTemplateCreateTime(); } /** @@ -104,6 +111,20 @@ public class TemplateInfoCollector extends AbstractPointCollector designerOpenHistory.update(); } + private void updateLatestTemplateInfo(TemplateInfo templateInfo) { + String templateID = templateInfo.getTemplateID(); + if (latestTemplateInfo.containsKey(templateID)) { + long latestSaveTime = latestTemplateInfo.get(templateID); + updateLatestTemplateInfo(templateID, Math.max(latestSaveTime, templateInfo.getSaveTime())); + } else { + updateLatestTemplateInfo(templateID, templateInfo.getSaveTime()); + } + } + + private void updateLatestTemplateInfo(String templateID, long saveTime) { + latestTemplateInfo.put(templateID, saveTime); + } + @Override public void readXML(XMLableReader reader) { if (reader.isChildNode()) { @@ -116,7 +137,8 @@ public class TemplateInfoCollector extends AbstractPointCollector reader.readXMLObject(designerOpenHistory); } else if (TemplateInfo.XML_TAG.equals(name)) { TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(reader); - pointInfoMap.put(templateInfo.getTemplateID(), templateInfo); + updateLatestTemplateInfo(templateInfo); + pointInfoMap.put(templateInfo.getTemplateInfoID(), templateInfo); } } catch (Exception ex) { // 什么也不做,使用默认值 @@ -138,4 +160,51 @@ public class TemplateInfoCollector extends AbstractPointCollector writer.end(); } + + /** + * 获取缓存文件存放路径 + */ + @Override + protected String getInfoFilePath() { + return XML_FILE_NAME; + } + + @Override + public void sendPointInfo() { + addIdleDayCount(); + List removeList = new ArrayList<>(); + List sendList = new ArrayList<>(); + for (String latestTemplateInfokey : latestTemplateInfo.keySet()) { + AbstractPointInfo pointInfo = pointInfoMap.get(latestTemplateInfokey + "_" + latestTemplateInfo.get(latestTemplateInfokey)); + if (pointInfo.isTestTemplate()) { + continue; + } + for (String key : pointInfoMap.keySet()) { + if (key.startsWith(latestTemplateInfokey)) { + sendList.add(key); + } + } + } + // 发送记录 + for (String key : sendList) { + if (SendHelper.sendPointInfo(pointInfoMap.get(key))) { + removeList.add(key); + } + } + + // 清空记录 + for (String key : removeList) { + pointInfoMap.remove(key); + } + + saveInfo(); + } + + + @Override + protected void loadFromFile() { + latestTemplateInfo = new ConcurrentHashMap<>(); + super.loadFromFile(); + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java new file mode 100644 index 0000000000..5c2cfb0711 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java @@ -0,0 +1,20 @@ +package com.fr.design.mainframe.template.info; + +import com.fr.json.JSONObject; + +/** + * Created by kerry on 2020-05-08 + */ +public interface TemplateOperate { + /** + * 获取模板操作类型 + * @return 操作类型 + */ + String getOperateType(); + + /** + * 将模板操作信息转换成json格式 + * @return jsonObject + */ + JSONObject toJSONObject(); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java index 427d48c73b..ea484e5324 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java @@ -1,6 +1,10 @@ package com.fr.design.mainframe.template.info; +import com.fr.base.Style; import com.fr.base.io.BaseBook; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chartx.attr.ChartProvider; +import com.fr.json.JSONArray; /** * Created by plough on 2017/3/17. @@ -19,12 +23,57 @@ public abstract class TemplateProcessInfo { // 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单 public abstract int getReportType(); + // 获取模板格子数 public abstract int getCellCount(); + // 获取模板悬浮元素个数 public abstract int getFloatCount(); + // 获取模板聚合块个数 public abstract int getBlockCount(); + // 获取模板控件数 public abstract int getWidgetCount(); + + //是否是测试模板 + public abstract boolean isTestTemplate(); + + //是否使用参数面板 + public abstract boolean useParaPane(); + + //获取组件信息 + public abstract JSONArray getComponentsInfo(); + + //获取重用组件数 + public abstract JSONArray getReuseCmpList(); + + + public abstract void updateTemplateOperationInfo(TemplateOperate templateOption); + + + protected boolean isTestCell(Object value, Style style) { + if (value instanceof ChartCollection && isTestChartCollection((ChartCollection) value)) { + return true; + } + if (value == null && Style.getInstance().equals(style)) { + return true; + } + return false; + } + + protected boolean isTestChartCollection(ChartCollection chartCollection) { + int chartCount = chartCollection.getChartCount(); + if (chartCount == 0) { + return true; + } + for (int i = 0; i < chartCount; i++) { + ChartProvider chart = chartCollection.getChart(i, ChartProvider.class); + if (chart.isTestChart()) { + return true; + } + } + return false; + } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java index d675aceb22..099684a81a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java @@ -63,7 +63,7 @@ public class BasicPropertyPane extends BasicPane { double[] columnSize = {p, f}; int[][] rowCount = {{1, 1}}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Name")), widgetName}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Name")), widgetName}, }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java index 9f73a06d34..e6ddd8138c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/BaseAccessibleEditor.java @@ -12,6 +12,7 @@ import java.util.ArrayList; import javax.swing.*; import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; @@ -222,7 +223,7 @@ public class BaseAccessibleEditor extends BasicPane implements AccessibleEditor } public static void showMessage(String message, Component editorComponent) { - JOptionPane.showMessageDialog(editorComponent, message, "Validation Error", JOptionPane.ERROR_MESSAGE); + FineJOptionPane.showMessageDialog(editorComponent, message, "Validation Error", JOptionPane.ERROR_MESSAGE); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java index 76434545ed..38f70de814 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/widget/accessibles/MobileTemplateStylePane.java @@ -1,11 +1,14 @@ package com.fr.design.mainframe.widget.accessibles; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.MobileTemplateStyleProvider; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.mobile.ui.TemplateStyleDefinePaneFactory; import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.general.cardtag.mobile.MobileTemplateStyle; import com.fr.general.cardtag.mobile.MobileTemplateStyleType; +import com.fr.invoke.Reflect; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.JList; @@ -18,9 +21,12 @@ import java.awt.Dimension; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; public class MobileTemplateStylePane extends AbstractTemplateStylePane { private static final List STYLE_LIST = new ArrayList(); @@ -29,6 +35,7 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane> map = new HashMap<>(); private JPanel right; private CardLayout card; + private Set> extraStyle = new HashSet<>(); public MobileTemplateStylePane(WCardTagLayout tagLayout){ init(tagLayout); } @@ -52,6 +60,7 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane list = getMobileTemplateStyleProvider(); + for (MobileTemplateStyleProvider provider : list) { + String displayName = provider.displayName(); + Class> clazz = provider.classFroMobileTemplateStyleAppearance(); + BasicBeanPane styleBasicBeanPane = Reflect.on(clazz).create().get(); + listModel.addElement(displayName); + map.put(displayName, styleBasicBeanPane); + right.add(displayName, styleBasicBeanPane); + extraStyle.add(provider.classFroMobileTemplateStyle()); + } + } + public static ListCellRenderer render = new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -97,16 +120,31 @@ public class MobileTemplateStylePane extends AbstractTemplateStylePane getMobileTemplateStyleProvider() { + List list = new ArrayList<>(); + Set sets = ExtraDesignClassManager.getInstance().getArray(MobileTemplateStyleProvider.XML_TAG); + list.addAll(sets); + return Collections.unmodifiableList(list); + } } diff --git a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java index f495e03f13..10f9944947 100644 --- a/designer-base/src/main/java/com/fr/design/menu/MenuDef.java +++ b/designer-base/src/main/java/com/fr/design/menu/MenuDef.java @@ -138,9 +138,13 @@ public class MenuDef extends ShortCut { */ public void addShortCut(ShortCut... shortcut) { for (ShortCut i : shortcut) { - this.shortcutList.add(i); + addShortCut(i); } } + + public void addShortCut(ShortCut shortCut) { + this.shortcutList.add(shortCut); + } public void removeShortCut(ShortCut shortCut) { diff --git a/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java index 7db0004937..acd9068974 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/DatabaseDialogAction.java @@ -24,11 +24,13 @@ public class DatabaseDialogAction implements OSBasedAction { @Override public void execute(Object... objects) { - if (ServerPreferenceConfig.getInstance().isUseUniverseDBM() && !OperatingSystem.isLinux()) { - UniversalDatabaseOpener.showUniverseDatabaseDialog(); - } else { - openDesignDatabaseManager(); - } +// if (ServerPreferenceConfig.getInstance().isUseUniverseDBM() && !OperatingSystem.isLinux()) { +// UniversalDatabaseOpener.showUniverseDatabaseDialog(); +// } else { +// } + // 直接这里屏蔽掉 防止有设置过 导致配置数据库值为true 即使设置界面屏蔽也没用 + openDesignDatabaseManager(); + } private void openDesignDatabaseManager() { diff --git a/designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java b/designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java new file mode 100644 index 0000000000..1ff796a1dc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java @@ -0,0 +1,78 @@ +package com.fr.design.os.impl; + +import com.fr.design.actions.help.AboutDialog; +import com.fr.design.actions.help.AboutPane; +import com.fr.design.mainframe.DesignerContext; +import com.fr.exit.DesignerExiter; +import com.fr.general.ComparatorUtils; +import com.fr.invoke.Reflect; +import com.fr.log.FineLoggerFactory; +import com.fr.stable.os.support.OSBasedAction; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/13 + */ +public class MacOsAddListenerAction implements OSBasedAction { + + @Override + public void execute(final Object... objects) { + try { + Class app = Class.forName("com.apple.eawt.Application"); + Class quitHandler = Class.forName("com.apple.eawt.QuitHandler"); + Object quitInstance = getProxy(quitHandler, "handleQuitRequestWith", new QuitAction()); + Class aboutHandler = Class.forName("com.apple.eawt.AboutHandler"); + Object aboutInstance = getProxy(aboutHandler, "handleAbout", new AboutAction()); + Reflect.on(Reflect.on(app).call("getApplication").get()).call("setQuitHandler", quitInstance) + .call("setAboutHandler", aboutInstance); + } catch (ClassNotFoundException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + + private Object getProxy(Class clazz, final String methodName, final Action action) { + return Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, + new InvocationHandler() { + @Override + public Object invoke(Object proxy, Method method, + Object[] args) throws Throwable { + if (ComparatorUtils.equals(methodName, method.getName())) { + action.execute(); + } + return null; + } + }); + } + + interface Action { + void execute(); + } + + private class QuitAction implements Action { + + @Override + public void execute() { + if (DesignerContext.getDesignerFrame() != null && DesignerContext.getDesignerFrame().isShowing()) { + DesignerContext.getDesignerFrame().exit(); + } else { + DesignerExiter.getInstance().execute(); + } + } + } + + private class AboutAction implements Action { + + @Override + public void execute() { + AboutPane aboutPane = new AboutPane(); + AboutDialog aboutDialog = new AboutDialog(DesignerContext.getDesignerFrame(), aboutPane); + aboutDialog.setVisible(true); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java index 9bc29b8295..366e7d565c 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/SupportOSImpl.java @@ -73,6 +73,50 @@ public enum SupportOSImpl implements SupportOS { public boolean support() { return FRContext.isChineseEnv() && !OperatingSystem.isMacos() && Arch.getArch() != Arch.ARM; } + }, + + /** + * mac下dock栏右键退出 + */ + DOCK_QUIT { + @Override + public boolean support() { + return OperatingSystem.isMacos(); + } + }, + + NON_GUARDIAN_START { + @Override + public boolean support() { + return OperatingSystem.isLinux() || Arch.getArch() == Arch.ARM || OperatingSystem.isMacos(); + } + }, + + DOCK_ICON { + @Override + public boolean support() { + return OperatingSystem.isMacos(); + } + }, + + + VM_OPTIONS_ADAPTER { + @Override + public boolean support() { + return OperatingSystem.isWindows(); + } + }, + + /** + * 原生文件选择器弹窗 + * https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8019464 mac下原生弹窗国际化设置无效,jdk11中有修复 + * + */ + NATIVE_CHOOSER { + @Override + public boolean support() { + return OperatingSystem.isWindows(); + } } } diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java index 30cac90eb2..d3efcae4aa 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java @@ -2,6 +2,7 @@ package com.fr.design.parameter; import com.fr.base.Parameter; import com.fr.base.ParameterConfig; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableSelfCreator; @@ -36,14 +37,14 @@ public class ParameterArrayPane extends JListControlPane { String tempName = getEditingName(); if (StringUtils.isEmpty(tempName)) { nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name")); setIllegalIndex(editingIndex); return; } if (!ComparatorUtils.equals(tempName, selectedName) && isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) { nameableList.stopEditing(); - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name")); setIllegalIndex(editingIndex); } diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java index 14487ca5fa..8e8819c67d 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java @@ -17,6 +17,7 @@ import com.fr.design.editor.editor.Editor; import com.fr.design.editor.editor.FloatEditor; import com.fr.design.editor.editor.IntegerEditor; import com.fr.design.editor.editor.TextEditor; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; @@ -24,6 +25,8 @@ import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; import java.util.Date; @@ -103,6 +106,12 @@ public class ParameterInputPane extends BasicPane { contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane)); //add editor to parameter hashtable. + textF.getCurrentEditor().addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); + } + }); this.editorNameMap.put(textF, parameter.getName()); nameAddedList.add(parameter.getName()); } diff --git a/designer-base/src/main/java/com/fr/design/present/dict/FormulaDictPane.java b/designer-base/src/main/java/com/fr/design/present/dict/FormulaDictPane.java index ff13846208..2eca81466b 100644 --- a/designer-base/src/main/java/com/fr/design/present/dict/FormulaDictPane.java +++ b/designer-base/src/main/java/com/fr/design/present/dict/FormulaDictPane.java @@ -10,6 +10,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.widget.FRWidgetFactory; import com.fr.stable.StringUtils; import javax.swing.*; @@ -20,6 +21,7 @@ public class FormulaDictPane extends FurtherBasicBeanPane { private static final int EDITOR_COLUMN = 15; private static final int LEFT_BORDER = 5; + private static final int MAX_WIDTH = 30; private FormulaEditor keyFormulaEditor; private FormulaEditor valueFormulaEditor; @@ -61,10 +63,9 @@ public class FormulaDictPane extends FurtherBasicBeanPane { valueFormulaContainer.add(new JLabel(icon)); valueFormulaContainer.add(valueFormulaEditor); - Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Actual_Value"), UILabel.LEFT), keyFormulaContainer}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Display_Value"), UILabel.LEFT), valueFormulaContainer}, + new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Actual_Value"), MAX_WIDTH, UILabel.LEFT), keyFormulaContainer}, + new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Display_Value"), MAX_WIDTH, UILabel.LEFT), valueFormulaContainer}, new Component[]{tag, null} }; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); diff --git a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java index 29a8a7deb6..c24125059c 100644 --- a/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java +++ b/designer-base/src/main/java/com/fr/design/report/fit/menupane/ReportFitAttrAction.java @@ -102,4 +102,4 @@ public class ReportFitAttrAction extends JTemplateAction { dialog.setVisible(true); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java b/designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java index 83768079ce..4df9b75144 100644 --- a/designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java +++ b/designer-base/src/main/java/com/fr/design/style/AbstractPopBox.java @@ -5,15 +5,22 @@ import com.fr.design.style.background.BackgroundJComponent; import com.fr.design.style.background.gradient.GradientBackgroundPane; import com.fr.general.Background; -import javax.swing.*; +import javax.swing.JPanel; +import javax.swing.JWindow; +import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.awt.AWTEvent; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; import java.awt.event.AWTEventListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; /** * @author kunsnat E-mail:kunsnat@gmail.com @@ -50,7 +57,7 @@ public abstract class AbstractPopBox extends JPanel { } }; - private void showPopupMenu() { + protected void showPopupMenu() { if (selectPopupWindow != null && selectPopupWindow.isVisible()) { hidePopupMenu(); return; @@ -98,12 +105,16 @@ public abstract class AbstractPopBox extends JPanel { private void mouseClick(MouseEvent evt) { Point point = new Point((int) (evt.getLocationOnScreen().getX()), (int) evt.getLocationOnScreen().getY()); Dimension popBoxD = AbstractPopBox.this.getSize(); - Point popBoxP = AbstractPopBox.this.getLocationOnScreen(); - Dimension popMenuD = this.getControlWindow().getSize(); - Point popMenuP = this.getControlWindow().getLocation(); - Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); - Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD); - if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) { + try { + Point popBoxP = AbstractPopBox.this.getLocationOnScreen(); + Dimension popMenuD = this.getControlWindow().getSize(); + Point popMenuP = this.getControlWindow().getLocation(); + Rectangle popBoxRect = new Rectangle(popBoxP, popBoxD); + Rectangle popMenuRect = new Rectangle(popMenuP, popMenuD); + if (!popBoxRect.contains(point) && !popMenuRect.contains(point)) { + this.hidePopupMenu(); + } + } catch (Exception ignore){ this.hidePopupMenu(); } } diff --git a/designer-base/src/main/java/com/fr/design/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/style/BorderPane.java index aa1185f5de..442f301894 100644 --- a/designer-base/src/main/java/com/fr/design/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/style/BorderPane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.style.color.NewColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; @@ -69,7 +70,7 @@ public class BorderPane extends BasicPane { private JToggleButton rightToggleButton; private LineComboBox currentLineCombo; - private ColorSelectBox currentLineColorPane; + private NewColorSelectBox currentLineColorPane; private UIButton insidebutton; @@ -88,7 +89,7 @@ public class BorderPane extends BasicPane { verticalToggleButton = new ToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/vertical.png"), BorderPane.VERTICAL_BORDER); rightToggleButton = new ToggleButton(BaseUtils.readIcon("/com/fr/base/images/dialog/border/right.png"), BorderPane.RIGHT_BORDER); this.currentLineCombo = new LineComboBox(CoreConstants.UNDERLINE_STYLE_ARRAY); - this.currentLineColorPane = new ColorSelectBox(100); + this.currentLineColorPane = new NewColorSelectBox(100); this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); diff --git a/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java b/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java index 66fa06c9e0..593250ca8c 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java +++ b/designer-base/src/main/java/com/fr/design/style/background/BackgroundPane.java @@ -118,6 +118,9 @@ public class BackgroundPane extends BasicPane { */ public void populate(Background background) { BackgroundUIWrapper wrapper = getBackgroundUIWrapper(background); + if (wrapper == null) { + return; + } int index = wrapper.getIndex(); BackgroundDetailPane quickPane = getTabItemPane(background, index); quickPane.populate(background); diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java index 33df00bc59..8c502114bf 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/FixedGradientBar.java @@ -1,6 +1,6 @@ package com.fr.design.style.background.gradient; -import com.fr.design.style.background.gradient.GradientBar; +import java.awt.Color; /** * 这个bar不能拖拽滑动 @@ -8,6 +8,8 @@ import com.fr.design.style.background.gradient.GradientBar; public class FixedGradientBar extends GradientBar { private static final long serialVersionUID = 2787525421995954889L; + public static final Color NEW_CHARACTER = new Color(99, 178, 238); + public FixedGradientBar(int minvalue, int maxvalue) { super(minvalue, maxvalue); } diff --git a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java index b197a3d396..efeffa4e49 100644 --- a/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java +++ b/designer-base/src/main/java/com/fr/design/style/background/gradient/GradientBar.java @@ -1,40 +1,38 @@ package com.fr.design.style.background.gradient; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.LinearGradientPaint; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.swing.JComponent; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - import com.fr.design.DesignerEnvManager; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.mainframe.DesignerContext; import com.fr.design.style.color.ColorCell; -import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.style.color.ColorSelectDetailPane; import com.fr.design.style.color.ColorSelectDialog; import com.fr.design.style.color.ColorSelectable; import com.fr.stable.AssistUtils; +import javax.swing.JComponent; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LinearGradientPaint; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.geom.Point2D; + /** * TODO:面板缩放的功能没有考虑(就是尾值过大,导致超过界面显示的情况),原来的那个实现完全是个BUG。要缩放的情况也比较少,就干脆以后弄吧 */ -public class GradientBar extends JComponent implements UIObserver,ColorSelectable{ +public class GradientBar extends JComponent implements UIObserver, ColorSelectable { /** * @@ -54,12 +52,12 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl private UINumberField endLabel; private ChangeListener changeListener = null; - private UIObserverListener uiObserverListener; - + private List uiObserverListener; + private static final int MOUSE_OFFSET = 4; - + private static final int MAX_VERTICAL = 45; - + // 选中的颜色 private Color color; @@ -89,6 +87,11 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl iniListener(); } + public void updateColor(Color begin, Color end) { + p1.setColorInner(begin); + p2.setColorInner(end); + } + protected void addMouseClickListener() { this.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { @@ -142,14 +145,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } private void iniListener() { + uiObserverListener = new ArrayList<>(); if (shouldResponseChangeListener()) { this.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - if (uiObserverListener == null) { - return; + for (UIObserverListener observerListener : uiObserverListener) { + observerListener.doChange(); } - uiObserverListener.doChange(); } }); } @@ -199,14 +202,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl * 状态改变 */ public void stateChanged() { - if (changeListener != null) { + if (changeListener != null) { changeListener.stateChanged(null); } } /** * 增加监听 - * + * * @param changeListener 监听 */ public void addChangeListener(ChangeListener changeListener) { @@ -215,14 +218,14 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl /** * 如果左右两个按钮还在初始位置,就为true - * @return 同上 + * + * @return 同上 */ public boolean isOriginalPlace() { return AssistUtils.equals(startLabel.getValue(), min) && AssistUtils.equals(endLabel.getValue(), max); } /** - * * @return */ public double getStartValue() { @@ -230,7 +233,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @return */ public double getEndValue() { @@ -238,23 +240,22 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @param startValue */ public void setStartValue(double startValue) { startLabel.setValue(startValue); + p1.setX(startValue); } /** - * * @param endValue */ public void setEndValue(double endValue) { endLabel.setValue(endValue); + p2.setX(endValue); } /** - * * @return */ public SelectColorPointBtn getSelectColorPointBtnP1() { @@ -262,7 +263,6 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl } /** - * * @return */ public SelectColorPointBtn getSelectColorPointBtnP2() { @@ -276,7 +276,7 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl * */ public void registerChangeListener(UIObserverListener listener) { - uiObserverListener = listener; + uiObserverListener.add(listener); } @Override @@ -288,22 +288,23 @@ public class GradientBar extends JComponent implements UIObserver,ColorSelectabl return true; } - @Override - public void setColor(Color color) { - this.color = color; - } - - @Override - public Color getColor() { - return this.color; - } - - /** - * 选中颜色 - * @param ColorCell 颜色单元格 - */ - @Override - public void colorSetted(ColorCell colorCell) { - - } + @Override + public void setColor(Color color) { + this.color = color; + } + + @Override + public Color getColor() { + return this.color; + } + + /** + * 选中颜色 + * + * @param ColorCell 颜色单元格 + */ + @Override + public void colorSetted(ColorCell colorCell) { + + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java index b5a5e40752..4ee3a119ea 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java @@ -38,6 +38,10 @@ public abstract class ColorControlWindow extends JPopupMenu { return selectionPopupPane.getColor(); } + public PopupHider getPopupHider() { + return popupHider; + } + /** * Init components. */ @@ -49,9 +53,13 @@ public abstract class ColorControlWindow extends JPopupMenu { setOpaque(false); setDoubleBuffered(true); setFocusable(false); + initSelectionPopupPane(isSupportTransparent); + this.pack(); + } + + protected void initSelectionPopupPane(boolean isSupportTransparent) { selectionPopupPane = new ColorSelectionPopupPane(isSupportTransparent); this.add(selectionPopupPane, BorderLayout.CENTER); - this.pack(); } class ColorSelectionPopupPane extends NewColorSelectPane { diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java new file mode 100644 index 0000000000..cbb0e97eaa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorControlWindowWithAuto.java @@ -0,0 +1,126 @@ +package com.fr.design.style.color; + +import com.fr.chart.base.ChartConstants; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ipoppane.PopupHider; +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 javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public abstract class ColorControlWindowWithAuto extends ColorControlWindow { + + private ColorSelectionPopupPaneWithAuto selectionPopupPaneWithAuto; + + public ColorControlWindowWithAuto(PopupHider popupHider) { + this(false, popupHider); + } + + public ColorControlWindowWithAuto(boolean isSupportTransparent, PopupHider popupHider) { + super(isSupportTransparent, popupHider); + } + + public Color getColor() { + if (selectionPopupPaneWithAuto == null) { + return null; + } + return selectionPopupPaneWithAuto.getColor(); + } + + protected void initSelectionPopupPane(boolean isSupportTransparent) { + selectionPopupPaneWithAuto = new ColorSelectionPopupPaneWithAuto(isSupportTransparent); + this.add(selectionPopupPaneWithAuto, BorderLayout.CENTER); + } + + class ColorSelectionPopupPaneWithAuto extends NewColorSelectPane { + private static final long serialVersionUID = 7822856562329146354L; + + private final static int BUTTON_HEIGHT = 15; + + public ColorSelectionPopupPaneWithAuto(boolean isSupportTransparent) { + super(isSupportTransparent); + + this.addChangeListener(new ChangeListener() { + + @Override + public void stateChanged(ChangeEvent e) { + colorChanged(); + } + }); + } + + protected void doTransparent() { + getPopupHider().hidePopupMenu(); + setColor(null); + } + + protected void doAuto() { + getPopupHider().hidePopupMenu(); + setColor(ChartConstants.AUTO_FONT_COLOR); + } + + public void customButtonPressed() { + getPopupHider().hidePopupMenu(); + super.customButtonPressed(); + } + + protected void initSelectButton(boolean isSupportTransparent) { + setSupportTransparent(isSupportTransparent); + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); + + UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); + UIButton autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto")); + + transparentButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doTransparent(); + } + }); + + autoButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + doAuto(); + } + }); + + if (isSupportTransparent) { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {f, 0}; + double[] rowSize = {p, p}; + + Component[][] components = new Component[][]{ + new Component[]{autoButton, null}, + new Component[]{transparentButton, null} + }; + + JPanel buttonGroup = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + this.add(buttonGroup, BorderLayout.NORTH); + } else { + this.add(autoButton, BorderLayout.NORTH); + } + } + + public Dimension getPreferredSize() { + if (isSupportTransparent()) { + return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT + BUTTON_HEIGHT); + } + return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT + BUTTON_HEIGHT); + } + + } + +} \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java index b717ea67e7..33eb6dbf15 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectDialog.java @@ -6,6 +6,7 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.utils.gui.GUICoreUtils; import javax.swing.JPanel; +import java.io.Serializable; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dialog; @@ -13,7 +14,6 @@ import java.awt.FlowLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.Serializable; /** @@ -136,8 +136,13 @@ public class ColorSelectDialog extends MiddleChartDialog{ * void */ public static void showDialog(Frame owner,ColorSelectDetailPane pane,Color initialColor,ColorSelectable selectePane){ + showDialog(owner,pane,initialColor,selectePane,false); + } + + public static void showDialog(Frame owner,ColorSelectDetailPane pane,Color initialColor,ColorSelectable selectePane, boolean alwaysOnTop){ ColorTracker okListener = new ColorTracker(pane); ColorSelectDialog dialog = new ColorSelectDialog(owner,pane,initialColor,okListener,selectePane); + dialog.setAlwaysOnTop(alwaysOnTop); dialog.setModal(true); dialog.show(); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java index bb902fa930..c82eac0c0d 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java @@ -11,16 +11,21 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; - -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.util.ArrayList; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; /** * The pane used to select color @@ -196,6 +201,6 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable @Override public void customButtonPressed() { pane = new ColorSelectDetailPane(Color.WHITE); - ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this); + ColorSelectDialog.showDialog(DesignerContext.getDesignerFrame(), pane, Color.WHITE, this, true); } } diff --git a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java index d532324165..6c21c10cba 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/NewColorSelectPane.java @@ -5,6 +5,7 @@ import com.fr.design.border.UIRoundedBorder; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; @@ -39,8 +40,8 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { // 是否支持透明 private boolean isSupportTransparent; - private final static int TRANSPANENT_WINDOW_HEIGHT = 165; - private final static int WINDWO_HEIGHT = 150; + public final static int TRANSPARENT_WINDOW_HEIGHT = 165; + public final static int WINDOW_HEIGHT = 150; // 最近使用颜色 private UsedColorPane usedColorPane; @@ -56,20 +57,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { * Constructor. */ NewColorSelectPane(boolean isSupportTransparent) { - this.isSupportTransparent = isSupportTransparent; - this.setLayout(FRGUIPaneFactory.createBorderLayout()); - this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); - if (isSupportTransparent) { - UIButton transpanrentButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); - this.add(transpanrentButton, BorderLayout.NORTH); - transpanrentButton.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - doTransparent(); - } - }); - } + initSelectButton(isSupportTransparent); // center JPanel centerPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); @@ -97,7 +85,7 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { centerPane.add(Box.createVerticalStrut(1)); // mod by anchore 16/11/16 - final UIButton customButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_More_Color")); + final UIButton customButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_More_Color")); // 不能使用 ActionListener,否则设计器工具栏中的"更多颜色"按钮会有问题(REPORT-13654) customButton.addMouseListener(new MouseAdapter() { @@ -117,6 +105,31 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { centerPane.add(centerPane1); } + public boolean isSupportTransparent() { + return isSupportTransparent; + } + + public void setSupportTransparent(boolean supportTransparent) { + isSupportTransparent = supportTransparent; + } + + protected void initSelectButton(boolean isSupportTransparent){ + this.isSupportTransparent = isSupportTransparent; + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + this.setBorder(new UIRoundedBorder(UIConstants.TOOLBAR_BORDER_COLOR, 1, 5)); + if (isSupportTransparent) { + UIButton transparentButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_ChartF_Transparency")); + this.add(transparentButton, BorderLayout.NORTH); + transparentButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + doTransparent(); + } + }); + } + } + /** * 添加监听 @@ -199,9 +212,9 @@ public class NewColorSelectPane extends BasicPane implements ColorSelectable { @Override public Dimension getPreferredSize() { if (isSupportTransparent) { - return new Dimension(super.getPreferredSize().width, TRANSPANENT_WINDOW_HEIGHT); + return new Dimension(super.getPreferredSize().width, TRANSPARENT_WINDOW_HEIGHT); } - return new Dimension(super.getPreferredSize().width, WINDWO_HEIGHT); + return new Dimension(super.getPreferredSize().width, WINDOW_HEIGHT); } /** diff --git a/designer-base/src/main/java/com/fr/design/unit/UnitConvertUtil.java b/designer-base/src/main/java/com/fr/design/unit/UnitConvertUtil.java new file mode 100644 index 0000000000..520430d51d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/unit/UnitConvertUtil.java @@ -0,0 +1,73 @@ +package com.fr.design.unit; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.ReportLengthUNITProvider; +import com.fr.design.unit.impl.CMReportLengthUNIT; +import com.fr.design.unit.impl.INCHReportLengthUNIT; +import com.fr.design.unit.impl.MMReportLengthUNIT; +import com.fr.design.unit.impl.PTReportLengthUNIT; +import com.fr.general.GeneralContext; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * Created by kerry on 2020-04-09 + */ +public class UnitConvertUtil { + private static List lengthUNITList = new ArrayList(); + + static { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent pluginEvent) { + initSupportedReportLengthUNIT(); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext pluginContext) { + return pluginContext.contain(ReportLengthUNITProvider.MARK_STRING); + } + }); + + initSupportedReportLengthUNIT(); + } + + private static void initSupportedReportLengthUNIT(){ + lengthUNITList.clear(); + lengthUNITList.add(new MMReportLengthUNIT()); + lengthUNITList.add(new CMReportLengthUNIT()); + lengthUNITList.add(new INCHReportLengthUNIT()); + lengthUNITList.add(new PTReportLengthUNIT()); + Set providers = ExtraDesignClassManager.getInstance().getArray(ReportLengthUNITProvider.MARK_STRING); + for (ReportLengthUNITProvider provider : providers) { + lengthUNITList.add(provider); + } + } + + private UnitConvertUtil() { + + } + + + public static ReportLengthUNITProvider parseLengthUNIT(int unitType) { + for (ReportLengthUNITProvider lengthUNIT : lengthUNITList) { + if (unitType == lengthUNIT.unitType()) { + return lengthUNIT; + } + } + return new MMReportLengthUNIT(); + } + + public static String[] getUnitItems() { + String[] unitItems = new String[lengthUNITList.size()]; + for (int i = 0; i < lengthUNITList.size(); i++) { + unitItems[i] = lengthUNITList.get(i).unitText(); + } + return unitItems; + } +} diff --git a/designer-base/src/main/java/com/fr/design/unit/impl/CMReportLengthUNIT.java b/designer-base/src/main/java/com/fr/design/unit/impl/CMReportLengthUNIT.java new file mode 100644 index 0000000000..ef4dcb64af --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/unit/impl/CMReportLengthUNIT.java @@ -0,0 +1,32 @@ +package com.fr.design.unit.impl; + +import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; +import com.fr.stable.Constants; +import com.fr.stable.unit.CM; +import com.fr.stable.unit.UNIT; + +/** + * Created by kerry on 2020-04-09 + */ +public class CMReportLengthUNIT extends AbstractReportLengthUNITProvider { + @Override + public String unitText() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM"); + } + + @Override + public int unitType() { + return Constants.UNIT_CM; + } + + @Override + public float unit2Value4Scale(UNIT value) { + return value.toCMValue4Scale2(); + } + + @Override + public UNIT float2UNIT(float value) { + return new CM(value); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/unit/impl/INCHReportLengthUNIT.java b/designer-base/src/main/java/com/fr/design/unit/impl/INCHReportLengthUNIT.java new file mode 100644 index 0000000000..5cfcb6920f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/unit/impl/INCHReportLengthUNIT.java @@ -0,0 +1,31 @@ +package com.fr.design.unit.impl; + +import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; +import com.fr.stable.Constants; +import com.fr.stable.unit.INCH; +import com.fr.stable.unit.UNIT; + +/** + * Created by kerry on 2020-04-09 + */ +public class INCHReportLengthUNIT extends AbstractReportLengthUNITProvider { + @Override + public String unitText() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH"); + } + + @Override + public int unitType() { + return Constants.UNIT_INCH; + } + + @Override + public float unit2Value4Scale(UNIT value) { + return value.toINCHValue4Scale3(); + } + + @Override + public UNIT float2UNIT(float value) { + return new INCH(value); + } +} diff --git a/designer-base/src/main/java/com/fr/design/unit/impl/MMReportLengthUNIT.java b/designer-base/src/main/java/com/fr/design/unit/impl/MMReportLengthUNIT.java new file mode 100644 index 0000000000..a4bc2bacaa --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/unit/impl/MMReportLengthUNIT.java @@ -0,0 +1,31 @@ +package com.fr.design.unit.impl; + +import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; +import com.fr.stable.Constants; +import com.fr.stable.unit.MM; +import com.fr.stable.unit.UNIT; + +/** + * Created by kerry on 2020-04-09 + */ +public class MMReportLengthUNIT extends AbstractReportLengthUNITProvider { + @Override + public String unitText() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_MM"); + } + + @Override + public int unitType() { + return Constants.UNIT_MM; + } + + @Override + public float unit2Value4Scale(UNIT value) { + return value.toMMValue4Scale2(); + } + + @Override + public UNIT float2UNIT(float value) { + return new MM(value); + } +} diff --git a/designer-base/src/main/java/com/fr/design/unit/impl/PTReportLengthUNIT.java b/designer-base/src/main/java/com/fr/design/unit/impl/PTReportLengthUNIT.java new file mode 100644 index 0000000000..9be7a8778a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/unit/impl/PTReportLengthUNIT.java @@ -0,0 +1,31 @@ +package com.fr.design.unit.impl; + +import com.fr.design.fun.impl.AbstractReportLengthUNITProvider; +import com.fr.stable.Constants; +import com.fr.stable.unit.PT; +import com.fr.stable.unit.UNIT; + +/** + * Created by kerry on 2020-04-09 + */ +public class PTReportLengthUNIT extends AbstractReportLengthUNITProvider { + @Override + public String unitText() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_PT_Duplicate"); + } + + @Override + public int unitType() { + return Constants.UNIT_PT; + } + + @Override + public float unit2Value4Scale(UNIT value) { + return value.toPTValue4Scale2(); + } + + @Override + public UNIT float2UNIT(float value) { + return new PT(value); + } +} 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 12b1d74b7c..efd809e791 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 @@ -58,7 +58,14 @@ public class DesignerPushUpdateManager { private String getFullLatestVersion() { try { - String res = HttpToolbox.get(CloudCenter.getInstance().acquireUrlByKind("jar10.update")); + String url = CloudCenter.getInstance().acquireUrlByKind("jar10.update"); + if(StringUtils.isBlank(url)){ + return StringUtils.EMPTY; + } + String res = HttpToolbox.get(url); + if(StringUtils.isBlank(res)){ + return StringUtils.EMPTY; + } return new JSONObject(res).optString("buildNO"); } catch (Throwable e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 52e4144deb..78df599c57 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 @@ -30,6 +30,8 @@ import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; +import com.fr.process.engine.core.FineProcessContext; +import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.*; import com.fr.stable.project.ProjectConstants; import com.fr.third.org.apache.http.client.methods.CloseableHttpResponse; @@ -598,6 +600,7 @@ public class UpdateMainDialog extends UIDialog { final String installLib = StableUtils.pathJoin(StableUtils.getInstallHome(), ProjectConstants.LOGS_NAME, UpdateConstants.INSTALL_LIB); final JFrame frame = DesignerContext.getDesignerFrame(); final RestartHelper helper = new RestartHelper(); + FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); new FileProcess(callBack) { @Override public void onDownloadSuccess() { 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 index 689c89942a..ea55c7537c 100644 --- a/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java +++ b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java @@ -88,7 +88,7 @@ public class UpmFinder { dialog.setVisible(true); } } else { - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message")); UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame()); dialog.setAutoUpdateAfterInit(); dialog.showDialog(); 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 09a5b683dc..2bf64642f2 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 @@ -291,10 +291,8 @@ public class DesignUtils { if (isDisplaySimSun(defaultLocale)) { guiFRFont = getNamedFont("SimSun"); - } else if (isDisplayDialog(defaultLocale)) { + } else { guiFRFont = getNamedFont("Dialog"); - } else { - guiFRFont = getNamedFont("Tahoma"); } //先初始化的设计器locale, 后初始化lookandfeel.如果顺序改了, 这边也要调整. 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 index cd02bc5c5e..1ad1948bfa 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java @@ -1,5 +1,6 @@ package com.fr.design.utils; +import com.fr.common.report.ReportState; import com.fr.design.DesignerEnvManager; import com.fr.design.RestartHelper; import com.fr.design.dialog.TipDialog; @@ -12,6 +13,9 @@ import com.fr.design.utils.gui.GUICoreUtils; import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLReadable; @@ -32,7 +36,7 @@ public class DesignerPort implements XMLReadable, XMLWriter { public static final String XML_TAG = "DesignerPort"; private static final int MIN_PORT = 1024; - private static final int MAX_PORT = 65536; + private static final int MAX_PORT = 65535; public static final DesignerPort INSTANCE = new DesignerPort(); @@ -86,7 +90,7 @@ public class DesignerPort implements XMLReadable, XMLWriter { } public void resetPort() { - + FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue())); TipDialog dialog = new TipDialog(null, StringUtils.EMPTY, Toolkit.i18nText("Fine-Design_Port_Found_Port_Conflict"), diff --git a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java b/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java index 5476cb3a16..c4c840227c 100644 --- a/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java @@ -25,7 +25,7 @@ public class WidgetBoundsPaneFactory { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), createRightPane(width, height)}, + new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)}, new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, }; double[] rowSize = {p, p}; @@ -53,11 +53,11 @@ public class WidgetBoundsPaneFactory { double p = TableLayout.PREFERRED; Component[][] northComponents = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Position")), createRightPane(x, y)}, + new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Position")), createRightPane(x, y)}, new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))}, }; Component[][] centerComponents = new Component[][]{ - new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), createRightPane(width, height)}, + new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)}, new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, }; double[] rowSize = {p, p}; @@ -79,7 +79,7 @@ public class WidgetBoundsPaneFactory { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), width}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), width}, }; double[] rowSize = {p}; double[] columnSize = {p, f}; diff --git a/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java b/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java index fcb272dd54..d07d42b3e2 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/CustomJobPane.java @@ -29,7 +29,7 @@ import java.awt.event.ActionListener; public abstract class CustomJobPane extends BasicBeanPane { protected UITextField classNameTextField; protected ObjectProperiesPane objectProperiesPane; - public static final int DEFAULT_LENGTH = 30; + private static final int DEFAULT_LENGTH = 25; public CustomJobPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); 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 15e5aed4a7..9df5d7916a 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 @@ -701,7 +701,7 @@ public class DBManipulationPane extends BasicBeanPane { } jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; for (int i = 0; i < jobs.length; i++) { - jobs[i] = dmlConfig.getSubmitJob(i); + jobs[i] = dmlConfig.getNameSubmitJob(i); } condition = dmlConfig.getCondition(); UpdateCheckBox.setSelected(dmlConfig.isUpdateSelected()); diff --git a/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java similarity index 53% rename from designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java rename to designer-base/src/main/java/com/fr/env/CheckServiceDialog.java index 3797c0f8a2..9134d6429f 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/CheckServiceDialog.java +++ b/designer-base/src/main/java/com/fr/env/CheckServiceDialog.java @@ -1,10 +1,15 @@ -package com.fr.design.write.submit; +package com.fr.env; +import com.fr.design.DesignerEnvManager; +import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.env.utils.DisplayUtils; import com.fr.general.FRFont; +import com.fr.general.GeneralContext; import com.fr.general.IOUtils; import javax.swing.BorderFactory; @@ -13,11 +18,15 @@ import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; +import javax.swing.JTextPane; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; /** * @author: Maksim @@ -28,37 +37,47 @@ public class CheckServiceDialog extends JDialog implements ActionListener { private JPanel topPanel; private JPanel centerPanel; private JPanel bottomPanel; + private UICheckBox remindBox; public CheckServiceDialog(Frame parent, String areaText, String localBranch, String remoteBranch){ super(parent,true); //上面的标签面板 topPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel imagePanel = new JPanel(); - Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning4.png"); + Icon icon = IOUtils.readIcon("com/fr/design/images/warnings/warning5.png"); JLabel imageLabel = new JLabel(); imageLabel.setIcon(icon); imagePanel.add(imageLabel); - imagePanel.setPreferredSize(new Dimension(100,80)); + imagePanel.setPreferredSize(new Dimension(110,100)); JPanel verticalPanel = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); FRFont font = FRFont.getInstance(); font = font.applySize(15).applyStyle(1); JLabel label = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Inconsistency")); label.setFont(font); - label.setPreferredSize(new Dimension(500,30)); - JLabel label2 = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") - + localBranch + "/" + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch); - label2.setPreferredSize(new Dimension(500,20)); - JLabel label3 = new JLabel(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Need_Update")); - label3.setPreferredSize(new Dimension(500,20)); + label.setPreferredSize(new Dimension(650,30)); + + String text = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + localBranch + + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch; + String delimiter = DisplayUtils.getDisplayLength(text) > 70? "
":"/"; + JLabel label2 = new JLabel(""+Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Local_Designer") + + localBranch + delimiter + Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remote_Server") + remoteBranch+""); + label2.setPreferredSize(new Dimension(600,30)); + + JTextPane tipsPane = new JTextPane(); + tipsPane.setEditable(false); + tipsPane.setBackground(verticalPanel.getBackground()); + tipsPane.setPreferredSize(new Dimension(500,40)); + tipsPane.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Need_Update")); verticalPanel.add(label); verticalPanel.add(label2); - verticalPanel.add(label3); + verticalPanel.add(tipsPane); topPanel.add(imagePanel,BorderLayout.WEST); topPanel.add(verticalPanel,BorderLayout.CENTER); + topPanel.setBorder(BorderFactory.createEmptyBorder(10,10,0,10)); //中间的文本域面板 centerPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); @@ -73,9 +92,13 @@ public class CheckServiceDialog extends JDialog implements ActionListener { centerPanel.add(checkArea,BorderLayout.CENTER); //下面的按钮面板 + remindBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Remind_Show")); + remindBox.addActionListener(remindCheckboxListener); UIButton okButton = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Button_Confirm")); - JPanel buttonPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane(); - buttonPanel.add(okButton); + JPanel buttonPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); + buttonPanel.setBorder(BorderFactory.createEmptyBorder(0,10,10,10)); + buttonPanel.add(remindBox, BorderLayout.WEST); + buttonPanel.add(okButton,BorderLayout.EAST); okButton.addActionListener(this ); bottomPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); bottomPanel.add(buttonPanel); @@ -86,7 +109,7 @@ public class CheckServiceDialog extends JDialog implements ActionListener { this.add(topPanel,BorderLayout.NORTH); this.add(centerPanel, BorderLayout.CENTER); this.add(buttonPanel,BorderLayout.SOUTH); - this.setSize(new Dimension(600, 500)); + this.setSize(new Dimension(GeneralContext.getLocale().equals(Locale.US)? 750:600, 500)); GUICoreUtils.centerWindow(this); } @@ -94,4 +117,19 @@ public class CheckServiceDialog extends JDialog implements ActionListener { public void actionPerformed(ActionEvent e) { this.dispose(); } + + + private ActionListener remindCheckboxListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + String remindTime = format.format(new Date()); + //环境已切换,通过当前环境获取,一定是远程环境 + String currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); + RemoteDesignerWorkspaceInfo currentEnv = (RemoteDesignerWorkspaceInfo)DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentEnvName); + currentEnv.setRemindTime(remindBox.isSelected()? remindTime : ""); + } + }; + } diff --git a/designer-base/src/main/java/com/fr/env/EnvListPane.java b/designer-base/src/main/java/com/fr/env/EnvListPane.java index 6300abe95a..911a7b22f8 100644 --- a/designer-base/src/main/java/com/fr/env/EnvListPane.java +++ b/designer-base/src/main/java/com/fr/env/EnvListPane.java @@ -96,8 +96,9 @@ public class EnvListPane extends JListControlPane { */ public String updateEnvManager() { DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); - mgr.clearAllEnv(); + //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖 Nameable[] res = this.update(); + mgr.clearAllEnv(); for (Nameable re : res) { NameObject nameObject = (NameObject) re; mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); 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 4871bb769c..9ea2f7019e 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -10,6 +10,7 @@ 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.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ipasswordfield.UIPassWordField; import com.fr.design.gui.itextfield.UITextField; @@ -25,17 +26,7 @@ import com.fr.workspace.WorkContext; import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.engine.exception.WorkspaceAuthException; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JDialog; -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.swing.JTextPane; -import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; -import javax.swing.ToolTipManager; -import javax.swing.UIManager; +import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; @@ -295,10 +286,13 @@ public class RemoteEnvPane extends BasicBeanPane { contentPanel.add(configPanel, BorderLayout.NORTH); contentPanel.add(accountPanel, BorderLayout.CENTER); - + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + panel.add(contentPanel, BorderLayout.NORTH); + panel.add(testPanel, BorderLayout.CENTER); + panel.setPreferredSize(new Dimension(440, 600)); + UIScrollPane scrollPane = new UIScrollPane(panel); this.setLayout(new BorderLayout()); - this.add(contentPanel, BorderLayout.NORTH); - this.add(testPanel, BorderLayout.CENTER); + this.add(scrollPane); } @Override 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 5362dbbd83..4524254f40 100644 --- a/designer-base/src/main/java/com/fr/env/TestConnectionResult.java +++ b/designer-base/src/main/java/com/fr/env/TestConnectionResult.java @@ -34,7 +34,7 @@ public enum TestConnectionResult { }, /** - * 不完全成功,版本不匹配,但测试连接成功。 + * 不完全成功,版本不匹配,但测试连接成功。该状态先保留 */ PARTLY_SUCCESS { @Override @@ -89,16 +89,7 @@ public enum TestConnectionResult { if (!value) { return FULLY_FAILED; } - try { - String serverVersion = new FunctionalHttpRequest(info).getServerVersion(); - if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) { - return FULLY_SUCCESS; - } - return PARTLY_SUCCESS; - } catch (Exception e) { - // 发生异常,说明没连接上。返回完全失败。 - FineLoggerFactory.getLogger().error(e.getMessage()); - return FULLY_FAILED; - } + //去掉测试连接时所做的检测 + return FULLY_SUCCESS; } } diff --git a/designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java b/designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java new file mode 100644 index 0000000000..1795c5fb14 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/utils/DisplayUtils.java @@ -0,0 +1,39 @@ +package com.fr.env.utils; + +/** + * @author: Maksim + * @Date: Created in 2020/3/16 + * @Description: + */ +public class DisplayUtils { + + /** + * 获取字符串显示时的计算长度 + * @param text 被计算的字符串 + * @return 计算长度 + */ + public static int getDisplayLength(String text){ + if (text == null) { + return 0; + } + char[] c = text.toCharArray(); + int len = 0; + for (int i = 0; i < c.length; i++) { + len++; + if(!isLetter(c[i])){ + len++; + }; + } + return len; + } + + /** + * 判断字符是否为字母、数字、英文符号 + * @param c 传入的字符 + * @return 如果符合上述条件,返回true + */ + public static boolean isLetter(char c) { + int k = 0x80; + return c / k == 0; + } +} diff --git a/designer-base/src/main/java/com/fr/exit/DesignerExiter.java b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java index c7319f4c63..b9067a22ee 100644 --- a/designer-base/src/main/java/com/fr/exit/DesignerExiter.java +++ b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java @@ -1,5 +1,6 @@ package com.fr.exit; +import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.StableUtils; @@ -14,16 +15,19 @@ public class DesignerExiter { public static final DesignerExiter INSTANCE = new DesignerExiter(); - private static final String DOT = "."; - public static DesignerExiter getInstance() { return INSTANCE; } public void execute() { - if (FineProcessContext.getParentPipe() != null || !DOT.equals(StableUtils.getInstallHome())) { - FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); + beforeExit(); + if (FineProcessContext.getParentPipe() != null) { + FineProcessContext.getParentPipe().syncFire(FineProcessEngineEvent.DESTROY); } System.exit(0); } + + private void beforeExit() { + DesignerWorkspaceGenerator.stop(); + } } diff --git a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java index ac76405d9f..96e722d116 100644 --- a/designer-base/src/main/java/com/fr/file/FILEChooserPane.java +++ b/designer-base/src/main/java/com/fr/file/FILEChooserPane.java @@ -505,9 +505,21 @@ public class FILEChooserPane extends BasicPane { if (StringUtils.isEmpty(fileName) || StringUtils.isEmpty(filterExtension) || fileFilter.containsExtension(fileExtension.getExtension())) { return fileName; } + if (!ComparatorUtils.equals(fileNameExtension, filterExtension) && !isMapping(fileNameExtension, filterExtension)) { + return fileName + filterExtension; + } return fileNameWithOutExtension + filterExtension; } + private boolean isMapping(String fromExtension, String toExtension){ + if(FileExtension.CPTX.matchExtension(fromExtension)){ + return FileExtension.CPT.matchExtension(toExtension); + }else if(FileExtension.CPT.matchExtension(fromExtension)){ + return FileExtension.CPTX.matchExtension(toExtension); + } + return false; + } + private void doCancel() { this.locationBtnPane.setPopDir(null); dialogExit(); @@ -734,6 +746,7 @@ public class FILEChooserPane extends BasicPane { fileNameTextField.setText(""); fileNameTextField.addDocumentListener(); } + dialog.setAlwaysOnTop(true); dialog.setVisible(true); return option; } diff --git a/designer-base/src/main/java/com/fr/file/RenameExportFILE.java b/designer-base/src/main/java/com/fr/file/RenameExportFILE.java index 8b03e943f6..75583051dc 100644 --- a/designer-base/src/main/java/com/fr/file/RenameExportFILE.java +++ b/designer-base/src/main/java/com/fr/file/RenameExportFILE.java @@ -99,4 +99,9 @@ public class RenameExportFILE extends AbstractFILE { } return out; } + + @Override + public void closeTemplate() throws Exception { + //do nothing + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java b/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java index a25ebe7b6e..147e1946d4 100644 --- a/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java +++ b/designer-base/src/main/java/com/fr/file/filter/ChooseFileFilter.java @@ -4,6 +4,8 @@ import com.fr.base.extension.FileExtension; import com.fr.file.FILE; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; +import com.fr.stable.CoreConstants; +import com.fr.stable.StringUtils; import javax.swing.filechooser.FileFilter; import java.io.File; @@ -275,25 +277,25 @@ public class ChooseFileFilter extends FileFilter implements FILEFilter, java.io. } /** + * 默认情况下 返回首位的后缀名 * get extention. */ public String getExtensionString() { - if (filters == null) { - return ""; - } - - StringBuffer extsb = new StringBuffer("."); - -// Enumeration keys = filters.keys(); -// while (keys.hasMoreElements()) { -// extsb.append((String) keys.nextElement()); -// } + return getExtensionString(0); + } - for (int i = 0; i < filters.size(); i++) { - extsb.append(filters.get(i)); + public String getExtensionString(int index) { + if (filters == null || filters.isEmpty() || index >= filters.size()) { + return StringUtils.EMPTY; } + return CoreConstants.DOT + filters.get(index); + } - return extsb.toString(); + public int getExtensionCount() { + if (filters == null || filters.isEmpty()) { + return 0; + } + return filters.size(); } /** 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 90ac634ce0..1469dd32ec 100644 --- a/designer-base/src/main/java/com/fr/start/BaseDesigner.java +++ b/designer-base/src/main/java/com/fr/start/BaseDesigner.java @@ -3,6 +3,7 @@ */ package com.fr.start; +import com.fr.common.report.ReportState; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.DesignerLaunchStatus; @@ -24,6 +25,9 @@ import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; import com.fr.stable.OperatingSystem; import java.awt.Window; @@ -75,6 +79,11 @@ public abstract class BaseDesigner extends ToolBarMenuDock { @Override public void on(Event event, Null param) { EventDispatcher.stopListen(this); + // 启动完成 停止监听 + ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); + if (eventPipe != null) { + eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); + } collectUserInformation(); } }); 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 d4e1143c61..d2b8498bb9 100644 --- a/designer-base/src/main/java/com/fr/start/ServerStarter.java +++ b/designer-base/src/main/java/com/fr/start/ServerStarter.java @@ -3,10 +3,9 @@ package com.fr.start; import com.fr.base.ServerConfig; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.BrowseUtils; -import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; -import com.fr.stable.StableUtils; import com.fr.start.server.FineEmbedServer; import com.fr.start.server.FineEmbedServerMonitor; import com.fr.workspace.WorkContext; @@ -25,23 +24,11 @@ public class ServerStarter { if (!WorkContext.getCurrent().isLocal()) { //有问题,这里拿不到远程的http端口 BrowseUtils.browser(WorkContext.getCurrent().getPath()); - } else if (ComparatorUtils.equals(StableUtils.getInstallHome(), ".")) {//august:供代码使用 - String web = GeneralContext.getCurrentAppNameOfEnv(); - browserURLWithLocalEnv("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + web + "/" + ServerConfig.getInstance().getServletName()); } else { - initDemoServerAndBrowser(); - } - - } - - - private static void initDemoServerAndBrowser() { - - try { - FineEmbedServer.start(); - } finally { - //先访问Demo, 后访问报表, 不需要重置服务器. - BrowseUtils.browser("http://localhost:" + DesignerEnvManager.getEnvManager().getEmbedServerPort() + "/" + GeneralContext.getCurrentAppNameOfEnv() + "/" + ServerConfig.getInstance().getServletName()); + browserURLWithLocalEnv("http://localhost:" + + DesignerEnvManager.getEnvManager().getEmbedServerPort() + + "/" + GeneralContext.getCurrentAppNameOfEnv() + + "/" + ServerConfig.getInstance().getServletName()); } } @@ -51,8 +38,8 @@ public class ServerStarter { * @param url 指定路径 */ public static void browserURLWithLocalEnv(final String url) { - - if (!FineEmbedServerMonitor.getInstance().isComplete()) { + // 内置服务器没有启动并且设计器已经打开,可以使用带进度条的启动方式 + if (!FineEmbedServer.isRunning() && DesignerContext.getDesignerFrame().isDesignerOpened()) { FineEmbedServerMonitor.getInstance().monitor(); ExecutorService service = Executors.newSingleThreadExecutor(new NamedThreadFactory("ServerStarter")); service.submit(new Runnable() { @@ -68,8 +55,15 @@ public class ServerStarter { } }); service.shutdown(); + } else if (!FineEmbedServer.isRunning()) { + // 普通方式启动内置服务器 + try { + FineEmbedServer.start(); + } finally { + BrowseUtils.browser(url); + } } 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 a67b7e55a8..33232c6601 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 @@ -62,6 +62,7 @@ public class FineEmbedServerActivator extends Activator { tomcat.setPort(DesignerEnvManager.getEnvManager().getEmbedServerPort()); // 设置解码uri使用的字符编码 tomcat.getConnector().setURIEncoding(EncodeConstants.ENCODING_UTF_8); + setMaxPostSize(); String docBase = new File(WorkContext.getCurrent().getPath()).getParent(); //内置的上下文使用工程目录比如webroot @@ -79,6 +80,18 @@ public class FineEmbedServerActivator extends Activator { context.addServletContainerInitializer(initializer, classes); } + // tomcat的maxPostSize会影响到post参数获取,默认2M + private void setMaxPostSize() { + + if (System.getProperty("tomcat-maxPostSize") != null) { + try { + tomcat.getConnector().setMaxPostSize(Integer.parseInt(System.getProperty("tomcat-maxPostSize"))); + } catch (Exception e) { + FineLoggerFactory.getLogger().error("maxPostSize error: " + e.getMessage(), e); + } + } + } + private void stopServerActivator() { diff --git a/designer-base/src/main/resources/com/fr/design/icon/logo.png b/designer-base/src/main/resources/com/fr/design/icon/logo.png new file mode 100644 index 0000000000..d4c7d8b24d Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/icon/logo.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png b/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png new file mode 100755 index 0000000000..4186fea2cf Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/gui/color/autoForeground.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png b/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png new file mode 100644 index 0000000000..059206e0cc Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/warnings/warning5.png differ diff --git a/designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java b/designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java new file mode 100644 index 0000000000..fa9915b315 --- /dev/null +++ b/designer-base/src/test/java/com/fr/common/detect/CommonPortDetectorTest.java @@ -0,0 +1,45 @@ +package com.fr.common.detect; + +import com.fr.invoke.Reflect; +import com.fr.log.FineLoggerFactory; +import junit.framework.TestCase; +import org.junit.Assert; + +import java.io.IOException; +import java.net.ServerSocket; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/10 + */ +public class CommonPortDetectorTest extends TestCase { + + private ServerSocket serverSocket; + + @Override + public void setUp() throws Exception { + serverSocket = new ServerSocket(55555); + new Thread(new Runnable() { + @Override + public void run() { + try { + serverSocket.accept(); + } catch (IOException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + }).start(); + } + + public void testCheckPort() { + CommonPortDetector detector = CommonPortDetector.getInstance(); + boolean access = Reflect.on(detector).call("checkPort", 55555).get(); + Assert.assertTrue(access); + } + + @Override + public void tearDown() throws Exception { + serverSocket.close(); + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java new file mode 100644 index 0000000000..f37c6e73d1 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java @@ -0,0 +1,58 @@ +package com.fr.design; + +import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; +import com.fr.env.CheckServiceDialog; +import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; +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.modules.junit4.PowerMockRunner; + +/** + * @author: Maksim + * @Date: Created in 2020/3/5 + * @Description: + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class}) +public class EnvChangeEntranceTest { + + @Test + public void showServiceDialog() throws Exception { + try { + EnvChangeEntrance entrance = EnvChangeEntrance.getInstance(); + DesignerWorkspaceInfo selectedEnv = EasyMock.mock(DesignerWorkspaceInfo.class); + WorkspaceConnectionInfo connectionInfo = EasyMock.mock(WorkspaceConnectionInfo.class); + + String remoteBranch = "Build#persist-2020.02.15.01.01.12.12"; + EasyMock.expect(selectedEnv.getConnection()).andReturn(connectionInfo); + EasyMock.expect(selectedEnv.getType()).andReturn(DesignerWorkspaceType.Remote); + EasyMock.expect(selectedEnv.getRemindTime()).andReturn(null); + + FunctionalHttpRequest request = EasyMock.mock(FunctionalHttpRequest.class); + EasyMock.expect(request.getServiceList()).andReturn(null); + + PowerMock.expectNew(FunctionalHttpRequest.class, connectionInfo).andReturn(request).anyTimes(); + EasyMock.expect(request.getServerBranch()).andReturn(remoteBranch); + + CheckServiceDialog dialog = EasyMock.mock(CheckServiceDialog.class); + PowerMock.expectNew(CheckServiceDialog.class, EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject(), EasyMock.anyObject()).andReturn(dialog); + + EasyMock.replay(request); + EasyMock.replay(selectedEnv); + EasyMock.replay(connectionInfo); + PowerMock.replayAll(); + + entrance.showServiceDialog(selectedEnv); + Assert.assertTrue(true); + }catch (Exception e){ + Assert.assertTrue(false); + } + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/base/clipboard/ClipboardFilterTest.java b/designer-base/src/test/java/com/fr/design/base/clipboard/ClipboardFilterTest.java new file mode 100644 index 0000000000..bb254e79c4 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/base/clipboard/ClipboardFilterTest.java @@ -0,0 +1,62 @@ +package com.fr.design.base.clipboard; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.ClipboardHandlerProvider; +import com.fr.plugin.injectable.PluginModule; +import com.fr.stable.fun.mark.Mutable; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +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.modules.junit4.PowerMockRunner; + +import java.util.HashSet; +import java.util.Set; + +@PrepareForTest(PluginModule.class) +@RunWith(PowerMockRunner.class) +public class ClipboardFilterTest { + + + @Before + public void setUp() throws Exception { + + Set providers = new HashSet<>(); + providers.add(new TestClipboardHandlerProvider()); + + ExtraDesignClassManager designClassManager = EasyMock.mock(ExtraDesignClassManager.class); + EasyMock.expect(designClassManager.getArray(ClipboardHandlerProvider.XML_TAG)) + .andReturn(providers) + .anyTimes(); + EasyMock.replay(designClassManager); + + PowerMock.mockStatic(PluginModule.class); + EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraDesign)) + .andReturn(designClassManager) + .anyTimes(); + PowerMock.replayAll(); + } + + @After + public void tearDown() throws Exception { + + PowerMock.resetAll(); + } + + @Test + public void testClipboard() { + + ClipboardFilter.cut("cut"); + String paste1 = ClipboardFilter.paste("paste"); + Assert.assertNull(paste1); + + ClipboardFilter.copy("copy"); + String paste2 = ClipboardFilter.paste("paste"); + Assert.assertNull(paste2); + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java b/designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java new file mode 100644 index 0000000000..36cdc54f04 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/base/clipboard/DesignerClipboardTest.java @@ -0,0 +1,75 @@ +package com.fr.design.base.clipboard; + +import com.fr.design.fun.ClipboardHandlerProvider; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.dnd.ArrayListTransferable; +import com.fr.form.main.ExtraFormClassManager; +import com.fr.plugin.injectable.PluginModule; +import com.fr.stable.fun.mark.Mutable; +import com.fr.third.guava.collect.Lists; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import javax.swing.JPanel; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +@PrepareForTest(PluginModule.class) +@RunWith(PowerMockRunner.class) +@PowerMockIgnore("javax.swing.*") +public class DesignerClipboardTest { + + @Before + public void setUp() throws Exception { + + Set providers = new HashSet<>(); + + ExtraFormClassManager formClassManager = EasyMock.mock(ExtraFormClassManager.class); + EasyMock.expect(formClassManager.getArray(ClipboardHandlerProvider.XML_TAG)) + .andReturn(providers) + .anyTimes(); + EasyMock.replay(formClassManager); + + PowerMock.mockStatic(PluginModule.class); + EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraForm)) + .andReturn(formClassManager) + .anyTimes(); + PowerMock.replayAll(); + } + + @After + public void tearDown() throws Exception { + + PowerMock.resetAll(); + } + + @Test + public void testClipboard() throws Exception { + + JPanel panel = new JPanel(); + Clipboard clipboard = DesignerContext.getClipboard(panel); + + ArrayList transferData = Lists.newArrayList("test", "test2"); + ArrayListTransferable transferable = new ArrayListTransferable(transferData); + clipboard.setContents(transferable, null); + + Transferable filterTransferable = clipboard.getContents(null); + DataFlavor[] flavors = transferable.getTransferDataFlavors(); + ArrayList transferData2 = (ArrayList) filterTransferable.getTransferData(flavors[0]); + + Assert.assertEquals(transferData.get(0), transferData2.get(0)); + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/base/clipboard/TestClipboardHandlerProvider.java b/designer-base/src/test/java/com/fr/design/base/clipboard/TestClipboardHandlerProvider.java new file mode 100644 index 0000000000..3282f257e6 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/base/clipboard/TestClipboardHandlerProvider.java @@ -0,0 +1,29 @@ +package com.fr.design.base.clipboard; + +import com.fr.design.fun.impl.AbstractClipboardHandlerProvider; + +/** + * created by Harrison on 2020/05/15 + **/ +class TestClipboardHandlerProvider extends AbstractClipboardHandlerProvider { + + @Override + public T cut(T selection) { + return selection; + } + + @Override + public T copy(T selection) { + return selection; + } + + @Override + public T paste(T selection) { + return null; + } + + @Override + public boolean support(Object selection) { + return true; + } +} diff --git a/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java b/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java new file mode 100644 index 0000000000..acd47a3c11 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java @@ -0,0 +1,44 @@ +package com.fr.design.data; + +import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/4/27 + */ +public class BasicTableDataUtilsTest extends TestCase { + + @Test + public void testIsInValidName() { + + boolean result1 = BasicTableDataUtils.isInValidName("a.b"); + boolean result2 = BasicTableDataUtils.isInValidName("a.b.c"); + boolean result3 = BasicTableDataUtils.isInValidName("a..b"); + boolean result4 = BasicTableDataUtils.isInValidName("a."); + boolean result5 = BasicTableDataUtils.isInValidName("a.b."); + boolean result6 = BasicTableDataUtils.isInValidName("abc"); + boolean result7 = BasicTableDataUtils.isInValidName(".abc"); + boolean result8 = BasicTableDataUtils.isInValidName(".ab.c"); + boolean result9 = BasicTableDataUtils.isInValidName("ab.c."); + boolean result10 = BasicTableDataUtils.isInValidName(".abc."); + boolean result11 = BasicTableDataUtils.isInValidName(".ab.c."); + boolean result12 = BasicTableDataUtils.isInValidName(".."); + + Assert.assertTrue(result1); + Assert.assertFalse(result2); + Assert.assertFalse(result3); + Assert.assertFalse(result4); + Assert.assertTrue(result5); + Assert.assertFalse(result6); + Assert.assertTrue(result7); + Assert.assertFalse(result8); + Assert.assertTrue(result9); + Assert.assertTrue(result10); + Assert.assertFalse(result11); + Assert.assertFalse(result12); + } + +} \ No newline at end of file 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 index c6675da0d3..9a5ce7b8c1 100644 --- a/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/data/DesignTableDataManagerTest.java @@ -9,6 +9,7 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.file.ProcedureConfig; import com.fr.file.TableDataConfig; import com.fr.invoke.Reflect; +import com.fr.stable.ArrayUtils; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; @@ -146,4 +147,12 @@ public class DesignTableDataManagerTest { "columnCache").get(); Assert.assertEquals(new String[]{"a", "b", "c"}, map.get(null).get("ds1")); } + + @Test + public void testGetDsColumnNames() { + Assert.assertTrue(ArrayUtils.isEmpty(DesignTableDataManager.getDsColumnNames("ds1"))); + String[] columnNames = new String[]{"a", "b", "c"}; + DesignTableDataManager.addDsColumnNames("ds1", new String[]{"a", "b", "c"}); + Assert.assertEquals(columnNames, DesignTableDataManager.getDsColumnNames("ds1")); + } } diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java new file mode 100644 index 0000000000..fe7f365e64 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java @@ -0,0 +1,54 @@ +package com.fr.design.env; + +import com.fr.base.operator.common.CommonOperator; +import com.fr.invoke.ReflectException; +import com.fr.workspace.WorkContext; +import com.fr.workspace.Workspace; +import com.fr.workspace.connect.WorkspaceConnectionInfo; +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.modules.junit4.PowerMockRunner; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/1/2 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({WorkContext.class}) +public class RemoteWorkspaceTest { + @Test + public void testIsWarDeploy() { + + Workspace workspace = EasyMock.mock(Workspace.class); + PowerMock.mockStatic(WorkContext.class); + EasyMock.expect(WorkContext.getCurrent()).andReturn(workspace).anyTimes(); + + CommonOperator operator = EasyMock.createMock(CommonOperator.class); + EasyMock.expect(workspace.get(CommonOperator.class)).andReturn(operator).anyTimes(); + + EasyMock.expect(operator.isWarDeploy()).andReturn(true).once(); + EasyMock.expect(operator.isWarDeploy()).andReturn(false).once(); + EasyMock.expect(operator.isWarDeploy()).andThrow(new ReflectException()).once(); + + EasyMock.replay(workspace, operator); + PowerMock.replayAll(); + + WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey"); + + RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info); + + Assert.assertTrue(remoteWorkspace.isWarDeploy()); + Assert.assertFalse(remoteWorkspace.isWarDeploy()); + Assert.assertFalse(remoteWorkspace.isWarDeploy()); + + EasyMock.verify(workspace, operator); + PowerMock.verifyAll(); + + + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java b/designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java new file mode 100644 index 0000000000..bd9f8484da --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/file/HistoryTemplateListCacheTest.java @@ -0,0 +1,33 @@ +package com.fr.design.file; + +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; +import com.fr.invoke.Reflect; +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.junit.Assert; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/23 + */ +public class HistoryTemplateListCacheTest extends TestCase { + + public void testContains() { + JTemplate jTemplate = EasyMock.mock(JTemplate.class); + FILE file = EasyMock.mock(FILE.class); + EasyMock.expect(jTemplate.getEditingFILE()).andReturn(file).anyTimes(); + EasyMock.replay(file); + EasyMock.replay(jTemplate); + Assert.assertEquals(-1, HistoryTemplateListCache.getInstance().contains(file)); + Assert.assertEquals(-1, HistoryTemplateListCache.getInstance().contains(jTemplate)); + Reflect.on(HistoryTemplateListCache.getInstance()).set("historyList", new ArrayList<>(Arrays.asList(jTemplate))); + Assert.assertEquals(0, HistoryTemplateListCache.getInstance().contains(file)); + Assert.assertEquals(0, HistoryTemplateListCache.getInstance().contains(jTemplate)); + } + +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java new file mode 100644 index 0000000000..c82423daa3 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/formula/FormulaPaneTest.java @@ -0,0 +1,25 @@ +package com.fr.design.formula; + +import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Arrays; + + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/5/20 + */ +public class FormulaPaneTest extends TestCase { + + @Test + public void testSimilarComparator() { + String[] strs = new String[] {"ScriptEval", "SPLIT", "SUMPRECISE"}; + String[] result = new String[] {"SPLIT", "ScriptEval", "SUMPRECISE"}; + Arrays.sort(strs, new FormulaPane.SimilarComparator("sp")); + Assert.assertArrayEquals(result, strs); + } + +} \ No newline at end of file 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 3235473c63..9395ef5b3d 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 @@ -1,19 +1,23 @@ package com.fr.design.mainframe.template.info; import com.fr.config.MarketConfig; -import com.fr.general.GeneralUtils; +import com.fr.design.DesignerEnvManager; import com.fr.invoke.Reflect; -import com.fr.json.JSONObject; +import com.fr.json.JSON; +import com.fr.json.JSONArray; +import com.fr.json.JSONFactory; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.third.org.apache.commons.io.FileUtils; import org.easymock.EasyMock; import org.junit.After; +import org.junit.Assert; import org.junit.Before; 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.io.File; @@ -29,7 +33,8 @@ import static org.junit.Assert.assertTrue; * Created by plough on 2019/4/18. */ @RunWith(PowerMockRunner.class) -@PrepareForTest({ProductConstants.class, MarketConfig.class, ProductConstants.class, GeneralUtils.class}) +@PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class}) +@SuppressStaticInitializationFor({"com.fr.jvm.assist.FineAssist"}) public class TemplateInfoCollectorTest { private String filePath; private String initialFileContent; @@ -51,6 +56,10 @@ public class TemplateInfoCollectorTest { EasyMock.expect(mockProcessInfo.getFloatCount()).andReturn(1).anyTimes(); EasyMock.expect(mockProcessInfo.getReportType()).andReturn(0).anyTimes(); EasyMock.expect(mockProcessInfo.getWidgetCount()).andReturn(0).anyTimes(); + EasyMock.expect(mockProcessInfo.useParaPane()).andReturn(false).anyTimes(); + EasyMock.expect(mockProcessInfo.getComponentsInfo()).andReturn(new JSONArray()).anyTimes(); + EasyMock.expect(mockProcessInfo.isTestTemplate()).andReturn(true).anyTimes(); + EasyMock.expect(mockProcessInfo.getReuseCmpList()).andReturn(JSONArray.create().add("reuse-id-1")).anyTimes(); EasyMock.replay(mockProcessInfo); // 缓存 tpl.info @@ -72,36 +81,37 @@ public class TemplateInfoCollectorTest { assertEquals(",,", DesignerOpenHistory.getInstance().toString()); TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); - assertEquals(7, ((Map) Reflect.on(collector).field("pointInfoMap").get()).size()); - assertEquals("2019-04-08,2019-04-03,2019-03-29", DesignerOpenHistory.getInstance().toString()); + assertEquals("2020-05-07,2020-05-06,2020-04-30", DesignerOpenHistory.getInstance().toString()); } @Test - public void testCollectInfo() { + public void testCollectInfo() throws Exception { + setUpMockForNewInstance(); TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); - String templateID = "16a988ce-8529-42f5-b17c-2ee849355071"; + String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa"; int timeConsume = 200; collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume); // 检查是否写入成功 Reflect.on(collector).call("loadFromFile"); - TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + TemplateInfo templateInfo = getTemplateInfoByID(templateID); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map processMap = Reflect.on(templateInfo).field("processMap").get(); - + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + - "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString()); - - assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\"," + - "\"jar_time\":\"不是安装版本\",\"create_time\":\"2019-03-26 16:13\"," + - "\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," + - "\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":329,\"originTime\":0," + - "\"version\":\"10.0\",\"username\":\"plough\"}", new JSONObject(consumingMap).toString()); + "\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + + "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" + + "}", + JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); + + Assert.assertEquals(71113, consumingMap.get("uid")); + Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time")); + Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID")); + Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid")); } @Test @@ -110,7 +120,7 @@ public class TemplateInfoCollectorTest { TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); - String templateID = "73a97777-8jnk-47cd-b57c-2ee89991279796"; + String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa"; int timeConsume = 200; collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume); @@ -119,20 +129,21 @@ public class TemplateInfoCollectorTest { Reflect.on(collector).call("loadFromFile"); assertTrue(collector.contains(templateID)); - TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + TemplateInfo templateInfo = getTemplateInfoByID(templateID); Map processMap = Reflect.on(templateInfo).field("processMap").get(); assertEquals(templateID, templateInfo.getTemplateID()); - + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + - "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", new JSONObject(processMap).toString()); + "\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + + "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" + + "}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); - assertEquals(templateID, consumingMap.get("templateID")); - assertEquals(StringUtils.EMPTY, consumingMap.get("originID")); - assertEquals(200, consumingMap.get("time_consume")); - assertEquals(0, consumingMap.get("originTime")); + Assert.assertEquals(71113, consumingMap.get("uid")); + Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time")); + Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID")); + Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid")); } @Test @@ -141,26 +152,28 @@ public class TemplateInfoCollectorTest { TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); - String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3"; + String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa"; String originID = "16a988ce-8529-42f5-b17c-2ee849355071"; int timeConsume = 200; - + collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume); - + // 检查是否写入成功 Reflect.on(collector).call("loadFromFile"); - TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + TemplateInfo templateInfo = getTemplateInfoByID(templateID); Map processMap = Reflect.on(templateInfo).field("processMap").get(); - + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + - "\"cell_count\":13,\"block_count\":3,\"report_type\":0," + - "\"templateID\":\"423238d4-5223-22vj-vlsj-42jc49245iw3\"}", new JSONObject(processMap).toString()); - + "\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," + + "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\",\"reuseCmptList\":\"[\\\"reuse-id-1\\\"]\"" + + "}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); + Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); - assertEquals(templateID, consumingMap.get("templateID")); - assertEquals(originID, consumingMap.get("originID")); - assertEquals(329, consumingMap.get("time_consume")); - assertEquals(129, consumingMap.get("originTime")); + Assert.assertEquals(71113, consumingMap.get("uid")); + Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time")); + Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID")); + Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid")); + Assert.assertEquals("16a988ce-8529-42f5-b17c-2ee849355071", consumingMap.get("originID")); } @Test @@ -169,36 +182,71 @@ public class TemplateInfoCollectorTest { TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); - String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3"; + String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa"; String originID = "3kha8jcs-31xw-42f5-h2ww-2ee84935312z"; int timeConsume = 200; collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume); - TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); + TemplateInfo templateInfo = getTemplateInfoByID(templateID); assertEquals(templateID, templateInfo.getTemplateID()); - assertEquals(originID, templateInfo.getOriginID()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); - assertEquals(templateID, consumingMap.get("templateID")); - assertEquals(originID, consumingMap.get("originID")); - assertEquals(200, consumingMap.get("time_consume")); - assertEquals(0, consumingMap.get("originTime")); + Assert.assertEquals(71113, consumingMap.get("uid")); + Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time")); + Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID")); + Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid")); + Assert.assertEquals("3kha8jcs-31xw-42f5-h2ww-2ee84935312z", consumingMap.get("originID")); } @Test public void testAddIdleDateCount() { - String templateID = "16a988ce-8529-42f5-b17c-2ee849355071"; + String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa"; TemplateInfoCollector collecter = TemplateInfoCollector.getInstance(); - TemplateInfo templateInfo = collecter.getOrCreateTemplateInfoByID(templateID); + TemplateInfo templateInfo = getTemplateInfoByID(templateID); - assertEquals(9, templateInfo.getIdleDayCount()); + assertEquals(0, templateInfo.getIdleDayCount()); Reflect.on(collecter).call("addIdleDayCount"); - assertEquals(10, templateInfo.getIdleDayCount()); + assertEquals(1, templateInfo.getIdleDayCount()); // 同一天内多次调用无效 Reflect.on(collecter).call("addIdleDayCount"); - assertEquals(10, templateInfo.getIdleDayCount()); + assertEquals(1, templateInfo.getIdleDayCount()); + } + + @Test + public void testContains() { + TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); + String templateID1 = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa"; + Assert.assertTrue(collector.contains(templateID1)); + String templateID2 = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffb"; + Assert.assertFalse(collector.contains(templateID2)); + } + + @Test + public void testGetTemplateCreateTime() throws Exception { + setUpMockForNewInstance(); + TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); + String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa"; + String createTime = Reflect.on(collector).call("getTemplateCreateTime", templateID).get(); + Assert.assertEquals("2020-05-07 17:25", createTime); + + templateID = "2521d03c-b238-41a5-9a1d-2498efff3a97"; + createTime = Reflect.on(collector).call("getTemplateCreateTime", templateID).get(); + Assert.assertEquals("2020-05-07 17:45", createTime); + } + + + private TemplateInfo getTemplateInfoByID(String templateID) { + TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); + Map latestTemplateInfo = Reflect.on(collector).field("latestTemplateInfo").get(); + Map pointInfoMap = Reflect.on(collector).field("pointInfoMap").get(); + if (latestTemplateInfo.containsKey(templateID)) { + long latestSaveTime = latestTemplateInfo.get(templateID); + return pointInfoMap.get(templateID + "_" + latestSaveTime); + } else { + return TemplateInfo.newInstance(templateID); + } } } diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java index 7f0ddd0bcc..1808736f30 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java @@ -1,13 +1,15 @@ package com.fr.design.mainframe.template.info; import com.fr.config.MarketConfig; -import com.fr.general.GeneralUtils; +import com.fr.design.DesignerEnvManager; import com.fr.invoke.Reflect; +import com.fr.json.JSON; +import com.fr.json.JSONFactory; import com.fr.json.JSONObject; -import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.xml.XMLableReader; import com.fr.third.javax.xml.stream.XMLStreamException; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -25,17 +27,17 @@ import static org.junit.Assert.assertEquals; * Created by plough on 2019/4/19. */ @RunWith(PowerMockRunner.class) -@PrepareForTest({MarketConfig.class, ProductConstants.class, GeneralUtils.class}) +@PrepareForTest({MarketConfig.class, DesignerEnvManager.class}) public class TemplateInfoTest { - private static final String NORMAL_INFO = "\n" + - "\n" + - "\n" + + private static final String NORMAL_INFO = "\n" + + "\n" + + "\n" + ""; - private static final String SAVE_AS_INFO = "\n" + - "\n" + - "\n" + + private static final String SAVE_AS_INFO = "\n" + + "\n" + + "\n" + ""; private TemplateInfo templateInfo; @@ -56,15 +58,14 @@ public class TemplateInfoTest { assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(StringUtils.EMPTY, Reflect.on(templateInfo).field("originID").get()); assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get()); + assertEquals(false, templateInfo.isTestTemplate()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); assertEquals(templateID, consumingMap.get("templateID")); - assertEquals(0, consumingMap.get("originTime")); assertEquals(StringUtils.EMPTY, consumingMap.get("originID")); - assertEquals(0, consumingMap.get("time_consume")); - assertEquals("不是安装版本", consumingMap.get("jar_time")); - assertEquals("plough", consumingMap.get("username")); - assertEquals("10.0", consumingMap.get("version")); + assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid")); + assertEquals(71113, consumingMap.get("uid")); + assertEquals(StringUtils.EMPTY, consumingMap.get("saveRecord")); } @Test @@ -73,26 +74,27 @@ public class TemplateInfoTest { String templateID = "24121212-u2c8-ncd2-82nx-8ud0i8138888"; String originID = "24avc8n2-1iq8-iuj2-wx24-8yy0i8132302"; - int originTime = 100; - TemplateInfo templateInfo = TemplateInfo.newInstance(templateID, originID, originTime); + String saveRecord = "{\"time\";:1588843629000,\"consume\":81}"; + String createTime = "2020-05-07 17:25"; + TemplateInfo templateInfo = TemplateInfo.newInstance(templateID, originID, saveRecord, createTime); assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(originID, Reflect.on(templateInfo).field("originID").get()); assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get()); + assertEquals(false, templateInfo.isTestTemplate()); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); assertEquals(templateID, consumingMap.get("templateID")); - assertEquals(originTime, consumingMap.get("originTime")); assertEquals(originID, consumingMap.get("originID")); - assertEquals(originTime, consumingMap.get("time_consume")); - assertEquals("不是安装版本", consumingMap.get("jar_time")); - assertEquals("plough", consumingMap.get("username")); - assertEquals("10.0", consumingMap.get("version")); + assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid")); + assertEquals(71113, consumingMap.get("uid")); + assertEquals(saveRecord, consumingMap.get("saveRecord")); + assertEquals(createTime, consumingMap.get("create_time")); } @Test public void testGetTemplateID() { - assertEquals("16a988ce-8529-42f5-b17c-2ee849355071", templateInfo.getTemplateID()); - assertEquals("49avd2c4-1104-92j2-wx24-3dd0k2136080", templateInfoSaveAs.getTemplateID()); + assertEquals("aac1139e-018b-4481-867a-a18fc6d6f3e6", templateInfo.getTemplateID()); + assertEquals("2521d03c-b238-41a5-9a1d-2498efff3a97", templateInfoSaveAs.getTemplateID()); } @Test @@ -102,19 +104,21 @@ public class TemplateInfoTest { Map processMap = Reflect.on(templateInfo).field("processMap").get(); Map consumingMap1 = Reflect.on(templateInfoSaveAs).field("consumingMap").get(); Map processMap1 = Reflect.on(templateInfoSaveAs).field("processMap").get(); - assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," + - "\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," + - "\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":129,\"originTime\":0,\"version\":\"10.0\"," + - "\"username\":\"plough\"}", new JSONObject(consumingMap).toString()); - - assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," + - "\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\",\"originID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"," + - "\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":429,\"originTime\":129,\"version\":\"10.0\"," + - "\"username\":\"plough\"}", new JSONObject(consumingMap1).toString()); - assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," + - "\"block_count\":0,\"report_type\":0,\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString()); - assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," + - "\"block_count\":0,\"report_type\":0,\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\"}", new JSONObject(processMap1).toString()); + assertJsonStringEquals("{\"uid\":71113,\"originID\":\"\",\"create_time\":\"2020-05-07 17:28\"," + + "\"saveRecord\":\"{\\\"time\\\":1588843693000,\\\"consume\\\":4}\"," + + "\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," + + "\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString()); + + assertJsonStringEquals("{\"uid\":71113,\"originID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," + + "\"create_time\":\"2020-05-07 17:45\",\"saveRecord\":\"{\\\"time\\\":1588844751000,\\\"consume\\\":1058}\"," + + "\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"," + + "\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap1).toString()); + assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," + + "\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," + + "\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString()); + assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," + + "\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," + + "\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"}", JSONFactory.createJSON(JSON.OBJECT, processMap1).toString()); } private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException { @@ -122,4 +126,18 @@ public class TemplateInfoTest { XMLableReader xmlReader = XMLableReader.createXMLableReader(sr); return TemplateInfo.newInstanceByRead(xmlReader); } + + @Test + public void testGetSaveTime() { + Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); + String saveRecord = (String) consumingMap.get("saveRecord"); + JSONObject object = JSONFactory.createJSON(JSON.OBJECT, saveRecord); + Assert.assertEquals(1588843693000L, object.optLong("time")); + } + + @Test + public void testGetTemplateCreateTime() { + Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); + Assert.assertEquals("2020-05-07 17:28", (String) consumingMap.get("create_time")); + } } diff --git a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java index be2b589892..8ba0278729 100644 --- a/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java +++ b/designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java @@ -1,10 +1,10 @@ package com.fr.design.mainframe.template.info; +import com.fr.config.BBSAttr; import com.fr.config.MarketConfig; +import com.fr.design.DesignerEnvManager; import com.fr.general.ComparatorUtils; -import com.fr.general.GeneralUtils; import com.fr.json.JSONObject; -import com.fr.stable.ProductConstants; import org.easymock.EasyMock; import org.powermock.api.easymock.PowerMock; @@ -33,17 +33,21 @@ class TemplateInfoTestHelper { static void setUpMockForNewInstance() throws Exception { MarketConfig mockMarketConfig = EasyMock.mock(MarketConfig.class); - EasyMock.expect(mockMarketConfig.getBbsUsername()).andReturn("plough").anyTimes(); + BBSAttr bbsAttr = EasyMock.mock(BBSAttr.class); + EasyMock.expect(bbsAttr.getBbsUid()).andReturn(71113).anyTimes(); + EasyMock.expect(mockMarketConfig.getBBSAttr()).andReturn(bbsAttr).anyTimes(); PowerMock.mockStatic(MarketConfig.class); EasyMock.expect(MarketConfig.getInstance()).andReturn(mockMarketConfig).anyTimes(); - PowerMock.mockStatic(GeneralUtils.class); - EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes(); + PowerMock.mockStatic(DesignerEnvManager.class); + DesignerEnvManager envManager = EasyMock.mock( DesignerEnvManager.class); + EasyMock.expect(envManager.getUUID()).andReturn("6b6699ff-ec63-43b0-9deb-b580a5f10411").anyTimes(); + EasyMock.expect(envManager.isJoinProductImprove()).andReturn(true).anyTimes(); + EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes(); + EasyMock.replay(mockMarketConfig, bbsAttr, envManager); - setFinalStatic(ProductConstants.class.getDeclaredField("VERSION"), "10.0"); - EasyMock.replay(mockMarketConfig); PowerMock.replayAll(); } } diff --git a/designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java b/designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java new file mode 100644 index 0000000000..298f51a4cc --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/menu/SnapChatMenuDefTest.java @@ -0,0 +1,106 @@ +package com.fr.design.menu; + +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.design.actions.UpdateAction; +import com.fr.design.notification.SnapChatAllTypes; +import com.fr.design.notification.SnapChatConfig; +import com.fr.stable.xml.XMLableReader; +import com.fr.store.StateHubManager; +import com.fr.store.impl.MemoryLock; +import com.fr.store.impl.MemoryStore; +import com.fr.transaction.Configurations; +import com.fr.transaction.LocalConfigurationHelper; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.api.support.membermodification.MemberMatcher; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; + +import java.awt.event.ActionEvent; +import java.util.HashMap; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({SnapChatConfig.class, SnapChatUpdateAction.class}) +@PowerMockIgnore({"javax.crypto.*","javax.net.ssl.*","sun.security.ssl.*","com.sun.*"}) +public class SnapChatMenuDefTest { + + @Before + public void before() throws Exception { + + DaoContext.setXmlEntityDao(new LocalXmlEntityDao()); + DaoContext.setClassHelperDao(new LocalClassHelperDao()); + DaoContext.setEntityDao(new LocalEntityDao()); + StateHubManager.setLock(new MemoryLock()); + StateHubManager.setStorage(new MemoryStore()); + Configurations.setHelper(new LocalConfigurationHelper()); + } + + @Test + public void testAddShortCut() throws Exception { + + PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class)); + SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class) + .addMockedMethod("readXML") + .createMock(); + Whitebox.setInternalState(snapChatConfig, "markReadMap", new HashMap()); + snapChatConfig.readXML(EasyMock.anyObject(XMLableReader.class)); + EasyMock.expectLastCall().anyTimes(); + EasyMock.replay(snapChatConfig); + + PowerMock.mockStatic(SnapChatConfig.class); + EasyMock.expect(SnapChatConfig.getInstance()).andReturn(snapChatConfig).anyTimes(); + PowerMock.replayAll(); + + SnapChatMenuDef menuDef = new SnapChatMenuDef("test", SnapChatAllTypes.Menu.BBS); + ShortCut action = new SnapChatUpdateAction(SnapChatAllTypes.Menu.BBS) { + @Override + protected void actionPerformed0(ActionEvent e) { + + } + }; + + Assert.assertTrue(menuDef.hasRead()); + + menuDef.addShortCut(action); + Assert.assertFalse(menuDef.hasRead()); + } + + @Test + public void testInsertShortCut() throws Exception { + + PowerMock.suppress(MemberMatcher.constructor(UpdateAction.class)); + SnapChatConfig snapChatConfig = EasyMock.partialMockBuilder(SnapChatConfig.class) + .addMockedMethod("readXML") + .createMock(); + Whitebox.setInternalState(snapChatConfig, "markReadMap", new HashMap()); + snapChatConfig.readXML(EasyMock.anyObject(XMLableReader.class)); + EasyMock.expectLastCall().anyTimes(); + EasyMock.replay(snapChatConfig); + + PowerMock.mockStatic(SnapChatConfig.class); + EasyMock.expect(SnapChatConfig.getInstance()).andReturn(snapChatConfig).anyTimes(); + PowerMock.replayAll(); + + SnapChatMenuDef menuDef = new SnapChatMenuDef("test", SnapChatAllTypes.Menu.BBS); + ShortCut action = new SnapChatUpdateAction(SnapChatAllTypes.Menu.BBS) { + @Override + protected void actionPerformed0(ActionEvent e) { + + } + }; + + Assert.assertTrue(menuDef.hasRead()); + + menuDef.insertShortCut(0, action); + Assert.assertFalse(menuDef.hasRead()); + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java b/designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java new file mode 100644 index 0000000000..181bd97887 --- /dev/null +++ b/designer-base/src/test/java/com/fr/env/utils/DisplayUtilsTest.java @@ -0,0 +1,52 @@ +package com.fr.env.utils; + +import org.junit.Assert; +import org.junit.Test; + + +/** + * @author: Maksim + * @Date: Created in 2020/3/16 + * @Description: + */ +public class DisplayUtilsTest { + + @Test + public void getDisplayLengthTest() { + String s1 = "本地设计器"; + String s2 = "リモートサーバ"; + String s3 = "Local Designer:"; + String s4 = "本地,设,计器: persist-2020.01.15"; + String s5 = "ローカルデザイナrelease-2020.03.03 ... Remote Server:persist-2020.01.15"; + String s6 = "本地 00:00ロ ーカDE / abc "; + + int length1 = DisplayUtils.getDisplayLength(s1); + int length2 = DisplayUtils.getDisplayLength(s2); + int length3 = DisplayUtils.getDisplayLength(s3); + int length4 = DisplayUtils.getDisplayLength(s4); + int length5 = DisplayUtils.getDisplayLength(s5); + int length6 = DisplayUtils.getDisplayLength(s6); + Assert.assertEquals(10,length1); + Assert.assertEquals(14,length2); + Assert.assertEquals(15,length3); + Assert.assertEquals(34,length4); + Assert.assertEquals(72,length5); + Assert.assertEquals(26,length6); + } + + @Test + public void isLetterTest(){ + char c1 = 'A'; + char c2 = '中'; + char c3 = ','; + char c4 = ','; + char c5 = 'デ'; + char c6 = ' '; + Assert.assertTrue(DisplayUtils.isLetter(c1)); + Assert.assertFalse(DisplayUtils.isLetter(c2)); + Assert.assertTrue(DisplayUtils.isLetter(c3)); + Assert.assertFalse(DisplayUtils.isLetter(c4)); + Assert.assertFalse(DisplayUtils.isLetter(c5)); + Assert.assertTrue(DisplayUtils.isLetter(c6)); + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java index c8431a8621..064cd05cec 100644 --- a/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java +++ b/designer-base/src/test/java/com/fr/file/FILEChooserPaneTest.java @@ -25,15 +25,30 @@ public class FILEChooserPaneTest { ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get(); - Assert.assertEquals("WorkBook1.cptx", result3); + Assert.assertEquals("WorkBook1.cpt.cptx", result3); ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); - Assert.assertEquals("WorkBook1.cpt", result4); + Assert.assertEquals("WorkBook1.cptx.cpt", result4); ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); Assert.assertEquals("WorkBook1.cptx", result5); + + ChooseFileFilter chooseFileFilter6 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + String result6 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.xls", chooseFileFilter6).get(); + Assert.assertEquals("WorkBook1.xls.cpt", result6); + + ChooseFileFilter chooseFileFilter7 = new ChooseFileFilter(FileExtension.XLS, StringUtils.EMPTY); + chooseFileFilter7.addExtension(".xlsx"); + String result7 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1", chooseFileFilter7).get(); + Assert.assertEquals("WorkBook1.xls", result7); + + ChooseFileFilter chooseFileFilter8 = new ChooseFileFilter(FileExtension.XLSX, StringUtils.EMPTY); + chooseFileFilter8.addExtension(".xls"); + String result8 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1", chooseFileFilter8).get(); + Assert.assertEquals("WorkBook1.xlsx", result8); + } } diff --git a/designer-base/src/test/java/com/fr/file/filter/ChooseFileFilterTest.java b/designer-base/src/test/java/com/fr/file/filter/ChooseFileFilterTest.java new file mode 100644 index 0000000000..ec6779bab0 --- /dev/null +++ b/designer-base/src/test/java/com/fr/file/filter/ChooseFileFilterTest.java @@ -0,0 +1,33 @@ +package com.fr.file.filter; + +import com.fr.base.extension.FileExtension; +import com.fr.stable.CoreConstants; +import com.fr.stable.StringUtils; +import junit.framework.TestCase; +import org.junit.Assert; + + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/18 + */ +public class ChooseFileFilterTest extends TestCase { + + public void testGetExtensionString() { + ChooseFileFilter chooseFileFilter = new ChooseFileFilter(FileExtension.XLSX, StringUtils.EMPTY); + chooseFileFilter.addExtension(FileExtension.XLS.getExtension()); + Assert.assertEquals(CoreConstants.DOT + FileExtension.XLSX.getExtension(), chooseFileFilter.getExtensionString()); + Assert.assertEquals(CoreConstants.DOT + FileExtension.XLS.getExtension(), chooseFileFilter.getExtensionString(1)); + ChooseFileFilter chooseFileFilter1 = new ChooseFileFilter(); + Assert.assertEquals(StringUtils.EMPTY, chooseFileFilter1.getExtensionString()); + Assert.assertEquals(StringUtils.EMPTY, chooseFileFilter1.getExtensionString(1)); + + } + + public void testGetExtensionCount() { + ChooseFileFilter chooseFileFilter = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); + chooseFileFilter.addExtension(FileExtension.CPTX.getExtension()); + Assert.assertEquals(2, chooseFileFilter.getExtensionCount()); + } +} \ No newline at end of file diff --git a/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info b/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info index eae77630fa..ff65b74e9a 100644 --- a/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info +++ b/designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info @@ -1,35 +1,35 @@ - + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + 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..65d6abd640 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,7 +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.file.HistoryTemplateListPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.design.module.ChartEmptyDataStyleAction; import com.fr.design.module.ChartHyperlinkGroup; @@ -16,7 +16,7 @@ import com.fr.locale.LocaleMarker; import com.fr.locale.LocaleScope; import com.fr.module.Activator; import com.fr.module.extension.Prepare; -import com.fr.plugin.chart.vanchart.imgevent.design.DesignImageEvent; +import com.fr.plugin.chart.vanchart.export.ImagePainter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import com.fr.van.chart.DownloadOnlineSourcesHelper; @@ -26,32 +26,32 @@ import com.fr.van.chart.map.server.ChartMapEditorAction; * Created by juhaoyu on 2018/6/27. */ public class ChartDesignerActivator extends Activator implements Prepare { - + @Override public void start() { - + StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); - + DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); - + DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); - + DesignModuleFactory.registerChartDialogClass(ChartDialog.class); - + DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); - + ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); ActionFactory.registerChartEmptyDataStyleAction(new ChartEmptyDataStyleAction()); ActionFactory.registerChartMapEditorAction(new ChartMapEditorAction()); - + ActionFactory.registerChartCollection(ChartCollection.class); - + DesignModuleFactory.registerExtraWidgetOptions(ChartTypeInterfaceManager.initWidgetOption()); - - DesignImageEvent.registerDefaultCallbackEvent(HistoryTemplateListPane.getInstance()); - DesignImageEvent.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper()); + + ImagePainter.registerDownloadSourcesEvent(new DownloadOnlineSourcesHelper()); + ImagePainter.registerDefaultCallbackEvent(HistoryTemplateListCache.getInstance()); ChartTypeInterfaceManager.addPluginChangedListener(); } @@ -63,6 +63,6 @@ public class ChartDesignerActivator extends Activator implements Prepare { @Override public void stop() { - + } } 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 3fae88fe40..aa7f9107b2 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 @@ -257,7 +257,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene if (resolution == 0){ resolution = ScreenResolution.getScreenResolution(); } - painter.paint(g2d, chartWidth, chartHeight, resolution, null); + painter.paint(g2d, chartWidth, chartHeight, resolution, null,this); } } diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPopAttrPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPopAttrPane.java index 4e1a4b2f46..ac30dbf3be 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPopAttrPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPopAttrPane.java @@ -13,13 +13,14 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.utils.gui.GUICoreUtils; - import com.fr.stable.ParameterProvider; -import com.fr.stable.StringUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import javax.swing.SwingConstants; import java.util.List; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; /** * 图表弹出超链, 悬浮窗属性设置界面. @@ -108,9 +109,6 @@ public class ChartHyperPopAttrPane extends AbstractChartAttrPane { */ public void updateBean(ChartHyperPoplink chartHyperlink) { String title = titleField.getText(); - if (StringUtils.isBlank(title)) { - title = "Chart"; - } chartHyperlink.setChartDigTitle(title); chartHyperlink.setWidth((int)widthField.getValue()); chartHyperlink.setHeight((int)heightField.getValue()); diff --git a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java index 96b157f105..15b2a4f6fd 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperRelateFloatLinkPane.java @@ -17,13 +17,13 @@ import javax.swing.JPanel; import javax.swing.border.Border; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; /** * @author kunsnat E-mail:kunsnat@gmail.com @@ -84,8 +84,12 @@ public class ChartHyperRelateFloatLinkPane extends AbstractHyperLinkPane { private static final Object[] HEADER_WITH_EMPTY = new Object[]{Toolkit.i18nText("Fine-Design_Chart_Area_Name"), Toolkit.i18nText("Fine-Design_Chart_Match_To"), ""}; - public MapAreaMatchPane(TwoTuple> treeNodeAndItems) { initButtonGroup(); initRefreshLabel(); areaNameBox = new UIComboBox(); - this.setLayout(new BorderLayout(5, 10)); + this.setLayout(new BorderLayout(5, 5)); this.add(createContentPane(), BorderLayout.NORTH); initTable(treeNodeAndItems); + + JPanel tablePane = new JPanel(); + tablePane.setLayout(new BorderLayout(5, 10)); + tablePane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 10)); JScrollPane matchAreaScroll = new JScrollPane(matchAreaTable) { @Override public Dimension getPreferredSize() { - return new Dimension(400, 300); + return new Dimension(400, 290); } }; - this.add(matchAreaScroll, BorderLayout.CENTER); + tablePane.add(matchAreaScroll, BorderLayout.CENTER); JScrollPane matchResultScroll = new JScrollPane(matchResultTable) { @Override public Dimension getPreferredSize() { @@ -91,8 +88,10 @@ public class MapAreaMatchPane extends BasicBeanPane { } }; matchResultScroll.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Custom_Match_List"))); - this.add(matchResultScroll, BorderLayout.SOUTH); - this.setBorder(BorderFactory.createEmptyBorder(5, 20, 5, 20)); + tablePane.add(matchResultScroll, BorderLayout.SOUTH); + + this.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); + this.add(tablePane, BorderLayout.CENTER); } private JPanel createContentPane() { @@ -119,6 +118,7 @@ public class MapAreaMatchPane extends BasicBeanPane { matchAreaTable.setItems(treeNodeAndItems.getSecond()); matchResultTable = new MatchResultTable(new Object[0][3], HEADER_WITH_EMPTY); + matchResultTable.setItems(treeNodeAndItems.getSecond()); DefaultTableModel model = new DefaultTableModel(new Object[0][3], HEADER_WITH_EMPTY); matchResultTable.setModel(model); @@ -180,10 +180,6 @@ public class MapAreaMatchPane extends BasicBeanPane { if (matchResult == null) { return; } - if (tableNameCombox.getSelectedItem() != null) { - matchResult.setTableName(tableNameCombox.getSelectedItem().getTableDataName()); - } - matchResult.setColumnName(GeneralUtils.objectToString(areaNameBox.getSelectedItem())); matchResultTable.updateBean(matchResult); } @@ -195,11 +191,6 @@ public class MapAreaMatchPane extends BasicBeanPane { public void populateBean(MapMatchResult matchResult, String tableName, String areaName) { //先取保存的数据集名称和区域名,若不存在,就取数据集面板配置的数据集名称和区域名 matchResultTable.populateBean(matchResult); - - if (matchResult != null && matchResult.getTableName() != null) { - tableName = matchResult.getTableName(); - areaName = matchResult.getColumnName(); - } tableNameCombox.setSelectedTableDataByName(tableName); if (StringUtils.isEmpty(areaName)) { return; @@ -218,50 +209,44 @@ public class MapAreaMatchPane extends BasicBeanPane { private Object[] getColumnData(String tableName, String columnName) { NameTableData nameTableData = new NameTableData(tableName); - TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getTarget()); + TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); Calculator calculator = Calculator.createCalculator(); calculator.setAttribute(TableDataSource.KEY, dataSource); - ParameterProvider[] parameters = nameTableData.getParameters(calculator); - final Map parameterMap = new HashMap<>(); - - if (ArrayUtils.isNotEmpty(parameters)) { - final ParameterInputPane pPane = new ParameterInputPane(parameters); - pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - @Override - public void doOk() { - parameterMap.putAll(pPane.update()); - } - }).setVisible(true); - } - for (ParameterProvider parameter : parameters) { - if (parameterMap.containsKey(parameter.getName())) { - parameter.setValue(parameterMap.get(parameter.getName())); - } - } - ParameterMapNameSpace parameterMapNameSpace = ParameterMapNameSpace.create(parameterMap); - calculator.pushNameSpace(parameterMapNameSpace); - + nameTableData.createTableData(calculator); try { - DataModel dataModel = ExecuteDataSetHelper.createDataModel(calculator, nameTableData); - int colIndex = DataCoreUtils.getColumnIndexByName(dataModel, columnName); + EmbeddedTableData tableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, nameTableData, Integer.MAX_VALUE, false); + int colIndex = getColIndex(tableData, columnName); if (colIndex == DataModel.COLUMN_NAME_NOT_FOUND) { return null; } - int size = dataModel.getRowCount(); + int size = tableData.getRowCount(); HashSet columnData = new LinkedHashSet<>(); for (int i = 0; i < size; i++) { - columnData.add(dataModel.getValueAt(i, colIndex)); + Object valueAt = tableData.getValueAt(i, colIndex); + columnData.add(GeneralUtils.objectToString(valueAt)); } return columnData.toArray(); - } catch (TableDataException ignore) { + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); return null; } } + private int getColIndex(EmbeddedTableData tableData, String columnName) { + int colIndex = 0; + + for (int count = tableData.getColumnCount(); colIndex < count; ++colIndex) { + if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(colIndex), columnName)) { + return colIndex; + } + } + return DataModel.COLUMN_NAME_NOT_FOUND; + } + private void populateMatchData(Object[] columnData) { Set geoAreas = matchAreaTable.getItems(); - Map resultMap = ChartGEOJSONHelper.matchArea(columnData, geoAreas, matchResultTable.getCustomResult()); + Map resultMap = ChartGEOJSONHelper.matchAreaList(columnData, geoAreas, matchResultTable.getCustomResult()); Object[][] data = new Object[resultMap.size()][2]; diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java index e8f98f2a3f..9dd13e77fb 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchAreaTable.java @@ -1,6 +1,5 @@ package com.fr.design.chartx.component; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.general.GeneralUtils; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; @@ -63,6 +62,16 @@ public class MatchAreaTable extends JTable { this.areaNameIndex = areaNameIndex; } + @Override + public boolean isCellEditable(int row, int column) { + //第一列不可编辑 + int col = convertColumnIndexToModel(column); + if (col == 0) { + return false; + } + return true; + } + public void setModel(TableModel dataModel) { super.setModel(dataModel); @@ -70,7 +79,6 @@ public class MatchAreaTable extends JTable { items = new HashSet<>(); } TableColumnModel columnModel = getColumnModel(); - columnModel.getColumn(0).setCellEditor(new UILabelEditor()); columnModel.getColumn(1).setCellEditor(new UIComboBoxRenderAndEditor()); columnModel.getColumn(1).setCellRenderer(new UIComboBoxRenderAndEditor()); } @@ -80,8 +88,7 @@ public class MatchAreaTable extends JTable { return; } int index = areaNameIndex.get(areaName); - Map resultMap = ChartGEOJSONHelper.matchArea(new Object[]{areaName}, items); - String result = resultMap.get(areaName); + String result = ChartGEOJSONHelper.matchArea(GeneralUtils.objectToString(areaName), items); getColumnModel().getColumn(1).getCellEditor().stopCellEditing(); this.setValueAt(result, index, 1); } @@ -114,7 +121,9 @@ public class MatchAreaTable extends JTable { } private void initComboBox(Object value, boolean editor) { - comboBox = new TableTreeComboBox(new JTree(root)); + //地图不显示第一层,钻取地图显示第一层。 + boolean showRoot = root.getUserObject() != null; + comboBox = new TableTreeComboBox(new JTree(root), showRoot); comboBox.setEditable(true); comboBox.setSelectedItem(value); @@ -126,23 +135,8 @@ public class MatchAreaTable extends JTable { } public Object getCellEditorValue() { + comboBox.resetText(); return comboBox.getSelectedItem(); } } - - public static class UILabelEditor extends AbstractCellEditor implements TableCellEditor { - - UILabel uiLabel; - - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, - int row, int column) { - uiLabel = new UILabel(GeneralUtils.objectToString(value)); - return uiLabel; - } - - public Object getCellEditorValue() { - return uiLabel.getText(); - } - } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java index 55287f00a7..5f03a75516 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MatchResultTable.java @@ -3,9 +3,11 @@ package com.fr.design.chartx.component; import com.fr.base.BaseUtils; import com.fr.base.Utils; import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; -import com.fr.plugin.chart.map.MapMatchResult; +import com.fr.general.GeneralUtils; +import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.stable.StringUtils; import javax.swing.AbstractCellEditor; @@ -18,7 +20,9 @@ import javax.swing.table.TableColumnModel; import javax.swing.table.TableModel; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Set; import java.util.Vector; +import java.awt.Color; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -32,6 +36,8 @@ public class MatchResultTable extends JTable { private MatchAreaTable matchAreaTable; + private Set items; + public MatchResultTable(Object[][] data, Object[] header) { super(data, header); this.getTableHeader().setReorderingAllowed(false); @@ -41,12 +47,26 @@ public class MatchResultTable extends JTable { this.matchAreaTable = matchAreaTable; } + public void setItems(Set items) { + this.items = items; + } + + @Override + public boolean isCellEditable(int row, int column) { + //第一列和第二列不可编辑 + int col = convertColumnIndexToModel(column); + if (col == 0 || col == 1) { + return false; + } + return true; + } + + public void setModel(TableModel dataModel) { super.setModel(dataModel); TableColumnModel columnModel = getColumnModel(); - columnModel.getColumn(0).setCellEditor(new MatchAreaTable.UILabelEditor()); - columnModel.getColumn(1).setCellEditor(new MatchAreaTable.UILabelEditor()); + columnModel.getColumn(1).setCellRenderer(new UILabelEditorAndRender()); columnModel.getColumn(2).setCellEditor(new UIButtonEditorAndRender()); columnModel.getColumn(2).setCellRenderer(new UIButtonEditorAndRender()); columnModel.getColumn(2).setMaxWidth(20); @@ -56,7 +76,6 @@ public class MatchResultTable extends JTable { int rowCount = this.getRowCount(); for (int i = 0; i < rowCount; i++) { if (ComparatorUtils.equals(this.getValueAt(i, 0), areaName)) { - getColumnModel().getColumn(1).getCellEditor().stopCellEditing(); this.setValueAt(result, i, 1); return; } @@ -143,4 +162,18 @@ public class MatchResultTable extends JTable { } } + public class UILabelEditorAndRender implements TableCellRenderer { + + UILabel uiLabel; + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + uiLabel = new UILabel(GeneralUtils.objectToString(value)); + if (!items.contains(value)) { + uiLabel.setForeground(Color.GRAY); + uiLabel.setText(value + Toolkit.i18nText("Fine-Design_Chart_Lost_Data")); + } + return uiLabel; + } + } + } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java index 793b49b31e..97426e4c73 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/TableTreeComboBox.java @@ -1,8 +1,10 @@ package com.fr.design.chartx.component; import com.fr.design.gui.icombobox.FRTreeComboBox; +import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.itextfield.UITextField; -import com.fr.general.IOUtils; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import javax.swing.JTextField; @@ -18,6 +20,8 @@ import java.awt.Component; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; /** * @author Bjorn @@ -28,8 +32,8 @@ public class TableTreeComboBox extends FRTreeComboBox { private JTextField textField; - public TableTreeComboBox(JTree tree) { - super(tree, null); + public TableTreeComboBox(JTree tree, boolean showRoot) { + super(tree, null, showRoot, false); textField = (JTextField) (this.getEditor().getEditorComponent()); textField.addKeyListener(treeKeyListener); tree.setCellRenderer(tableNameTreeRenderer); @@ -40,6 +44,24 @@ public class TableTreeComboBox extends FRTreeComboBox { matchLeafNode(parent, node, textField); } + @Override + public void setSelectedItemString(String name) { + super.setSelectedItemString(name); + this.textField.setText(name); + } + + public void resetText() { + Object selectedItem = this.getSelectedItem(); + if (!ComparatorUtils.equals(selectedItem, textField.getText())) { + textField.setText(GeneralUtils.objectToString(selectedItem)); + } + } + + @Override + protected UIComboBoxEditor createEditor() { + return new TableTreeComboBoxEditor(this); + } + private boolean matchLeafNode(TreePath parent, TreeNode node, UITextField textField) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); @@ -72,7 +94,6 @@ public class TableTreeComboBox extends FRTreeComboBox { .getLastPathComponent(); if (node.isLeaf()) { TableTreeComboBox.this.setSelectedItem(treePath); - textField.setText(pathToString(treePath)); MenuSelectionManager.defaultManager().clearSelectedPath(); } } @@ -86,9 +107,6 @@ public class TableTreeComboBox extends FRTreeComboBox { if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; Object userObj = node.getUserObject(); - if (node.getChildCount() > 0) { - this.setIcon(IOUtils.readIcon("com/fr/design/images/m_insert/expandCell.gif")); - } if (userObj != null) { this.setText(ChartGEOJSONHelper.getPresentNameWithPath(userObj.toString())); } @@ -97,4 +115,36 @@ public class TableTreeComboBox extends FRTreeComboBox { } }; + class TableTreeComboBoxEditor extends FrTreeSearchComboBoxEditor { + + public TableTreeComboBoxEditor(FRTreeComboBox comboBox) { + super(comboBox); + textField.addMouseListener(mouseListener); + } + + private MouseListener mouseListener = new MouseListener() { + + public void mouseClicked(MouseEvent e) { + + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + setPopupVisible(true); + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + }; + + } + } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java b/designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java new file mode 100644 index 0000000000..dd908505db --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/button/ColorButton.java @@ -0,0 +1,174 @@ +package com.fr.design.chartx.component.button; + +import com.fr.base.BaseUtils; +import com.fr.base.background.ColorBackground; +import com.fr.design.style.AbstractSelectBox; +import com.fr.design.style.color.ColorSelectPane; + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-03-06 + */ +public class ColorButton extends AbstractSelectBox { + + private static final double DEL_WIDTH = 7; + + public static final int WIDTH = 18; + + private BufferedImage closeIcon = BaseUtils.readImageWithCache("com/fr/design/images/toolbarbtn/chartChangeClose.png"); + + private Color color; + + private boolean isMoveOn = false; + + private ColorSelectPane colorPane; + + private boolean lastButton; + + private ChangeListener changeListener; + + public ColorButton(Color color) { + this.color = color; + addMouseListener(getMouseListener()); + } + + public Dimension getPreferredSize() { + return new Dimension(WIDTH, WIDTH); + } + + private void paintDeleteButton(Graphics g2d) { + Rectangle2D bounds = this.getBounds(); + + int x = (int) (bounds.getWidth() - DEL_WIDTH); + int y = 1; + + g2d.drawImage(closeIcon, x, y, closeIcon.getWidth(), closeIcon.getHeight(), null); + } + + public void setLastButton(boolean lastButton) { + this.lastButton = lastButton; + } + + @Override + public void paint(Graphics g) { + this.setSize(WIDTH, WIDTH); + Graphics2D g2d = (Graphics2D) g; + g2d.setPaint(color); + Rectangle2D rec = new Rectangle2D.Double(0, 0, WIDTH + 1, WIDTH + 1); + g2d.fill(rec); + + if (isMoveOn && !lastButton) { + paintDeleteButton(g); + } + } + + protected void deleteButton() { + + } + + + private void checkMoveOn(boolean moveOn) { + this.isMoveOn = moveOn; + repaint(); + } + + protected MouseListener getMouseListener() { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + mouseClick(e); + } + + public void mouseEntered(MouseEvent e) { + checkMoveOn(true); + } + + public void mouseExited(MouseEvent e) { + checkMoveOn(false); + } + }; + } + + + public void mouseClick(MouseEvent e) { + if (!lastButton) { + Rectangle2D bounds = this.getBounds(); + if (bounds == null) { + return; + } + if (e.getX() >= bounds.getWidth() - DEL_WIDTH && e.getY() <= DEL_WIDTH) { + deleteButton(); + hidePopupMenu(); + return; + } + } + //打开颜色选择面板 + showPopupMenu(); + } + + public JPanel initWindowPane(double preferredWidth) { + // 下拉的时候重新生成面板,刷新最近使用颜色 + colorPane = new ColorSelectPane(false) { + @Override + public void setVisible(boolean b) { + super.setVisible(b); + } + }; + colorPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + hidePopupMenu(); + color = ((ColorSelectPane) e.getSource()).getColor(); + fireDisplayComponent(ColorBackground.getInstance(color)); + ColorButton.this.stateChanged(); + } + }); + return colorPane; + } + + public void stateChanged() { + if (changeListener != null) { + changeListener.stateChanged(null); + } + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + + /** + * 获取当前选中的颜色 + * + * @return 当前选中的颜色 + */ + public Color getSelectObject() { + return this.color; + } + + /** + * 设置选中的颜色 + * + * @param color 颜色 + */ + public void setSelectObject(Color color) { + this.color = color; + colorPane.setColor(color); + + fireDisplayComponent(ColorBackground.getInstance(color)); + } + +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java new file mode 100644 index 0000000000..db59179a31 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java @@ -0,0 +1,258 @@ +package com.fr.design.chartx.component.combobox; + +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icombobox.UIComboBoxRenderer; +import com.fr.design.i18n.Toolkit; +import com.fr.general.GeneralUtils; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.JLabel; +import javax.swing.JList; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.LinearGradientPaint; +import java.awt.geom.Rectangle2D; + +/** + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-03-05 + * 一个带颜色展示的配色选择下拉框 + */ +public class ColorSchemeComboBox extends UIComboBox { + + private Map colorSchemes; + + public ColorSchemeComboBox() { + this(null); + } + + public ColorSchemeComboBox(Map colorSchemes) { + //通过配色方案的集合初始化下拉控件,如果参数为null,从配置中读取配色方案。 + if (colorSchemes == null) { + colorSchemes = getColorSchemesFromConfig(); + } + this.colorSchemes = colorSchemes; + + this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray())); + + this.setRenderer(new ColorSchemeCellRenderer()); + } + + private Map getColorSchemesFromConfig() { + Map colorSchemes = new LinkedHashMap<>(); + ChartPreStyleConfig config = ChartPreStyleConfig.getInstance(); + + //所有的样式名称 + Iterator names = config.names(); + + //添加默认的方案和第一个方案 + String defaultName = config.getCurrentStyle(); + ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName); + Object firstName = names.next(); + ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName); + if (defaultStyle == null) { + defaultStyle = firstStyle; + } + colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle)); + colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle)); + + //添加其他的配色方案 + while (names.hasNext()) { + Object key = names.next(); + ChartColorMatching colorMatching = (ChartColorMatching) config.getPreStyle(key); + colorSchemes.put(colorMatching.getId(), colorMatchingToColorInfo(colorMatching)); + } + + //添加自定义组合色和自定义渐变色 + colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Custom_Combination_Color"), null); + colorSchemes.put(Toolkit.i18nText("Fine-Design_Chart_Custom_Gradient"), null); + + return colorSchemes; + } + + public void refresh() { + this.colorSchemes = getColorSchemesFromConfig(); + this.setModel(new DefaultComboBoxModel(colorSchemes.keySet().toArray())); + } + + public ColorInfo getSelectColorInfo() { + String selectedItem = (String) getSelectedItem(); + return colorSchemes.get(selectedItem); + } + + private ColorInfo colorMatchingToColorInfo(ChartColorMatching colorMatching) { + ColorInfo colorInfo = new ColorInfo(); + colorInfo.setGradient(colorMatching.getGradient()); + colorInfo.setColors(colorMatching.getColorList()); + return colorInfo; + } + + public SelectType getSelectType() { + int selectedIndex = this.getSelectedIndex(); + int itemCount = this.getItemCount(); + if (selectedIndex == itemCount - 1) { + return SelectType.GRADATION_COLOR; + } + if (selectedIndex == itemCount - 2) { + return SelectType.COMBINATION_COLOR; + } + if (selectedIndex == 0) { + return SelectType.DEFAULT; + } + return SelectType.NORMAL; + } + + public void setSelectType(SelectType selectType) { + int itemCount = this.getItemCount(); + switch (selectType) { + case DEFAULT: + setSelectedIndex(0); + break; + case GRADATION_COLOR: + setSelectedIndex(itemCount - 1); + break; + case COMBINATION_COLOR: + setSelectedIndex(itemCount - 2); + break; + } + } + + public enum SelectType { + DEFAULT, + COMBINATION_COLOR, + GRADATION_COLOR, + NORMAL + } + + public Set getItems() { + return colorSchemes.keySet(); + } + + public class ColorInfo { + + private List colors; + + private boolean gradient; + + public List getColors() { + return colors; + } + + public void setColors(List colors) { + this.colors = colors; + } + + public boolean isGradient() { + return gradient; + } + + public void setGradient(boolean gradient) { + this.gradient = gradient; + } + } + + /** + * CellRenderer. + */ + class ColorSchemeCellRenderer extends UIComboBoxRenderer { + + private String schemeName = Toolkit.i18nText("Fine-Design_Report_Default"); + + //左边距 + private static final double X = 4d; + + //上边距 + private static final double Y = 4d; + + private static final String BLANK_SPACE = " "; + + private static final int HEIGHT = 20; + + private static final int MAX_COUNT = 5; + + private static final int BLANK = 1; + + @Override + public Dimension getPreferredSize() { + Dimension preferredSize = super.getPreferredSize(); + preferredSize.setSize(super.getPreferredSize().getWidth(), HEIGHT); + return preferredSize; + } + + @Override + public Dimension getMinimumSize() { + return getPreferredSize(); + } + + public Component getListCellRendererComponent( + JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + this.schemeName = GeneralUtils.objectToString(value); + ColorInfo colorInfo = colorSchemes.get(schemeName); + if (colorInfo == null) { + comp.setText(BLANK_SPACE + schemeName); + } else { + FontMetrics fontMetrics = comp.getFontMetrics(comp.getFont()); + //宽度是5倍的高加上4倍的留白 + double width = (HEIGHT - 2 * Y) * MAX_COUNT + BLANK * (MAX_COUNT - 1); + String fill = BLANK_SPACE; + //图形和文字之间留的宽度大于3倍的X + while (fontMetrics.stringWidth(fill) < width + 3 * X) { + fill += BLANK_SPACE; + } + comp.setText(fill + schemeName); + } + comp.setToolTipText(schemeName); + return comp; + } + + public void paint(Graphics g) { + super.paint(g); + + Graphics2D g2d = (Graphics2D) g; + + ColorInfo colorInfo = colorSchemes.get(schemeName); + if (colorInfo != null) { + if (colorInfo.isGradient()) { + drawGradient(g2d, colorInfo.getColors()); + } else { + drawCombineColor(g2d, colorInfo.getColors()); + } + } + } + + private void drawGradient(Graphics2D g2d, List colors) { + //上下留4px,宽度等于5倍高 + double height = HEIGHT - 2 * Y; + double width = height * MAX_COUNT + BLANK * (MAX_COUNT - 1); + LinearGradientPaint linearGradientPaint = new LinearGradientPaint((float) X, (float) Y, (float) (X + width), (float) Y, new float[]{0f, 1f}, colors.toArray(new Color[colors.size()])); + g2d.setPaint(linearGradientPaint); + Rectangle2D rec = new Rectangle2D.Double(X, Y, width, height); + g2d.fill(rec); + } + + private void drawCombineColor(Graphics2D g2d, List colors) { + int size = Math.min(colors.size(), MAX_COUNT); + double height = HEIGHT - 2 * Y; + //加上1px留白 + double width = ((height + BLANK) * MAX_COUNT - size) / size; + for (int i = 0; i < size; i++) { + g2d.setPaint(colors.get(i)); + Rectangle2D rec = new Rectangle2D.Double(X + (width + BLANK) * i, Y, width, height); + g2d.fill(rec); + } + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java index 975faffca3..1102f7a64e 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/data/drillMap/DrillMapLayerPane.java @@ -8,7 +8,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; -import com.fr.plugin.chart.map.MapMatchResult; +import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.plugin.chart.map.server.CompatibleGeoJSONTreeHelper; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; diff --git a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java index bec4e78b7e..1b6c6f9be0 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/fields/diff/MapDataSetFieldsPane.java @@ -9,7 +9,7 @@ import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.plugin.chart.map.MapMatchResult; +import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.server.ChartGEOJSONHelper; import com.fr.plugin.chart.vanchart.VanChart; @@ -63,7 +63,7 @@ public abstract class MapDataSetFieldsPane { double[] columnSize = {p, f}; double[] rowSize = {p,p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Style")),configStyleButton}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Change_Style")),configStyleButton}, new Component[]{configPane, null}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -107,19 +108,19 @@ public class ChangeConfigPane extends BasicBeanPane { double[] rowSize = {p, p, p}; timeInterval = new UISpinner(MIN_TIME, MAX_TIME, 1, 0); colorSelectBox4carousel = new ColorSelectBoxWithOutTransparent(WIDTH); - switchStyleGroup = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Hide")}); + switchStyleGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Show"), Toolkit.i18nText("Fine-Design_Report_Hide")}); Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Arrow_Style")), switchStyleGroup, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Interval")), timeInterval, new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Time_Second"))}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background")),colorSelectBox4carousel, null} + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Arrow_Style")), switchStyleGroup, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Time_Interval")), timeInterval, new UILabel(Toolkit.i18nText("Fine-Design_Chart_Time_Second"))}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Basic_Background")),colorSelectBox4carousel, null} }; return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); } private JPanel createTitleStylePane() { - final UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + final UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); styleAttrPane = new ChartTextAttrPane() { protected JPanel getContentPane(JPanel buttonPane) { double p = TableLayout.PREFERRED; @@ -132,7 +133,7 @@ public class ChangeConfigPane extends BasicBeanPane { protected Component[][] getComponents(JPanel buttonPane) { return new Component[][]{ - new Component[]{text, fontNameComboBox}, + new Component[]{text, getFontNameComboBox()}, new Component[]{null, buttonPane} }; } @@ -143,7 +144,7 @@ public class ChangeConfigPane extends BasicBeanPane { private JPanel createButtonBackgroundColorPane(){ colorSelectBox4button = new ColorSelectBoxWithOutTransparent(WIDTH); - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background"), colorSelectBox4button, EDIT_AREA_WIDTH); + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Basic_Background"), colorSelectBox4button, EDIT_AREA_WIDTH); } private JPanel createButtonConfigPane() { @@ -160,8 +161,8 @@ public class ChangeConfigPane extends BasicBeanPane { } private void initButtonGroup() { - configStyleButton = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Button_Style"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Carousel_Style")}); + configStyleButton = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Button_Style"), + Toolkit.i18nText("Fine-Design_Chart_Carousel_Style")}); configStyleButton.setPreferredSize(new Dimension(WIDTH * 2, (int) configStyleButton.getPreferredSize().getHeight())); configStyleButton.addActionListener(new ActionListener() { @Override @@ -227,6 +228,6 @@ public class ChangeConfigPane extends BasicBeanPane { @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"); + return Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes"); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java index ad549c5afd..67e7fc72b4 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartDataPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.GisMapPlot; import com.fr.chart.chartattr.MapPlot; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.chart.report.GisMapDataPane; import com.fr.design.chart.report.MapDataPane; import com.fr.design.gui.frpane.AttributeChangeListener; @@ -10,6 +11,9 @@ import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.data.DataContentsPane; import com.fr.design.mainframe.chart.gui.data.NormalChartDataPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -18,12 +22,12 @@ public class ChartDataPane extends AbstractChartAttrPane { public static final int LABEL_WIDTH = 85; public static final int LABEL_HEIGHT = 20; - + protected DataContentsPane contentsPane; protected AttributeChangeListener listener; - + private boolean supportCellData = true; - + public ChartDataPane(AttributeChangeListener listener) { super(); this.listener = listener; @@ -55,7 +59,7 @@ public class ChartDataPane extends AbstractChartAttrPane { if(contentsPane != null) { this.remove(contentsPane); } - + this.setLayout(new BorderLayout(0, 0)); if (collection == null) { throw new IllegalArgumentException("ChartCollection can not be null!"); @@ -69,7 +73,7 @@ public class ChartDataPane extends AbstractChartAttrPane { }else { contentsPane = new NormalChartDataPane(listener, ChartDataPane.this); } - + if(contentsPane != null) { contentsPane.setSupportCellData(supportCellData); } @@ -88,7 +92,7 @@ public class ChartDataPane extends AbstractChartAttrPane { contentsPane.setSupportCellData(supportCellData); } } - + /** * 更新界面 数据内容 */ @@ -106,11 +110,23 @@ public class ChartDataPane extends AbstractChartAttrPane { * 保存 数据界面内容 */ public void update(ChartCollection collection) { - if(contentsPane != null) { + if (contentsPane != null) { contentsPane.update(collection); + updateBuryingPoint(collection); } } + protected void updateBuryingPoint(ChartCollection collection){ + VanChart vanchart = collection.getSelectedChartProvider(VanChart.class); + if (vanchart != null) { + VanChartPlot plot = vanchart.getPlot(); + if( !plot.isInCustom()) { + ChartInfoCollector.getInstance().updateChartConfig(vanchart, ConfigType.DATA, + vanchart.getBuryingPointDataConfig()); + } + } + } + /** * 刷新图表数据界面 * @param collection 图表收集器 diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java index 90f896c754..9b494a1a45 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java @@ -3,6 +3,7 @@ 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.chartx.config.info.constant.ConfigType; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicPane; import com.fr.design.mainframe.chart.AbstractChartAttrPane; @@ -11,11 +12,12 @@ import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.other.ChartConditionAttrPane; import com.fr.design.mainframe.chart.gui.other.ChartInteractivePane; import com.fr.design.mainframe.chart.gui.type.ChartTabPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; import java.util.ArrayList; import java.util.List; +import java.awt.BorderLayout; public class ChartOtherPane extends AbstractChartAttrPane { private static final long serialVersionUID = -5612046386597783406L; @@ -121,6 +123,8 @@ public class ChartOtherPane extends AbstractChartAttrPane { if (ChartOtherPane.this.isHaveCondition()) { conditionAttrPane.updateBean(chart); } + //特效埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.EFFECT, chart.getBuryingPointEffectConfig()); } /** 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 1fbb87c423..4d7673b3e7 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 @@ -503,6 +503,13 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (this.isSelected()) { indexList.get(0).setSelected(true); changeCollectionSelected(indexList.get(0).getButtonName()); + } else {//删除的tab非选中状态, 原为选中状态的tab保持选中不变 + for (ChartChangeButton button : indexList) { + if (button.isSelected()) { + changeCollectionSelected(button.getButtonName()); + break; + } + } } } 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 3740e3e121..6c7edc2d2f 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 @@ -294,13 +294,14 @@ public class ChartTypePane extends AbstractChartAttrPane{ * @param collection */ public void reLayoutEditPane(String lastPlotID, ChartCollection collection){ + if (editPane == null) { + return; + } ChartProvider chart = collection.getSelectedChartProvider(ChartProvider.class); String plotID = chart.getID(); boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - if (editPane != null && editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ + if (editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))) { editPane.reLayout(chart); - }else { - throw new IllegalArgumentException("editPane can not be null."); } } diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java index 1277ae4632..42cf782c35 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java @@ -8,16 +8,15 @@ 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 com.fr.van.chart.designer.AbstractVanChartScrollPane; import javax.swing.BorderFactory; import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.ArrayList; -import java.util.List; /** * 一般数据界面 @@ -133,6 +132,14 @@ public class NormalChartDataPane extends DataContentsPane { tableDataPane.checkBoxUse(); } + /** + * 钻取地图需要同时更新层级 + */ + public void populate(ChartCollection collection, int level) { + populate(collection); + tableDataPane.refreshLevel(level); + } + /** * 保存 数据界面内容 */ 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 7f22a03a6b..8863977740 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 @@ -75,6 +75,7 @@ public class TableDataPane extends FurtherBasicBeanPane{ } if(dataContentPane != null) { dataContentPane.onSelectTableData(dataWrap); + dataContentPane.setTableName(dataWrap.getTableDataName()); } } @@ -124,6 +125,11 @@ public class TableDataPane extends FurtherBasicBeanPane{ add(dataContentPane, BorderLayout.CENTER); } } + + public void refreshLevel(int level){ + dataContentPane.refreshLevel(level); + } + /** * 更新界面属性 */ diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java index df5d99fbdb..710b2a4218 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/AbstractTableDataContentPane.java @@ -6,16 +6,26 @@ import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; import javax.swing.JSeparator; +import java.util.List; import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -import java.util.List; public abstract class AbstractTableDataContentPane extends BasicBeanPane{ protected static final double COMPONENT_WIDTH = 124; private boolean isNeedSummaryCaculateMethod = true; + + public String tableName; + + public String getTableName() { + return tableName; + } + + public void setTableName(String tableName) { + this.tableName = tableName; + } public abstract void updateBean(ChartCollection ob); @@ -129,4 +139,8 @@ public abstract class AbstractTableDataContentPane extends BasicBeanPane { this.add(panel, BorderLayout.SOUTH); } + protected UIComboBox createComboBox() { + UIComboBox uiComboBox = new UIComboBox(); + UIComponentUtils.setPreferedWidth(uiComboBox, 100); + return uiComboBox; + } /** * 检查box 是否使用, hasUse, 表示上层已经使用, 否则, 则此界面都可使用 * @param hasUse 是否使用 diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java new file mode 100644 index 0000000000..b053a5eb9b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartColorAdjustPane.java @@ -0,0 +1,235 @@ +package com.fr.design.mainframe.chart.gui.style; + +import com.fr.base.BaseUtils; +import com.fr.base.background.ColorBackground; +import com.fr.design.chartx.component.button.ColorButton; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.VerticalFlowLayout; +import com.fr.design.style.AbstractSelectBox; +import com.fr.design.style.color.ColorSelectPane; + +import javax.swing.JPanel; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.util.ArrayList; +import java.util.List; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +/** + * 配色方案选择组合色之后,可以调整颜色的组件 + * + * @author Bjorn + * @version 10.0 + * Created by Bjorn on 2020-03-25 + */ +public class ChartColorAdjustPane extends JPanel implements UIObserver { + + public static final Color[] DEFAULT_COLORS = { + new Color(99, 178, 238), + new Color(118, 218, 145), + new Color(248, 203, 127), + new Color(248, 149, 136), + new Color(124, 214, 207), + new Color(145, 146, 171), + new Color(120, 152, 225), + new Color(239, 166, 102), + new Color(237, 221, 134), + new Color(153, 135, 206), + }; + + private static final int COUNT_OF_ROW = 8; + + private static final int MAX_BUTTON = 40; + + private List colorButtons = new ArrayList<>(); + + private List uiObserverListener; + + private ChangeListener changeListener; + + + public ChartColorAdjustPane() { + this(DEFAULT_COLORS); + } + + public ChartColorAdjustPane(Color[] colors) { + iniListener(); + createColorButton(colors); + createContentPane(); + } + + public void updateColor(Color[] colors) { + createColorButton(colors); + relayout(); + } + + public Color[] getColors() { + int size = colorButtons.size(); + Color[] colors = new Color[size]; + for (int i = 0; i < size; i++) { + colors[i] = colorButtons.get(i).getSelectObject(); + } + return colors; + } + + private void relayout() { + this.removeAll(); + createContentPane(); + this.validate(); + this.repaint(); + } + + private void createContentPane() { + VerticalFlowLayout layout = new VerticalFlowLayout(0, 0, 0); + layout.setAlignLeft(true); + this.setLayout(layout); + + for (int i = 0, size = colorButtons.size(); i < size; i += COUNT_OF_ROW) { + JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); + int count = i + COUNT_OF_ROW > colorButtons.size() ? colorButtons.size() : i + COUNT_OF_ROW; + for (int j = i; j < count; j++) { + colorButtons.get(j).setLastButton(false); + panel.add(colorButtons.get(j)); + } + if (i + COUNT_OF_ROW > colorButtons.size()) { + panel.add(new AddColorButton()); + this.add(panel); + } else if (i + COUNT_OF_ROW == colorButtons.size() && colorButtons.size() != MAX_BUTTON) { + this.add(panel); + this.add(new AddColorButton()); + } else { + this.add(panel); + } + } + if (colorButtons.size() == 1) { + colorButtons.get(0).setLastButton(true); + } + } + + private void createColorButton(Color[] colors) { + colorButtons.clear(); + int size = Math.min(colors.length, MAX_BUTTON); + for (int i = 0; i < size; i++) { + colorButtons.add(createColorButton(colors[i])); + } + } + + private ColorButton createColorButton(Color color) { + ColorButton colorButton = new ColorButton(color) { + @Override + protected void deleteButton() { + colorButtons.remove(this); + stateChanged(); + relayout(); + } + }; + + colorButton.addChangeListener(changeListener); + return colorButton; + } + + private void iniListener() { + uiObserverListener = new ArrayList<>(); + if (shouldResponseChangeListener()) { + this.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + for (UIObserverListener observerListener : uiObserverListener) { + observerListener.doChange(); + } + } + }); + } + } + + public void stateChanged() { + if (changeListener != null) { + changeListener.stateChanged(null); + } + } + + public void addChangeListener(ChangeListener changeListener) { + this.changeListener = changeListener; + } + + public void registerChangeListener(UIObserverListener listener) { + uiObserverListener.add(listener); + } + + public boolean shouldResponseChangeListener() { + return true; + } + + + private class AddColorButton extends AbstractSelectBox { + + BufferedImage image = BaseUtils.readImageWithCache("/com/fr/design/images/buttonicon/add.png"); + + public AddColorButton() { + addMouseListener(getMouseListener()); + } + + @Override + public void paint(Graphics g) { + this.setSize(ColorButton.WIDTH, ColorButton.WIDTH); + Graphics2D g2d = (Graphics2D) g; + g2d.setPaint(Color.WHITE); + Rectangle2D rec = new Rectangle2D.Double(0, 0, ColorButton.WIDTH + 1, ColorButton.WIDTH + 1); + g2d.fill(rec); + g2d.drawImage(image, 0, 0, ColorButton.WIDTH + 1, ColorButton.WIDTH + 1, null); + } + + public Dimension getPreferredSize() { + return new Dimension(ColorButton.WIDTH, ColorButton.WIDTH); + } + + protected MouseListener getMouseListener() { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + showPopupMenu(); + } + }; + } + + public JPanel initWindowPane(double preferredWidth) { + // 下拉的时候重新生成面板,刷新最近使用颜色 + ColorSelectPane colorPane = new ColorSelectPane(false) { + public void setVisible(boolean b) { + super.setVisible(b); + } + }; + colorPane.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + hidePopupMenu(); + Color color = ((ColorSelectPane) e.getSource()).getColor(); + fireDisplayComponent(ColorBackground.getInstance(color)); + if(colorButtons.size() < MAX_BUTTON) { + colorButtons.add(createColorButton(color)); + } + ChartColorAdjustPane.this.stateChanged(); + relayout(); + } + }); + return colorPane; + } + + public Color getSelectObject() { + return null; + } + + public void setSelectObject(Color color) { + + } + } +} diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java index 820f0c3358..177168cd77 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoColorPane.java @@ -4,19 +4,17 @@ package com.fr.design.mainframe.chart.gui.style; -import com.fr.base.BaseUtils; -import com.fr.base.Utils; import com.fr.design.constants.LayoutConstants; -import com.fr.design.gui.ibutton.UIColorButton; -import com.fr.design.gui.ibutton.UIToggleButton; -import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.general.FRFont; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralUtils; -import javax.swing.*; -import java.awt.*; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; /** * Created by IntelliJ IDEA. @@ -25,34 +23,27 @@ import java.awt.*; * Date: 14-9-11 * Time: 上午11:27 */ -public class ChartTextAttrNoColorPane extends ChartTextAttrPane{ +public class ChartTextAttrNoColorPane extends ChartTextAttrPane { - public ChartTextAttrNoColorPane() { - super(); + public ChartTextAttrNoColorPane() { + super(); } protected void initComponents() { - fontColor = new UIColorButton(); - fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); - fontSizeComboBox = new UIComboBox(Font_Sizes); - bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); - italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); - double p = TableLayout.PREFERRED; double f = TableLayout.FILL; Component[] components1 = new Component[]{ - italic, bold + getItalic(), getBold() }; JPanel buttonPane = new JPanel(new BorderLayout()); - buttonPane.add(fontSizeComboBox, BorderLayout.CENTER); + buttonPane.add(getFontSizeComboBox(), BorderLayout.CENTER); buttonPane.add(GUICoreUtils.createFlowPane(components1, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST); - double[] columnSize = {f}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{fontNameComboBox}, + new Component[]{getFontNameComboBox()}, new Component[]{buttonPane} }; @@ -62,20 +53,9 @@ public class ChartTextAttrNoColorPane extends ChartTextAttrPane{ populate(FRFont.getInstance()); } - /** - * 更新字体 - * @return 字体 - */ public FRFont updateFRFont() { - int style = Font.PLAIN; - if (bold.isSelected() && !italic.isSelected()) { - style = Font.BOLD; - } else if (!bold.isSelected() && italic.isSelected()) { - style = Font.ITALIC; - } else if (bold.isSelected() && italic.isSelected()) { - style = 3; - } - return FRFont.getInstance(Utils.objectToString(fontNameComboBox.getSelectedItem()), style, - Float.valueOf(Utils.objectToString(fontSizeComboBox.getSelectedItem()))); + String name = GeneralUtils.objectToString(getFontNameComboBox().getSelectedItem()); + + return FRFont.getInstance(name, updateFontStyle(), updateFontSize()); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java index e1b17eb156..d04df2f72a 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrNoFontSizePane.java @@ -1,47 +1,36 @@ package com.fr.design.mainframe.chart.gui.style; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.FlowLayout; - -import javax.swing.JPanel; - -import com.fr.base.BaseUtils; -import com.fr.base.Utils; import com.fr.design.constants.LayoutConstants; -import com.fr.design.gui.ibutton.UIColorButton; -import com.fr.design.gui.ibutton.UIToggleButton; -import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.general.FRFont; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.general.FRFont; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.FlowLayout; /** * 字体格式设置, 无字体大小设置. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-1-21 下午03:35:47 */ public class ChartTextAttrNoFontSizePane extends ChartTextAttrPane { - - private static final long serialVersionUID = 4890526255627852602L; - public ChartTextAttrNoFontSizePane() { - super(); - } - - protected void initComponents() { - fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); - fontColor = new UIColorButton(); - fontSizeComboBox = new UIComboBox(Font_Sizes); - bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); - italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + private static final long serialVersionUID = 4890526255627852602L; + + public ChartTextAttrNoFontSizePane() { + super(); + } + protected void initComponents() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; Component[] components1 = new Component[]{ - fontColor, italic, bold + getFontColor(), getItalic(), getBold() }; JPanel buttonPane = new JPanel(new BorderLayout()); buttonPane.add(GUICoreUtils.createFlowPane(components1, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.CENTER); @@ -49,7 +38,7 @@ public class ChartTextAttrNoFontSizePane extends ChartTextAttrPane { double[] columnSize = {f}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{fontNameComboBox}, + new Component[]{getFontNameComboBox()}, new Component[]{buttonPane} }; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java index dea30d0c97..9a906cc7c0 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPane.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe.chart.gui.style; import com.fr.base.BaseUtils; +import com.fr.base.FRContext; import com.fr.base.Utils; import com.fr.chart.base.TextAttr; import com.fr.design.constants.LayoutConstants; @@ -10,10 +11,11 @@ import com.fr.design.gui.ibutton.UIColorButton; import com.fr.design.gui.ibutton.UIToggleButton; 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.utils.gui.GUICoreUtils; import com.fr.general.FRFont; - +import com.fr.general.GeneralUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; @@ -25,25 +27,52 @@ import java.awt.Font; public class ChartTextAttrPane extends BasicPane { private static final long serialVersionUID = 6731679928019436869L; - private static final int FONT_START = 6; - private static final int FONT_END = 72; - protected UIComboBox fontNameComboBox; - protected UIComboBox fontSizeComboBox; - protected UIToggleButton bold; - protected UIToggleButton italic; - protected UIColorButton fontColor; - public static Integer[] Font_Sizes = new Integer[FONT_END-FONT_START+1]; - static{ - for(int i = FONT_START; i <= FONT_END; i++){ - Font_Sizes [i - FONT_START] = new Integer(i); + public static final int FONT_START = 6; + public static final int FONT_END = 72; + private UIComboBox fontNameComboBox; + private UIComboBox fontSizeComboBox; + private UIToggleButton bold; + private UIToggleButton italic; + private UIColorButton fontColor; + public static Integer[] FONT_SIZES = new Integer[FONT_END - FONT_START + 1]; + static { + for (int i = FONT_START; i <= FONT_END; i++) { + FONT_SIZES[i - FONT_START] = i; } } + public ChartTextAttrPane() { + initState(); initComponents(); } + public UIComboBox getFontNameComboBox() { + return fontNameComboBox; + } + + public UIComboBox getFontSizeComboBox() { + return fontSizeComboBox; + } + + public UIToggleButton getBold() { + return bold; + } + + public UIToggleButton getItalic() { + return italic; + } + + public UIColorButton getFontColor() { + return fontColor; + } + + public void setFontColor(UIColorButton fontColor) { + this.fontColor = fontColor; + } + /** * 标题 + * * @return 标题 */ public String title4PopupWindow() { @@ -84,9 +113,7 @@ public class ChartTextAttrPane extends BasicPane { fontNameComboBox.setSelectedItem(frFont.getFamily()); bold.setSelected(frFont.isBold()); italic.setSelected(frFont.isItalic()); - if(fontSizeComboBox != null) { - fontSizeComboBox.setSelectedItem(frFont.getSize()); - } + populateFontSize(frFont); if (fontColor != null) { fontColor.setColor(frFont.getForeground()); } @@ -96,6 +123,12 @@ public class ChartTextAttrPane extends BasicPane { registerAllComboBoxListener(listener); } + protected void populateFontSize(FRFont frFont) { + if (fontSizeComboBox != null) { + fontSizeComboBox.setSelectedItem(frFont.getSize()); + } + } + private void removeAllComboBoxListener() { fontNameComboBox.removeChangeListener(); fontSizeComboBox.removeChangeListener(); @@ -108,9 +141,16 @@ public class ChartTextAttrPane extends BasicPane { /** * 更新字 + * * @return 更新字 */ public FRFont updateFRFont() { + String name = GeneralUtils.objectToString(fontNameComboBox.getSelectedItem()); + + return FRFont.getInstance(name, updateFontStyle(), updateFontSize(), fontColor.getColor()); + } + + protected int updateFontStyle() { int style = Font.PLAIN; if (bold.isSelected() && !italic.isSelected()) { style = Font.BOLD; @@ -119,8 +159,12 @@ public class ChartTextAttrPane extends BasicPane { } else if (bold.isSelected() && italic.isSelected()) { style = 3; } - return FRFont.getInstance(Utils.objectToString(fontNameComboBox.getSelectedItem()), style, - Float.valueOf(Utils.objectToString(fontSizeComboBox.getSelectedItem())), fontColor.getColor()); + + return style; + } + + protected float updateFontSize() { + return Float.parseFloat(GeneralUtils.objectToString(fontSizeComboBox.getSelectedItem())); } public void setEnabled(boolean enabled) { @@ -131,13 +175,23 @@ public class ChartTextAttrPane extends BasicPane { this.italic.setEnabled(enabled); } - protected void initComponents() { + protected Object[] getFontSizeComboBoxModel() { + return FONT_SIZES; + } + + protected void initState() { fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); - fontSizeComboBox = new UIComboBox(Font_Sizes); - fontColor = new UIColorButton(); + fontSizeComboBox = new UIComboBox(getFontSizeComboBoxModel()); bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); + initFontColorState(); + } + protected void initFontColorState() { + setFontColor(new UIColorButton()); + } + + protected void initComponents() { Component[] components1 = new Component[]{ fontColor, italic, bold }; @@ -148,24 +202,24 @@ public class ChartTextAttrPane extends BasicPane { this.setLayout(new BorderLayout()); this.add(getContentPane(buttonPane), BorderLayout.CENTER); - populate(FRFont.getInstance()); + populate(FRContext.getDefaultValues().getFRFont()); } - protected JPanel getContentPane (JPanel buttonPane) { + protected JPanel getContentPane(JPanel buttonPane) { double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f,e}; + double[] columnSize = {f, e}; return TableLayout4VanChartHelper.createGapTableLayoutPane(getComponents(buttonPane), getRowSize(), columnSize); } - protected double[] getRowSize () { + protected double[] getRowSize() { double p = TableLayout.PREFERRED; return new double[]{p, p, p}; } protected Component[][] getComponents(JPanel buttonPane) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); return new Component[][]{ new Component[]{null, null}, new Component[]{text, fontNameComboBox}, diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java new file mode 100644 index 0000000000..292d83c9e7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java @@ -0,0 +1,69 @@ +package com.fr.design.mainframe.chart.gui.style; + +import com.fr.chart.base.ChartConstants; +import com.fr.design.gui.ibutton.UIColorButton; +import com.fr.design.gui.ibutton.UIColorButtonWithAuto; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.type.FontAutoType; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRFont; +import com.fr.general.GeneralUtils; + +public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane { + + private static final String AUTO = Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); + private FontAutoType type; + public static String[] FONT_SIZES_WITH_AUTO = new String[FONT_END - FONT_START + 2]; + + static { + FONT_SIZES_WITH_AUTO[0] = AUTO; + + for (int i = 1; i < FONT_SIZES_WITH_AUTO.length; i++) { + FONT_SIZES_WITH_AUTO[i] = FONT_START + i - 1 + ""; + } + } + + public ChartTextAttrPaneWithAuto(FontAutoType type) { + this.type = type; + initState(); + initComponents(); + } + + private boolean isFontSizeAuto() { + return type == FontAutoType.SIZE || type == FontAutoType.SIZE_AND_COLOR; + } + + private boolean isFontColorAuto() { + return type == FontAutoType.COLOR || type == FontAutoType.SIZE_AND_COLOR; + } + + protected void initFontColorState() { + setFontColor(isFontColorAuto() ? new UIColorButtonWithAuto() : new UIColorButton()); + } + + protected Object[] getFontSizeComboBoxModel() { + return isFontSizeAuto() ? FONT_SIZES_WITH_AUTO : FONT_SIZES; + } + + protected float updateFontSize() { + if (isFontSizeAuto() && ComparatorUtils.equals(getFontSizeComboBox().getSelectedItem(), AUTO)) { + return ChartConstants.AUTO_FONT_SIZE; + } + + return Float.parseFloat(GeneralUtils.objectToString(getFontSizeComboBox().getSelectedItem())); + } + + protected void populateFontSize(FRFont frFont) { + if (getFontSizeComboBox() != null && isFontSizeAuto()) { + if (frFont.getSize() == ChartConstants.AUTO_FONT_SIZE) { + getFontSizeComboBox().setSelectedItem(AUTO); + } else { + getFontSizeComboBox().setSelectedItem(frFont.getSize() + ""); + } + } + + if (getFontSizeComboBox() != null && !isFontSizeAuto()) { + getFontSizeComboBox().setSelectedItem(frFont.getSize()); + } + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ChartSeriesPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ChartSeriesPane.java index 32fe831ff6..48ea41ec1d 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ChartSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ChartSeriesPane.java @@ -2,9 +2,11 @@ package com.fr.design.mainframe.chart.gui.style.series; import com.fr.chart.chartattr.Chart; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.van.chart.designer.AbstractVanChartScrollPane; import javax.swing.JPanel; @@ -60,6 +62,8 @@ public class ChartSeriesPane extends AbstractVanChartScrollPane { if(seriesStyleContentPane != null) { seriesStyleContentPane.setCurrentChart(chart); seriesStyleContentPane.updateBean(chart.getPlot()); + //系列埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.SERIES, chart.getPlot().getBuryingPointSeriesConfig()); } } 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 9880739265..a6c78de948 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 @@ -67,6 +67,15 @@ public class MapPlotPane extends AbstractDeprecatedChartTypePane { return new String[0]; } + public void reLayout(String chartID) { + + } + + @Override + public String getPlotID() { + return ChartConstants.MAP_CHART; + } + /** * 界面标题 * @return 界面标题 diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java index 66a103e657..34f917f153 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java @@ -7,11 +7,13 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.style.ChartAccColorPane; +import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane; import com.fr.design.style.background.gradient.FixedGradientBar; - import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -20,12 +22,11 @@ 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; /** * 预定义的图表配色界面. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-8-21 下午03:16:27 */ @@ -37,7 +38,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { private UIButton accButton; private UIButton gradientButton; - private ChartAccColorPane colorAcc; + private ChartColorAdjustPane colorAdjustPane; private FixedGradientBar colorGradient; public ChartPreFillStylePane() { @@ -53,13 +54,13 @@ public class ChartPreFillStylePane extends BasicBeanPane { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT)); - buttonPane.add(accButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Acc_Set"))); + buttonPane.add(accButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Color"))); buttonPane.add(gradientButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Gradient_Color"))); customPane.add(buttonPane, BorderLayout.NORTH); changeColorSetPane = new JPanel(cardLayout = new CardLayout()); changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); - changeColorSetPane.add(colorAcc = new ChartAccColorPane(), "acc"); + changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc"); cardLayout.show(changeColorSetPane, "acc"); customPane.add(changeColorSetPane, BorderLayout.CENTER); @@ -68,7 +69,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { customPane.setPreferredSize(new Dimension(200, 200)); colorGradient.setPreferredSize(new Dimension(120, 30)); colorGradient.getSelectColorPointBtnP1().setColorInner(Color.WHITE); - colorGradient.getSelectColorPointBtnP2().setColorInner(Color.black); + colorGradient.getSelectColorPointBtnP2().setColorInner(FixedGradientBar.NEW_CHARACTER); double p = TableLayout.PREFERRED; double[] columnSize = {p, p}; @@ -79,7 +80,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { }; this.setLayout(new BorderLayout()); - this.add(TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize), BorderLayout.WEST); + this.add(TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize), BorderLayout.WEST); } private void initListener() { @@ -130,8 +131,13 @@ public class ChartPreFillStylePane extends BasicBeanPane { gradientButton.setSelected(false); cardLayout.show(changeColorSetPane, "acc"); - if (colorList.size() > 0) { - colorAcc.populateBean(colorList.toArray(new Color[colorList.size()])); + if (colorList.isEmpty()) { + List resultList = new ArrayList<>(); + Collections.addAll(resultList, ChartColorAdjustPane.DEFAULT_COLORS); + condition.setColorList(resultList); + colorAdjustPane.updateColor(ChartColorAdjustPane.DEFAULT_COLORS); + } else { + colorAdjustPane.updateColor(colorList.toArray(new Color[colorList.size()])); } } } @@ -142,7 +148,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { List colorList = new ArrayList(); - if(gradientButton.isSelected()) { + if (gradientButton.isSelected()) { chartColorMatching.setGradient(true); Color start = colorGradient.getSelectColorPointBtnP1().getColorInner(); @@ -152,8 +158,8 @@ public class ChartPreFillStylePane extends BasicBeanPane { } else { chartColorMatching.setGradient(false); - Color[] colors = colorAcc.updateBean(); - for(Color color : colors) { + Color[] colors = colorAdjustPane.getColors(); + for (Color color : colors) { colorList.add(color); } } diff --git a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java index e0dbd8ba08..5d7a9e67d7 100644 --- a/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java +++ b/designer-chart/src/main/java/com/fr/design/module/ChartPreStyleAction.java @@ -1,6 +1,7 @@ package com.fr.design.module; import com.fr.base.ChartPreStyleConfig; +import com.fr.concurrent.NamedThreadFactory; import com.fr.design.actions.UpdateAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; @@ -8,11 +9,14 @@ import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.menu.MenuKeySet; import com.fr.general.IOUtils; +import com.fr.module.ModuleContext; import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; +import com.fr.van.chart.designer.component.VanChartFillStylePane; import javax.swing.KeyStroke; +import java.util.concurrent.ExecutorService; import java.awt.event.ActionEvent; /** @@ -22,6 +26,9 @@ import java.awt.event.ActionEvent; */ public class ChartPreStyleAction extends UpdateAction { + private static ExecutorService refreshDesignPool = ModuleContext.getExecutor().newFixedThreadPool( + 10, new NamedThreadFactory("refreshChartStylePane")); + public ChartPreStyleAction() { this.setMenuKeySet(CHART_DEFAULT_STYLE); this.setName(getMenuKeySet().getMenuKeySetName()+ "..."); @@ -54,6 +61,20 @@ public class ChartPreStyleAction extends UpdateAction { if (frame != null) { frame.repaint(); } + if (refreshDesignPool.isTerminated()) { + synchronized (refreshDesignPool) { + if (refreshDesignPool.isTerminated()) { + refreshDesignPool = ModuleContext.getExecutor().newFixedThreadPool( + 10, new NamedThreadFactory("refreshChartStylePane")); + } + } + } + refreshDesignPool.execute(new Runnable() { + @Override + public void run() { + DesignerContext.getDesignerBean(VanChartFillStylePane.name).refreshBeanElement(); + } + }); } })); } @@ -61,7 +82,7 @@ public class ChartPreStyleAction extends UpdateAction { pane.populateBean(); dialog.setVisible(true); - + } public static final MenuKeySet CHART_DEFAULT_STYLE = new MenuKeySet() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java index c0fd710680..33dba72f9b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java +++ b/designer-chart/src/main/java/com/fr/van/chart/DownloadOnlineSourcesHelper.java @@ -6,26 +6,32 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.extra.PluginConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.general.IOUtils; - import com.fr.general.CloudCenter; +import com.fr.general.IOUtils; import com.fr.general.http.HttpClient; import com.fr.plugin.chart.DownloadSourcesEvent; import com.fr.stable.CommonUtils; import com.fr.stable.StableUtils; import com.fr.workspace.WorkContext; -import javax.swing.*; -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; +import javax.swing.ImageIcon; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; import java.io.File; import java.io.FileOutputStream; import java.io.InputStream; import java.net.HttpURLConnection; import java.util.ArrayList; import java.util.List; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Rectangle; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; /** * Created by shine on 2017/8/21. @@ -51,13 +57,6 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { //总共字节数 private double totalBytes = 0; - - private static final double PHANTOM_MB = 96.1 * 1024 * 1024; - - public void addPhantomSiteInfo() { - this.addSiteInfo("plugin.phantomjs", ChartConstants.PHANTOMJS_URL, PHANTOM_MB); - } - private static final double MAP_JSON_MB = 4.5 * 1024 * 1024; public void addMapJSONSiteInfo() { @@ -219,7 +218,6 @@ public class DownloadOnlineSourcesHelper implements DownloadSourcesEvent { @Override public void downloadSources() { this.addMapJSONSiteInfo(); - this.addPhantomSiteInfo(); this.installOnline(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaConditionPane.java index c2de07ada9..f0ec07136a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaConditionPane.java @@ -20,7 +20,7 @@ import com.fr.van.chart.designer.other.condition.item.VanChartAreaFillColorCondi import com.fr.van.chart.designer.other.condition.item.VanChartDataSheetContentPane; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartLabelConditionPane; -import com.fr.van.chart.designer.other.condition.item.VanChartLineTypeConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartLineTypeConditionPaneWithoutDashed; import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTooltipConditionPane; @@ -50,7 +50,7 @@ public class VanChartAreaConditionPane extends DataSeriesConditionPane { classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); classPaneMap.put(VanChartAttrTrendLine.class, new VanChartTrendLineConditionPane(this)); classPaneMap.put(AttrAreaSeriesFillColorBackground.class, new VanChartAreaFillColorConditionPane(this, plot)); - classPaneMap.put(VanChartAttrLine.class, new VanChartLineTypeConditionPane(this)); + classPaneMap.put(VanChartAttrLine.class, new VanChartLineTypeConditionPaneWithoutDashed(this)); classPaneMap.put(AttrTooltip.class, new VanChartTooltipConditionPane(this, plot)); //是否使用数据表 if (plot.getDataSheet().isVisible()) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java index 45beccc7ef..a006ce54f3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java @@ -2,10 +2,16 @@ package com.fr.van.chart.area; import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; +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.ChartStylePane; import com.fr.van.chart.column.VanChartCustomStackAndAxisConditionPane; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.VanChartBeautyPane; +import com.fr.van.chart.designer.component.VanChartLineTypePane; +import com.fr.van.chart.designer.component.VanChartLineTypePaneWithoutDashed; +import com.fr.van.chart.designer.component.VanChartMarkerPane; import com.fr.van.chart.line.VanChartLineSeriesPane; import javax.swing.JPanel; @@ -27,7 +33,6 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { double[] col = {f}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createAreaFillColorPane()}, @@ -44,4 +49,18 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { protected Class getStackAndAxisPaneClass() { return VanChartCustomStackAndAxisConditionPane.class; } + + //风格 + protected VanChartBeautyPane createStylePane() { + return new VanChartBeautyPane(); + } + + protected VanChartLineTypePane getLineTypePane() { + return new VanChartLineTypePaneWithoutDashed(); + } + + protected JPanel createMarkerPane() { + markerPane = new VanChartMarkerPane(); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java index 44077c0ba7..0bb6ede075 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java @@ -37,14 +37,13 @@ public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { double[] col = {f}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createBubblePane()}, new Component[]{createStackedAndAxisPane()}, new Component[]{null} }; if (!((VanChartBubblePlot) plot).isForceBubble()) { - components[3] = new Component[]{createLargeDataModelPane()}; + components[2] = new Component[]{createLargeDataModelPane()}; } contentPane = TableLayoutHelper.createTableLayoutPane(components, row, col); diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java index 12c42408f1..fd870048cb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnSeriesPane.java @@ -53,7 +53,6 @@ public class VanChartColumnSeriesPane extends VanChartAbstractPlotSeriesPane { double[] columnSize = {f}; double[] rowSize = {p,p,p,p,p,p,p,p,p,p}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createSeriesStylePane(new double[]{p,p}, new double[]{f,e})}, new Component[]{createBorderPane()}, new Component[]{createStackedAndAxisPane()}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java index c49a1e2114..6c5f714bf8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomDataPane.java @@ -62,6 +62,7 @@ public class VanChartCustomDataPane extends ChartDataPane { public void update(ChartCollection collection){ if(contentsTabPane != null) { contentsTabPane.updateBean(collection); + updateBuryingPoint(collection); } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java index 68949897b7..e8f6f3a0a7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotDataContentsTabPane.java @@ -14,7 +14,7 @@ import com.fr.van.chart.custom.component.VanChartDataPane; import javax.swing.JPanel; import java.util.ArrayList; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -118,7 +118,7 @@ public class VanChartCustomPlotDataContentsTabPane extends VanChartCustomPlotTab } try { - Map definitionMap = new HashMap(); + Map definitionMap = new LinkedHashMap(); //已经有的数据配置不允许重置 diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java index 5e6953746a..a4b43843e4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/VanChartCustomPlotPane.java @@ -29,6 +29,7 @@ import com.fr.van.chart.designer.type.AbstractVanChartTypePane; import javax.swing.JPanel; import javax.swing.JSeparator; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import java.awt.CardLayout; import java.awt.Component; @@ -192,7 +193,7 @@ public class VanChartCustomPlotPane extends AbstractVanChartTypePane { return; } - Map newDefinitionMap = new HashMap(); + Map newDefinitionMap = new LinkedHashMap(); VanChartCustomPlot customPlot = (VanChartCustomPlot) chart.getPlot(); for (int i = 0; i < customPlot.getCustomPlotList().size(); i++) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotAxisPane.java index 86a1a7b53e..46ee566a29 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartCustomPlotAxisPane.java @@ -7,6 +7,7 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.base.AttrSeriesStackAndAxis; import com.fr.plugin.chart.custom.VanChartCustomPlot; +import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.custom.CustomPlotDesignerPaneFactory; import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.axis.VanChartAxisPane; @@ -52,4 +53,8 @@ public class VanChartCustomPlotAxisPane extends VanChartAxisPane { } } } + + @Override + protected void updateBuryingPoint(VanChart chart) { + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java index 0eb6278e4d..35b6d63e70 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomAxisPane.java @@ -1,8 +1,10 @@ package com.fr.van.chart.custom.style; import com.fr.chart.chartattr.Chart; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -63,6 +65,8 @@ public class VanChartCustomAxisPane extends BasicScrollPane { } VanChartCustomPlot plot = (VanChartCustomPlot) chart.getPlot(); axisPane.updateBean(plot); + //坐标轴埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.AXIS, chart.getBuryingPointAxisConfig()); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomLabelPane.java index a666d992ed..3192299ea2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomLabelPane.java @@ -2,8 +2,10 @@ package com.fr.van.chart.custom.style; import com.fr.chart.chartattr.Chart; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -63,6 +65,8 @@ public class VanChartCustomLabelPane extends BasicScrollPane { } labelPane.updateBean((VanChartCustomPlot)chart.getPlot()); + //标签埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.LABEL, chart.getBuryingPointLabelConfig()); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java index 425258a5bf..80685b4b4d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java @@ -1,11 +1,12 @@ package com.fr.van.chart.custom.style; import com.fr.chart.chartattr.Chart; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane; import com.fr.design.mainframe.chart.gui.style.series.ChartSeriesPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.van.chart.designer.component.VanChartBeautyPane; @@ -24,7 +25,7 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane { private JPanel seriesPane; protected VanChartCustomPlotSeriesTabPane plotSeriesPane; - private ChartFillStylePane fillStylePane;//配色 + private VanChartFillStylePane fillStylePane;//配色 private VanChartBeautyPane stylePane;//风格 @@ -81,7 +82,7 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane { }; JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); - panel.setBorder(BorderFactory.createEmptyBorder(10,10,0,15)); + panel.setBorder(BorderFactory.createEmptyBorder(5,5,0,5)); return panel; } @@ -113,6 +114,8 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane { if (seriesPane != null){ plotSeriesPane.updateBean(plot); } + //系列埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.SERIES, chart.getBuryingPointSeriesConfig()); } /** diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomTooltipPane.java index d27b95f3bf..2e05b4f519 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomTooltipPane.java @@ -1,8 +1,9 @@ package com.fr.van.chart.custom.style; import com.fr.chart.chartattr.Chart; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.dialog.BasicScrollPane; - +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -63,7 +64,8 @@ public class VanChartCustomTooltipPane extends BasicScrollPane { } tooltipPane.updateBean((VanChartCustomPlot)chart.getPlot()); - + //提示埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.TOOLTIP, chart.getBuryingPointTooltipConfig()); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java index 0b3bc7571a..8502888bd3 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/LineTypeComboBox.java @@ -59,10 +59,10 @@ public class LineTypeComboBox extends UIComboBox { FontMetrics fm = GraphHelper.getFontMetrics(rfont); GraphHelper.drawString(g2d, Toolkit.i18nText("Fine-Design_Report_None"), 4, (d.height - fm.getHeight()) / 2 + fm.getAscent()); break; - case NORMAL: + case SOLID: GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2); break; - case DASH: + case DASHED: GraphHelper.drawLine(g2d, 4, d.height / 2, d.width - 8, d.height / 2, Constants.LINE_DASH); break; default: diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java index f6642bd710..db41e8a480 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java @@ -29,7 +29,7 @@ public class VanChartBeautyPane extends BasicBeanPane { double[] columnSize = {f, e}; double[] rowSize = {p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Style")), styleBox}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), styleBox}, } ; JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); this.setLayout(new BorderLayout()); @@ -37,17 +37,17 @@ public class VanChartBeautyPane extends BasicBeanPane { } protected String[] getNameArray(){ - return new String[]{Toolkit.i18nText("Fine-Design_Chart_Default_Name"), - Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade") + return new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), + Toolkit.i18nText("Fine-Design_Chart_Off") }; } @Override public void populateBean(Integer ob) { int finalIndex; switch (ob){ - case ChartConstants.STYLE_NONE: finalIndex = 0; break; - case ChartConstants.STYLE_SHADE: finalIndex = 1; break; - default: finalIndex = 0; + case ChartConstants.STYLE_NONE: finalIndex = 1; break; + case ChartConstants.STYLE_SHADE: finalIndex = 0; break; + default: finalIndex = 1; } styleBox.setSelectedIndex(finalIndex); } @@ -57,8 +57,8 @@ public class VanChartBeautyPane extends BasicBeanPane { int index = styleBox.getSelectedIndex(); int style; switch (index){ - case 0: style = ChartConstants.STYLE_NONE; break; - case 1: style = ChartConstants.STYLE_SHADE; break; + case 0: style = ChartConstants.STYLE_SHADE; break; + case 1: style = ChartConstants.STYLE_NONE; break; default: style = ChartConstants.STYLE_NONE; } return style; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java index e395f26e94..7173f9678f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartFillStylePane.java @@ -1,42 +1,268 @@ package com.fr.van.chart.designer.component; +import com.fr.base.ChartColorMatching; +import com.fr.base.ChartPreStyleConfig; +import com.fr.base.Utils; +import com.fr.chart.base.AttrFillStyle; +import com.fr.chart.base.ChartConstants; +import com.fr.chart.base.ChartUtils; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.chartx.component.combobox.ColorSchemeComboBox; +import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; -import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane; - +import com.fr.design.mainframe.DesignerBean; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.chart.gui.style.ChartColorAdjustPane; +import com.fr.design.style.background.gradient.FixedGradientBar; +import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.BorderFactory; import javax.swing.JPanel; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by mengao on 2017/8/17. */ -public class VanChartFillStylePane extends ChartFillStylePane { +public class VanChartFillStylePane extends BasicBeanPane implements DesignerBean { - @Override - protected JPanel getContentPane () { + public static final String name = "vanChartFillStyle"; + + protected ColorSchemeComboBox styleSelectBox; + protected JPanel customPane; + protected JPanel changeColorSetPane; + protected FixedGradientBar colorGradient; + + protected CardLayout cardLayout; + + protected ChartColorAdjustPane colorAdjustPane; + + private Color[] gradientColors; + private Color[] accColors; + + private boolean gradientSelect = false; + + public VanChartFillStylePane() { + this.setLayout(new BorderLayout()); + + styleSelectBox = new ColorSchemeComboBox(); + customPane = new JPanel(FRGUIPaneFactory.createBorderLayout()) { + @Override + public Dimension getPreferredSize() { + if (!gradientSelect) { + return colorAdjustPane.getPreferredSize(); + } + return colorGradient.getPreferredSize(); + } + }; + + changeColorSetPane = new JPanel(cardLayout = new CardLayout()); + changeColorSetPane.add(colorGradient = new FixedGradientBar(4, 130), "gradient"); + gradientColors = new Color[]{Color.WHITE, FixedGradientBar.NEW_CHARACTER}; + changeColorSetPane.add(colorAdjustPane = new ChartColorAdjustPane(), "acc"); + accColors = ChartColorAdjustPane.DEFAULT_COLORS; + cardLayout.show(changeColorSetPane, "acc"); + customPane.add(changeColorSetPane, BorderLayout.CENTER); + initListener(); + initLayout(); + DesignerContext.setDesignerBean(name, this); + + } + + private void initListener() { + colorAdjustPane.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + accColors = colorAdjustPane.getColors(); + if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.COMBINATION_COLOR) { + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); + } + VanChartFillStylePane.this.revalidate(); + } + }); + colorGradient.registerChangeListener(new UIObserverListener() { + @Override + public void doChange() { + gradientColors[0] = colorGradient.getSelectColorPointBtnP1().getColorInner(); + gradientColors[1] = colorGradient.getSelectColorPointBtnP2().getColorInner(); + if (styleSelectBox.getSelectType() != ColorSchemeComboBox.SelectType.GRADATION_COLOR) { + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); + } + } + }); + styleSelectBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + switch (styleSelectBox.getSelectType()) { + case COMBINATION_COLOR: + colorAdjustPane.updateColor(accColors); + cardLayout.show(changeColorSetPane, "acc"); + gradientSelect = false; + break; + case GRADATION_COLOR: + colorGradient.updateColor(gradientColors[0], gradientColors[1]); + cardLayout.show(changeColorSetPane, "gradient"); + gradientSelect = true; + break; + default: + ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); + if (selectColorInfo.isGradient()) { + colorGradient.updateColor(selectColorInfo.getColors().get(0), selectColorInfo.getColors().get(1)); + cardLayout.show(changeColorSetPane, "gradient"); + gradientSelect = true; + } else { + colorAdjustPane.updateColor(selectColorInfo.getColors().toArray(new Color[]{})); + cardLayout.show(changeColorSetPane, "acc"); + gradientSelect = false; + } + break; + } + VanChartFillStylePane.this.revalidate(); + } + }); + } + + protected void initLayout() { + this.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); + this.setLayout(new BorderLayout()); + this.add(getContentPane(), BorderLayout.CENTER); + } + + protected JPanel getContentPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; double[] columnSize = {f, e}; double[] rowSize = {p, p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color_Match")),styleSelectBox}, - new Component[]{null,customPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Match_Color_Scheme")), styleSelectBox}, + new Component[]{null, customPane}, }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); - panel.setBorder(BorderFactory.createEmptyBorder(5,5,0,0)); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); + panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); return panel; } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color"); + } + + @Override + public void populateBean(AttrFillStyle condition) { + String fillStyleName = condition == null ? "" : condition.getFillStyleName(); + if (StringUtils.isBlank(fillStyleName) || !styleSelectBox.getItems().contains(fillStyleName)) {//兼容处理 + if (condition == null || condition.getColorStyle() == ChartConstants.COLOR_DEFAULT) { + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.DEFAULT);//默认 + } else { + int colorStyle = condition.getColorStyle(); + if (colorStyle == ChartConstants.COLOR_GRADIENT) { + gradientColors[0] = condition.getColorIndex(0); + gradientColors[1] = condition.getColorIndex(1); + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.GRADATION_COLOR); + } else { + int colorSize = condition.getColorSize(); + accColors = new Color[colorSize]; + for (int i = 0; i < colorSize; i++) { + accColors[i] = condition.getColorIndex(i); + } + styleSelectBox.setSelectType(ColorSchemeComboBox.SelectType.COMBINATION_COLOR); + } + } + } else { + styleSelectBox.setSelectedItem(fillStyleName); + } + } + @Override - public Dimension getPreferredSize() { - if(styleSelectBox.getSelectedIndex() != styleSelectBox.getItemCount() - 1) { - return new Dimension(styleSelectBox.getPreferredSize().width, 30); + public AttrFillStyle updateBean() { + switch (styleSelectBox.getSelectType()) { + case COMBINATION_COLOR: + return updateCombinationColor(); + case GRADATION_COLOR: + return updateGradationColor(); + case DEFAULT: + return updateDefaultColor(); + default: + return updateNormalColor(); } - return super.getPreferredSize(); + } + + private AttrFillStyle updateCombinationColor() { + AttrFillStyle condition = new AttrFillStyle(); + condition.clearColors(); + condition.setColorStyle(ChartConstants.COLOR_ACC); + for (int i = 0, length = accColors.length; i < length; i++) { + condition.addFillColor(accColors[i]); + } + condition.setCustomFillStyle(true); + return condition; + } + + private AttrFillStyle updateGradationColor() { + AttrFillStyle condition = new AttrFillStyle(); + condition.clearColors(); + condition.setColorStyle(ChartConstants.COLOR_GRADIENT); + Color start = gradientColors[0]; + Color end = gradientColors[1]; + condition.addFillColor(start); + condition.addFillColor(end); + condition.setCustomFillStyle(true); + return condition; + } + + private AttrFillStyle updateDefaultColor() { + AttrFillStyle condition = new AttrFillStyle(); + condition.clearColors(); + condition.setColorStyle(ChartConstants.COLOR_DEFAULT); + return condition; + } + + private AttrFillStyle updateNormalColor() { + ChartPreStyleConfig manager = ChartPreStyleConfig.getInstance(); + Object preStyle = manager.getPreStyle(styleSelectBox.getSelectedItem()); + if (preStyle instanceof ChartColorMatching) { + AttrFillStyle def = ChartUtils.chartColorMatching2AttrFillStyle((ChartColorMatching) preStyle); + def.setFillStyleName(Utils.objectToString(styleSelectBox.getSelectedItem())); + return def; + } else { + return updateModifyColor(); + } + } + + private AttrFillStyle updateModifyColor() { + AttrFillStyle condition = new AttrFillStyle(); + condition.clearColors(); + ColorSchemeComboBox.ColorInfo selectColorInfo = styleSelectBox.getSelectColorInfo(); + boolean isGradient = selectColorInfo.isGradient(); + List colors = selectColorInfo.getColors(); + condition.setColorList(colors); + condition.setCustomFillStyle(true); + condition.setColorStyle(isGradient ? ChartConstants.COLOR_GRADIENT : ChartConstants.COLOR_ACC); + return condition; + } + + /** + * 刷新组件对象 + */ + public void refreshBeanElement() { + AttrFillStyle attrFillStyle = updateBean(); + + styleSelectBox.refresh(); + + populateBean(attrFillStyle); + GUICoreUtils.repaint(this); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java index f5adcf26d1..10c3308b3c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePane.java @@ -2,7 +2,6 @@ package com.fr.van.chart.designer.component; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.i18n.Toolkit; @@ -13,8 +12,6 @@ import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.type.LineStyle; import com.fr.plugin.chart.type.LineType; -import com.fr.stable.Constants; -import com.fr.stable.CoreConstants; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.JPanel; @@ -30,26 +27,28 @@ import java.util.Arrays; public class VanChartLineTypePane extends BasicPane { private static final long serialVersionUID = -6581862503009962973L; - //线型支持虚线 恢复用注释。下面1行删除。 - protected LineComboBox lineWidth;//线型 + + private static final double LINE_WIDTH_MIN_VALUE = 0.5; + private static final double LINE_WIDTH_DIERTA_VALUE = 0.5; + private static final double LINE_WIDTH_DEFAULT_VALUE = 2; private LineTypeComboBox lineTypeComboBox;//线型 private UISpinner lineWidthSpinner;//线宽 - protected UIButtonGroup lineStyle;//形态 + private UIButtonGroup lineStyle;//形态 private UIButtonGroup nullValueBreak;//空值断开 private JPanel lineWidthPane; private JPanel lineStylePane; public VanChartLineTypePane() { - //线型支持虚线 恢复用注释。下面1行删除。 - lineWidth = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); JPanel typeAndWidthPane = createTypeAndWidthPane(); - createLineStyle(); + lineStyle = createLineStyle(); - nullValueBreak = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")}); + nullValueBreak = new UIButtonGroup(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Open"), + Toolkit.i18nText("Fine-Design_Chart_Close")}); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -67,16 +66,15 @@ public class VanChartLineTypePane extends BasicPane { lineStylePane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); this.setLayout(new BorderLayout(0, 6)); - //线型支持虚线 恢复用注释。取消注释。 - //this.add(typeAndWidthPane, BorderLayout.NORTH); + this.add(typeAndWidthPane, BorderLayout.NORTH); this.add(lineStylePane, BorderLayout.CENTER); } private JPanel createTypeAndWidthPane() { - lineTypeComboBox = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + lineTypeComboBox = createLineType(); - lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); + lineWidthSpinner = new UISpinner(LINE_WIDTH_MIN_VALUE, Integer.MAX_VALUE, LINE_WIDTH_DIERTA_VALUE, LINE_WIDTH_DEFAULT_VALUE); lineTypeComboBox.addActionListener(new ActionListener() { @Override @@ -87,6 +85,7 @@ public class VanChartLineTypePane extends BasicPane { }); Component[][] lineTypeComps = new Component[][]{ + new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineTypeComboBox} }; Component[][] lineWidthComps = new Component[][]{ @@ -96,10 +95,10 @@ public class VanChartLineTypePane extends BasicPane { }; double p = TableLayout.PREFERRED, f = TableLayout.FILL, e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] row = {p}, col = {f, e}; + double[] col = {f, e}; - JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineTypeComps, row, col); - lineWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineWidthComps, row, col); + JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineTypeComps, new double[]{p, p}, col); + lineWidthPane = TableLayout4VanChartHelper.createGapTableLayoutPane(lineWidthComps, new double[]{p}, col); JPanel contentPane = new JPanel(new BorderLayout(0, 6)); @@ -109,20 +108,21 @@ public class VanChartLineTypePane extends BasicPane { return contentPane; } - protected void createLineStyle() { - String[] textArray = new String[]{Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), - Toolkit.i18nText("Fine-Design_Chart_StepLine"), Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; - lineStyle = new UIButtonGroup(textArray, LineStyle.values()); + protected LineTypeComboBox createLineType() { + return new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); + } + + protected UIButtonGroup createLineStyle() { + String[] textArray = new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), + Toolkit.i18nText("Fine-Design_Chart_StepLine"), + Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; + + return new UIButtonGroup<>(textArray, LineStyle.values()); } protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { return new Component[][]{ - //线型支持虚线 恢复用注释。下面5行删除。 - new Component[]{null, null}, - new Component[]{ - FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), - UIComponentUtils.wrapWithBorderLayoutPane(lineWidth) - }, lineStyleComponent, nullValueBreakComponent }; @@ -136,21 +136,15 @@ public class VanChartLineTypePane extends BasicPane { private void checkLineStyle() { if (lineStylePane != null && lineTypeComboBox != null) { - lineStylePane.setVisible(!ComparatorUtils.equals(lineTypeComboBox.getSelectedItem(),LineType.NONE)); + lineStylePane.setVisible(!ComparatorUtils.equals(lineTypeComboBox.getSelectedItem(), LineType.NONE)); } } public void checkLarge(boolean large) { - //线型支持虚线 恢复用注释。下面4行删除。 if (large) { - lineWidth.setSelectedLineStyle(Constants.LINE_NONE); + lineTypeComboBox.setSelectedItem(LineType.NONE); } - lineWidth.setEnabled(!large); - //线型支持虚线 恢复用注释。取消注释。 -// if (large) { -// lineTypeComboBox.setSelectedItem(LineType.NONE); -// } -// lineTypeComboBox.setEnabled(!large); + lineTypeComboBox.setEnabled(!large); lineStyle.setEnabled(!large); } @@ -162,11 +156,8 @@ public class VanChartLineTypePane extends BasicPane { if (line == null) { line = initVanChartAttrLine(); } - //线型支持虚线 恢复用注释。下面1行删除。 - lineWidth.setSelectedLineStyle(line.getLineWidth()); - //线型支持虚线 恢复用注释。取消注释。 -// lineTypeComboBox.setSelectedItem(line.getLineType()); -// lineWidthSpinner.setValue(line.getLineWidth()); + lineTypeComboBox.setSelectedItem(line.getLineType()); + lineWidthSpinner.setValue(line.getLineWidth()); lineStyle.setSelectedItem(line.getLineStyle()); nullValueBreak.setSelectedIndex(line.isNullValueBreak() ? 0 : 1); } @@ -177,11 +168,8 @@ public class VanChartLineTypePane extends BasicPane { public VanChartAttrLine update() { VanChartAttrLine line = new VanChartAttrLine(); - //线型支持虚线 恢复用注释。下面1行删除。 - line.setLineWidth(lineWidth.getSelectedLineStyle()); - //线型支持虚线 恢复用注释。取消注释。 -// line.setLineType((LineType) lineTypeComboBox.getSelectedItem()); -// line.setLineWidth(lineWidthSpinner.getValue()); + line.setLineType((LineType) lineTypeComboBox.getSelectedItem()); + line.setLineWidth(lineWidthSpinner.getValue()); line.setLineStyle(lineStyle.getSelectedItem()); line.setNullValueBreak(nullValueBreak.getSelectedIndex() == 0); return line; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePaneWithoutDashed.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePaneWithoutDashed.java new file mode 100644 index 0000000000..55e75f88bc --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineTypePaneWithoutDashed.java @@ -0,0 +1,11 @@ +package com.fr.van.chart.designer.component; + +import com.fr.plugin.chart.type.LineType; + +public class VanChartLineTypePaneWithoutDashed extends VanChartLineTypePane{ + + @Override + protected LineTypeComboBox createLineType() { + return new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID}); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java index ed06b3d4db..46f461e69d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLineWidthPane.java @@ -1,22 +1,16 @@ package com.fr.van.chart.designer.component; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.Toolkit; - import java.awt.Component; /** * 线型+线宽+空值断开 */ -public class VanChartLineWidthPane extends VanChartLineTypePane { +public class VanChartLineWidthPane extends VanChartLineTypePaneWithoutDashed { private static final long serialVersionUID = 4537158946119294689L; @Override protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { return new Component[][]{ - //线型支持虚线 恢复用注释。下面2行删除。 - new Component[]{null, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, nullValueBreakComponent }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java index e2aff03f54..58d717af1b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java @@ -1,6 +1,7 @@ package com.fr.van.chart.designer.component; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.i18n.Toolkit; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.plugin.chart.base.VanChartAttrMarker; @@ -25,13 +26,13 @@ public class VanChartMarkerPane extends BasicPane { private CardLayout cardLayout; private VanChartCommonMarkerPane commonMarkerPane; - + private BasicBeanPane imageMarkerPane; public VanChartMarkerPane() { this.setLayout(new BorderLayout(0, 4)); - String[] array = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rule"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}; + String[] array = new String[]{Toolkit.i18nText("Fine-Design_Chart_Rule"), Toolkit.i18nText("Fine-Design_Chart_Custom")}; commonORCustom = new UIButtonGroup(array, array); commonORCustom.addChangeListener(new ChangeListener() { @@ -56,8 +57,8 @@ public class VanChartMarkerPane extends BasicPane { } } }; - centerPane.add(commonMarkerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rule")); - centerPane.add(imageMarkerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); + centerPane.add(commonMarkerPane, Toolkit.i18nText("Fine-Design_Chart_Rule")); + centerPane.add(imageMarkerPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); layoutComponents(); } @@ -75,8 +76,10 @@ public class VanChartMarkerPane extends BasicPane { } protected VanChartCommonMarkerPane createCommonMarkerPane() { + return new VanChartCommonMarkerPane(){ - protected double[] getcolumnSize () { + + protected double[] getColumnSize() { double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; return new double[] {d, s}; @@ -85,7 +88,7 @@ public class VanChartMarkerPane extends BasicPane { } protected void layoutComponents() { - this.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Point_Style"), commonORCustom), BorderLayout.NORTH); + this.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Point_Style"), commonORCustom), BorderLayout.NORTH); this.add(centerPane, BorderLayout.CENTER); } @@ -98,7 +101,7 @@ public class VanChartMarkerPane extends BasicPane { } protected String title4PopupWindow(){ - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Marker"); + return Toolkit.i18nText("Fine-Design_Chart_Marker"); } public void populate(VanChartAttrMarker marker) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java index de01ab612c..eb8bd0f16d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTrendLinePane.java @@ -4,7 +4,6 @@ import com.fr.chart.base.AttrColor; import com.fr.chart.base.AttrLineStyle; import com.fr.chart.base.LineStyleInfo; import com.fr.design.dialog.BasicPane; -import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; @@ -17,7 +16,6 @@ import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.TrendLineType; import com.fr.plugin.chart.base.VanChartAttrTrendLine; -import com.fr.plugin.chart.base.VanChartConstants; import com.fr.plugin.chart.type.LineType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -34,14 +32,15 @@ import java.awt.event.ActionListener; public class VanChartTrendLinePane extends BasicPane{ private static final TrendLineType[] TYPES = new TrendLineType[] {TrendLineType.EXP, TrendLineType.LINE, TrendLineType.LOG, TrendLineType.POLY}; + private static final int PREFERRED_WIDTH = 100; + private static final double LINE_WIDTH_MIN_VALUE = 0.5; + private static final double LINE_WIDTH_DIERTA_VALUE = 0.5; + private static final double LINE_WIDTH_DEFAULT_VALUE = 1; + private UITextField trendLineName; private ColorSelectBox trendLineColor; - - //线型支持虚线 恢复用注释。下面1行删除。 - private LineComboBox trendLineStyle;//线型 - //线型支持虚线 恢复用注释。取消注释。 -// private LineTypeComboBox trendLineStyle;//线型 -// private UISpinner lineWidthSpinner;//线宽 + private LineTypeComboBox trendLineStyle;//线型 + private UISpinner lineWidthSpinner;//线宽 private UIComboBox trendLineType;//趋势线函数类型 private UISpinner prePeriod; @@ -58,15 +57,11 @@ public class VanChartTrendLinePane extends BasicPane{ double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] row = {p, p, p, p, p, p}; double[] col = {f, e}; trendLineName = new UITextField(); - trendLineColor = new ColorSelectBox(100); - //线型支持虚线 恢复用注释。下面1行删除。 - trendLineStyle = new LineComboBox(VanChartConstants.ALERT_LINE_STYLE); - //线型支持虚线 恢复用注释。取消注释。 -// trendLineStyle = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); -// lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); + trendLineColor = new ColorSelectBox(PREFERRED_WIDTH); + trendLineStyle = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); + lineWidthSpinner = new UISpinner(LINE_WIDTH_MIN_VALUE, Integer.MAX_VALUE, LINE_WIDTH_DIERTA_VALUE, LINE_WIDTH_DEFAULT_VALUE); trendLineType = new UIComboBox(TYPES); prePeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0); afterPeriod = new UISpinner(0, Integer.MAX_VALUE, 1, 0); @@ -82,42 +77,26 @@ public class VanChartTrendLinePane extends BasicPane{ UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Period")); label.setVerticalAlignment(SwingConstants.TOP); - //线型支持虚线 恢复用注释。开始删除。 Component[][] components = new Component[][]{ new Component[]{null, null}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, new Component[]{ FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) - }, + } + }; + + Component[][] componentsMayHide = new Component[][]{ + new Component[]{ + FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), + UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, new Component[]{label, periodPane} }; - //线型支持虚线 恢复用注释。结束删除。 - - //线型支持虚线 恢复用注释。取消注释。 -// Component[][] components = new Component[][]{ -// new Component[]{null, null}, -// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Name")), trendLineName}, -// new Component[]{ -// FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), -// UIComponentUtils.wrapWithBorderLayoutPane(trendLineStyle) -// } -// }; -// -// Component[][] componentsMayHide = new Component[][]{ -// new Component[]{ -// FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), -// UIComponentUtils.wrapWithBorderLayoutPane(lineWidthSpinner)}, -// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), trendLineColor}, -// new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), trendLineType}, -// new Component[]{label, periodPane} -// }; -// trendLineHidePane = TableLayout4VanChartHelper.createGapTableLayoutPane(componentsMayHide, row, col); - - - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p,p,p}, col); + trendLineHidePane = TableLayout4VanChartHelper.createGapTableLayoutPane(componentsMayHide, new double[]{p,p,p,p}, col); trendLineStyle.addActionListener(new ActionListener() { @Override @@ -129,8 +108,7 @@ public class VanChartTrendLinePane extends BasicPane{ checkHidePaneVisible(); this.add(panel, BorderLayout.CENTER); - //线型支持虚线 恢复用注释。取消注释。 - //this.add(trendLineHidePane, BorderLayout.SOUTH); + this.add(trendLineHidePane, BorderLayout.SOUTH); } protected String title4PopupWindow(){ @@ -142,12 +120,14 @@ public class VanChartTrendLinePane extends BasicPane{ if(trendLine != null){ trendLineName.setText(trendLine.getTrendLineName()); LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo(); + AttrLineStyle attrLineStyle = lineStyleInfo.getAttrLineStyle(); + + if (attrLineStyle != null) { + trendLineStyle.setSelectedItem(attrLineStyle.getLineType()); + lineWidthSpinner.setValue(attrLineStyle.getLineWidth()); + } + trendLineColor.setSelectObject(lineStyleInfo.getAttrLineColor().getSeriesColor()); - //线型支持虚线 恢复用注释。下面1行删除。 - trendLineStyle.setSelectedLineStyle(lineStyleInfo.getAttrLineStyle().getLineStyle()); - //线型支持虚线 恢复用注释。取消注释。 -// trendLineStyle.setSelectedItem(lineStyleInfo.getAttrLineStyle().getLineType()); -// lineWidthSpinner.setValue(lineStyleInfo.getAttrLineStyle().getLineWidth()); trendLineType.setSelectedItem(trendLine.getTrendLineType()); prePeriod.setValue(trendLine.getPrePeriod()); afterPeriod.setValue(trendLine.getAfterPeriod()); @@ -159,11 +139,13 @@ public class VanChartTrendLinePane extends BasicPane{ trendLine.setTrendLineName(trendLineName.getText()); LineStyleInfo lineStyleInfo = trendLine.getLineStyleInfo(); - //线型支持虚线 恢复用注释。下面1行删除。 - lineStyleInfo.setAttrLineStyle(new AttrLineStyle(trendLineStyle.getSelectedLineStyle())); - //线型支持虚线 恢复用注释。取消注释。 -// lineStyleInfo.getAttrLineStyle().setLineWidth(lineWidthSpinner.getValue()); -// lineStyleInfo.getAttrLineStyle().setLineType((LineType) trendLineStyle.getSelectedItem()); + AttrLineStyle attrLineStyle = lineStyleInfo.getAttrLineStyle(); + + if (attrLineStyle != null) { + attrLineStyle.setLineWidth(lineWidthSpinner.getValue()); + attrLineStyle.setLineType((LineType) trendLineStyle.getSelectedItem()); + } + lineStyleInfo.setAttrLineColor(new AttrColor(trendLineColor.getSelectObject())); trendLine.setTrendLineType((TrendLineType) trendLineType.getSelectedItem()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java index 7a03bd465f..444bebfaa1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java @@ -5,26 +5,33 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.xcombox.MarkerComboBox; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.marker.type.MarkerType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.background.VanChartMarkerBackgroundPane; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by Mitisky on 16/5/19. * 通用标记点,标记点类型/颜色/半径 */ public class VanChartCommonMarkerPane extends BasicBeanPane { - private MarkerComboBox markerPane; + private MarkerComboBox markerTypeComboBox; private VanChartMarkerBackgroundPane markerFillColor; private UISpinner radius; + private JPanel markerTypePane; + private JPanel markerConfigPane; + private static final MarkerType[] NORMAL_TYPES = { - MarkerType.MARKER_NULL, MarkerType.MARKER_CIRCLE, MarkerType.MARKER_SQUARE, MarkerType.MARKER_DIAMOND, @@ -34,114 +41,106 @@ public class VanChartCommonMarkerPane extends BasicBeanPane MarkerType.MARKER_DIAMOND_HOLLOW, MarkerType.MARKER_TRIANGLE_HOLLOW }; - private static Marker[] normalMarkers = null; - protected static Marker[] getNormalMarkers() { - if(normalMarkers == null){ - normalMarkers = new Marker[NORMAL_TYPES.length]; - int i = 0; - for(MarkerType markerType : NORMAL_TYPES){ - normalMarkers[i++] = Marker.createMarker(markerType); - } - } - return normalMarkers; - } - //没有无这个选项 - private static final MarkerType[] MAP_TYPES = { - MarkerType.MARKER_CIRCLE, - MarkerType.MARKER_SQUARE, - MarkerType.MARKER_DIAMOND, - MarkerType.MARKER_TRIANGLE, - MarkerType.MARKER_CIRCLE_HOLLOW, - MarkerType.MARKER_SQUARE_HOLLOW, - MarkerType.MARKER_DIAMOND_HOLLOW, - MarkerType.MARKER_TRIANGLE_HOLLOW - }; - private static Marker[] mapMarkers = null; - protected static Marker[] getMapScatterMarkers() { - if(mapMarkers == null){ - mapMarkers = new Marker[MAP_TYPES.length]; - int i = 0; - for(MarkerType markerType : MAP_TYPES){ - mapMarkers[i++] = Marker.createMarker(markerType); - } + protected Marker[] getNormalMarkersWithCustom(MarkerType[] types) { + MarkerType[] customTypes = types == null ? new MarkerType[0] : types; + Marker[] result = new Marker[customTypes.length + NORMAL_TYPES.length]; + + int i = 0; + + for (MarkerType markerType : customTypes) { + result[i++] = Marker.createMarker(markerType); } - return mapMarkers; - } - //甘特图的菱形是实心的,之前写的空心。 - //兼容:模板属性不做兼容。只是之前空心做界面兼容。前台展现实心空心一样的效果,所以不用做什么 - private static final MarkerType[] GANTT_TYPES = { - MarkerType.MARKER_TRIANGLE, - MarkerType.MARKER_DIAMOND, - MarkerType.MARKER_STAR - }; - private static Marker[] ganttMarkers = null; - protected static Marker[] getGanttMarkers() { - if(ganttMarkers == null){ - ganttMarkers = new Marker[GANTT_TYPES.length]; - int i = 0; - for(MarkerType markerType : GANTT_TYPES){ - ganttMarkers[i++] = Marker.createMarker(markerType); - } + for (MarkerType markerType : NORMAL_TYPES) { + result[i++] = Marker.createMarker(markerType); } - return ganttMarkers; + + return result; } + public MarkerComboBox getMarkerTypeComboBox() { + return markerTypeComboBox; + } - protected MarkerComboBox getMarkerPane(){ - return markerPane; + public UISpinner getRadius() { + return radius; } public VanChartCommonMarkerPane() { - markerPane = new MarkerComboBox(getMarkers()); - markerFillColor = new VanChartMarkerBackgroundPane(){ + markerTypeComboBox = new MarkerComboBox(getMarkers()); + markerFillColor = new VanChartMarkerBackgroundPane() { + protected JPanel initContentPanel() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double e = getColumnSize()[1]; + double[] columnSize = {f, e}; + double[] rowSize = {p, p, p}; + + return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize); + } + protected Component[][] getPaneComponents() { - return new Component[][]{ - new Component[]{typeComboBox, null}, - new Component[]{centerPane, null}, + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), typeComboBox}, + new Component[]{null, centerPane}, }; } }; radius = new UISpinner(0, 100, 0.5, 0); double p = TableLayout.PREFERRED; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - double[] row = {p, p, p}; - Component[][] components = getUseComponent(); + markerTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(getMarkerTypeComponent(), new double[]{p}, getColumnSize()); + markerConfigPane = TableLayout4VanChartHelper.createGapTableLayoutPane(getMarkerConfigComponent(), new double[]{p, p}, getColumnSize()); - JPanel jPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, getcolumnSize()); + markerTypeComboBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkMarkType(); + } + }); - this.add(jPanel); - } + JPanel contentPane = new JPanel(new BorderLayout(0, 6)); - protected double[] getcolumnSize () { - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - return new double[] {d, e}; - } + contentPane.add(markerTypePane, BorderLayout.CENTER); + contentPane.add(markerConfigPane, BorderLayout.SOUTH); - protected Marker[] getMarkers() { - return getNormalMarkers(); + this.add(contentPane); } - protected Component[][] getUseComponent() { - return new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), markerPane}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), markerFillColor}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius")), radius}, + protected Component[][] getMarkerTypeComponent() { + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Type")), markerTypeComboBox} }; } - protected Component[][] getUseComponentWithOutFillColor() { - return new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Type")), markerPane}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius")), radius}, + protected Component[][] getMarkerConfigComponent() { + return new Component[][]{ + new Component[]{markerFillColor, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Radius")), radius} }; } + private void checkMarkType() { + if (markerConfigPane != null && markerTypeComboBox != null) { + MarkerType type = MarkerType.parse(markerTypeComboBox.getSelectedMarkder().getMarkerType()); + + markerConfigPane.setVisible(type != MarkerType.MARKER_NULL); + } + } + + protected double[] getColumnSize() { + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; + return new double[]{d, e}; + } + + protected Marker[] getMarkers() { + return getNormalMarkersWithCustom(new MarkerType[]{MarkerType.MARKER_NULL}); + } /** * title应该是一个属性,不只是对话框的标题时用到,与其他组件结合时,也会用得到 @@ -158,22 +157,25 @@ public class VanChartCommonMarkerPane extends BasicBeanPane @Override public void populateBean(VanChartAttrMarker marker) { - if(marker == null){ + if (marker == null) { marker = new VanChartAttrMarker(); marker.setCommon(true); } - markerPane.setSelectedMarker(Marker.createMarker(populateMarkType(marker))); + markerTypeComboBox.setSelectedMarker(Marker.createMarker(populateMarkType(marker))); populateColor(marker); radius.setValue(marker.getRadius()); + + checkMarkType(); } protected void populateColor(VanChartAttrMarker marker) { markerFillColor.populate(marker.getColorBackground()); } - protected MarkerType populateMarkType(VanChartAttrMarker marker){ + protected MarkerType populateMarkType(VanChartAttrMarker marker) { return marker.getMarkerType(); } + /** * Update. */ @@ -184,14 +186,14 @@ public class VanChartCommonMarkerPane extends BasicBeanPane return marker; } - public void updateBean(VanChartAttrMarker marker){ + public void updateBean(VanChartAttrMarker marker) { marker.setCommon(true); updateColor(marker); marker.setRadius(radius.getValue()); - marker.setMarkerType(MarkerType.parse(markerPane.getSelectedMarkder().getMarkerType())); + marker.setMarkerType(MarkerType.parse(markerTypeComboBox.getSelectedMarkder().getMarkerType())); } - protected void updateColor(VanChartAttrMarker marker){ + protected void updateColor(VanChartAttrMarker marker) { marker.setColorBackground(markerFillColor.update()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java index f25cbe9923..f402418d7d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/VanChartInteractivePane.java @@ -14,6 +14,7 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; 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.plugin.chart.attr.axis.VanChartAxis; @@ -60,6 +61,7 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private UIComboBox largeDataMode; private UISpinner largeModeThresholdNumber; + protected UILabel chartAnimationLabel; protected UIButtonGroup isChartAnimation; //坐标轴翻转属性 @@ -371,7 +373,17 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { protected JPanel createAnimationPane() { isChartAnimation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation_Effects"), isChartAnimation); + chartAnimationLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Animation_Effects")); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + double[] columnSize = {f, e}; + double[] rowSize = {p,p}; + Component[][] components = new Component[][]{ + new Component[]{null,null}, + new Component[]{chartAnimationLabel,isChartAnimation} + }; + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Animation"), panel); } @@ -499,7 +511,9 @@ public class VanChartInteractivePane extends AbstractVanChartScrollPane { private void populateChartAnimate(Chart chart, Plot plot) { if (plot.isSupportAnimate()) { isChartAnimation.setSelectedIndex(chart.isJSDraw() ? 0 : 1); - isChartAnimation.setEnabled(!largeModel(plot)); + boolean largeModel = largeModel(plot); + isChartAnimation.setEnabled(!largeModel); + chartAnimationLabel.setEnabled(!largeModel); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineTypeConditionPaneWithoutDashed.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineTypeConditionPaneWithoutDashed.java new file mode 100644 index 0000000000..f9ec11dbc7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartLineTypeConditionPaneWithoutDashed.java @@ -0,0 +1,16 @@ +package com.fr.van.chart.designer.other.condition.item; + +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.van.chart.designer.component.VanChartLineTypePane; +import com.fr.van.chart.designer.component.VanChartLineTypePaneWithoutDashed; + +public class VanChartLineTypeConditionPaneWithoutDashed extends VanChartLineTypeConditionPane { + + public VanChartLineTypeConditionPaneWithoutDashed(ConditionAttributesPane conditionAttributesPane) { + super(conditionAttributesPane); + } + + protected VanChartLineTypePane createLinePane() { + return new VanChartLineTypePaneWithoutDashed(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartTrendLineConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartTrendLineConditionPane.java index 328d7fcacb..bf81bdb373 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartTrendLineConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/other/condition/item/VanChartTrendLineConditionPane.java @@ -2,7 +2,7 @@ package com.fr.van.chart.designer.other.condition.item; import com.fr.chart.base.DataSeriesCondition; import com.fr.design.condition.ConditionAttributesPane; - +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.van.chart.designer.component.VanChartTrendLinePane; @@ -16,7 +16,7 @@ public class VanChartTrendLineConditionPane extends AbstractNormalMultiLineCondi @Override protected String getItemLabelString() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine"); + return Toolkit.i18nText("Fine-Design_Chart_TrendLine"); } @Override @@ -34,7 +34,7 @@ public class VanChartTrendLineConditionPane extends AbstractNormalMultiLineCondi * @return item的名称 */ public String nameForPopupMenuItem() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine"); + return Toolkit.i18nText("Fine-Design_Chart_TrendLine"); } @Override @@ -42,6 +42,10 @@ public class VanChartTrendLineConditionPane extends AbstractNormalMultiLineCondi return nameForPopupMenuItem(); } + public void setDefault() { + trendLinePane.populate(new VanChartAttrTrendLine()); + } + public void populate(DataSeriesCondition condition) { if (condition instanceof VanChartAttrTrendLine) { this.trendLinePane.populate((VanChartAttrTrendLine) condition); @@ -53,5 +57,4 @@ public class VanChartTrendLineConditionPane extends AbstractNormalMultiLineCondi } - } \ 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 db0d5c8641..60c535ceb9 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 @@ -3,6 +3,7 @@ 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.i18n.Toolkit; 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; @@ -38,8 +39,8 @@ public class HeatMapRangeLegendPane extends VanChartRangeLegendPane { @Override protected UIButtonGroup createLegendTypeButton(){ return new UIButtonGroup(new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend_Section") + Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"), + Toolkit.i18nText("Fine-Design_Chart_Legend_Section") }, new LegendType[]{LegendType.GRADUAL, LegendType.SECTION}); } @@ -53,7 +54,7 @@ public class HeatMapRangeLegendPane extends VanChartRangeLegendPane { 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[]{new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), numberDragPane}, new Component[]{null, legendGradientBar} }; } @@ -64,7 +65,7 @@ public class HeatMapRangeLegendPane extends VanChartRangeLegendPane { @Override protected SectionLegendPane createSectionLegendPane() { - return new SectionLegendPane(this.parent) { + return new SectionLegendPane(this.getLegendPaneParent()) { @Override protected MapColorPickerPaneWithFormula createSectionIntervalConfigPane(AbstractAttrNoScrollPane parent) { return new SectionIntervalConfigPaneWithOutNum(parent); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartLegendPane.java index facef9208a..52bf9e92ba 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartLegendPane.java @@ -2,7 +2,9 @@ package com.fr.van.chart.designer.style; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.AbstractVanChartScrollPane; @@ -52,6 +54,9 @@ public class VanChartLegendPane extends AbstractVanChartScrollPane { } VanChartLegend legend = (VanChartLegend) plot.getLegend(); legendContent.updateBean(legend); + + //图例埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.LEGEND, chart.getBuryingPointLegendConfig()); } @Override @@ -68,6 +73,7 @@ public class VanChartLegendPane extends AbstractVanChartScrollPane { if (plot == null) { return; } + legendContent.setPlot(plot); VanChartLegend legend = (VanChartLegend) plot.getLegend(); if (legendContent != null) { legendContent.populateBean(legend); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java index f4e1127f24..7e597bd5d9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.designer.style; import com.fr.base.BaseUtils; import com.fr.base.Style; +import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.UIBubbleFloatPane; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -9,13 +10,16 @@ import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.icheckbox.UICheckBox; 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.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartLegend; +import com.fr.plugin.chart.type.LayoutType; import com.fr.stable.Constants; +import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartFloatPositionPane; import com.fr.van.chart.designer.component.background.VanChartBackgroundWithOutImagePane; @@ -44,32 +48,33 @@ public class VanChartPlotLegendPane extends BasicPane { private static final int HEIGHT = 100; private static final int GAP = 20; - protected UICheckBox isLegendVisible; + private Plot plot; - protected JPanel legendPane; + private UICheckBox isLegendVisible; + private JPanel legendPane; - protected ChartTextAttrPane textAttrPane; - protected VanChartBorderWithRadiusPane borderPane; - protected VanChartBackgroundWithOutImagePane backgroundPane; - protected UIButtonGroup location; - protected UIToggleButton customFloatPositionButton; - protected VanChartFloatPositionPane customFloatPositionPane; + private ChartTextAttrPane textAttrPane; + private VanChartBorderWithRadiusPane borderPane; + private VanChartBackgroundWithOutImagePane backgroundPane; + private UIButtonGroup location; + private UIToggleButton customFloatPositionButton; + private UIButtonGroup layoutButton; + private JPanel layoutPane; + private VanChartFloatPositionPane customFloatPositionPane; //区域显示策略 恢复用注释。下面4行删除。 - protected UIButtonGroup limitSize; - protected UISpinner maxProportion; - private UILabel limitSizeTitle; + private UIButtonGroup customSize; + private UISpinner maxProportion; private JPanel maxProportionPane; //区域显示策略 恢复用注释。取消注释。 //private LimitPane limitPane; //高亮显示的按钮 - protected UIButtonGroup highlightButton; - protected JPanel highlightPane; - - - protected VanChartStylePane parent; + private UILabel highlightLabel; + private UIButtonGroup highlightButton; + private JPanel highlightPane; + private VanChartStylePane parent; public VanChartPlotLegendPane() { initComponents(); @@ -80,8 +85,28 @@ public class VanChartPlotLegendPane extends BasicPane { initComponents(); } - protected void initComponents(){ - isLegendVisible = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend_Visible")); + public void setPlot(Plot plot) { + this.plot = plot; + } + + public JPanel getHighlightPane() { + return highlightPane; + } + + public VanChartStylePane getLegendPaneParent() { + return parent; + } + + public UIButtonGroup getLegendLocation() { + return location; + } + + public UIToggleButton getCustomFloatPositionButton() { + return customFloatPositionButton; + } + + private void initComponents() { + isLegendVisible = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Legend_Visible")); legendPane = createLegendPane(); double p = TableLayout.PREFERRED; @@ -100,7 +125,7 @@ public class VanChartPlotLegendPane extends BasicPane { addLegendListener(); } - protected void addLegendListener(){ + private void addLegendListener() { isLegendVisible.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { checkBoxUse(); @@ -121,9 +146,9 @@ public class VanChartPlotLegendPane extends BasicPane { Component[][] components = new Component[][]{ new Component[]{createTitlePositionPane(new double[]{p,p,p},columnSize),null}, new Component[]{createTitleStylePane(),null} , - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), createDisplayStrategy()),null} + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), createDisplayStrategy()),null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } @@ -146,18 +171,26 @@ public class VanChartPlotLegendPane extends BasicPane { Component[][] components = new Component[][]{ new Component[]{createTitlePositionPane(new double[]{p,p,p},columnSize),null}, new Component[]{createTitleStylePane(),null} , - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel),null}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } - protected JPanel createTitlePositionPane(double[] row, double[] col){ - String[] textArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Top"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Bottom"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Left"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Right"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Right_Top")}; + private JPanel createTitlePositionPane(double[] row, double[] col) { + String[] textArray = { + Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Top"), + Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Bottom"), + Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Left"), + Toolkit.i18nText("Fine-Design_Chart_Style_Alignment_Right"), + Toolkit.i18nText("Fine-Design_Chart_Right_Top") + }; + Integer[] valueArray = {Constants.TOP, Constants.BOTTOM, Constants.LEFT, Constants.RIGHT, Constants.RIGHT_TOP}; - Icon[] iconArray = {BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_top.png"), + + Icon[] iconArray = { + BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_top.png"), BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_bottom.png"), BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_left.png"), BaseUtils.readIcon("/com/fr/design/images/chart/ChartLegend/layout_right.png"), @@ -167,22 +200,45 @@ public class VanChartPlotLegendPane extends BasicPane { location = new UIButtonGroup(iconArray, valueArray); location.setAllToolTips(textArray); - customFloatPositionButton = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Float_Position")); + customFloatPositionButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Chart_Custom_Float_Position")); UIComponentUtils.setLineWrap(customFloatPositionButton); customFloatPositionButton.setEventBannded(true); Component[][] components = new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),location}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),location}, new Component[]{null,customFloatPositionButton} }; customFloatPositionPane = new VanChartFloatPositionPane(); + layoutPane = createLayoutPane(); initPositionListener(); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,row,col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel); + JPanel positionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + + JPanel panel = new JPanel(new BorderLayout()); + panel.add(positionPane, BorderLayout.NORTH); + panel.add(layoutPane, BorderLayout.CENTER); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Basic_Form_Layout"), panel); + } + + private JPanel createLayoutPane() { + layoutButton = new UIButtonGroup<>( + new String[]{Toolkit.i18nText("Fine-Design_Chart_Layout_Flow"), Toolkit.i18nText("Fine-Design_Chart_Layout_Aligned")}, + new LayoutType[]{LayoutType.FLOW, LayoutType.ALIGNED}); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Arrange")), layoutButton} + }; + + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{f, e}); } private void initPositionListener(){ @@ -191,6 +247,7 @@ public class VanChartPlotLegendPane extends BasicPane { @Override public void stateChanged(ChangeEvent e) { customFloatPositionButton.setSelected(false); + checkLayoutPaneVisible(); checkDisplayStrategyUse(); } }); @@ -200,6 +257,7 @@ public class VanChartPlotLegendPane extends BasicPane { public void mouseClicked(MouseEvent e) { if(!customFloatPositionButton.isSelected()){ customFloatPositionButton.setSelected(true); + checkLayoutPaneVisible(); checkDisplayStrategyUse(); } } @@ -228,26 +286,24 @@ public class VanChartPlotLegendPane extends BasicPane { }); } - protected JPanel createTitleStylePane(){ + private JPanel createTitleStylePane() { textAttrPane = new ChartTextAttrPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), textAttrPane); } - protected JPanel createDisplayStrategy(){ + private JPanel createDisplayStrategy() { //区域显示策略 恢复用注释。开始删除。 maxProportion = new UISpinner(0, 100, 1, 30); - limitSize = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Limit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Limit")}); - limitSizeTitle = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion")); + customSize = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Auto"), Toolkit.i18nText("Fine-Design_Chart_Custom")}); - - JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Size"), limitSize); - maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); + JPanel limitSizePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Area_Size"), customSize); + maxProportionPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Max_Proportion"), maxProportion, TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH); maxProportionPane.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); JPanel panel = new JPanel(new BorderLayout()); panel.add(limitSizePane, BorderLayout.NORTH); panel.add(maxProportionPane, BorderLayout.CENTER); - limitSize.addActionListener(new ActionListener() { + customSize.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { checkMaxProPortionUse(); @@ -262,8 +318,8 @@ public class VanChartPlotLegendPane extends BasicPane { } private JPanel createHighlightPane(){ - highlightButton = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); - + highlightButton = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + highlightLabel = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Highlight")); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; @@ -271,21 +327,36 @@ public class VanChartPlotLegendPane extends BasicPane { double[] rowSize = {p,p}; Component[][] components = new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Highlight")),highlightButton} + new Component[]{highlightLabel, highlightButton} }; return TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); } protected void checkAllUse() { checkBoxUse(); + checkLayoutPaneVisible(); checkDisplayStrategyUse(); this.repaint(); } + protected void checkLayoutPaneVisible() { + layoutPane.setVisible(isVisibleLayoutPane()); + } + + protected boolean isVisibleLayoutPane() { + if (customFloatPositionButton.isSelected()) { + return false; + } + + int locationIntValue = getLegendLocation().getSelectedItem(); + + return locationIntValue == Constants.TOP || locationIntValue == Constants.BOTTOM; + } + //检查显示策略界面是否可用 protected void checkDisplayStrategyUse() { //区域显示策略 恢复用注释。下面2行删除。 - limitSize.setEnabled(!customFloatPositionButton.isSelected()); + customSize.setEnabled(!customFloatPositionButton.isSelected()); checkMaxProPortionUse(); //区域显示策略 恢复用注释。取消注释。 // GUICoreUtils.setEnabled(limitPane, !customFloatPositionButton.isSelected()); @@ -295,8 +366,7 @@ public class VanChartPlotLegendPane extends BasicPane { //区域显示策略 恢复用注释。删除下面方法。 //检查最大显示占比是否可用 private void checkMaxProPortionUse() { - maxProportion.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); - maxProportionPane.setVisible(limitSize.getSelectedIndex() == 0 && limitSize.isEnabled()); + maxProportionPane.setVisible(customSize.getSelectedIndex() == 1 && customSize.isEnabled()); } protected void checkBoxUse() { @@ -327,8 +397,9 @@ public class VanChartPlotLegendPane extends BasicPane { legend.setPosition(-1); } legend.setFloating(customFloatPositionButton.isSelected()); + legend.setLayout(layoutButton.getSelectedItem()); //区域显示策略 恢复用注释。下面2行删除。 - legend.setLimitSize(limitSize.getSelectedIndex() == 0); + legend.setCustomSize(customSize.getSelectedIndex() == 1); legend.setMaxHeight(maxProportion.getValue()); //区域显示策略 恢复用注释。取消注释。 //legend.setLimitAttribute(limitPane.updateBean()); @@ -351,13 +422,17 @@ public class VanChartPlotLegendPane extends BasicPane { customFloatPositionButton.setSelected(legend.isFloating()); customFloatPositionPane.setFloatPosition_x(legend.getFloatPercentX()); customFloatPositionPane.setFloatPosition_y(legend.getFloatPercentY()); + layoutButton.setSelectedItem(legend.getLayout()); //区域显示策略 恢复用注释。下面2行删除。 - limitSize.setSelectedIndex(legend.isLimitSize() ? 0 : 1); + customSize.setSelectedIndex(legend.isCustomSize() ? 1 : 0); maxProportion.setValue(legend.getMaxHeight()); //区域显示策略 恢复用注释。取消注释。 //limitPane.populateBean(legend.getLimitAttribute()); if(highlightButton != null){ highlightButton.setSelectedItem(legend.isHighlight()); + boolean largeDataModel = PlotFactory.largeDataModel(plot); + highlightButton.setEnabled(!largeDataModel); + highlightLabel.setEnabled(!largeDataModel); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java index 2e7ae32781..25ef2a15b2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java @@ -3,6 +3,7 @@ package com.fr.van.chart.designer.style; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.layout.TableLayout; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.attr.VanChartLegend; import com.fr.plugin.chart.range.VanChartRangeLegend; @@ -49,10 +50,10 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { ordinaryLegendPane = new JPanel(); //渐变色图例面板 gradualLegendPane = createGradualLegendPane(); - gradualLegendPane.setParentPane(parent); + gradualLegendPane.setParentPane(this.getLegendPaneParent()); //区域段图例面板 sectionLegendPane = createSectionLegendPane(); - sectionLegendPane.setParentPane(parent); + sectionLegendPane.setParentPane(this.getLegendPaneParent()); JPanel panel = new JPanel(new CardLayout()){ @Override @@ -79,7 +80,7 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { } protected SectionLegendPane createSectionLegendPane() { - return new SectionLegendPane(this.parent); + return new SectionLegendPane(this.getLegendPaneParent()); } private JPanel createTableLayoutPaneWithTitle(String title, Component component) { @@ -88,9 +89,9 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { protected UIButtonGroup createLegendTypeButton(){ return new UIButtonGroup(new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend_Ordinary"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend_Section") + Toolkit.i18nText("Fine-Design_Chart_Legend_Ordinary"), + Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"), + Toolkit.i18nText("Fine-Design_Chart_Legend_Section") }, new LegendType[]{LegendType.ORDINARY, LegendType.GRADUAL, LegendType.SECTION}); } @@ -104,7 +105,7 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { initLegendTypeButtonListener(); - JPanel legendTypeButtonWithTilePane = createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Legend_Form"),legendTypeButton); + JPanel legendTypeButtonWithTilePane = createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Legend_Form"), legendTypeButton); legendTypeButtonWithTilePane.setBorder(BorderFactory.createEmptyBorder(0,5,0,0)); rangeLegendPane = createRangeLegendPane(); @@ -129,6 +130,7 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { @Override public void actionPerformed(ActionEvent e) { checkCardPane(); + checkLayoutPaneVisible(); } }); } @@ -138,33 +140,26 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { cardLayout.show(rangeLegendPane, legendTypeButton.getSelectedItem().getStringType()); } - @Override - protected void addLegendListener(){ - isLegendVisible.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - checkBoxUse(); - } - }); - } - @Override protected void checkAllUse() { checkBoxUse(); + checkLayoutPaneVisible(); checkDisplayStrategyUse(); checkCardPane(); this.repaint(); } - @Override - protected void checkBoxUse() { - isLegendVisible.setEnabled(true); - legendPane.setVisible(isLegendVisible.isSelected()); + protected boolean isVisibleLayoutPane() { + + return super.isVisibleLayoutPane() && legendTypeButton.getSelectedItem() != LegendType.GRADUAL; } private void checkHighlightVisible(){ - if(this.highlightPane != null){ + JPanel highlightPane = this.getHighlightPane(); + + if (highlightPane != null) { LegendType legendType = legendTypeButton.getSelectedItem(); - this.highlightPane.setVisible(legendType != LegendType.GRADUAL); + highlightPane.setVisible(legendType != LegendType.GRADUAL); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java index 6a7987bcdb..908a75d212 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java @@ -5,6 +5,7 @@ import com.fr.base.BaseUtils; import com.fr.base.Style; import com.fr.base.Utils; import com.fr.chart.base.TextAttr; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.frpane.UIBubbleFloatPane; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -16,6 +17,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.plugin.chart.attr.VanChartTitle; import com.fr.plugin.chart.vanchart.VanChart; @@ -362,6 +364,9 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane { title.setFloatPercentY(customFloatPositionPane.getFloatPosition_y()); textAttrPane.update(textAttr); backgroundPane.update(title); + + //标题埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.TITLE, chart.getBuryingPointTitleConfig()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java index 232143496e..5c71317f20 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartAxisPane.java @@ -3,8 +3,10 @@ package com.fr.van.chart.designer.style.axis; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.beans.BasicBeanPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; @@ -16,12 +18,12 @@ import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.designer.style.axis.component.VanChartAxisButtonPane; import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.CardLayout; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.awt.BorderLayout; +import java.awt.CardLayout; /** * 样式-坐标轴界面 @@ -237,6 +239,12 @@ public class VanChartAxisPane extends BasicBeanPane { updateBean(plot); + updateBuryingPoint(chart); + } + + protected void updateBuryingPoint(VanChart chart) { + //坐标轴埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.AXIS, chart.getBuryingPointAxisConfig()); } public void updateBean(Plot plot){ diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java index ac1a0a0f7f..b1f516e342 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeAxisPane.java @@ -24,6 +24,8 @@ public class VanChartGaugeAxisPane extends VanChartAxisPane { this.setLayout(new BorderLayout()); gaugeAxisPane = new VanChartAxisScrollPaneWithGauge(); this.add(gaugeAxisPane, BorderLayout.CENTER); + + gaugeAxisPane.setParentPane(parent); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java index e047830291..cdb6b04b4c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java @@ -2,14 +2,18 @@ package com.fr.van.chart.designer.style.axis.gauge; import com.fr.design.gui.ibutton.UIButtonGroup; 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.PaneTitleConstants; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; import com.fr.design.style.color.ColorSelectBox; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis; import com.fr.plugin.chart.gauge.VanChartGaugePlot; +import com.fr.plugin.chart.type.FontAutoType; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -77,13 +81,13 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { } protected JPanel createLabelPane(double[] row, double[] col){ - showLabel = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Show"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Hidden")}); + showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")}); labelTextAttrPane = getChartTextAttrPane(); labelPanel = new JPanel(new BorderLayout()); labelPanel.add(labelTextAttrPane); labelPanel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0)); JPanel panel = new JPanel(new BorderLayout(0, 6)); - panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel), BorderLayout.NORTH); + panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel), BorderLayout.NORTH); panel.add(labelPanel, BorderLayout.CENTER); showLabel.addActionListener(new ActionListener() { @Override @@ -96,11 +100,17 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { return jPanel; } + protected ChartTextAttrPane getChartTextAttrPane() { + if (isMulti(gaugeStyle)) { + return new ChartTextAttrPaneWithAuto(FontAutoType.SIZE_AND_COLOR); + } else { + return new ChartTextAttrPane(); + } + } + private JPanel createValueDefinition(){ switch (gaugeStyle){ case RING: - minMaxValuePane = new MinMaxValuePaneWithOutTick(); - break; case SLOT: minMaxValuePane = new MinMaxValuePaneWithOutTick(); break; @@ -108,18 +118,18 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane { minMaxValuePane = new VanChartMinMaxValuePane(); break; } - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), minMaxValuePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), minMaxValuePane); } private JPanel createTickColorPane(double[] row, double[] col){ mainTickColor = new ColorSelectBox(100); secTickColor = new ColorSelectBox(100); Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTickColor}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secTickColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Main_Graduation_Line")), mainTickColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Second_Graduation_Line")), secTickColor}, }; JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); - JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TickColor"), panel); + JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_TickColor"), panel); panel.setBorder(BorderFactory.createEmptyBorder(10,10,0,15)); return jPanel; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java index 27336baf0c..85aff83629 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAlertValuePane.java @@ -2,12 +2,15 @@ package com.fr.van.chart.designer.style.background; import com.fr.base.BaseFormula; import com.fr.base.Utils; +import com.fr.chart.base.AttrColor; +import com.fr.chart.base.AttrLineStyle; import com.fr.design.beans.BasicBeanPane; import com.fr.design.formula.TinyFormulaPane; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.icombobox.LineComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.i18n.Toolkit; import com.fr.design.gui.style.FRFontPane; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; @@ -18,9 +21,10 @@ import com.fr.general.FRFont; import com.fr.general.GeneralUtils; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.axis.VanChartAlertValue; -import com.fr.plugin.chart.base.VanChartConstants; +import com.fr.plugin.chart.type.LineType; import com.fr.stable.Constants; import com.fr.stable.StableUtils; +import com.fr.van.chart.designer.component.LineTypeComboBox; import javax.swing.BoxLayout; import javax.swing.JPanel; @@ -39,13 +43,16 @@ public class VanChartAlertValuePane extends BasicBeanPane { private static final int VALUE_WD = 100; private static final int TEXT_WD = 200; private static final long serialVersionUID = -1208941770684286439L; + + private static final int PREFERRED_WIDTH = 100; + private static final double LINE_WIDTH_MIN_VALUE = 0.5; + private static final double LINE_WIDTH_DIERTA_VALUE = 0.5; + private static final double LINE_WIDTH_DEFAULT_VALUE = 1; + private UIButtonGroup alertAxis; protected TinyFormulaPane alertValue; - //线型支持虚线 恢复用注释。下面1行删除。 - protected LineComboBox alertLineStyle; - //线型支持虚线 恢复用注释。取消注释。 -// protected LineTypeComboBox alertLineStyle;//线型 -// private UISpinner lineWidthSpinner;//线宽 + protected LineTypeComboBox alertLineStyle;//线型 + private UISpinner lineWidthSpinner;//线宽 protected ColorSelectBox alertLineColor; private UIButtonGroup alertTextPosition; @@ -56,23 +63,20 @@ public class VanChartAlertValuePane extends BasicBeanPane { private VanChartAlertValue chartAlertValue; - public VanChartAlertValuePane(){ + public VanChartAlertValuePane() { initComponents(); } - private void initComponents(){ + private void initComponents() { alertValue = new TinyFormulaPane(); //設置大小,防止文本過長導致界面“變形” alertValue.setPreferredSize(new Dimension(VALUE_WD, HT)); - //线型支持虚线 恢复用注释。下面1行删除。 - alertLineStyle = new LineComboBox(VanChartConstants.ALERT_LINE_STYLE); - //线型支持虚线 恢复用注释。取消注释。 -// alertLineStyle = new LineTypeComboBox(new LineType[]{LineType.NORMAL, LineType.DASH}); -// lineWidthSpinner = new UISpinner(0.5, Integer.MAX_VALUE, 0.5, 2); - alertLineColor = new ColorSelectBox(100); - alertTextPosition = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Top"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom")}); + alertLineStyle = new LineTypeComboBox(new LineType[]{LineType.SOLID, LineType.DASHED}); + lineWidthSpinner = new UISpinner(LINE_WIDTH_MIN_VALUE, Integer.MAX_VALUE, LINE_WIDTH_DIERTA_VALUE, LINE_WIDTH_DEFAULT_VALUE); + alertLineColor = new ColorSelectBox(PREFERRED_WIDTH); + alertTextPosition = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Axis_Top"), Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom")}); alertText = new TinyFormulaPane(); //設置大小,防止文本過長導致界面“變形” alertText.setPreferredSize(new Dimension(TEXT_WD, HT)); @@ -83,26 +87,25 @@ public class VanChartAlertValuePane extends BasicBeanPane { } - private void doLayoutPane(){ + private void doLayoutPane() { this.removeAll(); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); //警戒线设置 JPanel top = FRGUIPaneFactory.createBorderLayout_L_Pane(); this.add(top); - top.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Set") + ":", null)); + top.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Alert_Set") + ":", null)); top.add(createTopPane()); //提示文字 JPanel bottom = FRGUIPaneFactory.createBorderLayout_L_Pane(); this.add(bottom); - bottom.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Text") + ":", null)); + bottom.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_Alert_Text") + ":", null)); bottom.add(createBottomPane()); } - protected JPanel createTopPane() - { + protected JPanel createTopPane() { double p = TableLayout.PREFERRED; - double[] columnSize = {p,p}; - double[] rowSize = {p,p,p,p,p}; + double[] columnSize = {p, p}; + double[] rowSize = {p, p, p, p, p}; Component[][] components = getTopPaneComponents(); return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -110,26 +113,25 @@ public class VanChartAlertValuePane extends BasicBeanPane { protected Component[][] getTopPaneComponents() { return new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),alertAxis}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Value")),alertValue}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Style")),alertLineStyle}, - //线型支持虚线 恢复用注释。取消注释。 - //new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line_Width")), lineWidthSpinner}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),alertLineColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), alertAxis}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Use_Value")), alertValue}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), alertLineStyle}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), lineWidthSpinner}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), alertLineColor}, }; } - private JPanel createBottomPane(){ + private JPanel createBottomPane() { alertTextPosition.setSelectedIndex(0); double p = TableLayout.PREFERRED; - double[] columnSize = {p,p}; - double[] rowSize = {p,p,p,p,p}; + double[] columnSize = {p, p}; + double[] rowSize = {p, p, p, p, p}; Component[][] components = new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position")),alertTextPosition}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content")),alertText}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Font")),fontName}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_FRFont_Size")),fontSize}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),fontColor}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")), alertTextPosition}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Content")), alertText}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Form_Font")), fontName}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Form_FRFont_Size")), fontSize}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), fontColor}, }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); @@ -137,20 +139,20 @@ public class VanChartAlertValuePane extends BasicBeanPane { private void checkPositionPane() { boolean selectXAxis = VanChartAttrHelper.isXAxis(alertAxis.getSelectedItem().toString()); - if(selectXAxis){ - alertTextPosition = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Top"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom")}); + if (selectXAxis) { + alertTextPosition = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Axis_Top"), Toolkit.i18nText("Fine-Design_Chart_Axis_Bottom")}); } else { - alertTextPosition = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Left"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Right")}); + alertTextPosition = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Alert_Left"), Toolkit.i18nText("Fine-Design_Chart_Alert_Right")}); } doLayoutPane(); } - protected String title4PopupWindow(){ - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Alert_Line"); + protected String title4PopupWindow() { + return Toolkit.i18nText("Fine-Design_Chart_Alert_Line"); } - public void populateBean(VanChartAlertValue chartAlertValue){ - this.chartAlertValue =chartAlertValue; + public void populateBean(VanChartAlertValue chartAlertValue) { + this.chartAlertValue = chartAlertValue; alertAxis = new UIButtonGroup(chartAlertValue.getAxisNamesArray(), chartAlertValue.getAxisNamesArray()); alertAxis.setSelectedItem(chartAlertValue.getAxisName()); alertAxis.addChangeListener(new ChangeListener() { @@ -163,14 +165,20 @@ public class VanChartAlertValuePane extends BasicBeanPane { checkPositionPane(); alertValue.populateBean(Utils.objectToString(chartAlertValue.getAlertValueFormula())); - //线型支持虚线 恢复用注释。下面1行删除。 - alertLineStyle.setSelectedLineStyle(chartAlertValue.getLineStyle().getLineStyle()); - //线型支持虚线 恢复用注释。取消注释。 -// alertLineStyle.setSelectedItem(chartAlertValue.getLineStyle().getLineType()); -// lineWidthSpinner.setValue(chartAlertValue.getLineStyle().getLineWidth()); - alertLineColor.setSelectObject(chartAlertValue.getLineColor().getSeriesColor()); - - if(VanChartAttrHelper.isXAxis(chartAlertValue.getAxisName())){ + + AttrColor attrColor = chartAlertValue.getLineColor(); + AttrLineStyle attrLineStyle = chartAlertValue.getLineStyle(); + + if (attrColor != null) { + alertLineColor.setSelectObject(attrColor.getSeriesColor()); + } + + if (attrLineStyle != null) { + alertLineStyle.setSelectedItem(attrLineStyle.getLineType()); + lineWidthSpinner.setValue(attrLineStyle.getLineWidth()); + } + + if (VanChartAttrHelper.isXAxis(chartAlertValue.getAxisName())) { alertTextPosition.setSelectedIndex(chartAlertValue.getAlertPosition() == Constants.BOTTOM ? 1 : 0); } else { alertTextPosition.setSelectedIndex(chartAlertValue.getAlertPosition() == Constants.LEFT ? 0 : 1); @@ -186,16 +194,22 @@ public class VanChartAlertValuePane extends BasicBeanPane { fontColor.setSelectObject(chartAlertValue.getAlertFont().getForeground()); } - public VanChartAlertValue updateBean(){ + public VanChartAlertValue updateBean() { chartAlertValue.setAxisName(alertAxis.getSelectedItem().toString()); chartAlertValue.setAlertValueFormula(BaseFormula.createFormulaBuilder().build(alertValue.updateBean())); - chartAlertValue.getLineColor().setSeriesColor(alertLineColor.getSelectObject()); - //线型支持虚线 恢复用注释。下面1行删除。 - chartAlertValue.getLineStyle().setLineStyle(alertLineStyle.getSelectedLineStyle()); - //线型支持虚线 恢复用注释。取消注释。 -// chartAlertValue.getLineStyle().setLineType((LineType) alertLineStyle.getSelectedItem()); -// chartAlertValue.getLineStyle().setLineWidth(lineWidthSpinner.getValue()); + + AttrColor attrColor = chartAlertValue.getLineColor(); + AttrLineStyle attrLineStyle = chartAlertValue.getLineStyle(); + + if (attrColor != null) { + attrColor.setSeriesColor(alertLineColor.getSelectObject()); + } + + if (attrLineStyle != null) { + attrLineStyle.setLineType((LineType) alertLineStyle.getSelectedItem()); + attrLineStyle.setLineWidth(lineWidthSpinner.getValue()); + } String contentString = alertText.updateBean(); Object contentObj; @@ -210,7 +224,7 @@ public class VanChartAlertValuePane extends BasicBeanPane { int size = Utils.objectToNumber(fontSize.getSelectedItem(), true).intValue(); Color color = fontColor.getSelectObject(); chartAlertValue.setAlertFont(FRFont.getInstance(name, Font.PLAIN, size, color)); - if(VanChartAttrHelper.isXAxis(Utils.objectToString(alertAxis.getSelectedItem()))){ + if (VanChartAttrHelper.isXAxis(Utils.objectToString(alertAxis.getSelectedItem()))) { chartAlertValue.setAlertPosition(alertTextPosition.getSelectedIndex() == 0 ? Constants.TOP : Constants.BOTTOM); } else { chartAlertValue.setAlertPosition(alertTextPosition.getSelectedIndex() == 0 ? Constants.LEFT : Constants.RIGHT); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaPane.java index 2aca9e8866..dcc43e045e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAreaPane.java @@ -1,20 +1,22 @@ package com.fr.van.chart.designer.style.background; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ThirdTabPane; import com.fr.design.mainframe.chart.gui.style.legend.AutoSelectedPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.vanchart.VanChart; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.BorderFactory; import javax.swing.JPanel; -import java.awt.BorderLayout; -import java.awt.FlowLayout; import java.util.ArrayList; import java.util.List; +import java.awt.BorderLayout; +import java.awt.FlowLayout; /** * 属性表, 图表样式-背景界面. @@ -94,6 +96,8 @@ public class VanChartAreaPane extends ThirdTabPane implements AutoSele public void updateBean(VanChart chart) { areaPane.updateBean(chart); plotPane.updateBean(chart); + //背景埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.BACKGROUND, chart.getBuryingPointBackGroundConfig()); } /** diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java index 7e09e987ce..b781d0bb63 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/VanChartAxisAreaPane.java @@ -10,8 +10,11 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorSelectBox; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.VanChartAttrHelper; +import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; +import com.fr.plugin.chart.type.LineType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.LineTypeComboBox; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -20,7 +23,6 @@ import java.awt.CardLayout; import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Arrays; /** * 样式-背景-绘图区背景-坐标轴图表特有(间隔背景、网格线、警戒线) @@ -28,8 +30,7 @@ import java.util.Arrays; public class VanChartAxisAreaPane extends BasicBeanPane { private static final long serialVersionUID = -1880497996650835504L; - protected ColorSelectBox horizontalGridLine; - protected ColorSelectBox verticalGridLine; + private static final int PREFERRED_WIDTH = 100; protected AlertLineListControlPane alertLine; @@ -40,22 +41,22 @@ public class VanChartAxisAreaPane extends BasicBeanPane { private ColorSelectBox verticalColorBackground; protected BackgroundListControlPane customIntervalBackground; - //线型支持虚线 恢复用注释。取消注释。 -// private LineTypeComboBox horizonLineType;//横向线型 -// private LineTypeComboBox verticalLineType;//纵向线型 -// private JPanel horizontalColorPane; -// private JPanel verticalColorPane; + private LineTypeComboBox horizonLineType; + private LineTypeComboBox verticalLineType; + private ColorSelectBox horizontalColorBox; + private ColorSelectBox verticalColorBox; + private JPanel horizontalColorPane; + private JPanel verticalColorPane; public VanChartAxisAreaPane() { initComponents(); } - protected void initComponents() { - horizontalGridLine = new ColorSelectBox(100); - verticalGridLine = new ColorSelectBox(100); - //线型支持虚线 恢复用注释。取消注释。 -// horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); -// verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.NORMAL, LineType.DASH}); + private void initComponents() { + horizontalColorBox = new ColorSelectBox(PREFERRED_WIDTH); + verticalColorBox = new ColorSelectBox(PREFERRED_WIDTH); + horizonLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); + verticalLineType = new LineTypeComboBox(new LineType[]{LineType.NONE, LineType.SOLID, LineType.DASHED}); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -74,78 +75,66 @@ public class VanChartAxisAreaPane extends BasicBeanPane { this.add(panel, BorderLayout.CENTER); } - //线型支持虚线 恢复用注释。删除下面方法。 protected JPanel createGridLinePane() { - horizontalGridLine = new ColorSelectBox(100); - verticalGridLine = new ColorSelectBox(100); - Component[][] components = new Component[][]{ + initGridLineComponents(); + + JPanel panel = new JPanel(new BorderLayout(0, 4)); + + panel.add(createSingleGridLinePane(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), true), BorderLayout.NORTH); + panel.add(createSingleGridLinePane(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), false), BorderLayout.CENTER); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); + } + + protected void initGridLineComponents() { + Component[][] upComponent = new Component[][]{ new Component[]{null, null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal")), horizontalGridLine}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")), verticalGridLine}, + new Component[]{null, horizontalColorBox} }; - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] row = new double[components.length]; - Arrays.fill(row, p); - double[] col = {f, e}; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); + horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent); + + Component[][] downComponent = new Component[][]{ + new Component[]{null, null}, + new Component[]{null, verticalColorBox} + }; + verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent); + + horizonLineType.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (horizontalColorBox == null || horizonLineType == null) { + return; + } + horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); + } + }); + + verticalLineType.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (verticalColorBox == null || verticalLineType == null) { + return; + } + verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); + } + }); + + checkColorBoxVisible(); } - //线型支持虚线 恢复用注释。取消注释。 -// protected JPanel createGridLinePane() { -// -// Component[][] upComponent = new Component[][]{ -// new Component[]{null, null}, -// new Component[]{null, horizontalGridLine} -// }; -// horizontalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(upComponent); -// -// Component[][] downComponent = new Component[][]{ -// new Component[]{null,null}, -// new Component[]{null, verticalGridLine} -// }; -// verticalColorPane = TableLayout4VanChartHelper.createGapTableLayoutPane(downComponent); -// -// horizonLineType.addActionListener(new ActionListener() { -// @Override -// public void actionPerformed(ActionEvent e) { -// if (horizontalGridLine == null || horizonLineType == null){ -// return; -// } -// horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); -// } -// }); -// -// verticalLineType.addActionListener(new ActionListener() { -// @Override -// public void actionPerformed(ActionEvent e) { -// if (verticalGridLine == null || verticalLineType == null){ -// return; -// } -// verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); -// } -// }); -// -// checkColorBoxVisible(); -// -// JPanel horizonLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), horizonLineType); -// JPanel horizontal = new JPanel(new BorderLayout()); -// horizontal.add(horizonLineTypePane, BorderLayout.NORTH); -// horizontal.add(horizontalColorPane, BorderLayout.CENTER); -// -// JPanel verticalLineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), verticalLineType); -// JPanel vertical = new JPanel(new BorderLayout()); -// vertical.add(verticalLineTypePane, BorderLayout.NORTH); -// vertical.add(verticalColorPane, BorderLayout.CENTER); -// -// JPanel panel = new JPanel(new BorderLayout(0, 4)); -// panel.add(horizontal, BorderLayout.NORTH); -// panel.add(vertical, BorderLayout.CENTER); -// -// return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); -// } + protected JPanel createSingleGridLinePane(String title, boolean isHorizontal) { + LineTypeComboBox lineTypeComboBox = isHorizontal ? horizonLineType : verticalLineType; + JPanel colorSelectPane = isHorizontal ? horizontalColorPane : verticalColorPane; + + JPanel lineTypePane = TableLayout4VanChartHelper.createGapTableLayoutPane(title, lineTypeComboBox); + + JPanel singleGridLinePane = new JPanel(new BorderLayout()); + + singleGridLinePane.add(lineTypePane, BorderLayout.NORTH); + singleGridLinePane.add(colorSelectPane, BorderLayout.CENTER); + + return singleGridLinePane; + } protected JPanel createAlertLinePane() { alertLine = getAlertLinePane(); @@ -227,13 +216,19 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } private void populateGridLine(VanChartRectanglePlot rectanglePlot) { - horizontalGridLine.setSelectObject(rectanglePlot.getDefaultYAxis().getMainGridColor()); - verticalGridLine.setSelectObject(rectanglePlot.getDefaultXAxis().getMainGridColor()); -//线型支持虚线 恢复用注释。取消注释。 -// horizonLineType.setSelectedItem(rectanglePlot.getDefaultYAxis().getGridLineType()); -// verticalLineType.setSelectedItem(rectanglePlot.getDefaultXAxis().getGridLineType()); - } + VanChartAxis defaultXAxis = rectanglePlot.getDefaultXAxis(); + VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); + + if (defaultXAxis != null) { + verticalColorBox.setSelectObject(defaultXAxis.getMainGridColor()); + verticalLineType.setSelectedItem(defaultXAxis.getGridLineType()); + } + if (defaultYAxis != null) { + horizontalColorBox.setSelectObject(defaultYAxis.getMainGridColor()); + horizonLineType.setSelectedItem(defaultYAxis.getGridLineType()); + } + } public void updateBean(Plot plot) { VanChartRectanglePlot rectanglePlot = (VanChartRectanglePlot) plot; @@ -254,11 +249,18 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } private void updateGirdLine(VanChartRectanglePlot rectanglePlot) { - rectanglePlot.getDefaultYAxis().setMainGridColor(horizontalGridLine.getSelectObject()); - rectanglePlot.getDefaultXAxis().setMainGridColor(verticalGridLine.getSelectObject()); - //线型支持虚线 恢复用注释。取消注释。 -// rectanglePlot.getDefaultYAxis().setGridLineType((LineType)horizonLineType.getSelectedItem()); -// rectanglePlot.getDefaultXAxis().setGridLineType((LineType)verticalLineType.getSelectedItem()); + VanChartAxis defaultXAxis = rectanglePlot.getDefaultXAxis(); + VanChartAxis defaultYAxis = rectanglePlot.getDefaultYAxis(); + + if (defaultXAxis != null) { + defaultXAxis.setMainGridColor(verticalColorBox.getSelectObject()); + defaultXAxis.setGridLineType((LineType) verticalLineType.getSelectedItem()); + } + + if (defaultYAxis != null) { + defaultYAxis.setMainGridColor(horizontalColorBox.getSelectObject()); + defaultYAxis.setGridLineType((LineType) horizonLineType.getSelectedItem()); + } } /** @@ -278,13 +280,12 @@ public class VanChartAxisAreaPane extends BasicBeanPane { } private void checkColorBoxVisible() { -//线型支持虚线 恢复用注释。取消注释。 -// if (horizontalColorPane != null && horizonLineType != null){ -// horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); -// } -// -// if (verticalColorPane != null && verticalLineType != null){ -// verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); -// } + if (horizontalColorPane != null && horizonLineType != null) { + horizontalColorPane.setVisible(horizonLineType.getSelectedItem() != LineType.NONE); + } + + if (verticalColorPane != null && verticalLineType != null) { + verticalColorPane.setVisible(verticalLineType.getSelectedItem() != LineType.NONE); + } } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java index 687516c357..790b6e93fa 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/background/radar/VanChartRadarAxisAreaPane.java @@ -3,15 +3,14 @@ package com.fr.van.chart.designer.style.background.radar; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.layout.TableLayout; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.background.AlertLineListControlPane; import com.fr.van.chart.designer.style.background.BackgroundListControlPane; import com.fr.van.chart.designer.style.background.VanChartAxisAreaPane; import javax.swing.JPanel; +import java.awt.BorderLayout; import java.awt.Component; -import java.util.Arrays; /** * 样式-背景-绘图区背景-雷达图只有Y轴的配置(间隔背景、网格线、警戒线) @@ -23,24 +22,18 @@ public class VanChartRadarAxisAreaPane extends VanChartAxisAreaPane { //雷达图只有横向的y轴的网格线配置 @Override protected JPanel createGridLinePane() { + initGridLineComponents(); + + JPanel panel = new JPanel(new BorderLayout(0, 4)); + + panel.add(createSingleGridLinePane(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), true), BorderLayout.CENTER); - Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),horizontalGridLine}, - }; - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] row = new double[components.length]; - Arrays.fill(row, p); - double[] col = {f, e}; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Grid_Line"), panel); } protected Component[][] getIntervalPaneComponents() { return new Component[][]{ - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color")),horizontalColorBackground}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), horizontalColorBackground}, }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java index 81451cbe7c..884a1e1c46 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/datasheet/VanChartDataSheetPane.java @@ -4,15 +4,16 @@ import com.fr.base.FRContext; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.DataSheet; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.style.FormatPane; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.PaneTitleConstants; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.general.ComparatorUtils; import com.fr.general.FRFont; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot; import com.fr.plugin.chart.base.VanChartConstants; @@ -135,6 +136,9 @@ public class VanChartDataSheetPane extends AbstractVanChartScrollPane { if(isShowDataSheet.isSelected()){ update(dataSheet); } + + //数据表埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.DATA_TABLE, chart.getBuryingPointDataTableConfig()); // plot.setDataSheet2PlotList(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java index 4199e8f7c3..64187f89b9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java @@ -1,11 +1,6 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.layout.TableLayout; -import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; - -import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.label.LabelContentPaneWithCate; @@ -13,39 +8,34 @@ import com.fr.van.chart.designer.component.label.LabelContentPaneWithPercent; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; -import javax.swing.SwingConstants; import java.awt.Component; /** * 仪表盘的分类(多指针时)或者百分比标签 */ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabelDetailPane { - //todo 重新整理这个面板 private static final long serialVersionUID = 5176535960949074945L; - private GaugeStyle gaugeStyle; - public VanChartGaugeCateOrPercentLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } protected double[] getLabelPaneRowSize(Plot plot, double p) { - return hasLabelPosition(plot) ? new double[]{p,p,p} : new double[]{p,p}; - } + if (hasLabelAlign(plot)) { + return new double[]{p, p, p, p}; + } - private void initGaugeStyle(Plot plot) { - if(gaugeStyle == null){ - gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle(); + if (hasLabelPosition(plot)) { + return new double[]{p, p, p}; } + + return new double[]{p, p}; } protected void initToolTipContentPane(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - dataLabelContentPane = new LabelContentPaneWithCate(parent, VanChartGaugeCateOrPercentLabelDetailPane.this); - break; case POINTER_SEMI: dataLabelContentPane = new LabelContentPaneWithCate(parent, VanChartGaugeCateOrPercentLabelDetailPane.this); break; @@ -55,13 +45,17 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe } } + protected boolean isFontSizeAuto() { + return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; + } + protected boolean isFontColorAuto() { + return getGaugeStyle() == GaugeStyle.RING || getGaugeStyle() == GaugeStyle.SLOT; + } protected boolean hasLabelPosition(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case RING: - return false; case SLOT: return false; default: @@ -70,67 +64,10 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe } protected double[] getLabelStyleRowSize(double p) { - switch (gaugeStyle){ - case RING: - return new double[] {p, p}; - case SLOT: - return new double[] {p, p}; - default: - return new double[] {p}; - } + return new double[]{p, p}; } protected JPanel createTableLayoutPaneWithTitle(String title, Component component) { return TableLayout4VanChartHelper.createTableLayoutPaneWithSmallTitle(title, component); } - - - protected Component[][] getLabelStyleComponents(Plot plot) { - initGaugeStyle(plot); - if (gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); - return new Component[][]{ - new Component[]{text,style}, - new Component[]{textFontPane,null}, - }; - } else { - return new Component[][]{ - new Component[]{textFontPane, null}, - }; - } - } - - protected ChartTextAttrPane initTextFontPane () { - //todo 需要再整理下 - if (gaugeStyle == GaugeStyle.RING || gaugeStyle == GaugeStyle.SLOT){ - return new ChartTextAttrPane(){ - protected double[] getRowSize () { - double p = TableLayout.PREFERRED; - return new double[]{p, p}; - } - - protected Component[][] getComponents(JPanel buttonPane) { - return new Component[][]{ - new Component[]{null, fontNameComboBox}, - new Component[]{null, buttonPane} - }; - } - }; - } else { - return new ChartTextAttrPane(){ - protected double[] getRowSize () { - double p = TableLayout.PREFERRED; - return new double[]{p, p}; - } - - protected Component[][] getComponents(JPanel buttonPane) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); - return new Component[][]{ - new Component[]{text, fontNameComboBox}, - new Component[]{null, buttonPane} - }; - } - }; - } - } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java index 3cf057df59..bbdb6acb3d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java @@ -1,28 +1,61 @@ package com.fr.van.chart.designer.style.label; +import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.Plot; +import com.fr.chartx.TwoTuple; import com.fr.design.gui.ibutton.UIButtonGroup; +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.style.ChartTextAttrPane; - +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.base.AttrLabelDetail; +import com.fr.plugin.chart.gauge.VanChartGaugePlot; +import com.fr.plugin.chart.type.FontAutoType; +import com.fr.plugin.chart.type.GaugeStyle; +import com.fr.stable.Constants; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dimension; /** * Created by mengao on 2017/8/13. */ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { + private static final int TEXT_FONT_PANE_HEIGHT = 50; + private GaugeStyle gaugeStyle; + private UIButtonGroup align; + private JPanel alignPane; + private Integer[] oldAlignValues; + public VanChartGaugeLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } + protected void initLabelDetailPane(Plot plot) { + setGaugeStyle(((VanChartGaugePlot) plot).getGaugeStyle()); + super.initLabelDetailPane(plot); + } + + public GaugeStyle getGaugeStyle() { + return ((VanChartGaugePlot)this.getPlot()).getGaugeStyle(); + } + + public void setGaugeStyle(GaugeStyle gaugeStyle) { + this.gaugeStyle = gaugeStyle; + } + protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) { - style = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); textFontPane = initTextFontPane(); initStyleListener(); @@ -30,16 +63,168 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return TableLayoutHelper.createTableLayoutPane(getLabelStyleComponents(plot), row, col); } + protected boolean isFontSizeAuto() { + return false; + } + + protected boolean isFontColorAuto() { + return false; + } - protected ChartTextAttrPane initTextFontPane () { - return new ChartTextAttrPane(); + private FontAutoType getFontAutoType() { + if (isFontSizeAuto() && isFontColorAuto()) { + return FontAutoType.SIZE_AND_COLOR; + } + if (isFontSizeAuto()) { + return FontAutoType.SIZE; + } + if (isFontColorAuto()) { + return FontAutoType.COLOR; + } + return FontAutoType.NONE; } - protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ - return TableLayoutHelper.createTableLayoutPane(comps,row,col); + protected ChartTextAttrPane initTextFontPane() { + return new ChartTextAttrPaneWithAuto(getFontAutoType()) { + protected double[] getRowSize() { + double p = TableLayout.PREFERRED; + return new double[]{p, p}; + } + + protected Component[][] getComponents(JPanel buttonPane) { + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + return new Component[][]{ + new Component[]{text, getFontNameComboBox()}, + new Component[]{null, buttonPane} + }; + } + }; + } + + protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) { + return TableLayoutHelper.createTableLayoutPane(comps, row, col); } protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { return TableLayout4VanChartHelper.createGapTableLayoutPane(title, panel); } + + protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { + if (hasLabelAlign(plot)) { + + return new Component[][]{ + new Component[]{dataLabelContentPane, null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical"), plot), null}, + new Component[]{createLabelAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")), null}, + new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null}, + }; + } else { + + return super.getLabelPaneComponents(plot, p, columnSize); + } + } + + private JPanel createLabelAlignPane(String title) { + JPanel panel = new JPanel(new BorderLayout()); + + alignPane = new JPanel(); + checkAlignPane(title); + panel.add(alignPane, BorderLayout.CENTER); + + return panel; + } + + protected void checkAlignPane(String title) { + if (alignPane == null && !hasLabelAlign(getPlot())) { + return; + } + if (alignPane != null && !hasLabelAlign(getPlot())) { + oldAlignValues = null; + alignPane.removeAll(); + return; + } + if (alignPane == null && hasLabelAlign(getPlot())) { + alignPane = new JPanel(); + } + TwoTuple result = getAlignNamesAndValues(); + + String[] names = result.getFirst(); + Integer[] values = result.getSecond(); + if (ComparatorUtils.equals(values, oldAlignValues)) { + return; + } + + oldAlignValues = values; + + align = new UIButtonGroup(names, values); + + Component[][] comps = new Component[2][2]; + + comps[0] = new Component[]{null, null}; + comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), align}; + + double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; + double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; + + alignPane.removeAll(); + alignPane.setLayout(new BorderLayout()); + alignPane.add(getLabelPositionPane(comps, row, col), BorderLayout.CENTER); + + if (parent != null) { + parent.initListener(alignPane); + } + } + + private TwoTuple getAlignNamesAndValues() { + String[] names = new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow"), Toolkit.i18nText("Fine-Design_Chart_Align_Left"), Toolkit.i18nText("Fine-Design_Chart_Align_Right")}; + Integer[] values = new Integer[]{ChartConstants.AUTO_LABEL_POSITION, Constants.LEFT, Constants.RIGHT}; + + return new TwoTuple<>(names, values); + } + + protected Component[][] getLabelStyleComponents(Plot plot) { + return new Component[][]{ + new Component[]{textFontPane, null}, + }; + } + + protected void checkPane() { + String verticalTitle = hasLabelAlign(getPlot()) + ? Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical") + : Toolkit.i18nText("Fine-Design_Chart_Layout_Position"); + + checkPositionPane(verticalTitle); + checkAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")); + } + + protected void checkStyleUse() { + textFontPane.setVisible(true); + textFontPane.setPreferredSize(new Dimension(0, TEXT_FONT_PANE_HEIGHT)); + } + + protected boolean hasLabelAlign(Plot plot) { + return getGaugeStyle() == GaugeStyle.THERMOMETER && !((VanChartGaugePlot) plot).getGaugeDetailStyle().isHorizontalLayout(); + } + + public void populate(AttrLabelDetail detail) { + super.populate(detail); + + style.setSelectedIndex(1); + if (hasLabelAlign(this.getPlot()) && align != null) { + align.setSelectedItem(detail.getAlign()); + } + } + + public void update(AttrLabelDetail detail) { + super.update(detail); + + detail.setCustom(true); + if (align != null) { + if (align.getSelectedItem() != null) { + detail.setAlign(align.getSelectedItem()); + } else { + align.setSelectedItem(detail.getAlign()); + } + } + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java index 42e6909e9f..0f81deefca 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java @@ -7,6 +7,7 @@ import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.design.i18n.Toolkit; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -28,16 +29,14 @@ public class VanChartGaugePlotLabelPane extends VanChartPlotLabelPane { labelDetailPane = new VanChartGaugeCateOrPercentLabelDetailPane(this.plot, this.parent); gaugeValueLabelPane = new VanChartGaugeValueLabelDetailPane(this.plot, this.parent); GaugeStyle gaugeStyle = ((VanChartGaugePlot)this.plot).getGaugeStyle(); - String cateTitle, valueTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Label"); + String cateTitle, valueTitle = Toolkit.i18nText("Fine-Design_Chart_Value_Label"); switch (gaugeStyle){ case POINTER: - cateTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Label"); - break; case POINTER_SEMI: - cateTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Label"); + cateTitle = Toolkit.i18nText("Fine-Design_Chart_Category_Label"); break; default: - cateTitle = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Percent_Label"); + cateTitle = Toolkit.i18nText("Fine-Design_Chart_Percent_Label"); break; } JPanel cateOrPercentPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(cateTitle, labelDetailPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java index 1d66925554..01a21d3823 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java @@ -1,7 +1,6 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; -import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.label.LabelContentPaneWithCateValue; @@ -17,24 +16,13 @@ import java.awt.Component; public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailPane { private static final long serialVersionUID = 2601073419430634281L; - private GaugeStyle gaugeStyle; - public VanChartGaugeValueLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); } - private void initGaugeStyle(Plot plot) { - if(gaugeStyle == null){ - gaugeStyle = ((VanChartGaugePlot)plot).getGaugeStyle(); - } - } - protected void initToolTipContentPane(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - dataLabelContentPane = new LabelContentPaneWithOutCate(parent, VanChartGaugeValueLabelDetailPane.this); - break; case POINTER_SEMI: dataLabelContentPane = new LabelContentPaneWithOutCate(parent, VanChartGaugeValueLabelDetailPane.this); break; @@ -45,10 +33,8 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP } protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - return getLabelPaneComponentsWithBackground(plot, p, columnSize); case POINTER_SEMI: return getLabelPaneComponentsWithBackground(plot, p, columnSize); default: @@ -57,43 +43,32 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP } private Component[][] getLabelPaneComponentsWithBackground(Plot plot, double p, double[] columnSize) { - return new Component[][]{ - new Component[]{dataLabelContentPane,null}, - new Component[]{createLabelStylePane(new double[]{p}, columnSize, plot),null}, - new Component[]{createBackgroundColorPane(),null}, + return new Component[][]{ + new Component[]{dataLabelContentPane, null}, + new Component[]{createLabelStylePane(new double[]{p}, columnSize, plot), null}, + new Component[]{createBackgroundColorPane(), null}, }; } protected double[] getLabelPaneRowSize(Plot plot, double p) { - initGaugeStyle(plot); - switch (gaugeStyle){ + switch (getGaugeStyle()) { case POINTER: - return new double[]{p,p,p,p,p}; case POINTER_SEMI: - return new double[]{p,p,p,p,p}; + return new double[]{p, p, p, p, p}; default: return super.getLabelPaneRowSize(plot, p); } } + protected boolean isFontSizeAuto() { + return getGaugeStyle() != GaugeStyle.THERMOMETER; + } + protected boolean hasLabelPosition(Plot plot) { - initGaugeStyle(plot); - switch (gaugeStyle){ - case THERMOMETER: - return true; - default: - return false; - } + return getGaugeStyle() == GaugeStyle.THERMOMETER; } protected JPanel createTableLayoutPaneWithTitle(String title, Component component) { return TableLayout4VanChartHelper.createTableLayoutPaneWithSmallTitle(title, component); } - - protected Component[][] getLabelStyleComponents(Plot plot) { - return new Component[][]{ - new Component[]{textFontPane,null}, - }; - } - } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java index 174f9cf93b..dfcd1a6443 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java @@ -4,7 +4,9 @@ import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrLabel; import com.fr.van.chart.designer.AbstractVanChartScrollPane; @@ -70,6 +72,8 @@ public class VanChartLabelPane extends AbstractVanChartScrollPane { if (attrLabel != null) { attrList.addDataSeriesCondition(attrLabel); } + //标签埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.LABEL, chart.getBuryingPointLabelConfig()); } @Override 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 b774de89ea..c506d89ea1 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 @@ -11,6 +11,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.style.color.ColorSelectBox; +import com.fr.design.i18n.Toolkit; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.attr.plot.VanChartLabelPositionPlot; @@ -58,13 +59,20 @@ public class VanChartPlotLabelDetailPane extends BasicPane { public VanChartPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { this.parent = parent; this.plot = plot; + initLabelDetailPane(plot); + } + protected void initLabelDetailPane (Plot plot) { this.setLayout(new BorderLayout()); initToolTipContentPane(plot); JPanel contentPane = createLabelPane(plot); this.add(contentPane,BorderLayout.CENTER); } + public Plot getPlot() { + return plot; + } + //默认从factory中取 protected void initToolTipContentPane(Plot plot) { dataLabelContentPane = PlotFactory.createPlotLabelContentPane(plot, parent, VanChartPlotLabelDetailPane.this); @@ -85,7 +93,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(hasLabelPosition(plot)){ return new Component[][]{ new Component[]{dataLabelContentPane,null}, - new Component[]{createLabelPositionPane(new double[]{p,p,p}, columnSize, plot),null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot),null}, }; } else { @@ -112,7 +120,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); } - private TwoTuple getPositionNamesAndValues() { + protected TwoTuple getPositionNamesAndValues() { if (plot instanceof VanChartLabelPositionPlot) { String[] names = ((VanChartLabelPositionPlot) plot).getLabelLocationNameArray(); @@ -130,33 +138,33 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return null; } - private JPanel createLabelPositionPane(double[] row, double[] col, Plot plot) { + protected JPanel createLabelPositionPane(String title, Plot plot) { if (getPositionNamesAndValues() == null) { return new JPanel(); } - autoAdjust = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + autoAdjust = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); JPanel panel = new JPanel(new BorderLayout()); positionPane = new JPanel(); - checkPositionPane(); + checkPositionPane(title); panel.add(positionPane, BorderLayout.CENTER); if (plot.isSupportLeadLine()) { - tractionLine = new UIToggleButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show_Guideline")); + tractionLine = new UIToggleButton(Toolkit.i18nText("Fine-Design_Chart_Show_Guideline")); tractionLinePane = TableLayout4VanChartHelper.createGapTableLayoutPane("", tractionLine); panel.add(tractionLinePane, BorderLayout.SOUTH); initPositionListener(); } else if (PlotFactory.plotAutoAdjustLabelPosition(plot)) { - panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"), autoAdjust), BorderLayout.SOUTH); + panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"), autoAdjust), BorderLayout.SOUTH); } return panel; } - private void checkPositionPane() { + protected void checkPositionPane(String title) { if (positionPane == null) { return; } @@ -176,7 +184,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { Component[][] comps = new Component[2][2]; comps[0] = new Component[]{null, null}; - comps[1] = new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), SwingConstants.LEFT), position}; + comps[1] = new Component[]{new UILabel(title, SwingConstants.LEFT), position}; double[] row = new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; double[] col = new double[]{TableLayout.FILL, TableLayout4VanChartHelper.EDIT_AREA_WIDTH}; @@ -193,7 +201,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_Form_Attr_Layout"), panel); + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); } @@ -207,14 +215,14 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) { - style = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom")}); textFontPane =initTextFontPane(); initStyleListener(); JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(getLabelStyleComponents(plot),row,col); - return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); } protected ChartTextAttrPane initTextFontPane () { @@ -222,7 +230,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected Component[][] getComponents(JPanel buttonPane) { return new Component[][]{ new Component[]{null, null}, - new Component[]{null, fontNameComboBox}, + new Component[]{null, getFontNameComboBox()}, new Component[]{null, buttonPane} }; } @@ -230,7 +238,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } protected Component[][] getLabelStyleComponents(Plot plot) { - UILabel text = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); + UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); return new Component[][]{ new Component[]{null,null}, new Component[]{text,style}, @@ -249,7 +257,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected JPanel createBackgroundColorPane() { backgroundColor = new ColorSelectBox(100); - return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundColor); + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundColor); } protected String title4PopupWindow() { @@ -264,7 +272,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { checkPositionEnabled(); } - private void checkStyleUse() { + protected void checkStyleUse() { textFontPane.setVisible(style.getSelectedIndex() == 1); textFontPane.setPreferredSize(style.getSelectedIndex() == 1 ? new Dimension(0, 60) : new Dimension(0, 0)); } @@ -277,9 +285,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { tractionLinePane.setVisible(position.getSelectedItem() == Constants.OUTSIDE); } - public void populate(AttrLabelDetail detail) { - checkPositionPane(); + protected void checkPane(){ + checkPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position")); + } + public void populate(AttrLabelDetail detail) { + checkPane(); dataLabelContentPane.populateBean(detail.getContent()); if(position != null){ position.setSelectedItem(detail.getPosition()); @@ -306,7 +317,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(position != null && position.getSelectedItem() != null){ detail.setPosition(position.getSelectedItem()); - + } else if(position != null){ position.setSelectedItem(detail.getPosition()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java index 3d8fef03f0..2bcdda7895 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java @@ -10,8 +10,8 @@ import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.design.mainframe.chart.gui.style.ChartFillStylePane; import com.fr.design.mainframe.chart.gui.style.series.AbstractPlotSeriesPane; import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.plot.VanChartPlot; @@ -23,7 +23,6 @@ import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.base.VanChartAttrTrendLine; import com.fr.van.chart.custom.style.VanChartCustomStylePane; -import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartAreaSeriesFillColorPane; import com.fr.van.chart.designer.component.VanChartBeautyPane; @@ -62,6 +61,8 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP private VanChartBorderPane borderPane;//边框 + protected VanChartFillStylePane vanChartFillStylePane;//配色 + private UINumberDragPane transparent;//不透明度 protected VanChartStackedAndAxisListControlPane stackAndAxisEditPane;//堆積和坐標軸 @@ -86,18 +87,18 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); } JPanel panel = new JPanel(new BorderLayout()); - if (fillStylePane != null) { - panel.add(fillStylePane, BorderLayout.NORTH); + JPanel colorPane = getColorPane(); + if(colorPane != null) { + panel.add(colorPane, BorderLayout.NORTH); } panel.add(getContentInPlotType(), BorderLayout.CENTER); return panel; } - @Override /** * 返回 填充界面. */ - protected ChartFillStylePane getFillStylePane() { + protected VanChartFillStylePane getVanChartFillStylePane() { //如果是自定義組合圖,則不創建填充界面 return parentPane instanceof VanChartCustomStylePane ? null : new VanChartFillStylePane(); } @@ -111,9 +112,13 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP protected JPanel getColorPane() { JPanel panel = new JPanel(new BorderLayout()); stylePane = createStylePane(); + vanChartFillStylePane = getVanChartFillStylePane(); + if (vanChartFillStylePane != null) { + panel.add(vanChartFillStylePane, BorderLayout.NORTH); + } setColorPaneContent(panel); - JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Color"), panel); - panel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); + JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel); + panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); return panel.getComponentCount() == 0 ? null : colorPane; } @@ -127,13 +132,13 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //趋势线 protected JPanel createTrendLinePane() { trendLinePane = new VanChartTrendLinePane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_TrendLine"), trendLinePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_TrendLine"), trendLinePane); } //线 protected JPanel createLineTypePane() { lineTypePane = getLineTypePane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Line"), lineTypePane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Line"), lineTypePane); } protected VanChartLineTypePane getLineTypePane() { @@ -143,26 +148,26 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //标记点类型 protected JPanel createMarkerPane() { markerPane = new VanChartMarkerPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); } //填充颜色 protected JPanel createAreaFillColorPane() { areaSeriesFillColorPane = new VanChartAreaSeriesFillColorPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area"), areaSeriesFillColorPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Area"), areaSeriesFillColorPane); } //边框(默认没有圆角) protected JPanel createBorderPane() { borderPane = createDiffBorderPane(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); } //半径界面 - protected JPanel createRadiusPane() { + protected JPanel createRadiusPane(String title) { radiusPane = initRadiusPane(); - radiusPaneWithTitle = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Radius_Set"), radiusPane); + radiusPaneWithTitle = TableLayout4VanChartHelper.createGapTableLayoutPane(title, radiusPane); return ((VanChartPlot) plot).isInCustom() ? null : radiusPaneWithTitle; } @@ -175,7 +180,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkLarge(); } }); - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Model"), largeDataModelGroup); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Large_Model"), largeDataModelGroup); return createLargeDataModelPane(panel); } @@ -197,12 +202,12 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP } protected JPanel createLargeDataModelPane(JPanel jPanel) { - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Large_Data"), jPanel); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Large_Data"), jPanel); return panel; } protected UIButtonGroup createLargeDataModelGroup() { - String[] strings = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")}; + String[] strings = new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")}; DataProcessor[] values = new DataProcessor[]{new LargeDataModel(), new NormalDataModel()}; return new UIButtonGroup(strings, values); } @@ -221,7 +226,10 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP protected boolean largeModel(Plot plot) { - return PlotFactory.largeDataModel(plot); + //大数据模式 恢复用注释。下面1行删除。 + return largeDataModelGroup != null && largeDataModelGroup.getSelectedIndex() == 0; + //大数据模式 恢复用注释。取消注释。 + //return PlotFactory.largeDataModel(plot); } @@ -237,7 +245,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //不透明度 protected JPanel createAlphaPane() { transparent = new UINumberDragPane(0, 100); - return TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alpha"), transparent); + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Report_Alpha"), transparent); } //堆积和坐标轴设置(自定义柱形图等用到) @@ -263,7 +271,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP checkoutMapType(plot); - super.populateBean(plot);//配色 + if(vanChartFillStylePane != null) { //配色 + vanChartFillStylePane.populateBean(plot.getPlotFillStyle()); + } if (stylePane != null) {//风格 stylePane.populateBean(plot.getPlotStyle()); @@ -320,7 +330,9 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP //更新之前先更新界面的map类型属性 checkoutMapType(plot); - super.updateBean(plot);//配色 + if(vanChartFillStylePane != null) {//配色 + plot.setPlotFillStyle(vanChartFillStylePane.updateBean()); + } if (stylePane != null) {//风格 plot.setPlotStyle(stylePane.updateBean()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java index e3f45a9c0a..1c3ed4aa53 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java @@ -4,7 +4,7 @@ import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; -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.style.ChartTextAttrPane; @@ -52,7 +52,7 @@ public class VanChartPlotTooltipPane extends BasicPane { } protected void addComponents(Plot plot) { - isTooltipShow = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Tooltip")); + isTooltipShow = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Use_Tooltip")); tooltipPane = createTooltipPane(plot); double p = TableLayout.PREFERRED; @@ -96,8 +96,8 @@ public class VanChartPlotTooltipPane extends BasicPane { Component[][] components = new Component[][]{ new Component[]{tooltipContentPane,null}, new Component[]{createLabelStylePane(),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, - new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, + new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, new Component[]{createDisplayStrategy(plot),null}, }; return components; @@ -109,25 +109,25 @@ public class VanChartPlotTooltipPane extends BasicPane { } protected JPanel createLabelStylePane() { - style = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Automatic"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"),Toolkit.i18nText("Fine-Design_Chart_Custom")}); textFontPane = new ChartTextAttrPane() { protected Component[][] getComponents(JPanel buttonPane) { return new Component[][]{ new Component[]{null, null}, - new Component[]{null, fontNameComboBox}, + new Component[]{null, getFontNameComboBox()}, new Component[]{null, buttonPane} }; } }; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Character"), style); + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Character"), style); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(panel, BorderLayout.CENTER); panel1.add(textFontPane, BorderLayout.SOUTH); initStyleListener(); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel1); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel1); } @@ -142,8 +142,8 @@ public class VanChartPlotTooltipPane extends BasicPane { protected JPanel createDisplayStrategy(Plot plot) { showAllSeries = new UICheckBox(getShowAllSeriesLabelText()); - followMouse = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Follow_Mouse"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Not_Follow_Mouse")}); + followMouse = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow_Mouse"), + Toolkit.i18nText("Fine-Design_Chart_Not_Follow_Mouse")}); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; @@ -151,17 +151,17 @@ public class VanChartPlotTooltipPane extends BasicPane { double[] rowSize = { p,p,p}; Component[][] components = new Component[3][2]; components[0] = new Component[]{null,null}; - components[1] = new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Prompt_Box")), UIComponentUtils.wrapWithBorderLayoutPane(followMouse)}; + components[1] = new Component[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Prompt_Box")), UIComponentUtils.wrapWithBorderLayoutPane(followMouse)}; if(plot.isSupportTooltipSeriesType() && hasTooltipSeriesType()){ components[2] = new Component[]{showAllSeries,null}; } JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Display_Strategy"), panel); } protected String getShowAllSeriesLabelText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Show_All_Series"); + return Toolkit.i18nText("Fine-Design_Chart_Show_All_Series"); }; protected boolean hasTooltipSeriesType() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartTooltipPane.java index 14fa52a2c7..491de9c410 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartTooltipPane.java @@ -4,7 +4,8 @@ import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; - +import com.fr.chartx.config.info.constant.ConfigType; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.base.AttrTooltip; import com.fr.van.chart.designer.AbstractVanChartScrollPane; @@ -67,6 +68,8 @@ public class VanChartTooltipPane extends AbstractVanChartScrollPane { if (attrTooltip != null) { attrList.addDataSeriesCondition(attrTooltip); } + //提示埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.TOOLTIP, chart.getBuryingPointTooltipConfig()); } @Override 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 36f34c9953..c2406e0d2c 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 @@ -105,14 +105,14 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane { dataDefinitionType.setSelectedIndex(MapDataPaneHelper.isFromBottomData(ob) ? 0 : 1); ChartCollection bottomDataChartCollection = MapDataPaneHelper.getBottomDataDrillMapChartCollection(ob); - bottomDataDefinitionPane.populateBean(bottomDataChartCollection); + + bottomDataDefinitionPane.populateBean(bottomDataChartCollection, ChartGEOJSONHelper.BOTTOM_LEVEL); eachLayerDataDefinitionPane.populateBean(ob); parent.initAllListeners(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java index 6fd6ecabbc..0c6fcc1e4c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/DrillMapLayerPane.java @@ -7,9 +7,9 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.drillmap.DrillMapHelper; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot; +import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.plugin.chart.map.server.CompatibleGeoJSONTreeHelper; import com.fr.plugin.chart.type.MapType; import com.fr.plugin.chart.type.ZoomLevel; @@ -19,10 +19,11 @@ import com.fr.van.chart.map.designer.type.VanChartMapSourceChoosePane; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.tree.DefaultMutableTreeNode; -import java.awt.BorderLayout; -import java.awt.Component; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.Component; /** * Created by Mitisky on 16/6/20. @@ -125,6 +126,7 @@ public class DrillMapLayerPane extends BasicScrollPane { if (drillMapPlot != null) { java.util.List levelList = drillMapPlot.getLayerLevelList(); java.util.List mapTypeList = drillMapPlot.getLayerMapTypeList(); + List matchResultList = drillMapPlot.getMatchResultList(); if (detailComps == null || drillMapPlot.getMapType() != oldMapType || !ComparatorUtils.equals(drillMapPlot.getGeoUrl(), oldGeoUrl)) { oldMapType = drillMapPlot.getMapType(); @@ -151,6 +153,11 @@ public class DrillMapLayerPane extends BasicScrollPane { mapTypeList.add(mapType); } + int matchSize = matchResultList.size(); + for (int k = matchSize; k < depth; k++) { + matchResultList.add(new MapMatchResult()); + } + for (int i = 0; i < depth; i++) { Component[] components = detailComps[i + 1]; if (components != null) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java index 26f8c42c3c..37e7f823f0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/EachLayerDataDefinitionPane.java @@ -16,9 +16,9 @@ import com.fr.plugin.chart.type.MapType; import com.fr.van.chart.map.designer.data.MapDataPaneHelper; import javax.swing.tree.DefaultMutableTreeNode; -import java.awt.CardLayout; import java.util.ArrayList; import java.util.List; +import java.awt.CardLayout; /** * Created by Mitisky on 16/6/20. @@ -95,7 +95,7 @@ public class EachLayerDataDefinitionPane extends MultiTabPane { MapType mapType = oldMapList.get(i); if (basicPane instanceof SingleLayerDataDefinitionPane) { ChartCollection clone = MapDataPaneHelper.getLayerChartCollection(chartCollection, i, mapType); - ((SingleLayerDataDefinitionPane) basicPane).populateBean(clone); + ((SingleLayerDataDefinitionPane) basicPane).populateBean(clone, i); } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java index 1aca1a32db..16906845e7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/drillmap/designer/data/comp/SingleLayerDataDefinitionPane.java @@ -78,6 +78,11 @@ public class SingleLayerDataDefinitionPane extends FurtherBasicBeanPane> treeNodeAndItems; + + @Override + public void actionPerformed(ActionEvent e) { + if (treeNodeAndItems == null) { + treeNodeAndItems = ChartGEOJSONHelper.getTreeNodeAndItems(plot.getGeoUrl(), level, plot.getMapType()); + } + final MapAreaMatchPane pane = new MapAreaMatchPane(treeNodeAndItems); + + final String nameTable = getTableName(); + + BasicDialog dialog = pane.showWindow(new JFrame()); + dialog.addDialogActionListener(new DialogActionListener() { + @Override + public void doOk() { + pane.updateBean(matchResult); + } + + @Override + public void doCancel() { + + } + }); + dialog.addWindowListener(new WindowListener() { + @Override + public void windowOpened(WindowEvent e) { + pane.populateBean(matchResult, nameTable, Utils.objectToString(areaBox.getSelectedItem())); + } + + @Override + public void windowClosing(WindowEvent e) { + + } + + @Override + public void windowClosed(WindowEvent e) { + + } + + @Override + public void windowIconified(WindowEvent e) { + + } + + @Override + public void windowDeiconified(WindowEvent e) { + + } + + @Override + public void windowActivated(WindowEvent e) { + + } + + @Override + public void windowDeactivated(WindowEvent e) { + + } + }); + dialog.setVisible(true); + } + }; + } + + @Override + public void refreshLevel(int level) { + this.setLevel(level); + } +} \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java index 724da26752..2e25e1bc20 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/data/contentpane/table/VanPointMapPlotTableDataContentPane.java @@ -2,12 +2,14 @@ package com.fr.van.chart.map.designer.data.contentpane.table; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.BoldFontTextLabel; 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.plugin.chart.map.data.VanMapTableDefinitionProvider; import com.fr.van.chart.map.designer.data.component.table.AbstractLongLatAreaPane; +import com.fr.van.chart.map.designer.data.component.table.AreaPane; import com.fr.van.chart.map.designer.data.component.table.PointMapAreaPane; import com.fr.van.chart.map.designer.data.component.table.PointMapLongLatAreaPane; @@ -15,11 +17,11 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; -import java.util.List; /** * Created by Mitisky on 16/5/17. @@ -214,7 +216,17 @@ public class VanPointMapPlotTableDataContentPane extends VanAreaMapPlotTableData } protected AbstractLongLatAreaPane createAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) { - return new PointMapAreaPane(longLatAreaTableComboPane); + return new PointMapAreaPane(longLatAreaTableComboPane) { + protected void initAreaPane(VanPointMapPlotTableDataContentPane.LongLatAreaTableComboPane parentPane) { + areaPane = new AreaPane(parentPane) { + protected Component[][] getComponent () { + return new Component[][]{ + new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Area_Name")), VanPointMapPlotTableDataContentPane.this.createAreaPanel(areaNameCom)} + }; + } + }; + } + }; } protected AbstractLongLatAreaPane createLongLatAreaPane(LongLatAreaTableComboPane longLatAreaTableComboPane) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelPane.java index 0853ddf724..6d22d97001 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelPane.java @@ -3,7 +3,9 @@ package com.fr.van.chart.map.designer.style.label; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.chartx.config.info.constant.ConfigType; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.attr.AttrMapLabel; import com.fr.van.chart.designer.AbstractVanChartScrollPane; @@ -116,6 +118,9 @@ public class VanChartMapLabelPane extends AbstractVanChartScrollPane { } defaultAttr.addDataSeriesCondition(attrMapLabel); + + //标签埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.LABEL, chart.getBuryingPointLabelConfig()); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapScatterMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapScatterMarkerPane.java index 7a0583ab98..8d8c16ebaa 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapScatterMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/series/VanChartMapScatterMarkerPane.java @@ -1,6 +1,9 @@ package com.fr.van.chart.map.designer.style.series; import com.fr.chart.chartglyph.Marker; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.marker.type.MarkerType; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane; @@ -11,18 +14,21 @@ import java.awt.Component; * 只有标记点类型和半径 */ public class VanChartMapScatterMarkerPane extends VanChartCommonMarkerPane { - @Override - protected Component[][] getUseComponent() { - return super.getUseComponentWithOutFillColor(); + + protected Component[][] getMarkerConfigComponent() { + + return new Component[][]{ + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Radius")), getRadius()} + }; } @Override protected Marker[] getMarkers() { - return getMapScatterMarkers(); + return getNormalMarkersWithCustom(new MarkerType[0]); } @Override - protected double[] getcolumnSize () { + protected double[] getColumnSize() { double s = TableLayout4VanChartHelper.SECOND_EDIT_AREA_WIDTH; double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; return new double[] {d, s}; diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipPane.java index b13599304d..204fecaa9a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipPane.java @@ -3,7 +3,8 @@ package com.fr.van.chart.map.designer.style.tooltip; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; - +import com.fr.chartx.config.info.constant.ConfigType; +import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.attr.AttrMapTooltip; import com.fr.van.chart.designer.AbstractVanChartScrollPane; @@ -119,6 +120,8 @@ public class VanChartMapTooltipPane extends AbstractVanChartScrollPane { attrMapTooltip.setLineTooltip(lineTooltipPane.update()); } defaultAttr.addDataSeriesCondition(attrMapTooltip); + //提示埋点 + ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.TOOLTIP, chart.getBuryingPointTooltipConfig()); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java index 8f44c0a9bc..004ac81b38 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/type/VanChartMapPlotPane.java @@ -89,7 +89,6 @@ public class VanChartMapPlotPane extends AbstractVanChartTypePane { } } } - /** * 不同地图类型的超链不需要复制 * 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 f609debe90..e58797dca3 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 @@ -42,7 +42,7 @@ import com.fr.van.chart.drillmap.designer.data.comp.MapDataTree; import com.fr.workspace.WorkContext; import javax.swing.BorderFactory; -import javax.swing.JOptionPane; +import javax.swing.DefaultComboBoxModel; import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.SwingWorker; @@ -51,6 +51,8 @@ import javax.swing.event.PopupMenuListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; @@ -61,8 +63,6 @@ import java.awt.event.ItemEvent; 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. @@ -280,14 +280,12 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { public void popupMenuWillBecomeVisible(PopupMenuEvent e) { String selected = Utils.objectToString(gisLayer.getSelectedItem()); + ZoomLevel zoomSelected = (ZoomLevel) zoomLevel.getSelectedItem(); - gisLayer.removeAllItems(); - - for (String item : MapLayerConfigManager.getLayerItems()) { - gisLayer.addItem(item); - } + gisLayer.setModel(new DefaultComboBoxModel(MapLayerConfigManager.getLayerItems())); gisLayer.setSelectedItem(selected); + zoomLevel.setSelectedItem(zoomSelected); } }); @@ -346,10 +344,7 @@ public class VanChartMapSourceChoosePane extends JPanel implements UIObserver { } else { levels = ZOOM_LEVELS; } - zoomLevel.removeAllItems(); - for (int i = 0; i < levels.length; i++) { - zoomLevel.addItem(levels[i]); - } + zoomLevel.setModel(new DefaultComboBoxModel(levels)); } 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 2a0d4ed5a7..1cc66a2bf5 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 @@ -4,8 +4,13 @@ import com.fr.chart.chartattr.Plot; import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.ConditionAttributesPane; import com.fr.design.i18n.Toolkit; +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; @@ -47,6 +52,17 @@ public class MultiPieIndependentVanChartInterface extends AbstractIndependentVan // }; // } + //图表数据结构 恢复用注释。删除下面两个方法 getTableDataSourcePane getReportDataSourcePane。 + @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 BasicBeanPane getPlotSeriesPane(ChartStylePane parent, Plot plot){ return new VanChartMultiPieSeriesPane(parent, plot); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java index df967518b7..4fa61802de 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieSeriesPane.java @@ -7,9 +7,9 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; - import com.fr.plugin.chart.multilayer.VanChartMultiPiePlot; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.pie.VanChartPieSeriesPane; import javax.swing.JPanel; @@ -90,4 +90,9 @@ public class VanChartMultiPieSeriesPane extends VanChartPieSeriesPane { multiPiePlot.setSupportRotation(supportRotation.getSelectedIndex() == 0); } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java index 0ec79c3b8a..a6a1a5e28a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPieSeriesPane.java @@ -8,6 +8,7 @@ import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.PiePlot4VanChart; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -40,7 +41,6 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane { double[] columnSize = {f}; double[] rowSize = {p,p,p,p,p,p}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createSeriesStylePane(rowSize, new double[]{f, e})}, new Component[]{createBorderPane()}, }; @@ -53,21 +53,21 @@ public class VanChartPieSeriesPane extends VanChartAbstractPlotSeriesPane { startAngle = new UISpinner(MIN_ANGLE, MAX_ANGLE, 1, 0); endAngle = new UISpinner(MIN_ANGLE, MAX_ANGLE, 1, 0); innerRadius = new UISpinner(0, 100, 1, 0); - supportRotation = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_On"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); + supportRotation = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_On"), Toolkit.i18nText("Fine-Design_Chart_Off")}, new Boolean[]{true, false}); Component[][] components = new Component[][]{ new Component[]{null,null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Angle")),startAngle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Angle")),endAngle}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Inner_Radius")),innerRadius}, - new Component[]{createRadiusPane(),null}, - new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Rotation")),supportRotation} + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Start_Angle")),startAngle}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_End_Angle")),endAngle}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Radius")),innerRadius}, + new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")),null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Rotation")),supportRotation} }; JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); } public void populateBean(Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java index 6838969229..5500cf9a32 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarSeriesPane.java @@ -43,7 +43,6 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane { private Component[][] getPaneComponents() { if(plot instanceof VanChartRadarPlot && ((VanChartRadarPlot)plot).isStackChart()) { return new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createRadarTypePane()}, new Component[]{createBorderPane()}, }; @@ -59,7 +58,9 @@ public class VanChartRadarSeriesPane extends VanChartAbstractPlotSeriesPane { //设置色彩面板内容 protected void setColorPaneContent (JPanel panel) { - panel.add(createAlphaPane(), BorderLayout.CENTER); + if(plot instanceof VanChartRadarPlot && ((VanChartRadarPlot)plot).isStackChart()) { + panel.add(createAlphaPane(), BorderLayout.CENTER); + } } private JPanel createRadarTypePane() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java index 10b762350d..c1e7886c9c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterConditionPane.java @@ -17,13 +17,13 @@ import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltip; import com.fr.van.chart.bubble.VanChartBubbleConditionSelectionPane; import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.other.condition.item.VanChartEffectConditionPane; -import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; import com.fr.van.chart.designer.other.condition.item.VanChartTrendLineConditionPane; import com.fr.van.chart.scatter.component.VanChartScatterLineTypeConditionPane; +import com.fr.van.chart.scatter.component.VanChartScatterMarkerConditionPane; import com.fr.van.chart.scatter.component.label.VanChartScatterLabelConditionPane; import com.fr.van.chart.scatter.component.tooltip.VanChartScatterTooltipConditionPane; -import com.fr.van.chart.scatter.large.VanChartLargeModelMarkerConditionPane; +import com.fr.van.chart.scatter.large.VanChartScatterLargeModelMarkerConditionPane; import java.awt.Dimension; @@ -53,10 +53,10 @@ public class VanChartScatterConditionPane extends DataSeriesConditionPane { classPaneMap.put(VanChartAttrTrendLine.class, new VanChartTrendLineConditionPane(this)); classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); if(PlotFactory.largeDataModel(plot)){ - classPaneMap.put(VanChartAttrMarker.class, new VanChartLargeModelMarkerConditionPane(this)); + classPaneMap.put(VanChartAttrMarker.class, new VanChartScatterLargeModelMarkerConditionPane(this)); } else { classPaneMap.put(VanChartAttrLine.class, new VanChartScatterLineTypeConditionPane(this)); - classPaneMap.put(VanChartAttrMarker.class, new VanChartMarkerConditionPane(this)); + classPaneMap.put(VanChartAttrMarker.class, new VanChartScatterMarkerConditionPane(this)); classPaneMap.put(ScatterAttrLabel.class, new VanChartScatterLabelConditionPane(this, plot)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getScatterPlotDefaultEffect())); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java index a85725a8e7..1bbb71e4df 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java @@ -1,13 +1,18 @@ package com.fr.van.chart.scatter; import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartglyph.Marker; import com.fr.design.beans.BasicBeanPane; +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.ChartStylePane; +import com.fr.plugin.chart.marker.type.MarkerType; import com.fr.van.chart.custom.component.VanChartCustomAxisConditionPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartLineTypePane; +import com.fr.van.chart.designer.component.VanChartMarkerPane; +import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import com.fr.van.chart.designer.style.series.VanChartStackedAndAxisListControlPane; import com.fr.van.chart.scatter.component.VanChartScatterLineTypePane; @@ -35,7 +40,6 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane { double[] col = {f}; Component[][] components = new Component[][]{ - new Component[]{getColorPane()}, new Component[]{createLineTypePane()}, new Component[]{createMarkerPane()}, new Component[]{createStackedAndAxisPane()}, @@ -64,7 +68,7 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane { @Override public String getPaneTitle() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Axis"); + return Toolkit.i18nText("Fine-Design_Chart_Custom_Axis"); } }; stackAndAxisEditExpandablePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(stackAndAxisEditPane.getPaneTitle(), stackAndAxisEditPane); @@ -82,4 +86,19 @@ public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane { checkLinePane(); } + + protected JPanel createMarkerPane() { + markerPane = new VanChartMarkerPane() { + protected VanChartCommonMarkerPane createCommonMarkerPane() { + + return new VanChartCommonMarkerPane() { + protected Marker[] getMarkers() { + return getNormalMarkersWithCustom(new MarkerType[]{MarkerType.MARKER_AUTO}); + } + }; + } + }; + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Marker"), markerPane); + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java index 8808a78e38..340b93f147 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterLineTypePane.java @@ -1,11 +1,10 @@ package com.fr.van.chart.scatter.component; import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.VanChartAttrLine; import com.fr.plugin.chart.type.LineStyle; -import com.fr.stable.Constants; +import com.fr.plugin.chart.type.LineType; +import com.fr.design.i18n.Toolkit; import com.fr.van.chart.designer.component.VanChartLineTypePane; import java.awt.Component; @@ -16,18 +15,17 @@ import java.awt.Component; public class VanChartScatterLineTypePane extends VanChartLineTypePane { @Override - protected void createLineStyle() { - String[] textArray = new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; - lineStyle = new UIButtonGroup(textArray, new LineStyle[]{LineStyle.NORMAL, LineStyle.CURVE}); + protected UIButtonGroup createLineStyle() { + String[] textArray = new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Normal_Line"), + Toolkit.i18nText("Fine-Design_Chart_CurveLine")}; + + return new UIButtonGroup<>(textArray, new LineStyle[]{LineStyle.NORMAL, LineStyle.CURVE}); } @Override protected Component[][] createContentComponent(Component[] lineStyleComponent, Component[] nullValueBreakComponent) { return new Component[][]{ - //线型支持虚线 恢复用注释。下面2行删除。 - new Component[]{null, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), lineWidth}, lineStyleComponent }; } @@ -36,10 +34,7 @@ public class VanChartScatterLineTypePane extends VanChartLineTypePane { protected VanChartAttrLine initVanChartAttrLine() { VanChartAttrLine attrLine = new VanChartAttrLine(); //默认为无线型,且默認空值不斷開 - //线型支持虚线 恢复用注释。下面1行删除。 - attrLine.setLineWidth(Constants.LINE_NONE); - //线型支持虚线 恢复用注释。取消注释。 - //attrLine.setLineType(LineType.NONE); + attrLine.setLineType(LineType.NONE); attrLine.setNullValueBreak(false); return attrLine; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterMarkerConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterMarkerConditionPane.java new file mode 100644 index 0000000000..06b617401a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/VanChartScatterMarkerConditionPane.java @@ -0,0 +1,28 @@ +package com.fr.van.chart.scatter.component; + +import com.fr.chart.chartglyph.Marker; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.plugin.chart.marker.type.MarkerType; +import com.fr.van.chart.designer.component.VanChartMarkerPane; +import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane; +import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; + +public class VanChartScatterMarkerConditionPane extends VanChartMarkerConditionPane { + + public VanChartScatterMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { + super(conditionAttributesPane); + } + + protected void initMarkerPane() { + markerPane = new VanChartMarkerPane() { + protected VanChartCommonMarkerPane createCommonMarkerPane() { + + return new VanChartCommonMarkerPane() { + protected Marker[] getMarkers() { + return getNormalMarkersWithCustom(new MarkerType[]{MarkerType.MARKER_AUTO}); + } + }; + } + }; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/large/VanChartScatterLargeModelMarkerConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/large/VanChartScatterLargeModelMarkerConditionPane.java new file mode 100644 index 0000000000..32dc88be14 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/large/VanChartScatterLargeModelMarkerConditionPane.java @@ -0,0 +1,29 @@ +package com.fr.van.chart.scatter.large; + +import com.fr.chart.chartglyph.Marker; +import com.fr.design.condition.ConditionAttributesPane; +import com.fr.plugin.chart.marker.type.MarkerType; +import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane; +import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; + +public class VanChartScatterLargeModelMarkerConditionPane extends VanChartMarkerConditionPane { + + public VanChartScatterLargeModelMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { + super(conditionAttributesPane); + } + + protected void initMarkerPane() { + + markerPane = new VanChartLargeModelMarkerPane() { + protected VanChartCommonMarkerPane createCommonMarkerPane() { + + return new VanChartCommonMarkerPane() { + protected Marker[] getMarkers() { + return getNormalMarkersWithCustom(new MarkerType[]{MarkerType.MARKER_AUTO}); + } + }; + } + + }; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java index b9e5427112..ee2cda46a6 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureSeriesPane.java @@ -10,10 +10,10 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.style.color.ColorSelectBox; - import com.fr.plugin.chart.base.AttrNode; import com.fr.plugin.chart.structure.VanChartStructurePlot; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import javax.swing.JPanel; @@ -142,4 +142,9 @@ public class VanChartStructureSeriesPane extends VanChartAbstractPlotSeriesPane } } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java index d5ab61b950..884e96b330 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java @@ -15,10 +15,10 @@ import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRFont; import com.fr.general.IOUtils; - import com.fr.plugin.chart.wordcloud.CloudShapeType; import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot; import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import javax.swing.JPanel; @@ -228,4 +228,9 @@ public class VanChartWordCloudSeriesPane extends VanChartAbstractPlotSeriesPane } } } + + @Override + protected VanChartBeautyPane createStylePane() { + return null; + } } diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/cuvette.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/cuvette.png old mode 100644 new mode 100755 index 680f9ed18e..c2220b4b52 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/cuvette.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/cuvette.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_180.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_180.png old mode 100644 new mode 100755 index b20420280c..a0fa2b2147 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_180.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_180.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_360.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_360.png old mode 100644 new mode 100755 index d4058631fb..f7c3f25b25 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_360.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_360.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/ring.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/ring.png old mode 100644 new mode 100755 index f3bf1b31d8..979c60f6d3 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/ring.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/ring.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/cuvette.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/cuvette.png old mode 100644 new mode 100755 index 57847bc24a..d0125c71c7 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/cuvette.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/cuvette.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_180.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_180.png old mode 100644 new mode 100755 index 2c9cc91339..8a4f9a333b Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_180.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_180.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_360.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_360.png old mode 100644 new mode 100755 index db13dc1a26..c2f0933d84 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_360.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_360.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/ring.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/ring.png old mode 100644 new mode 100755 index 88a25aa898..2a89fb3454 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/ring.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/ring.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/slot.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/slot.png old mode 100644 new mode 100755 index 920cf6cc0b..4cb26a2e4c Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/slot.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/slot.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/slot.png b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/slot.png old mode 100644 new mode 100755 index bb44ca5136..6dc29a8dfa Binary files a/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/slot.png and b/designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/slot.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/cuvette.png b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/cuvette.png index 5f68049e8b..39f034740e 100644 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/cuvette.png and b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/cuvette.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer.png b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer.png index 3bf259dfa0..58b1f0a35b 100644 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer.png and b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer_180.png b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer_180.png index 9839a82013..213a052d4c 100644 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer_180.png and b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/pointer_180.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/ring.png b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/ring.png index beeaecbb54..10d0b637ec 100644 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/ring.png and b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/ring.png differ diff --git a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/slot.png b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/slot.png index d7ee4d1c09..e900e4ba89 100644 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/slot.png and b/designer-chart/src/main/resources/com/fr/van/chart/gauge/images/slot.png differ diff --git a/designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java b/designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java index c6f64c498c..6227c169b1 100644 --- a/designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java +++ b/designer-form/src/main/java/com/fr/design/actions/FormMobileAttrAction.java @@ -56,6 +56,9 @@ public class FormMobileAttrAction extends JTemplateAction { final FormMobileAttrPane mobileAttrPane = new FormMobileAttrPane(); mobileAttrPane.populateBean(mobileAttr); + + final boolean oldMobileOnly = mobileAttr.isMobileOnly(); + final boolean oldAdaptive = mobileAttr.isAdaptivePropertyAutoMatch(); BasicDialog dialog = mobileAttrPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { @@ -75,14 +78,17 @@ public class FormMobileAttrAction extends JTemplateAction { recordFunction(); // 设置移动端属性并刷新界面 formTpl.setFormMobileAttr(formMobileAttr); // 会调整 body 的自适应布局,放到最后 - ((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); - jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent()); - //当自适应属性自动匹配处于勾选状态 进行切换 - if (formMobileAttr.isMobileOnly() && formMobileAttr.isAdaptivePropertyAutoMatch()) { + boolean changeSize = (!oldMobileOnly && formMobileAttr.isMobileOnly()) || (oldMobileOnly && !formMobileAttr.isMobileOnly()); + if (changeSize) { + ((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); + } + //改变布局为自适应布局,只在移动端属性设置保存后改变一次 + boolean changeLayout = !oldAdaptive && formMobileAttr.isAdaptivePropertyAutoMatch(); + if (changeLayout) { + jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent()); doChangeBodyLayout(); + WidgetPropertyPane.getInstance().refreshDockingView(); } - - WidgetPropertyPane.getInstance().refreshDockingView(); jf.fireTargetModified(); } }); @@ -106,7 +112,7 @@ public class FormMobileAttrAction extends JTemplateAction { private static final MenuKeySet REPORT_APP_ATTR = new MenuKeySet() { @Override public char getMnemonic() { - return 'T'; + return 'P'; } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java index 1d529743a2..9718d4a6fd 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRCardMainBorderLayoutAdapter.java @@ -3,6 +3,7 @@ package com.fr.design.designer.beans.adapters.layout; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.form.layout.FRBorderLayout; import com.fr.general.ComparatorUtils; @@ -47,13 +48,13 @@ public class FRCardMainBorderLayoutAdapter extends FRBorderLayoutAdapter { if (ComparatorUtils.equals(constraints, BorderLayout.NORTH) || ComparatorUtils.equals(constraints, BorderLayout.SOUTH)) { int containerHeight = container.getHeight(); if (rectangle.height > containerHeight) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); return true; } } else if (ComparatorUtils.equals(constraints, BorderLayout.EAST) || ComparatorUtils.equals(constraints, BorderLayout.WEST)) { int containerWidth = container.getWidth(); if (rectangle.width > containerWidth) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); return true; } } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java b/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java index 2c0c285049..d7f1a199ca 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/events/CreatorEventListenerTable.java @@ -1,10 +1,14 @@ package com.fr.design.designer.beans.events; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.designer.creator.XComponent; +import com.fr.design.fun.DesignerEditListenerProvider; import com.fr.general.ComparatorUtils; +import com.fr.plugin.injectable.PluginModule; import javax.swing.SwingUtilities; import java.util.ArrayList; +import java.util.Set; public class CreatorEventListenerTable { @@ -28,6 +32,7 @@ public class CreatorEventListenerTable { } private void fireCreatorModified(final DesignerEvent evt) { + for (int i = 0; i < listeners.size(); i++) { final DesignerEditListener listener = listeners.get(i); SwingUtilities.invokeLater(new Runnable() { @@ -37,6 +42,14 @@ public class CreatorEventListenerTable { } }); } + + //触发插件的事件 + ExtraDesignClassManager manager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = manager.getArray(DesignerEditListenerProvider.XML_TAG); + for (DesignerEditListenerProvider provider : providers) { + provider.fireCreatorModified(evt); + } + } public void fireCreatorModified(XComponent creator, int eventID) { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index 052ae05390..dd964e4ab5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -1,15 +1,23 @@ package com.fr.design.designer.beans.models; import com.fr.common.inputevent.InputEventBaseOnOS; +import com.fr.design.base.clipboard.ClipboardFilter; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Location; -import com.fr.design.designer.creator.*; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelection; @@ -18,7 +26,9 @@ import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.stable.ArrayUtils; -import java.awt.*; +import java.awt.LayoutManager; +import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -109,9 +119,12 @@ public class SelectionModel { */ public void cutSelectedCreator2ClipBoard() { if (hasSelectionComponent()) { - selection.cut2ClipBoard(clipboard); - designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); - designer.repaint(); + FormSelection cutSelection = ClipboardFilter.cut(selection); + if (cutSelection != null) { + cutSelection.cut2ClipBoard(clipboard); + designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_CUTED); + designer.repaint(); + } } } @@ -120,7 +133,10 @@ public class SelectionModel { */ public void copySelectedCreator2ClipBoard() { if (!selection.isEmpty()) { - selection.copy2ClipBoard(clipboard); + FormSelection copySelection = ClipboardFilter.copy(selection); + if (copySelection != null) { + copySelection.copy2ClipBoard(clipboard); + } } } @@ -130,7 +146,8 @@ public class SelectionModel { * @return 否 */ public boolean pasteFromClipBoard() { - if (!clipboard.isEmpty()) { + FormSelection pasteSelection = ClipboardFilter.paste(clipboard); + if (pasteSelection != null && !pasteSelection.isEmpty()) { if (!hasSelectedPasteSource()) { //未选 unselectedPaste(); @@ -257,12 +274,15 @@ public class SelectionModel { designer.removeParaComponent(); } removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); + FormDesignerUtils.removeWidgetProcessInfo(creator.toData()); creator.deleteRelatedComponent(creator, designer); creator.removeAll(); // 清除被选中的组件 selection.reset(); } + + setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); // 触发事件 designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java b/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java index e94022ebe8..44996df8cd 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XButton.java @@ -3,8 +3,8 @@ */ package com.fr.design.designer.creator; -import com.fr.base.ScreenResolution; import com.fr.base.background.GradientBackground; +import com.fr.design.form.util.FontTransformUtil; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; @@ -40,13 +40,13 @@ import java.beans.IntrospectionException; * @since 6.5.3 */ public class XButton extends XWidgetCreator { - + public final static Background DEFAULTBG = new GradientBackground(new Color(247,247,247),new Color(210,210,210), GradientBackground.TOP2BOTTOM); public final static Font DEFAULTFT = new Font("Song_TypeFace",0,12); public final static Color DEFAULTFOREGROUNDCOLOR = Color.BLACK; private Background bg; private UILabel contentLabel; - + public XButton(Button widget, Dimension initSize) { this(new FreeButton(widget),initSize); } @@ -54,11 +54,11 @@ public class XButton extends XWidgetCreator { public XButton(FreeButton widget, Dimension initSize) { super(widget, initSize); } - + public XButton(FormSubmitButton widget, Dimension initSize) { super(widget, initSize); } - + public Background getContentBackground() { return bg; } @@ -74,7 +74,7 @@ public class XButton extends XWidgetCreator { public void setContentLabel(UILabel contentLabel) { this.contentLabel = contentLabel; } - + /** *根据下拉框选择返回按钮样式的默认设置或自定义设置列表 * @return 列表 @@ -148,7 +148,7 @@ public class XButton extends XWidgetCreator { FreeButton button = (FreeButton) data; if (button.getFont() != null) { contentLabel.setFont(button.getFont().applyResolutionNP( - ScreenResolution.getScreenResolution())); + FontTransformUtil.getDesignerFontResolution())); contentLabel.setForeground(button.getFont().getForeground()); } } @@ -205,7 +205,7 @@ public class XButton extends XWidgetCreator { protected UILabel initContentLabel() { return new UILabel(); } - + @Override public void paintComponent(Graphics g) { super.paintComponent(g); @@ -218,15 +218,15 @@ public class XButton extends XWidgetCreator { bg.paint(g, new Rectangle2D.Double(0, 0, panelSize.getWidth(), panelSize.getHeight())); } } - + public void setButtonText(String text) { contentLabel.setText(text); } - + private void checkButonType() { UILabel l = contentLabel; FreeButton button = (FreeButton) data; - + if (!button.isCustomStyle()) { l.setBorder(BorderFactory.createLineBorder(new Color(148, 148, 148))); bg = DEFAULTBG; @@ -240,7 +240,7 @@ public class XButton extends XWidgetCreator { editor.add(l,BorderLayout.CENTER); if (button.getFont() != null) { contentLabel.setFont(button.getFont().applyResolutionNP( - ScreenResolution.getScreenResolution())); + FontTransformUtil.getDesignerFontResolution())); contentLabel.setForeground(button.getFont().getForeground()); } l.setBounds(0, 0, button.getButtonWidth() == 0 ? this.getWidth() : button.getButtonWidth(), button @@ -248,7 +248,7 @@ public class XButton extends XWidgetCreator { bg = button.getInitialBackground(); } } - + @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); @@ -257,7 +257,7 @@ public class XButton extends XWidgetCreator { FreeButton button = (FreeButton) data; l.setText(button.getText()); if (button.isCustomStyle() && button.getFont() != null) { - l.setFont(button.getFont().applyResolutionNP(ScreenResolution.getScreenResolution())); + l.setFont(button.getFont().applyResolutionNP(FontTransformUtil.getDesignerFontResolution())); l.setForeground(button.getFont().getForeground()); } @@ -303,7 +303,7 @@ public class XButton extends XWidgetCreator { checkButonType(); if (button.getFont() != null) { contentLabel.setFont(button.getFont().applyResolutionNP( - ScreenResolution.getScreenResolution())); + FontTransformUtil.getDesignerFontResolution())); contentLabel.setForeground(button.getFont().getForeground()); } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java index 233c369c41..df2252c7af 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLabel.java @@ -4,9 +4,9 @@ package com.fr.design.designer.creator; import com.fr.base.BaseUtils; -import com.fr.base.ScreenResolution; import com.fr.base.Style; import com.fr.design.border.UIRoundedBorder; +import com.fr.design.form.util.FontTransformUtil; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.widget.editors.FontEditor; @@ -98,7 +98,8 @@ public class XLabel extends XWidgetCreator { .toString(), Style.getInstance(label.getFont()).deriveHorizontalAlignment(label.getTextalign()) .deriveVerticalAlignment(label.isVerticalCenter() ? SwingConstants.CENTER : SwingConstants.TOP) .deriveTextStyle(label.isWrap() ? Style.TEXTSTYLE_WRAPTEXT : Style.TEXTSTYLE_SINGLELINE), - ScreenResolution.getScreenResolution()); + FontTransformUtil.getDesignerFontResolution()); + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java b/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java index 3e122d070e..af207457f9 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XRadio.java @@ -15,7 +15,9 @@ import java.beans.IntrospectionException; /** * @author richer * @since 6.5.3 + * @deprecated */ +@Deprecated public class XRadio extends XWidgetCreator { public XRadio(Radio widget, Dimension initSize) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 22d702dfd5..7c852f2820 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -111,7 +111,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { private void initPercent(WAbsoluteLayout widget) { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension scrnsize = toolkit.getScreenSize(); - double screenValue = FRScreen.getByDimension(scrnsize).getValue(); + double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) { this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); } @@ -247,7 +247,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { */ @Override public void updateChildBound(int minHeight) { - double prevContainerPercent = FRScreen.getByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; + double prevContainerPercent = FRScreen.getDesignScreenByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) { for (int i = 0; i < this.getComponentCount(); i++) { XCreator creator = getXCreator(i); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java index ff67634e4e..6d2003e21c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java @@ -28,7 +28,7 @@ public class XWBorderLayout extends XLayoutContainer { public XWBorderLayout(){ super(new WBorderLayout(),new Dimension(WBorderLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_HEIGHT)); } - + public XWBorderLayout(WBorderLayout widget, Dimension initSize) { super(widget, initSize); } @@ -77,7 +77,7 @@ public class XWBorderLayout extends XLayoutContainer { @Override public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { return new CRPropertyDescriptor[] { - new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")), + new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Basic_Component_Name")), new CRPropertyDescriptor("customTitleName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Title")) }; } @@ -101,7 +101,7 @@ public class XWBorderLayout extends XLayoutContainer { } isRefreshing = false; } - + /** * 设计界面中有组件添加时,要通知WLayout容器重新paint @@ -202,9 +202,9 @@ public class XWBorderLayout extends XLayoutContainer { creator.setDirections(new int[]{Direction.RIGHT}); } } - + @Override public LayoutAdapter getLayoutAdapter() { return new FRBorderLayoutAdapter(this); } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 3fb0b5f969..352899bcbb 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -72,7 +72,7 @@ public class XWFitLayout extends XLayoutContainer { private void initPercent(){ Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension scrnsize = toolkit.getScreenSize(); - double screenValue = FRScreen.getByDimension(scrnsize).getValue(); + double screenValue = FRScreen.getDesignScreenByDimension(scrnsize).getValue(); if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) { this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); } @@ -1331,4 +1331,4 @@ public class XWFitLayout extends XLayoutContainer { } } } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index c51fe491e4..25da3e7754 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -514,13 +514,4 @@ public class XWCardMainBorderLayout extends XWBorderLayout { public boolean isSupportShared() { return true; } - - @Override - public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { - if (FormDesignerUtils.isAppRelayout(WidgetPropertyPane.getInstance().getEditingFormDesigner())) { - return new WidgetPropertyUIProvider[] {new MobileBooKMarkUsePropertyUI(this)}; - } else { - return super.getWidgetPropertyUIProviders(); - } - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java index f2f58f17b3..508f3f7dfa 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java @@ -8,11 +8,15 @@ import com.fr.design.designer.creator.CRPropertyDescriptor; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.properties.mobile.MobileBooKMarkUsePropertyUI; +import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormHierarchyTreePane; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.ButtonTypeEditor; import com.fr.design.mainframe.widget.editors.ImgBackgroundEditor; import com.fr.design.utils.gui.LayoutUtils; diff --git a/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkCombinePropertyUI.java b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkCombinePropertyUI.java new file mode 100644 index 0000000000..29bc2fb9aa --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/properties/mobile/MobileBookMarkCombinePropertyUI.java @@ -0,0 +1,36 @@ +package com.fr.design.designer.properties.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicPane; +import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; +import com.fr.design.gui.itable.AbstractPropertyTable; +import com.fr.design.widget.ui.designer.mobile.MobileBookMarkCombinePane; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/4/18 + */ +public class MobileBookMarkCombinePropertyUI extends AbstractWidgetPropertyUIProvider { + + private XCreator xCreator; + + public MobileBookMarkCombinePropertyUI(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public AbstractPropertyTable createWidgetAttrTable() { + return null; + } + + @Override + public BasicPane createWidgetAttrPane() { + return new MobileBookMarkCombinePane(xCreator); + } + + @Override + public String tableTitle() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); + } +} diff --git a/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileTemplateSettingsPane.java b/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileTemplateSettingsPane.java index 21f6d3b09f..2eac9c5863 100644 --- a/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileTemplateSettingsPane.java +++ b/designer-form/src/main/java/com/fr/design/form/mobile/FormMobileTemplateSettingsPane.java @@ -47,9 +47,7 @@ public class FormMobileTemplateSettingsPane extends BasicBeanPane { + + private static final String REGEX = "^" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title") + "\\d+$"; + + private static final Pattern PATTERN = Pattern.compile(REGEX); + + private Map componentProcessInfoMap = new ConcurrentHashMap(); + public JFormProcessInfo(Form form) { super(form); } @@ -20,21 +50,190 @@ public class JFormProcessInfo extends TemplateProcessInfo
{ public int getCellCount() { return 0; } + // 获取模板悬浮元素个数 public int getFloatCount() { return 0; } + // 获取模板聚合块个数 public int getBlockCount() { return 0; } + // 获取模板控件数 public int getWidgetCount() { - int widgetCount = 0; - for (int i = 0; i < template.getContainer().getWidgetCount(); i++) { - WLayout wl = (WLayout) template.getContainer().getWidget(i); - widgetCount += wl.getWidgetCount(); + final AtomicInteger widgetCount = new AtomicInteger(); + Form.traversalWidget(this.template.getContainer(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + if (ComponentOperate.ComponentType.supportComponent(widget)) { + widgetCount.incrementAndGet(); + } + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, null); + return widgetCount.get(); + } + + @Override + public boolean isTestTemplate() { + Iterator it = this.template.getTableDataNameIterator(); + if (!it.hasNext() || getWidgetCount() <= 1 || + hasEmptyParaPane() || hasTestAbsolutePane() + || hasTestTabLayout() || hasTestECReport() || hasTestChart()) { + return true; + } + return false; + } + + private boolean hasTestECReport() { + ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases(); + for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) { + FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); + Iterator it = elementCase.cellIterator(); + if (!it.hasNext()) { + return true; + } + while (it.hasNext()) { + DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next(); + Object value = ce.getValue(); + if (isTestCell(value, ce.getStyle())) { + return true; + } + } + + } + return false; + } + + private boolean hasTestChart() { + final boolean[] hasTestChart = {false}; + Form.traversalWidget(this.template.getContainer(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + ChartCollection chartCollection = (ChartCollection) ((BaseChartEditor) widget).getChartCollection(); + if (isTestChartCollection(chartCollection)) { + hasTestChart[0] = true; + } + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, BaseChartEditor.class); + return hasTestChart[0]; + } + + + private boolean hasTestTabLayout() { + final boolean[] hasTestTabLayout = {false}; + Form.traversalWidget(this.template.getContainer(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + String title = ((CardSwitchButton) widget).getText(); + Matcher matcher = PATTERN.matcher(title); + if (matcher.find()) { + hasTestTabLayout[0] = true; + } + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, CardSwitchButton.class); + return hasTestTabLayout[0]; + } + + private boolean hasTestAbsolutePane() { + final boolean[] hasTestAbsolutePane = {false}; + Form.traversalWidget(this.template.getContainer(), new WidgetGather() { + @Override + public void dealWith(Widget widget) { + if (((WAbsoluteLayout) widget).getWidgetCount() == 0) { + hasTestAbsolutePane[0] = true; + } + } + + @Override + public boolean dealWithAllCards() { + return true; + } + }, WAbsoluteLayout.class); + return hasTestAbsolutePane[0]; + } + + private boolean hasEmptyParaPane() { + WLayout paraContainer = this.template.getParaContainer(); + return paraContainer != null && paraContainer.getWidgetCount() == 0; + } + + @Override + public boolean useParaPane() { + return this.template.getParaContainer() != null; + } + + @Override + public JSONArray getComponentsInfo() { + JSONArray ja = new JSONArray(); + for (JSONObject value : componentProcessInfoMap.values()) { + ja.put(value); + } + this.componentProcessInfoMap.clear(); + return ja; + } + + @Override + public JSONArray getReuseCmpList() { + + final JSONArray jo = JSONArray.create(); + WLayout container = this.template.getContainer(); + WidgetUtil.bfsTraversalWidget(container, new WidgetUtil.BfsWidgetGather() { + @Override + public boolean dealWith(AbstractBorderStyleWidget styleWidget) { + ExtendSharableAttrMark widgetAttrMark = styleWidget.getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG); + if (widgetAttrMark != null) { + String shareId = widgetAttrMark.getShareId(); + jo.add(shareId); + return true; + } + return false; + } + }, AbstractBorderStyleWidget.class); + return jo; + } + + @Override + public void updateTemplateOperationInfo(TemplateOperate templateOperate) { + if (ComparatorUtils.equals(ComponentCreateOperate.OPERATE_TYPE, templateOperate.getOperateType())) { + addComponentCreateInfo(templateOperate.toJSONObject()); + } + if (ComparatorUtils.equals(ComponentDeleteOperate.OPERATE_TYPE, templateOperate.getOperateType())) { + addComponentRemoveInfo(templateOperate.toJSONObject()); + } + } + + private void addComponentCreateInfo(JSONObject jsonObject) { + String componentID = jsonObject.getString("componentID"); + componentProcessInfoMap.put(componentID, jsonObject); + } + + private void addComponentRemoveInfo(JSONObject jsonObject) { + String componentID = jsonObject.getString("componentID"); + if (componentID == null){ + return; + } + JSONObject info = componentProcessInfoMap.get(componentID); + if (info == null) { + info = jsonObject; + componentProcessInfoMap.put(componentID, jsonObject); } - return widgetCount; + info.put("deleteTime", System.currentTimeMillis()); } } diff --git a/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java b/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java index b8bfe4e0b0..7c967efed8 100644 --- a/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java +++ b/designer-form/src/main/java/com/fr/design/parameter/ParameterPropertyPane.java @@ -124,7 +124,7 @@ public class ParameterPropertyPane extends JPanel{ hideInJForm = jt instanceof JForm && !(creator instanceof XWParameterLayout || creator.getParent() instanceof XWParameterLayout); } catch (NullPointerException ex) { - hideInJForm = true; + hideInJForm = toolbarPane.updateBean().length <= 0; } if (isVisible && toolbarPane.hasSelectedLabelItem() && !hideInJForm) { addParaPane.setVisible(true); diff --git a/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java b/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java index 9df0a32012..1947e9ec4e 100644 --- a/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java +++ b/designer-form/src/main/java/com/fr/design/widget/FormWidgetDefinePaneFactoryBase.java @@ -127,6 +127,11 @@ public class FormWidgetDefinePaneFactoryBase { } + + public static void registerDefinePane(Class widget, Appearance appearance) { + defineMap.put(widget, appearance); + } + public static RN createWidgetDefinePane(XCreator creator, FormDesigner designer, Widget widget, Operator operator) { if (isExtraXWidget(widget)) { WidgetDefinePane widgetDefinePane = new WidgetDefinePane(creator, designer); @@ -165,4 +170,4 @@ public class FormWidgetDefinePaneFactoryBase { } } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java index 9117b5c517..140e294e08 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/RadioDefinePane.java @@ -11,6 +11,10 @@ import com.fr.general.FRFont; import javax.swing.*; import java.awt.*; +/** + * @deprecated + */ +@Deprecated public class RadioDefinePane extends AbstractDataModify { public RadioDefinePane(XCreator xCreator) { super(xCreator); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java index c9928759bf..ab148f2ae6 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetBoundPane.java @@ -10,6 +10,7 @@ import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.FormDesigner; @@ -115,11 +116,11 @@ public class WidgetBoundPane extends BasicPane { PaddingMargin margin = wabs.getMargin(); if (bounds.width != w) { if (bounds.width == rec.width - margin.getLeft() - margin.getRight()) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds")); width.setValue(bounds.width); return; } else if (w < minWidth) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Width") + Integer.toString(minWidth)); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Width") + Integer.toString(minWidth)); width.setValue(bounds.width); return; } @@ -136,11 +137,11 @@ public class WidgetBoundPane extends BasicPane { int minHeight = (int) (MINHEIGHT * ((WFitLayout) wabs).getResolutionScaling()); if (bounds.height != h) { if (bounds.height == rec.height - margin.getTop() - margin.getBottom()) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Bounds")); height.setValue(bounds.height); return; } else if (h < minHeight) { - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Height") + Integer.toString(minHeight)); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Min_Height") + Integer.toString(minHeight)); height.setValue(bounds.height); return; } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java index 97bc5aaa3b..22d544c1a6 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/component/WidgetCardTagBoundPane.java @@ -4,6 +4,7 @@ import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; @@ -48,13 +49,13 @@ public class WidgetCardTagBoundPane extends WidgetBoundPane { Rectangle rectangle = tabLayout.getBounds(); if(ComparatorUtils.equals(displayPosition, WTabDisplayPosition.TOP_POSITION) || ComparatorUtils.equals(displayPosition, WTabDisplayPosition.BOTTOM_POSITION)){ if(rectangle.height < size){ - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); return; } parentBounds.height = size; }else{ if(rectangle.width < size){ - JOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); + FineJOptionPane.showMessageDialog(null, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Beyond_Tablayout_Bounds")); return; } parentBounds.width = size; diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java index 31c29d72e5..723616280c 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ElementCaseDefinePane.java @@ -107,9 +107,9 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Horizontal"), SwingConstants.LEFT), hComboBox}, new Component[] {new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Vertical"), SwingConstants.LEFT), vComboBox}, createComponents(), - new Component[] {heightRestrictCheckBox, null}, new Component[] {allowFullCheckBox, null}, new Component[] {functionalWhenUnactivatedCheckBox, null}, + new Component[] {heightRestrictCheckBox, null}, new Component[] {maxHeightLabel, maxHeightSpinner} }; double f = TableLayout.FILL; diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java index 587ea53950..542641c248 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileAdvanceDefinePane.java @@ -1,38 +1,14 @@ package com.fr.design.widget.ui.designer.mobile; -import com.fr.design.constants.LayoutConstants; -import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.AttributeChangeListener; -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.FRGUIPaneFactory; -import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.form.main.Form; -import com.fr.form.ui.FormWidgetHelper; -import com.fr.form.ui.Widget; -import com.fr.form.ui.container.WLayout; -import com.fr.form.ui.container.WSortLayout; -import com.fr.form.ui.mobile.MobileBookMark; -import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; -import com.fr.stable.StringUtils; +import com.fr.design.widget.ui.designer.mobile.component.MobileAdvanceInnerPane; import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.util.Iterator; /** * @author hades @@ -42,8 +18,7 @@ import java.util.Iterator; public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { private XCreator xCreator; - private UICheckBox useBookMarkCheck; - private UITextField bookMarkNameField; + private MobileAdvanceInnerPane innerPane; public MobileAdvanceDefinePane(XCreator xCreator) { this.xCreator = xCreator; @@ -52,71 +27,13 @@ public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { @Override public void initPropertyGroups(Object source) { this.setLayout(FRGUIPaneFactory.createBorderLayout()); - JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - this.useBookMarkCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Use_BookMark"), false); - this.bookMarkNameField = new UITextField() { - @Override - protected void initListener() { - if (shouldResponseChangeListener()) { - addFocusListener(new FocusAdapter() { - @Override - public void focusLost(FocusEvent e) { - attributeChange(); - } - }); - addKeyListener(new KeyAdapter() { - @Override - public void keyTyped(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER) { - attributeChange(); - } - } - }); - } - } - }; - JPanel useBookMarkPane = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{new Component[]{useBookMarkCheck}}, - TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); - final JPanel bookMarkNamePane = TableLayoutHelper.createGapTableLayoutPane( - new Component[][]{new Component[]{new UILabel( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Name")), bookMarkNameField}}, - TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); - this.useBookMarkCheck.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - boolean selected = MobileAdvanceDefinePane.this.useBookMarkCheck.isSelected(); - Widget widget = MobileAdvanceDefinePane.this.xCreator.toData(); - MobileBookMark bookMark = widget.getMobileBookMark(); - bookMarkNamePane.setVisible(selected); - if (selected && StringUtils.isEmpty(bookMark.getBookMarkName())) { - String name = widget.getWidgetName(); - MobileAdvanceDefinePane.this.bookMarkNameField.setText(name); - bookMark.setBookMarkName(name); - } - } - }); - bookMarkNamePane.setVisible(xCreator.toData().getMobileBookMark().isUseBookMark()); - contentPane.add(useBookMarkPane, BorderLayout.NORTH); - contentPane.add(bookMarkNamePane, BorderLayout.CENTER); - UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark"), 280, 20, contentPane); + this.innerPane = new MobileAdvanceInnerPane(xCreator); + UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark"), 280, 20, innerPane); JPanel wrapPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); wrapPane.add(uiExpandablePane, BorderLayout.NORTH); this.add(wrapPane, BorderLayout.NORTH); - initData(); } - private void initData() { - MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); - String bookMarkName = bookMark.getBookMarkName(); - if (StringUtils.isEmpty(bookMarkName)) { - String widgetName = xCreator.toData().getWidgetName(); - this.bookMarkNameField.setText(widgetName); - bookMark.setBookMarkName(widgetName); - } else { - this.bookMarkNameField.setText(bookMarkName); - } - } private void bindListeners2Widgets() { reInitAllListeners(); @@ -145,49 +62,13 @@ public class MobileAdvanceDefinePane extends MobileWidgetDefinePane { @Override public void populate(FormDesigner designer) { - MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); - this.bookMarkNameField.setText(bookMark.getBookMarkName()); - if (bookMark.isFrozen()) { - this.useBookMarkCheck.setSelected(false); - this.useBookMarkCheck.setEnabled(false); - } else { - this.useBookMarkCheck.setSelected(bookMark.isUseBookMark()); - } + this.innerPane.populate(); this.bindListeners2Widgets(); } @Override public void update() { - MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); - bookMark.setUseBookMark(this.useBookMarkCheck.isSelected()); - String newBookMarkName = this.bookMarkNameField.getText(); - DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); - if (ComparatorUtils.equals(newBookMarkName, bookMark.getBookMarkName())) { - return; - } - if (!isExist(newBookMarkName)) { - bookMark.setBookMarkName(newBookMarkName); - } else { - FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_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")); - this.bookMarkNameField.setText(bookMark.getBookMarkName()); - } - } - - private boolean isExist(String name) { - Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); - WLayout container = form.getContainer(); - WSortLayout wSortLayout = (WSortLayout) container.getWidget(container.getWidgetCount() - 1); - Iterator iterator = wSortLayout.getMobileWidgetIterator(); - while (iterator.hasNext()) { - Widget widget = form.getWidgetByName(iterator.next()); - if (widget != null && ComparatorUtils.equals(widget.getMobileBookMark().getBookMarkName(), name)) { - return true; - } - } - return false; + this.innerPane.update(); } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkCombinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkCombinePane.java new file mode 100644 index 0000000000..cd46026017 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/MobileBookMarkCombinePane.java @@ -0,0 +1,69 @@ +package com.fr.design.widget.ui.designer.mobile; + +import com.fr.design.designer.creator.XCreator; +import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.widget.ui.designer.mobile.component.MobileAdvanceInnerPane; +import com.fr.design.widget.ui.designer.mobile.component.MobileBookMarkUsePane; + +import javax.swing.*; +import java.awt.*; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/4/18 + */ +public class MobileBookMarkCombinePane extends MobileWidgetDefinePane { + + private MobileBookMarkUsePane mobileBookMarkUsePane; + private MobileAdvanceInnerPane mobileAdvanceInnerPane; + private XCreator xCreator; + + + public MobileBookMarkCombinePane(XCreator xCreator) { + this.xCreator = xCreator; + } + + @Override + public void initPropertyGroups(Object source) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.mobileAdvanceInnerPane = new MobileAdvanceInnerPane(xCreator); + this.mobileBookMarkUsePane = new MobileBookMarkUsePane(); + panel.add(this.mobileBookMarkUsePane, BorderLayout.NORTH); + panel.add(this.mobileAdvanceInnerPane, BorderLayout.CENTER); + UIExpandablePane uiExpandablePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, panel); + this.add(uiExpandablePane, BorderLayout.NORTH); + } + + private void bindListeners2Widgets() { + reInitAllListeners(); + AttributeChangeListener changeListener = new AttributeChangeListener() { + @Override + public void attributeChange() { + update(); + } + }; + this.addAttributeChangeListener(changeListener); + } + + private void reInitAllListeners() { + initListener(this); + } + + @Override + public void populate(FormDesigner designer) { + this.mobileBookMarkUsePane.populate(xCreator); + this.mobileAdvanceInnerPane.populate(); + this.bindListeners2Widgets(); + } + + @Override + public void update() { + this.mobileBookMarkUsePane.update(xCreator); + this.mobileAdvanceInnerPane.update(); + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java index 5cf7f74f78..5919985d59 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/TabMobileWidgetDefinePane.java @@ -5,6 +5,7 @@ import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.foldablepane.UIExpandablePane; +import com.fr.design.form.util.FormDesignerUtils; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; @@ -14,6 +15,8 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.accessibles.AccessibleTemplateStyleEditor; import com.fr.design.mainframe.widget.accessibles.MobileTemplateStylePane; +import com.fr.design.widget.ui.designer.mobile.component.MobileAdvanceInnerPane; +import com.fr.design.widget.ui.designer.mobile.component.MobileBookMarkUsePane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentMarginPane; import com.fr.design.widget.ui.designer.mobile.component.MobileComponentLayoutIntervalPane; import com.fr.form.ui.container.cardlayout.WCardTagLayout; @@ -30,6 +33,7 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { private AttributeChangeListener changeListener; private MobileComponentMarginPane marginPane; private MobileComponentLayoutIntervalPane intervalPane; + private MobileBookMarkUsePane mobileBookMarkUsePane; public TabMobileWidgetDefinePane(XCreator xCreator) { this.xCreator = xCreator; @@ -62,9 +66,15 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { JPanel holder = FRGUIPaneFactory.createBorderLayout_S_Pane(); holder.add(jPanel, BorderLayout.NORTH); if (!shouldHidePadding(designer)) { + JPanel innerAdvancePane = FRGUIPaneFactory.createBorderLayout_S_Pane(); marginPane = new MobileComponentMarginPane(FormTabPaddingAttrMark.XML_TAG); intervalPane = new MobileComponentLayoutIntervalPane(FormTabPaddingAttrMark.XML_TAG); - UIExpandablePane advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, marginPane); + if (FormDesignerUtils.isAppRelayout(designer)) { + mobileBookMarkUsePane = new MobileBookMarkUsePane(); + innerAdvancePane.add(mobileBookMarkUsePane, BorderLayout.CENTER); + } + innerAdvancePane.add(marginPane, BorderLayout.NORTH); + UIExpandablePane advancePane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 280, 20, innerAdvancePane); UIExpandablePane layoutPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Layout"), 280, 20, intervalPane); //高级 holder.add(advancePane, BorderLayout.CENTER); @@ -77,27 +87,35 @@ public class TabMobileWidgetDefinePane extends MobileWidgetDefinePane { @Override public void populate(FormDesigner designer) { - templateStyleEditor.setValue(((WCardTagLayout) xCreator.toData()).getMobileTemplateStyle()); + WCardTagLayout wCardTagLayout = (WCardTagLayout) xCreator.toData(); + templateStyleEditor.setValue((wCardTagLayout).getMobileTemplateStyle()); // 数据 populate 完成后,再设置监听 this.bindListeners2Widgets(); this.addAttributeChangeListener(changeListener); if (marginPane != null) {//业务层面可以写成shouldHidePadding但是这样写应该性能差点 - marginPane.populate((WCardTagLayout) xCreator.toData()); + marginPane.populate(wCardTagLayout); } if (intervalPane != null) { - intervalPane.populate((WCardTagLayout) xCreator.toData()); + intervalPane.populate(wCardTagLayout); + } + if (mobileBookMarkUsePane != null) { + mobileBookMarkUsePane.populate(xCreator); } } @Override public void update() { - ((WCardTagLayout) xCreator.toData()).setMobileTemplateStyle((MobileTemplateStyle) templateStyleEditor.getValue()); + WCardTagLayout wCardTagLayout = (WCardTagLayout) xCreator.toData(); + (wCardTagLayout).setMobileTemplateStyle((MobileTemplateStyle) templateStyleEditor.getValue()); DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 if (marginPane != null) { - marginPane.update((WCardTagLayout) xCreator.toData()); + marginPane.update(wCardTagLayout); } if (intervalPane != null) { - intervalPane.update((WCardTagLayout) xCreator.toData()); + intervalPane.update(wCardTagLayout); + } + if (mobileBookMarkUsePane != null) { + mobileBookMarkUsePane.update(xCreator); } } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileAdvanceInnerPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileAdvanceInnerPane.java new file mode 100644 index 0000000000..33a957479b --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileAdvanceInnerPane.java @@ -0,0 +1,169 @@ +package com.fr.design.widget.ui.designer.mobile.component; + +import com.fr.design.constants.LayoutConstants; +import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.FineJOptionPane; +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.FRGUIPaneFactory; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.form.main.Form; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WLayout; +import com.fr.form.ui.container.WSortLayout; +import com.fr.form.ui.mobile.MobileBookMark; +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.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.List; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/4/17 + */ +public class MobileAdvanceInnerPane extends BasicPane { + + private XCreator xCreator; + private UICheckBox useBookMarkCheck; + private UITextField bookMarkNameField; + + + public MobileAdvanceInnerPane(XCreator xCreator) { + this.xCreator = xCreator; + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + initComponent(); + } + + private void initComponent() { + JPanel contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + this.useBookMarkCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_Use_BookMark"), false); + this.bookMarkNameField = new UITextField() { + @Override + protected void initListener() { + if (shouldResponseChangeListener()) { + addFocusListener(new FocusAdapter() { + @Override + public void focusLost(FocusEvent e) { + attributeChange(); + } + }); + addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + attributeChange(); + } + } + }); + } + } + }; + JPanel useBookMarkPane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{useBookMarkCheck}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); + final JPanel bookMarkNamePane = TableLayoutHelper.createGapTableLayoutPane( + new Component[][]{new Component[]{new UILabel( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_Name")), bookMarkNameField}}, + TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.HGAP_LARGE); + this.useBookMarkCheck.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + boolean selected = MobileAdvanceInnerPane.this.useBookMarkCheck.isSelected(); + Widget widget = MobileAdvanceInnerPane.this.xCreator.toData(); + MobileBookMark bookMark = widget.getMobileBookMark(); + bookMarkNamePane.setVisible(selected); + if (selected && StringUtils.isEmpty(bookMark.getBookMarkName())) { + String name = widget.getWidgetName(); + MobileAdvanceInnerPane.this.bookMarkNameField.setText(name); + bookMark.setBookMarkName(name); + } + } + }); + bookMarkNamePane.setVisible(xCreator.toData().getMobileBookMark().isUseBookMark()); + contentPane.add(useBookMarkPane, BorderLayout.NORTH); + contentPane.add(bookMarkNamePane, BorderLayout.CENTER); + this.add(contentPane); + initData(); + } + + private void initData() { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + String bookMarkName = bookMark.getBookMarkName(); + if (StringUtils.isEmpty(bookMarkName)) { + String widgetName = xCreator.toData().getWidgetName(); + this.bookMarkNameField.setText(widgetName); + bookMark.setBookMarkName(widgetName); + } else { + this.bookMarkNameField.setText(bookMarkName); + } + } + + public void populate() { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + this.bookMarkNameField.setText(bookMark.getBookMarkName()); + if (bookMark.isFrozen()) { + this.useBookMarkCheck.setSelected(false); + this.useBookMarkCheck.setEnabled(false); + } else { + this.useBookMarkCheck.setSelected(bookMark.isUseBookMark()); + } + } + + public void update() { + MobileBookMark bookMark = xCreator.toData().getMobileBookMark(); + bookMark.setUseBookMark(this.useBookMarkCheck.isSelected()); + String newBookMarkName = this.bookMarkNameField.getText(); + DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); + if (ComparatorUtils.equals(newBookMarkName, bookMark.getBookMarkName())) { + return; + } + if (!isExist(newBookMarkName)) { + bookMark.setBookMarkName(newBookMarkName); + } else { + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Mobile_BookMark_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")); + this.bookMarkNameField.setText(bookMark.getBookMarkName()); + } + } + + private boolean isExist(String name) { + Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); + WLayout container = form.getContainer(); + WSortLayout wSortLayout = (WSortLayout) container.getWidget(container.getWidgetCount() - 1); + List list = wSortLayout.getOrderedMobileWidgetList(); + for (String value : list) { + Widget widget = form.getWidgetByName(value); + if (widget != null && ComparatorUtils.equals(widget.getMobileBookMark().getBookMarkName(), name)) { + return true; + } + CRBoundsWidget boundsWidget = (CRBoundsWidget) wSortLayout.getWidget(value); + if (boundsWidget != null && ComparatorUtils.equals(boundsWidget.getWidget().getMobileBookMark().getBookMarkName(), name)) { + return true; + } + } + return false; + } + + @Override + protected String title4PopupWindow() { + return "MobileAdvanceInnerPane"; + } +} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java index fb4148629a..7038330697 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileBookMarkUsePane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer.mobile.component; import com.fr.design.designer.IntervalConstants; +import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.creator.XCreator; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; @@ -8,12 +9,11 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.form.ui.container.WLayout; 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.Color; import java.awt.Component; @@ -77,6 +77,7 @@ public class MobileBookMarkUsePane extends BasicPane { public void update(XCreator xCreator) { WLayout wLayout = ((WLayout) xCreator.toData()); wLayout.setShowBookmarks(showHierarchicalBookmarksCheck.isSelected()); + WidgetPropertyPane.getInstance().getEditingFormDesigner().getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); } @Override diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java index 2492650972..de86a07f2b 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileComponentFrozenPane.java @@ -11,9 +11,12 @@ import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.main.Form; import com.fr.form.ui.FormWidgetHelper; import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WSortLayout; +import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.stable.ArrayUtils; import javax.swing.BorderFactory; @@ -58,6 +61,7 @@ public class MobileComponentFrozenPane extends BasicPane { } List widgetList = ((WSortLayout) selectedModel).getNonContainerWidgetList(); + widgetList.removeAll(frozenWidgets()); return widgetList.toArray(new String[0]); } @@ -99,6 +103,21 @@ public class MobileComponentFrozenPane extends BasicPane { uiComboCheckBox.setSelectedValues(map); } + private List frozenWidgets() { + Form form = WidgetPropertyPane.getInstance().getEditingFormDesigner().getTarget(); + WLayout container = form.getContainer(); + WSortLayout wSortLayout = (WSortLayout) container.getWidget(container.getWidgetCount() - 1); + List list = wSortLayout.getNonContainerWidgetList(); + List widgets = new ArrayList<>(); + for (String value : list) { + CRBoundsWidget boundsWidget = (CRBoundsWidget) wSortLayout.getWidget(value); + if (boundsWidget.getWidget().getMobileBookMark().isUseBookMark()) { + widgets.add(value); + } + } + return widgets; + } + @Override protected String title4PopupWindow() { return "ComponentFrozenPane"; diff --git a/designer-form/src/test/java/com/fr/design/designer/beans/models/SelectionModelTest.java b/designer-form/src/test/java/com/fr/design/designer/beans/models/SelectionModelTest.java new file mode 100644 index 0000000000..6ab4dd3088 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/designer/beans/models/SelectionModelTest.java @@ -0,0 +1,100 @@ +package com.fr.design.designer.beans.models; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.designer.beans.events.CreatorEventListenerTable; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.fun.ClipboardHandlerProvider; +import com.fr.design.fun.impl.AbstractClipboardHandlerProvider; +import com.fr.design.mainframe.FormDesigner; +import com.fr.plugin.injectable.PluginModule; +import com.fr.stable.fun.mark.Mutable; +import org.easymock.EasyMock; +import org.easymock.IAnswer; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; + +import java.util.HashSet; +import java.util.Set; + +@PrepareForTest(PluginModule.class) +@SuppressStaticInitializationFor({"com.fr.design.mainframe.FormDesigner"}) +@PowerMockIgnore("javax.swing.*") +@RunWith(PowerMockRunner.class) +public class SelectionModelTest { + + @Before + public void setUp() throws Exception { + + AbstractClipboardHandlerProvider provider = EasyMock.mock(AbstractClipboardHandlerProvider.class); + EasyMock.expect(provider.cut(EasyMock.anyObject())).andAnswer(new IAnswer() { + @Override + public Object answer() throws Throwable { + return null; + } + }).anyTimes(); + EasyMock.expect(provider.copy(EasyMock.anyObject())).andAnswer(new IAnswer() { + @Override + public Object answer() throws Throwable { + return EasyMock.getCurrentArguments()[0]; + } + }).anyTimes(); + EasyMock.expect(provider.support(EasyMock.anyObject())).andReturn(true).anyTimes(); + EasyMock.expect(provider.paste(EasyMock.anyObject())).andReturn(null).anyTimes(); + EasyMock.replay(provider); + + Set providers = new HashSet<>(); + providers.add(provider); + + ExtraDesignClassManager designManager = EasyMock.mock(ExtraDesignClassManager.class); + EasyMock.expect(designManager.getArray(ClipboardHandlerProvider.XML_TAG)) + .andReturn(providers) + .anyTimes(); + EasyMock.expect(designManager.getArray("DesignerEditListenerProvider")) + .andReturn(new HashSet()) + .anyTimes(); + EasyMock.replay(designManager); + + PowerMock.mockStatic(PluginModule.class); + EasyMock.expect(PluginModule.getAgent(PluginModule.ExtraDesign)) + .andReturn(designManager) + .anyTimes(); + PowerMock.replayAll(); + } + + @After + public void tearDown() throws Exception { + + PowerMock.resetAll(); + } + + @Test + public void testPaste() { + + FormDesigner formDesigner = EasyMock.partialMockBuilder(FormDesigner.class).createMock(); + XCreator xCreator = EasyMock.mock(XCreator.class); + EasyMock.expect(xCreator.acceptType(EasyMock.anyObject(Class[].class))).andReturn(true).anyTimes(); + CreatorEventListenerTable table = new CreatorEventListenerTable(); + Whitebox.setInternalState(formDesigner, "edit", table); + EasyMock.replay(formDesigner, xCreator); + + SelectionModel model = new SelectionModel(formDesigner); + model.cutSelectedCreator2ClipBoard(); + boolean paste1 = model.pasteFromClipBoard(); + Assert.assertFalse(paste1); + + model.setSelectedCreator(xCreator); + model.copySelectedCreator2ClipBoard(); + boolean paste2 = model.pasteFromClipBoard(); + Assert.assertFalse(paste2); + } + +} \ No newline at end of file diff --git a/designer-form/src/test/java/com/fr/design/designer/creator/XCreatorUtilsTest.java b/designer-form/src/test/java/com/fr/design/designer/creator/XCreatorUtilsTest.java new file mode 100644 index 0000000000..1efd752d13 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/designer/creator/XCreatorUtilsTest.java @@ -0,0 +1,17 @@ +package com.fr.design.designer.creator; + +import com.fr.form.ui.EditorHolder; +import org.junit.Assert; +import org.junit.Test; + +public class XCreatorUtilsTest { + + @Test + public void testCreateXCreator() throws Exception { + + XCreator xCreator = XCreatorUtils.createXCreator(new EditorHolder() { + }); + + Assert.assertFalse(xCreator instanceof NullCreator); + } +} \ No newline at end of file diff --git a/designer-form/src/test/java/com/fr/design/form/util/FontTransformUtilTest.java b/designer-form/src/test/java/com/fr/design/form/util/FontTransformUtilTest.java new file mode 100644 index 0000000000..224ca551c4 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/form/util/FontTransformUtilTest.java @@ -0,0 +1,68 @@ +package com.fr.design.form.util; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.FormAdaptiveConfigUIProcessor; +import com.fr.stable.Constants; +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.modules.junit4.PowerMockRunner; + +/** + * Created by kerry on 2020-05-14 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(ExtraDesignClassManager.class) +public class FontTransformUtilTest { + + @Test + public void testGetDesignerFontResolution() { + mockEnvironment(Constants.DEFAULT_FONT_PAINT_RESOLUTION); + Assert.assertEquals(Constants.DEFAULT_FONT_PAINT_RESOLUTION, FontTransformUtil.getDesignerFontResolution()); + + mockEnvironment(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION); + Assert.assertEquals(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION, FontTransformUtil.getDesignerFontResolution()); + + } + + @Test + public void testPt2px() { + mockEnvironment(Constants.DEFAULT_FONT_PAINT_RESOLUTION); + Assert.assertEquals(12, (int) FontTransformUtil.pt2px(12)); + + mockEnvironment(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION); + Assert.assertEquals(16, (int) FontTransformUtil.pt2px(12)); + } + + @Test + public void testPx2pt() { + mockEnvironment(Constants.DEFAULT_FONT_PAINT_RESOLUTION); + Assert.assertEquals(12, (int) FontTransformUtil.px2pt(12)); + + mockEnvironment(Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION); + Assert.assertEquals(9, (int) FontTransformUtil.px2pt(12)); + } + + + private void mockEnvironment(int dpi) { + ExtraDesignClassManager mockDesignManager = EasyMock.mock(ExtraDesignClassManager.class); + EasyMock.expect(mockDesignManager.getSingle(FormAdaptiveConfigUIProcessor.MARK_STRING)) + .andReturn(mockProcessor(dpi)).anyTimes(); + EasyMock.replay(mockDesignManager); + + PowerMock.mockStatic(ExtraDesignClassManager.class); + EasyMock.expect(ExtraDesignClassManager.getInstance()).andReturn(mockDesignManager).once(); + PowerMock.replayAll(ExtraDesignClassManager.class); + } + + private FormAdaptiveConfigUIProcessor mockProcessor(int dpi) { + FormAdaptiveConfigUIProcessor processor = EasyMock.mock(FormAdaptiveConfigUIProcessor.class); + EasyMock.expect(processor.fontResolution()).andReturn(dpi).once(); + EasyMock.replay(processor); + return processor; + } + +} diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java new file mode 100644 index 0000000000..474f580e3d --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java @@ -0,0 +1,90 @@ +package com.fr.design.mainframe.template.info; + +import com.fr.form.ui.CardAddButton; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.FreeButton; +import com.fr.form.ui.TextEditor; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteBodyLayout; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WCardLayout; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.general.ComparatorUtils; +import com.fr.json.JSONObject; +import org.junit.Assert; +import org.junit.Test; + +import java.awt.Rectangle; + +/** + * Created by kerry on 2020-05-08 + */ +public class ComponentCreateOperateTest { + + @Test + public void testConstructor() { + ElementCaseEditor caseEditor = new ElementCaseEditor(); + caseEditor.setWidgetName("report0"); + caseEditor.setWidgetID("xxxx0"); + WTitleLayout wTitleLayout = new WTitleLayout(); + wTitleLayout.addBody(caseEditor, new Rectangle()); + ComponentOperate componentOperate0 = new ComponentCreateOperate(caseEditor); + ComponentOperate componentOperate1 = new ComponentCreateOperate(wTitleLayout); + ComparatorUtils.equals(componentOperate0.toJSONObject(), componentOperate1.toJSONObject()); + + WScaleLayout scaleLayout = new WScaleLayout(); + TextEditor textEditor = new TextEditor(); + scaleLayout.addWidget(new CRBoundsWidget(textEditor, new Rectangle())); + ComponentOperate componentOperate3 = new ComponentCreateOperate(scaleLayout); + ComponentOperate componentOperate4 = new ComponentCreateOperate(textEditor); + ComparatorUtils.equals(componentOperate3.toJSONObject(), componentOperate4.toJSONObject()); + + + WCardMainBorderLayout wCardMainBorderLayout = new WCardMainBorderLayout(); + WCardLayout wCardLayout = new WCardLayout(); + wCardMainBorderLayout.addCenter(wCardLayout); + ComponentOperate componentOperate5 = new ComponentCreateOperate(wCardMainBorderLayout); + ComponentOperate componentOperate6 = new ComponentCreateOperate(wCardLayout); + ComparatorUtils.equals(componentOperate5.toJSONObject(), componentOperate6.toJSONObject()); + + } + + @Test + public void testToJSONObject() { + Widget button = new FreeButton(); + button.setWidgetName("button1"); + ComponentCreateOperate info = new ComponentCreateOperate(button); + button.setWidgetID("xxxxxxx"); + JSONObject jo = info.toJSONObject(); + Assert.assertEquals("xxxxxxx", jo.optString("componentID")); + Assert.assertEquals("button1", jo.optString("componentName")); + Assert.assertEquals("Widget", jo.optString("componentType")); + Assert.assertEquals("0", jo.optString("deleteTime")); + } + + @Test + public void testComponentType() { + Assert.assertEquals(ComponentOperate.ComponentType.Widget, ComponentOperate.ComponentType.parseType(new FreeButton())); + Assert.assertEquals(ComponentOperate.ComponentType.Report, ComponentOperate.ComponentType.parseType(new ElementCaseEditor())); + Assert.assertEquals(ComponentOperate.ComponentType.Chart, ComponentOperate.ComponentType.parseType(new ChartEditor())); + Assert.assertEquals(ComponentOperate.ComponentType.Absolute, ComponentOperate.ComponentType.parseType(new WAbsoluteLayout())); + Assert.assertEquals(ComponentOperate.ComponentType.TabLayout, ComponentOperate.ComponentType.parseType(new WCardLayout())); + } + + @Test + public void testSupportComponent() { + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new FreeButton())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new ElementCaseEditor())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new ChartEditor())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new WAbsoluteLayout())); + Assert.assertTrue(ComponentOperate.ComponentType.supportComponent(new WCardLayout())); + Assert.assertFalse(ComponentOperate.ComponentType.supportComponent(new CardSwitchButton())); + Assert.assertFalse(ComponentOperate.ComponentType.supportComponent(new CardAddButton())); + Assert.assertFalse(ComponentOperate.ComponentType.supportComponent(new WAbsoluteBodyLayout())); + } +} diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java new file mode 100644 index 0000000000..663be87581 --- /dev/null +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java @@ -0,0 +1,179 @@ +package com.fr.design.mainframe.template.info; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.form.main.Form; +import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.FreeButton; +import com.fr.form.ui.container.WAbsoluteBodyLayout; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WBorderLayout; +import com.fr.form.ui.container.WCardLayout; +import com.fr.form.ui.container.WFitLayout; +import com.fr.form.ui.container.WParameterLayout; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import com.fr.invoke.Reflect; +import com.fr.json.JSONArray; +import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.report.cell.DefaultTemplateCellElement; +import com.fr.report.worksheet.FormElementCase; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by kerry on 2020-05-08 + */ +public class JFormProcessInfoTest { + @Test + public void testHasTestECReport() { + Form form = new Form(); + WFitLayout wFitLayout = new WFitLayout(); + ElementCaseEditor editor = new ElementCaseEditor(); + FormElementCase elementCase = new FormElementCase(); + editor.setElementCase(elementCase); + wFitLayout.addWidget(editor); + form.setContainer(wFitLayout); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result1); + + elementCase.addCellElement(new DefaultTemplateCellElement()); + boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result2); + } + + @Test + public void testHasTestChart() { + Form form = new Form(); + WFitLayout wFitLayout = new WFitLayout(); + ChartEditor editor = new ChartEditor(); + ChartCollection collection = new ChartCollection(); + editor.resetChangeChartCollection(collection); + wFitLayout.addWidget(editor); + form.setContainer(wFitLayout); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestChart").get(); + Assert.assertTrue(result1); + + collection.addChart(new VanChart()); + boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestChart").get(); + Assert.assertTrue(result2); + + } + + @Test + public void testHasTestTabLayout() { + Form form = new Form(); + WFitLayout wFitLayout = new WFitLayout(); + WCardLayout editor = new WCardLayout(); + wFitLayout.addWidget(editor); + form.setContainer(wFitLayout); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestTabLayout").get(); + Assert.assertFalse(result1); + + WCardTagLayout tagLayout = new WCardTagLayout(); + CardSwitchButton button = new CardSwitchButton(); + button.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title") + "0"); + tagLayout.addWidget(button); + editor.addWidget(tagLayout); + boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestTabLayout").get(); + Assert.assertTrue(result2); + + button.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title") + "test"); + boolean result3 = Reflect.on(jFormProcessInfo).call("hasTestTabLayout").get(); + Assert.assertFalse(result3); + + } + + @Test + public void testHasTestAbsolutePane() { + Form form = new Form(); + WFitLayout wFitLayout = new WFitLayout(); + WAbsoluteLayout editor = new WAbsoluteLayout(); + wFitLayout.addWidget(editor); + form.setContainer(wFitLayout); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestAbsolutePane").get(); + Assert.assertTrue(result1); + + editor.addWidget(new FreeButton()); + boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestAbsolutePane").get(); + Assert.assertFalse(result2); + } + + @Test + public void testHasEmptyParaPane() { + Form form = new Form(); + WBorderLayout borderLayout = new WBorderLayout(); + form.setContainer(borderLayout); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + boolean result1 = Reflect.on(jFormProcessInfo).call("hasEmptyParaPane").get(); + Assert.assertFalse(result1); + + borderLayout.addNorth(new WParameterLayout()); + boolean result2 = Reflect.on(jFormProcessInfo).call("hasEmptyParaPane").get(); + Assert.assertTrue(result2); + } + + @Test + public void testUseParaPane() { + Form form = new Form(); + WBorderLayout borderLayout = new WBorderLayout(); + form.setContainer(borderLayout); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + Assert.assertFalse(jFormProcessInfo.useParaPane()); + + borderLayout.addNorth(new WParameterLayout()); + Assert.assertTrue(jFormProcessInfo.useParaPane()); + + } + + @Test + public void testGetComponentsInfo() { + Form form = new Form(); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + FreeButton button1 = new FreeButton(); + FreeButton button2 = new FreeButton(); + button1.setWidgetID("xxxx1"); + button2.setWidgetID("xxxx2"); + Reflect.on(jFormProcessInfo).call("addComponentCreateInfo", new ComponentCreateOperate(button1).toJSONObject()); + Reflect.on(jFormProcessInfo).call("addComponentRemoveInfo", new ComponentDeleteOperate(button2).toJSONObject()); + JSONArray ja = jFormProcessInfo.getComponentsInfo(); + Assert.assertEquals(2, ja.size()); + + Reflect.on(jFormProcessInfo).call("addComponentCreateInfo", new ComponentCreateOperate(button1).toJSONObject()); + FreeButton button3 = new FreeButton(); + Reflect.on(jFormProcessInfo).call("addComponentRemoveInfo", new ComponentDeleteOperate(button3).toJSONObject()); + Assert.assertEquals(1, jFormProcessInfo.getComponentsInfo().size()); + + ja = jFormProcessInfo.getComponentsInfo(); + Assert.assertEquals(0, ja.size()); + } + + @Test + public void testGetWidgetCount() { + Form form = new Form(); + WBorderLayout borderLayout = new WBorderLayout(); + form.setContainer(borderLayout); + WFitLayout fitLayout = new WFitLayout(); + borderLayout.addCenter(fitLayout); + fitLayout.addWidget(new FreeButton()); + fitLayout.addWidget(new ElementCaseEditor()); + JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); + Assert.assertEquals(2, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new ChartEditor()); + Assert.assertEquals(3, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new WAbsoluteBodyLayout()); + Assert.assertEquals(3, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new CardSwitchButton()); + Assert.assertEquals(3, jFormProcessInfo.getWidgetCount()); + + fitLayout.addWidget(new ChartEditor()); + Assert.assertEquals(4, jFormProcessInfo.getWidgetCount()); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java index 3ea8d984b2..66870ff6fe 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/NewPresentAction.java @@ -9,9 +9,13 @@ import com.fr.general.GeneralUtils; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.Selection; +import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; +import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.StableUtils; +import java.awt.*; + public class NewPresentAction extends PresentCheckBoxAction { private String itemName = null; @@ -28,10 +32,28 @@ public class NewPresentAction extends PresentCheckBoxAction { if (!ComparatorUtils.equals(this.itemName, "NOPRESENT")) { CellElementPropertyPane.getInstance().GoToPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Present"), this.itemName); } else { - TemplateCellElement ce = getSelectedCellElement(); - // 只有原来ce设置了形态的情况下才有undo操作 - if (ce != null && ce.getPresent() != null) { - ce.setPresent(null); + ElementCasePane ePane = this.getEditingComponent(); + TemplateElementCase elementCase = ePane.getEditingElementCase(); + Selection sel = ePane.getSelection(); + if (sel instanceof CellSelection) { + CellSelection cs = (CellSelection) sel; + int cellRectangleCount = cs.getCellRectangleCount(); + for (int rect = 0; rect < cellRectangleCount; rect++) { + Rectangle cellRectangle = cs.getCellRectangle(rect); + for (int j = 0; j < cellRectangle.height; j++) { + for (int i = 0; i < cellRectangle.width; i++) { + int column = i + cellRectangle.x; + int row = j + cellRectangle.y; + TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row); + if (cellElement == null) { + cellElement = new DefaultTemplateCellElement(column, row); + elementCase.addCellElement(cellElement); + } else if (cellElement.getPresent() != null) { + cellElement.setPresent(null); + } + } + } + } return true; } else { return false; diff --git a/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java b/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java index c9cc9e1b59..f7e86d2c03 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnRowSizingAction.java @@ -4,20 +4,18 @@ package com.fr.design.actions.columnrow; import com.fr.design.DesignerEnvManager; +import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.gui.frpane.UnitInputPane; import com.fr.design.gui.frpane.UnitInputPane.ValueNotChangeException; import com.fr.design.mainframe.DesignerContext; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.fun.ReportLengthUNITProvider; +import com.fr.design.unit.UnitConvertUtil; import com.fr.grid.selection.CellSelection; import com.fr.report.elementcase.ElementCase; import com.fr.stable.ArrayUtils; -import com.fr.stable.Constants; -import com.fr.stable.unit.CM; -import com.fr.stable.unit.INCH; -import com.fr.stable.unit.MM; -import com.fr.stable.unit.PT; import com.fr.stable.unit.UNIT; /** @@ -28,7 +26,7 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction protected ColumnRowSizingAction(ElementCasePane t, int indexOfColumnOrRow) { super(t, indexOfColumnOrRow); } - + @Override protected boolean executeActionReturnUndoRecordNeededWithCellSelection( CellSelection cs) { @@ -43,7 +41,7 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction }; UNIT len = getShowLen(report, cs); populateNumberDialog(uPane, len); - + final CellSelection finalCS = cs; uPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @@ -52,21 +50,13 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction try { float newHeight = (float) uPane.update(); int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); - UNIT len; - if (unitType == Constants.UNIT_CM) { - len = new CM(newHeight); - } else if (unitType == Constants.UNIT_INCH) { - len = new INCH(newHeight); - } else if (unitType == Constants.UNIT_PT) { - len = new PT(newHeight); - } else { - len = new MM(newHeight); - } + ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); + UNIT len = lengthUNIT.float2UNIT(newHeight); updateAction(report, len, finalCS); } catch (ValueNotChangeException e) { // nothing } - + ePane.fireTargetModified(); } }).setVisible(true); @@ -75,28 +65,16 @@ public abstract class ColumnRowSizingAction extends AbstractColumnRowIndexAction protected void populateNumberDialog(final UnitInputPane uPane, UNIT unit) { int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit(); - float va; - if (unitType == Constants.UNIT_CM) { - va = unit.toCMValue4Scale2(); - uPane.setUnitText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM")); - } else if (unitType == Constants.UNIT_INCH) { - va = unit.toINCHValue4Scale3(); - uPane.setUnitText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH")); - } else if (unitType == Constants.UNIT_PT) { - va = unit.toPTValue4Scale2(); - uPane.setUnitText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_PT")); - } else { - va = unit.toMMValue4Scale2(); - uPane.setUnitText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_MM")); - } - + ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); + float va = lengthUNIT.unit2Value4Scale(unit); + uPane.setUnitText(lengthUNIT.unitText()); uPane.populate(va); } - + protected abstract String title4UnitInputPane(); - + protected abstract void updateAction(ElementCase report, UNIT len, CellSelection cs); - + protected abstract UNIT getShowLen(ElementCase report, CellSelection cs); protected abstract UNIT getIndexLen(int index, ElementCase report); diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java index a31108f2c4..a002f56e8a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportMobileAttrAction.java @@ -1,5 +1,6 @@ package com.fr.design.actions.report; +import com.fr.base.PaperSize; import com.fr.base.iofile.attr.MobileOnlyTemplateAttrMark; import com.fr.design.actions.JWorkBookAction; import com.fr.design.dialog.BasicDialog; @@ -13,8 +14,10 @@ import com.fr.general.IOUtils; import com.fr.intelli.record.Focus; import com.fr.main.TemplateWorkBook; +import com.fr.page.PaperSettingProvider; import com.fr.record.analyzer.EnableMetrics; import com.fr.report.mobile.ElementCaseMobileAttr; +import com.fr.report.report.Report; import javax.swing.*; import java.awt.event.ActionEvent; @@ -51,6 +54,7 @@ public class ReportMobileAttrAction extends JWorkBookAction{ final ReportMobileAttrPane mobileAttrPane = new ReportMobileAttrPane(); mobileAttrPane.populateBean(mobileAttr); + final boolean oldMobileCanvasSize = mobileAttr.isMobileCanvasSize(); BasicDialog dialog = mobileAttrPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override public void doOk() { @@ -69,7 +73,16 @@ public class ReportMobileAttrAction extends JWorkBookAction{ } recordFunction(); // 设置移动端属性并刷新界面 - wbTpl.setReportMobileAttr(elementCaseMobileAttr); // 会同时修改页面设置,放到最后 + wbTpl.setReportMobileAttr(elementCaseMobileAttr); + boolean change = !oldMobileCanvasSize && elementCaseMobileAttr.isMobileCanvasSize(); + if (change) { + // 当相关属性从未勾选到勾选状态时 设置成移动端标准页面大小 + for (int i = 0; i < wbTpl.getReportCount(); i++) { + Report report = wbTpl.getReport(i); + PaperSettingProvider paperSetting = report.getReportSettings().getPaperSetting(); + paperSetting.setPaperSize(PaperSize.PAPERSIZE_MOBILE); + } + } jwb.fireTargetModified(); } }); diff --git a/designer-realize/src/main/java/com/fr/design/actions/server/StyleListAction.java b/designer-realize/src/main/java/com/fr/design/actions/server/StyleListAction.java index 4f57bdc2ac..ff16a33633 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/server/StyleListAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/server/StyleListAction.java @@ -40,10 +40,13 @@ public class StyleListAction extends UpdateAction { public void actionPerformed(ActionEvent evt) { DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); final StyleManagerPane styleListPane = new StyleManagerPane(); - BasicDialog styleListDialog = styleListPane.showWindow(designerFrame); + final BasicDialog styleListDialog = styleListPane.showWindow(designerFrame); styleListDialog.addDialogActionListener(new DialogActionAdapter() { @Override public void doOk() { + if (!styleListPane.isNamePermitted()) { + styleListDialog.setDoOKSucceed(false); + } Configurations.modify(new WorkerFacade(ServerPreferenceConfig.class) { @Override public void run() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/server/StyleManagerPane.java b/designer-realize/src/main/java/com/fr/design/actions/server/StyleManagerPane.java index 37e62cb70c..51ca8a7d11 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/server/StyleManagerPane.java +++ b/designer-realize/src/main/java/com/fr/design/actions/server/StyleManagerPane.java @@ -34,4 +34,8 @@ public class StyleManagerPane extends BasicPane { public void update(ServerPreferenceConfig configManager) { this.styleArrayPane.update(configManager); } + + public boolean isNamePermitted() { + return styleArrayPane.isNamePermitted(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java index e97a92b4d1..f3cea39410 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/BiasTextPainterCellEditor.java @@ -88,7 +88,7 @@ public class BiasTextPainterCellEditor extends AbstractCellEditor { Window parentWindow = SwingUtilities.getWindowAncestor(grid); this.biasTextPainterPane = new BiasTextPainterPane(); Dimension dimension = this.biasTextPainterPane.getPreferredSize(); - Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * MULTIPLE)); + Dimension wrapDimension = new Dimension((int) (dimension.width * MULTIPLE), (int) (dimension.height * Math.pow(MULTIPLE, 2))); this.biasTextPainterPane.populate(biasTextPainter); return this.biasTextPainterPane.showWindowWithCustomSize(parentWindow, new DialogActionAdapter() { diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java index a7fb154e05..97efbda442 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/DSColumnCellEditor.java @@ -65,7 +65,7 @@ public class DSColumnCellEditor extends AbstractCellEditor implements DialogActi this.dsColumnPane = new DSColumnPane(); dsColumnPane.putElementcase(grid.getElementCasePane()); dsColumnPane.putCellElement(cellElement); - BasicDialog dsColumnDialog = this.dsColumnPane.showWindow(SwingUtilities.getWindowAncestor(grid)); + BasicDialog dsColumnDialog = this.dsColumnPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(grid), null, DSColumnPane.DEFAULT_DIMENSION); dsColumnDialog.addDialogActionListener(this); diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index 5fc09d53f1..52a33ff12a 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -1,5 +1,5 @@ /** - * + * */ package com.fr.design.cell.editor; @@ -8,6 +8,7 @@ import com.fr.base.BaseUtils; import com.fr.base.Utils; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.form.util.FontTransformUtil; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.UIFormula; import com.fr.design.gui.ibutton.UIButton; @@ -21,7 +22,6 @@ import com.fr.design.style.color.UIToolbarColorButton; import com.fr.general.FRFont; import com.fr.log.FineLoggerFactory; import com.fr.report.cell.cellattr.core.RichTextConverter; -import com.fr.stable.Constants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -71,17 +71,17 @@ public class RichTextToolBar extends BasicPane{ private UIToggleButton superPane; private UIToggleButton subPane; private UIToggleButton formulaPane; - + //外部传进来的 private RichTextEditingPane textPane; public RichTextToolBar() { this.initComponents(); } - + public RichTextToolBar(RichTextEditingPane textPane) { this.textPane = textPane; - + this.initComponents(); } @@ -96,14 +96,14 @@ public class RichTextToolBar extends BasicPane{ //添加到工具栏 addToToolBar(); } - + private void initAllButton(){ fontNameComboBox = new UIComboBox(Utils.getAvailableFontFamilyNames4Report()); fontNameComboBox.setPreferredSize(new Dimension(144, 20)); fontSizeComboBox = new UIComboBox(FRFontPane.getFontSizes()); colorSelectPane = new UIToolbarColorButton(BaseUtils.readIcon("/com/fr/design/images/gui/color/foreground.png")); colorSelectPane.set4Toolbar(); - + bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); @@ -120,7 +120,7 @@ public class RichTextToolBar extends BasicPane{ //绑定监听器 bindListener(); } - + private void setAllButtonStyle(){ setButtonStyle(bold); setButtonStyle(italic); @@ -129,7 +129,7 @@ public class RichTextToolBar extends BasicPane{ setButtonStyle(superPane); setButtonStyle(formulaPane); } - + private void setButtonStyle(UIButton button){ button.setNormalPainted(false); button.setBackground(null); @@ -137,10 +137,10 @@ public class RichTextToolBar extends BasicPane{ button.setPreferredSize(BUTTON_SIZE); button.setBorderPaintedOnlyWhenPressed(true); } - + private void addToToolBar(){ this.setLayout(new FlowLayout(FlowLayout.LEFT)); - + this.add(fontNameComboBox); this.add(fontSizeComboBox); this.add(bold); @@ -151,14 +151,14 @@ public class RichTextToolBar extends BasicPane{ this.add(subPane); this.add(formulaPane); } - + private void bindListener(){ FRFont defaultFont = (this.textPane != null) ? FRFont.getInstance(this.textPane.getFont()) : RichTextPane.DEFAUL_FONT; fontNameComboBox.addItemListener(fontNameItemListener); - fontNameComboBox.setSelectedItem(defaultFont.getFontName()); + fontNameComboBox.setSelectedItem(defaultFont.getFamily()); fontSizeComboBox.addItemListener(fontSizeItemListener); fontSizeComboBox.setSelectedItem(scaleDown(defaultFont.getSize())); - + bold.addActionListener(blodChangeAction); italic.addActionListener(itaChangeAction); underline.addActionListener(underlineChangeAction); @@ -166,7 +166,7 @@ public class RichTextToolBar extends BasicPane{ superPane.addActionListener(superChangeAction); colorSelectPane.addColorChangeListener(colorChangeAction); formulaPane.addActionListener(formulaActionListener); - + //选中文字的监听器 textPane.addCaretListener(textCareListener); textPane.addMouseListener(setMouseCurrentStyle); @@ -192,32 +192,32 @@ public class RichTextToolBar extends BasicPane{ subPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sub_Script")); formulaPane.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula")); } - + /** * 移除输入监听 * 用于populate时, 插入字符串, 那时不需要插入监听 - * + * * * @date 2015-1-5-下午5:13:04 - * + * */ public void removeInputListener(){ this.textPane.getDocument().removeDocumentListener(inputListener); } - + /** * 增加输入监听事件 - * + * * * @date 2015-1-5-下午5:13:26 - * + * */ public void addInputListener(){ this.textPane.getDocument().addDocumentListener(inputListener); } - + private ActionListener blodChangeAction = new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { boolean isBold = RichTextToolBar.this.bold.isSelected(); @@ -227,9 +227,9 @@ public class RichTextToolBar extends BasicPane{ setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - + private ActionListener itaChangeAction = new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { boolean isIta = RichTextToolBar.this.italic.isSelected(); @@ -239,9 +239,9 @@ public class RichTextToolBar extends BasicPane{ setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - + private ActionListener underlineChangeAction = new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { boolean isUnder = RichTextToolBar.this.underline.isSelected(); @@ -252,7 +252,7 @@ public class RichTextToolBar extends BasicPane{ } }; private ActionListener subChangeAction = new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { boolean isSub = RichTextToolBar.this.subPane.isSelected(); @@ -263,7 +263,7 @@ public class RichTextToolBar extends BasicPane{ } }; private ActionListener superChangeAction = new ActionListener() { - + @Override public void actionPerformed(ActionEvent e) { boolean isSuper = RichTextToolBar.this.superPane.isSelected(); @@ -273,7 +273,7 @@ public class RichTextToolBar extends BasicPane{ setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - + private ChangeListener colorChangeAction = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { @@ -285,13 +285,13 @@ public class RichTextToolBar extends BasicPane{ setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - + // 设置文本区选择文本的样式 private void setCharacterAttributes(JEditorPane editor, AttributeSet attr, boolean replace) { //注意不要失焦 textPane.requestFocus(); - + // 取得选择文本的起始位置和结束位置 int start = editor.getSelectionStart(); int end = editor.getSelectionEnd(); @@ -303,19 +303,19 @@ public class RichTextToolBar extends BasicPane{ doc.setCharacterAttributes(start, end - start, attr, replace); } } - + private ItemListener fontSizeItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { int fontSize = (Integer) RichTextToolBar.this.fontSizeComboBox.getSelectedItem(); - fontSize = scaleUp(fontSize); + fontSize= scaleUp(fontSize); // 调用setCharacterAttributes函数设置文本区选择文本的字体 MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setFontSize(attr, fontSize); setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - + private ItemListener fontNameItemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { @@ -326,7 +326,7 @@ public class RichTextToolBar extends BasicPane{ setCharacterAttributes(RichTextToolBar.this.textPane, attr, false); } }; - + private ActionListener formulaActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { final UIFormula formulaPane = FormulaFactory.createFormulaPane(); @@ -348,7 +348,7 @@ public class RichTextToolBar extends BasicPane{ }).setVisible(true); } }; - + private int roundUp(double num){ String numStr = Double.toString(num); numStr = new BigDecimal(numStr).setScale(0, BigDecimal.ROUND_HALF_UP).toString(); @@ -356,7 +356,7 @@ public class RichTextToolBar extends BasicPane{ } private CaretListener textCareListener = new CaretListener() { - + //根据选中部分的文字样式, 来动态显示工具栏上按钮的状态 private void setSelectedCharStyle(int start, int end, StyledDocument doc){ boolean isBold = true; @@ -367,11 +367,11 @@ public class RichTextToolBar extends BasicPane{ String fontName_1st = null; int fontSize_1st = 0; Color fontColor_1st = null; - + for (int i = start; i < end; i++) { Element ele = doc.getCharacterElement(i); AttributeSet attrs = ele.getAttributes(); - + //粗体 isBold = isBold && StyleConstants.isBold(attrs); //斜体 @@ -382,22 +382,22 @@ public class RichTextToolBar extends BasicPane{ isSubscript = isSubscript && StyleConstants.isSubscript(attrs); //上标 isSuperscript = isSuperscript && StyleConstants.isSuperscript(attrs); - + if(i == start){ - fontName_1st = (String) attrs.getAttribute(StyleConstants.FontFamily); - fontSize_1st = (Integer) attrs.getAttribute(StyleConstants.FontSize); + fontName_1st = (String) attrs.getAttribute(StyleConstants.FontFamily); + fontSize_1st = (Integer) attrs.getAttribute(StyleConstants.FontSize); fontColor_1st = (Color) attrs.getAttribute(StyleConstants.Foreground); fontColor_1st = fontColor_1st == null ? Color.BLACK : fontColor_1st; } } - setButtonSelected(isBold, isItalic, isUnderline, isSubscript, isSuperscript, + setButtonSelected(isBold, isItalic, isUnderline, isSubscript, isSuperscript, fontName_1st, fontSize_1st, fontColor_1st); } - + //动态显示工具栏上按钮的状态 - private void setButtonSelected(boolean isBold, boolean isItalic, boolean isUnderline, - boolean isSubscript, boolean isSuperscript, String fontName_1st, + private void setButtonSelected(boolean isBold, boolean isItalic, boolean isUnderline, + boolean isSubscript, boolean isSuperscript, String fontName_1st, int fontSize_1st, Color fontColor_1st){ bold.setSelected(isBold); italic.setSelected(isItalic); @@ -412,75 +412,75 @@ public class RichTextToolBar extends BasicPane{ fontSizeComboBox.addItemListener(fontSizeItemListener); selectColorPane(fontColor_1st); } - + private void selectColorPane(Color color){ colorSelectPane.removeColorChangeListener(colorChangeAction); colorSelectPane.setColor(color); colorSelectPane.addColorChangeListener(colorChangeAction); } - + @Override public void caretUpdate(CaretEvent e) { StyledDocument doc = (StyledDocument) textPane.getDocument(); - + // 取得选择文本的起始位置和结束位置 int start = textPane.getSelectionStart(); int end = textPane.getSelectionEnd(); - + //如果没有选定字符 if(end == start){ return; } - + setSelectedCharStyle(start, end, doc); } }; - + //设置当前光标位样式 private MouseListener setMouseCurrentStyle = new MouseAdapter() { - + @Override public void mouseClicked(MouseEvent e) { StyledDocument doc = (StyledDocument) textPane.getDocument(); - + // 取得选择文本的起始位置和结束位置 int start = textPane.getSelectionStart(); int end = textPane.getSelectionEnd(); - + if(start != end){ return; } - + setToLastCharStyle(end, doc); } - + //如果默认不选字符, 那么设置为最后一个字符的样式 private void setToLastCharStyle(int end, StyledDocument doc){ if(textPane.isUpdating()){ return; } - + //取前一个字符的样式 Element ele = doc.getCharacterElement(end - 1); AttributeSet attrs = ele.getAttributes(); populateToolBar(attrs); } }; - + /** * 从样式中更新工具栏上的按钮状态 - * + * * @param attrs 样式 - * + * * * @date 2015-1-5-下午5:12:33 - * + * */ public void populateToolBar(AttributeSet attrs){ int size = scaleDown(StyleConstants.getFontSize(attrs)); fontNameComboBox.setSelectedItem(StyleConstants.getFontFamily(attrs)); fontSizeComboBox.setSelectedItem(size); - + bold.setSelected(StyleConstants.isBold(attrs)); italic.setSelected(StyleConstants.isItalic(attrs)); underline.setSelected(StyleConstants.isUnderline(attrs)); @@ -491,31 +491,23 @@ public class RichTextToolBar extends BasicPane{ colorSelectPane.setColor(foreGround); colorSelectPane.repaint(); } - + //pt转为px =*4/3 - private int scaleUp(int fontSize){ - return scale(fontSize, true); + private int scaleUp(int fontSize) { + return (int) FontTransformUtil.pt2px(fontSize); } - + //px转pt = *3/4 - private int scaleDown(int fontSize){ - return scale(fontSize, false); - } - - private int scale(int fontSize, boolean isUp){ - double dpi96 = Constants.FR_PAINT_RESOLUTION; - double dpi72 = Constants.DEFAULT_FONT_PAINT_RESOLUTION; - double scale = isUp ? (dpi96 / dpi72) : (dpi72 / dpi96); - - return roundUp(fontSize * scale); + private int scaleDown(int fontSize) { + return (int) FontTransformUtil.px2pt(fontSize); } - + private DocumentListener inputListener = new DocumentListener() { - + @Override public void removeUpdate(DocumentEvent e) { } - + @Override public void insertUpdate(DocumentEvent e) { //标志正在更新内容 @@ -523,7 +515,7 @@ public class RichTextToolBar extends BasicPane{ final MutableAttributeSet attr = updateStyleFromToolBar(); final int start = textPane.getSelectionStart(); int end = textPane.getSelectionEnd(); - + if (start != end) { textPane.finishUpdating(); return; @@ -538,19 +530,19 @@ public class RichTextToolBar extends BasicPane{ } }); } - + //根据Style来显示populate按钮 private void changeContentStyle(int start, MutableAttributeSet attr){ changeContentStyle(start, attr, 1); } - + private void changeContentStyle(int start, MutableAttributeSet attr, int contentLength){ // 将所选文本设置为新的样式,replace为false表示不覆盖原有的样式 StyledDocument doc = (StyledDocument) textPane.getDocument(); doc.setCharacterAttributes(start, contentLength, attr, false); textPane.finishUpdating(); } - + //将界面上的设置赋值给输入的字符 private MutableAttributeSet updateStyleFromToolBar(){ final boolean isBold = bold.isSelected(); @@ -561,7 +553,7 @@ public class RichTextToolBar extends BasicPane{ final String fontName = (String) fontNameComboBox.getSelectedItem(); final int fontSize = scaleUp((Integer) fontSizeComboBox.getSelectedItem()); final Color foreGround = colorSelectPane.getColor() == null ? Color.BLACK : colorSelectPane.getColor(); - + MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setBold(attr, isBold); StyleConstants.setItalic(attr, isItalic); @@ -571,7 +563,7 @@ public class RichTextToolBar extends BasicPane{ StyleConstants.setForeground(attr, foreGround); StyleConstants.setFontFamily(attr, fontName); StyleConstants.setFontSize(attr, fontSize); - + return attr; } @@ -581,7 +573,7 @@ public class RichTextToolBar extends BasicPane{ private int inputStart = NOT_INITED; private static final int JDK_6 = 6; private static final int JDK_7 = 7; - + @Override public void changedUpdate(DocumentEvent e) { //这边需要注意, jdk1.6和1.7对于输入法的处理逻辑不一样, jdk6时直接在输入法中输入一大段中文 @@ -595,7 +587,7 @@ public class RichTextToolBar extends BasicPane{ StyledDocument doc = (StyledDocument) textPane.getDocument(); final String content; initFlag(doc); - + final int start = textPane.getSelectionStart(); final int inputLen = start - inputStart; //检测输入内容 @@ -604,7 +596,7 @@ public class RichTextToolBar extends BasicPane{ } catch (BadLocationException e1) { return; } - + //中文输入法, 默认输入字符会被输入法的框截取住, jtextpane得到是一个空格, 此时不做处理 if(StringUtils.isBlank(content) || inputLen <= 0){ return; @@ -613,7 +605,7 @@ public class RichTextToolBar extends BasicPane{ setContentStyle(inputLen); } } - + private void setContentStyle(final int inputLen){ //缓存下Start, 下面要用来设置样式 final int _start = inputStart; @@ -632,15 +624,15 @@ public class RichTextToolBar extends BasicPane{ } }); } - + private boolean isUpdating(){ return inputStart == UPDATING; } - + private void startUpdating(){ inputStart = UPDATING; } - + //初始标记状态, 用于记录中文输入法多个字符同时输入的问题 private void initFlag(StyledDocument doc){ if(inputStart != NOT_INITED){ @@ -648,7 +640,7 @@ public class RichTextToolBar extends BasicPane{ } inputStart = textPane.getSelectionStart() - 1; } - + //重置标记状态 private void resetFlag(){ inputStart = NOT_INITED; diff --git a/designer-realize/src/main/java/com/fr/design/condition/WHPane.java b/designer-realize/src/main/java/com/fr/design/condition/WHPane.java index dce2d466ad..7b4f636a64 100644 --- a/designer-realize/src/main/java/com/fr/design/condition/WHPane.java +++ b/designer-realize/src/main/java/com/fr/design/condition/WHPane.java @@ -3,17 +3,16 @@ package com.fr.design.condition; import com.fr.design.DesignerEnvManager; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UIBasicSpinner; +import com.fr.design.fun.ReportLengthUNITProvider; +import com.fr.design.unit.UnitConvertUtil; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.report.cell.cellattr.highlight.HighlightAction; -import com.fr.stable.Constants; -import com.fr.stable.unit.*; +import com.fr.stable.unit.UNIT; -import javax.swing.*; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; import java.math.BigDecimal; -import java.text.ParseException; /** * @author richie @@ -45,23 +44,12 @@ public abstract class WHPane extends ConditionAttrSingleConditionPane extends Tar actionMap.put("paste", new AbstractAction() { public void actionPerformed(ActionEvent evt) { if (paste()) { - QuickEditorRegion.getInstance().populate(getCurrentEditor()); - fireTargetModified(); - QuickEditorRegion.getInstance().populate(getCurrentEditor()); + afterPasteAction(); } } }); @@ -942,6 +940,12 @@ public abstract class ElementCasePane extends Tar }); } + protected void afterPasteAction() { + QuickEditorRegion.getInstance().populate(getCurrentEditor()); + fireTargetModified(); + QuickEditorRegion.getInstance().populate(getCurrentEditor()); + } + /** * 是否列表头可见 * diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java index d4767e4d3c..22ab323443 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java @@ -38,6 +38,7 @@ import com.fr.stable.ArrayUtils; import javax.swing.JPanel; import java.awt.BorderLayout; + /** * 类说明: 设计面板中最上方的"插入" "单元格"下拉列表Menu模块. * @@ -113,6 +114,13 @@ public class ElementCasePaneDelegate extends ElementCasePane { } } + @Override + protected void afterPasteAction() { + refreshPropertyPanes(); + fireTargetModified(); + repaint(); + } + @Override protected boolean supportRepeatedHeaderFooter() { return true; 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 b4b43cafd9..b0e8066578 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 @@ -198,6 +198,9 @@ public class InformationCollector implements XMLReadable, XMLWriter { } JSONObject content = getJSONContentAsByte(); String url = CloudCenter.getInstance().acquireUrlByKind("user.info.v10"); + if (StringUtils.isBlank(url)) { + return; + } boolean success = false; try { HashMap para = new HashMap<>(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java index b68e49e168..48ddb6a05a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java @@ -3,6 +3,8 @@ */ package com.fr.design.mainframe; +import com.fr.design.mainframe.template.info.JPolyWorkBookProcessInfo; +import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.file.FILEChooserPane; import com.fr.main.impl.WorkBook; import com.fr.report.poly.PolyWorkSheet; @@ -49,4 +51,14 @@ public class JPolyWorkBook extends JWorkBook { protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser) { } + + + @Override + public TemplateProcessInfo getProcessInfo() { + if (processInfo == null) { + processInfo = new JPolyWorkBookProcessInfo(template); + } + return processInfo; + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 621d3f40b6..0759ddf983 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -1188,4 +1188,9 @@ public class JWorkBook extends JTemplate { provider.addChooseFileFilter(fileChooser, this.suffix()); } } + + @Override + public void whenClose() { + reportComposite.doRemoveAction(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index 71fb275029..0299899a06 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.common.inputevent.InputEventBaseOnOS; import com.fr.design.designer.EditingState; +import com.fr.design.event.RemoveListener; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icontainer.UIModeControlContainer; @@ -30,7 +31,7 @@ import java.util.ArrayList; * @editor zhou * @since 2012-3-27下午12:12:05 */ -public class ReportComponentComposite extends JComponent { +public class ReportComponentComposite extends JComponent implements RemoveListener { private static final int MAX = 400; private static final int HUND = 100; @@ -250,4 +251,9 @@ public class ReportComponentComposite extends JComponent { public void fireTargetModified() { parent.fireTargetModified(); } + + @Override + public void doRemoveAction() { + sheetNameTab.doRemoveAction(); + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/SheetAuthorityEditPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/SheetAuthorityEditPane.java index f559c828fc..baa19fd715 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/SheetAuthorityEditPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/SheetAuthorityEditPane.java @@ -8,6 +8,7 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; +import com.fr.design.ui.util.UIUtil; import com.fr.general.ComparatorUtils; import com.fr.main.impl.WorkBook; @@ -119,9 +120,14 @@ public class SheetAuthorityEditPane extends AuthorityEditPane { if (StringUtils.isEmpty(name.getText())){ return; } - checkPane.add(populateCheckPane(), BorderLayout.CENTER); - checkPane.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); - checkVisibleCheckBoxes(); + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + checkPane.add(populateCheckPane(), BorderLayout.CENTER); + checkPane.setBorder(BorderFactory.createEmptyBorder(0, LEFT_CHECKPANE, 0, 0)); + checkVisibleCheckBoxes(); + } + }); } /** 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 747789cdbe..74443e831c 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 @@ -5,6 +5,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; +import java.awt.event.ComponentListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -27,6 +28,7 @@ import com.fr.base.vcs.DesignerMode; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.event.RemoveListener; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; @@ -44,7 +46,6 @@ import com.fr.poly.PolyDesigner; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.report.TemplateReport; import com.fr.report.worksheet.WorkSheet; -import com.fr.stable.ProductConstants; /** * NameTabPane of sheets @@ -52,7 +53,7 @@ import com.fr.stable.ProductConstants; * @editor zhou * @since 2012-3-26下午1:45:53 */ -public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener { +public class SheetNameTabPane extends JComponent implements MouseListener, MouseMotionListener, RemoveListener { private static final Color LINE_COLOR = new Color(0xababab); @@ -140,6 +141,10 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse private boolean isAuthorityEditing = false; + private ComponentListener listener; + + private DesignerFrame designerFrame; + public SheetNameTabPane(ReportComponentComposite reportCompositeX) { this.reportComposite = reportCompositeX; this.setLayout(new BorderLayout(0, 0)); @@ -203,14 +208,20 @@ public class SheetNameTabPane extends JComponent implements MouseListener, Mouse } } }); - - DesignerContext.getDesignerFrame().addComponentListener(new ComponentAdapter(){ + listener = new ComponentAdapter(){ @Override public void componentResized(ComponentEvent e) { for (int i = 0; i < lastOneIndex * NUM; i++) { moveLeft(); } } - }); + }; + designerFrame = DesignerContext.getDesignerFrame(); + designerFrame.addComponentListener(listener); + } + + @Override + public void doRemoveAction() { + designerFrame.removeComponentListener(listener); } private ActionListener createLeftButtonActionListener() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index 05267220b6..ce0d987767 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -10,6 +10,7 @@ import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; +import com.fr.general.ComparatorUtils; import com.fr.general.http.HttpToolbox; import com.fr.json.JSONArray; import com.fr.json.JSONObject; @@ -67,7 +68,12 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { if (jsonArray != null && jsonArray.length() > 0) { for (int i = 0; i < jsonArray.length(); i++) { AlphaFineHelper.checkCancel(); - AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson((JSONObject) jsonArray.get(i)); + JSONObject jo = jsonArray.getJSONObject(i); + JSONObject innerJo = jo.getJSONObject("result"); + if (innerJo != null && ComparatorUtils.equals("failed", innerJo.get("state"))) { + continue; + } + AlphaCellModel alphaCellModel = CellModelHelper.getModelFromJson(jo); if (alphaCellModel != null && !alreadyContain(alphaCellModel) && !this.recommendModelList.contains(alphaCellModel)) { this.recommendModelList.add(alphaCellModel); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java index 5e12f224f9..ea99f70e4d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/bbs/BBSConstants.java @@ -64,7 +64,7 @@ public class BBSConstants { } private static String[] loadAllGuestsInfoOnline(String key, String defaultValue) { - String guest = CloudCenter.getInstance().acquireUrlByKind(key, defaultValue); + String guest = CloudCenter.getInstance().acquireConf(key, defaultValue); if (StringUtils.isNotEmpty(guest)) { return guest.split("\\|"); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java index f6e2722176..0f7466af09 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandAttrPane.java @@ -1,6 +1,5 @@ package com.fr.design.mainframe.cell.settingpane; -import com.fr.base.BaseUtils; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.expand.ExpandLeftFatherPane; @@ -10,18 +9,23 @@ import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.icheckbox.UICheckBox; 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.general.ComparatorUtils; - +import com.fr.general.IOUtils; import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.elementcase.TemplateElementCase; import com.fr.stable.Constants; -import javax.swing.*; -import java.awt.*; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Rectangle; /** * 单元格扩展属性面板,是属性表面板的一个种类 @@ -38,58 +42,66 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private JPanel layoutPane; private JPanel basicPane; private JPanel seniorPane; + private CellExpandExtraAttrPane extraPane; + /** - * @return + * @return content panel */ public JPanel createContentPane() { - String[] nameArray = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Not_Expand"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom"), com.fr.design.i18n.Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right")}; + String[] nameArray = {Toolkit.i18nText("Fine-Design_Report_ExpandD_Not_Expand"), Toolkit.i18nText("Fine-Design_Report_Utils_Top_To_Bottom"), Toolkit.i18nText("FIne-Design_Report_Utils_Left_To_Right")}; Icon[][] iconArray = { - {BaseUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), BaseUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")}, - {BaseUtils.readIcon("/com/fr/design/images/expand/vertical.png"), BaseUtils.readIcon("/com/fr/design/images/expand/vertical_selected@1x.png")}, - {BaseUtils.readIcon("/com/fr/design/images/expand/landspace.png"), BaseUtils.readIcon("/com/fr/design/images/expand/landspace_selected@1x.png")} + {IOUtils.readIcon("/com/fr/design/images/expand/none16x16.png"), IOUtils.readIcon("/com/fr/design/images/expand/none16x16_selected@1x.png")}, + {IOUtils.readIcon("/com/fr/design/images/expand/vertical.png"), IOUtils.readIcon("/com/fr/design/images/expand/vertical_selected@1x.png")}, + {IOUtils.readIcon("/com/fr/design/images/expand/landspace.png"), IOUtils.readIcon("/com/fr/design/images/expand/landspace_selected@1x.png")} }; Byte[] valueArray = {Constants.NONE, Constants.TOP_TO_BOTTOM, Constants.LEFT_TO_RIGHT}; expandDirectionButton = new UIButtonGroup(iconArray, valueArray); expandDirectionButton.setAllToolTips(nameArray); leftFatherPane = new ExpandLeftFatherPane(); rightFatherPane = new ExpandUpFatherPane(); - horizontalExpandableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); - verticalExpandableCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); + horizontalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")); + verticalExpandableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Vertical_Extendable")); sortAfterExpand = new SortExpandAttrPane(); initAllNames(); return layoutPane(); } private void initAllNames() { - expandDirectionButton.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction")); - leftFatherPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LeftParent")); - rightFatherPane.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell")); - horizontalExpandableCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable")); - verticalExpandableCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable")); + expandDirectionButton.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction")); + leftFatherPane.setGlobalName(Toolkit.i18nText("Fine-Design_Report_LeftParent")); + rightFatherPane.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell")); + horizontalExpandableCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable")); + verticalExpandableCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable")); } private JPanel layoutPane() { layoutPane = new JPanel(new BorderLayout()); basicPane = new JPanel(); seniorPane = new JPanel(); - basicPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane()); - seniorPane = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane()); + basicPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Basic"), 223, 24, basicPane()); + seniorPane = new UIExpandablePane(Toolkit.i18nText("Fine-Design_Report_Advanced"), 223, 24, seniorPane()); layoutPane.add(basicPane, BorderLayout.NORTH); layoutPane.add(seniorPane, BorderLayout.CENTER); - return layoutPane; + + extraPane = CellExpandExtraAttrPane.getInstance(); + + JPanel content = new JPanel(new BorderLayout()); + content.add(layoutPane, BorderLayout.NORTH); + content.add(extraPane, BorderLayout.CENTER); + return content; } private JPanel basicPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel direction = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"), SwingConstants.LEFT); + UILabel direction = new UILabel(Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"), SwingConstants.LEFT); JPanel directionPane = new JPanel(new BorderLayout()); directionPane.add(direction, BorderLayout.NORTH); - UILabel left = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LeftParent"), SwingConstants.LEFT); + UILabel left = new UILabel(Toolkit.i18nText("Fine-Design_Report_LeftParent"), SwingConstants.LEFT); JPanel leftPane = new JPanel(new BorderLayout()); leftPane.add(left, BorderLayout.NORTH); - UILabel up = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"), SwingConstants.LEFT); + UILabel up = new UILabel(Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"), SwingConstants.LEFT); JPanel upPane = new JPanel(new BorderLayout()); upPane.add(up, BorderLayout.NORTH); Component[][] components = new Component[][]{ @@ -107,7 +119,7 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { private JPanel seniorPane() { double f = TableLayout.FILL; double p = TableLayout.PREFERRED; - UILabel expendSort = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT); + UILabel expendSort = new UILabel(Toolkit.i18nText("Fine-Design_Report_Expend_Sort"), SwingConstants.LEFT); JPanel expendSortPane = new JPanel(new BorderLayout()); expendSortPane.add(expendSort, BorderLayout.NORTH); horizontalExpandableCheckBox.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); @@ -118,9 +130,9 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { new Component[]{verticalExpandableCheckBox, null}, new Component[]{expendSortPane, sortAfterExpand}, }; - double[] rowSize = {p, p, p, p, p, p, p, p}; + double[] rowSize = {p, p, p, p, p}; double[] columnSize = {p, f}; - int[][] rowCount = {{1, 1}, {1, 1}, {1, 3}, {1, 3}}; + int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}}; return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, SENIOR_HORIZONTAL_GAP, LayoutConstants.VGAP_LARGE); } @@ -158,13 +170,15 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } sortAfterExpand.populate(cellExpandAttr); + + extraPane.populate(cellElement); } @Override public String getIconPath() { // return "com/fr/design/images/expand/cellAttr.gif"; - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Expand"); + return Toolkit.i18nText("Fine-Design_Report_Expand"); } @@ -175,19 +189,19 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { cellExpandAttr = new CellExpandAttr(); cellElement.setCellExpandAttr(cellExpandAttr); } - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"))) { + if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Direction"))) { cellExpandAttr.setDirection(expandDirectionButton.getSelectedItem()); } - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LeftParent"))) { + if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_LeftParent"))) { this.leftFatherPane.update(cellExpandAttr); } - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"))) { + if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_ExpandD_Up_Father_Cell"))) { this.rightFatherPane.update(cellExpandAttr); } // extendable - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"))) { + if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_ExpandD_Expandable"))) { if (horizontalExpandableCheckBox.isSelected()) { if (verticalExpandableCheckBox.isSelected()) { cellExpandAttr.setExtendable(CellExpandAttr.Both_EXTENDABLE); @@ -203,10 +217,11 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } } - if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) { + if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Basic_ExpandD_Sort_After_Expand"))) { sortAfterExpand.update(cellExpandAttr); } + extraPane.update(cellElement); } /** @@ -234,10 +249,10 @@ public class CellExpandAttrPane extends AbstractCellAttrPane { } /** - * @return + * @return title */ public String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Attribute"); + return Toolkit.i18nText("Fine-Design_Report_ExpandD_Expand_Attribute"); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java new file mode 100644 index 0000000000..58f11277c1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellExpandExtraAttrPane.java @@ -0,0 +1,125 @@ +package com.fr.design.mainframe.cell.settingpane; + +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.fun.CellExpandAttrPanelProvider; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.event.EventDispatcher; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; +import com.fr.report.cell.TemplateCellElement; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Component; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import static com.fr.plugin.observer.PluginEventType.AfterRun; +import static com.fr.plugin.observer.PluginEventType.AfterStop; + +/** + * @author yaohwu + * created by yaohwu at 2020/4/28 10:01 + */ +public class CellExpandExtraAttrPane extends JPanel { + + private static final double V_GAP = 5; + private static final double H_GAP = 0; + private static final int DEFAULT_COMPONENT_SIZE = 2; + + private List> extras = null; + private TemplateCellElement cellElement = null; + + + private static final class Holder { + private static final CellExpandExtraAttrPane INSTANCE = new CellExpandExtraAttrPane(); + } + + static { + PluginFilter filter = new PluginFilter() { + @Override + public boolean accept(PluginContext pluginContext) { + return pluginContext.contain(PluginModule.ExtraDesign, CellExpandAttrPanelProvider.MARK_STRING); + } + }; + PluginEventListener listener = new PluginEventListener() { + @Override + public void on(PluginEvent event) { + CellExpandExtraAttrPane.getInstance().refresh(); + } + }; + EventDispatcher.listen(AfterRun, listener, filter); + EventDispatcher.listen(AfterStop, listener, filter); + } + + public static CellExpandExtraAttrPane getInstance() { + return Holder.INSTANCE; + } + + /** + * Creates a new JPanel with a double buffer + * and a flow layout. + */ + private CellExpandExtraAttrPane() { + this.setBorder(null); + this.setLayout(new BorderLayout()); + } + + public void populate(TemplateCellElement cellElement) { + this.cellElement = cellElement; + if (extras != null) { + for (BasicBeanPane extra : extras) { + extra.populateBean(cellElement); + } + } + } + + public void update(TemplateCellElement cellElement) { + this.cellElement = cellElement; + if (extras != null) { + for (BasicBeanPane extra : extras) { + extra.updateBean(cellElement); + } + } + } + + private void refresh() { + this.removeAll(); + if (extras == null) { + extras = new ArrayList<>(); + } + extras.clear(); + Set attrProviders = ExtraDesignClassManager.getInstance().getArray(CellExpandAttrPanelProvider.MARK_STRING); + if (attrProviders != null) { + for (CellExpandAttrPanelProvider attrProvider : attrProviders) { + BasicBeanPane extra = attrProvider.createPanel(); + if (extra != null) { + extras.add(extra); + } + } + } + Component[][] components = new Component[extras.size()][DEFAULT_COMPONENT_SIZE]; + + for (int i = 0; i < extras.size(); i++) { + components[i] = new Component[]{extras.get(i), null}; + } + double[] rowSize = new double[extras.size()]; + Arrays.fill(rowSize, TableLayout.PREFERRED); + double[] columnSize = {TableLayout.PREFERRED, TableLayout.FILL}; + JPanel content = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, H_GAP, V_GAP); + this.add(content, BorderLayout.CENTER); + if (this.cellElement != null) { + this.populate(cellElement); + } + this.validate(); + this.repaint(); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java index e22e1059ed..81da862123 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java @@ -17,6 +17,7 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.EnvChangedListener; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import java.io.File; import java.io.FileInputStream; @@ -100,7 +101,10 @@ public class ErrorInfoUploader { private void downloadSolution(File localCacheZip) { try { - String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution"); + String downloadURL = CloudCenter.getInstance().acquireUrlByKind("solution.download"); + if (StringUtils.isBlank(downloadURL)) { + return; + } downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken()); InputStream in = HttpToolbox.post(downloadURL, new HashMap(), HttpResponseType.STREAM); StableUtils.makesureFileExist(localCacheZip); @@ -119,7 +123,10 @@ public class ErrorInfoUploader { private boolean needUpdate(File localCacheZip) { if (localCacheZip.exists()) { // 判断本地文件大小. - String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/solution/cache/check"); + String checkURL = CloudCenter.getInstance().acquireUrlByKind("solution.check"); + if (StringUtils.isBlank(checkURL)) { + return false; + } checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken()); try { JSONObject res = new JSONObject(HttpToolbox.get(checkURL)); @@ -143,6 +150,9 @@ public class ErrorInfoUploader { } File[] files = folder.listFiles(); + if (files == null) { + return; + } if (ArrayUtils.getLength(files) > MAX_ERROR_SIZE) { CommonIOUtils.deleteFile(folder); return; @@ -166,9 +176,12 @@ public class ErrorInfoUploader { } jsonArray.put(new JSONObject(content)); tempFiles.add(file); - if( jsonArray.length() == MAX_ITEMS || count == files.length){ + if (jsonArray.length() == MAX_ITEMS || count == files.length) { String url = CloudCenter.getInstance().acquireUrlByKind("design.error"); - if(sendErrorInfo(url, jsonArray)){ + if (StringUtils.isBlank(url)) { + return; + } + if (sendErrorInfo(url, jsonArray)) { deleteFiles(tempFiles); } jsonArray = new JSONArray(); @@ -182,7 +195,7 @@ public class ErrorInfoUploader { } private void deleteFiles(List files) { - for(File file : files) { + for (File file : files) { CommonIOUtils.deleteFile(file); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java index 07954c796e..9a85bd053e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java @@ -5,6 +5,7 @@ package com.fr.design.mainframe.form; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignState; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.AllowAuthorityEditAction; import com.fr.design.actions.ExitAuthorityEditAction; import com.fr.design.base.mode.DesignModeContext; @@ -25,6 +26,7 @@ import com.fr.design.menu.NameSeparator; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.present.ConditionAttributesGroupPane; +import com.fr.design.fun.FormAdaptiveConfigUIProcessor; import com.fr.design.selection.SelectableElement; import com.fr.design.selection.Selectedable; import com.fr.design.selection.SelectionListener; @@ -78,6 +80,7 @@ public class FormElementCaseDesigner } + @Override public void setTarget(T t) { super.setTarget(t); @@ -123,6 +126,10 @@ public class FormElementCaseDesigner */ @Override public BufferedImage getElementCaseImage(Dimension size) { + FormAdaptiveConfigUIProcessor adaptiveConfigUI = ExtraDesignClassManager.getInstance().getSingle(FormAdaptiveConfigUIProcessor.MARK_STRING); + if (adaptiveConfigUI != null) { + return adaptiveConfigUI.paintFormElementCaseImage(size, this.elementCasePane); + } BufferedImage image = null; try { image = new java.awt.image.BufferedImage(size.width, size.height, @@ -351,4 +358,4 @@ public class FormElementCaseDesigner public FormElementCaseProvider getEditingElementCase() { return this.getEditingElementCasePane().getTarget(); } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java index d2740d681a..55d11fe7de 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCasePaneDelegate.java @@ -1,8 +1,5 @@ package com.fr.design.mainframe.form; -import javax.swing.JComponent; -import javax.swing.JPanel; - import com.fr.design.DesignState; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; @@ -11,7 +8,6 @@ import com.fr.design.actions.form.FormECColumnsAction; import com.fr.design.actions.form.FormECFrozenAction; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; -import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.mainframe.*; import com.fr.design.mainframe.cell.QuickEditorRegion; @@ -22,13 +18,14 @@ import com.fr.design.menu.ToolBarDef; import com.fr.design.present.ConditionAttributesGroupPane; import com.fr.form.main.Form; import com.fr.grid.Grid; -import com.fr.js.NameJavaScriptGroup; import com.fr.page.ReportSettingsProvider; -import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.worksheet.FormElementCase; import com.fr.design.selection.SelectionEvent; import com.fr.design.selection.SelectionListener; +import javax.swing.JComponent; +import javax.swing.JPanel; + /** */ public class FormElementCasePaneDelegate extends ElementCasePane{ @@ -72,6 +69,13 @@ public class FormElementCasePaneDelegate extends ElementCasePane params = new HashMap<>(); - params.put(ATTR_CIPHER_TEXT, cipherText); - params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); - HttpToolbox.post(SOLID_UPLOAD_URL, params); + String cipherText = requestContent(); + if (StringUtils.isNotEmpty(cipherText)) { + Map params = new HashMap<>(); + params.put(ATTR_CIPHER_TEXT, cipherText); + params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); + HttpToolbox.post(url, params); - String deleteUrl = WorkContext.getCurrent().getPath() + DELETE_URL; - HttpToolbox.post(deleteUrl, getParams()); - } + deleteSolidFile(); } FineLoggerFactory.getLogger().info("send solid content to cloud center success."); } catch (Exception e) { FineLoggerFactory.getLogger().info(e.getMessage(), e); } finally { - String unlockUrl = WorkContext.getCurrent().getPath() + UNLOCK_URL; try { - HttpToolbox.post(unlockUrl, getParams()); - } catch (IOException e) { + unlockSolidFile(); + } catch (Exception e) { FineLoggerFactory.getLogger().warn(e.getMessage(), e); } } @@ -81,17 +73,42 @@ public class SolidCollector { /** * 获取服务端固化文件内容 + * * @return 回传内容 */ - public String requestContent() throws Exception { - Map params = new HashMap(); - params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); - return HttpToolbox.get(WorkContext.getCurrent().getPath() + CONTENT_URL, params); + private String requestContent() throws Exception { + return WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler() { + @Override + public String callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return StringUtils.EMPTY; + } + }).feedBackTask(StringUtils.EMPTY); } - private Map getParams() { - Map params = new HashMap(); - params.put("token", JwtUtils.createDefaultJWT(REQUEST_SUBJECT, TIME_OUT)); - return params; + /** + * 删除服务端固化文件 + */ + private void deleteSolidFile() throws Exception { + WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler() { + @Override + public Void callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return null; + } + }).deleteSolidFile(); + } + + /** + * unlock + */ + private void unlockSolidFile() throws Exception { + WorkContext.getCurrent().get(SolidRecordExecutor.class, new ExceptionHandler() { + @Override + public Void callHandler(RPCInvokerExceptionInfo info) { + FineLoggerFactory.getLogger().error(info.getException().getMessage(), info.getException()); + return null; + } + }).unlockSolidFile(); } } 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 63bc3d999b..79061dbab2 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 @@ -3,6 +3,7 @@ package com.fr.design.mainframe.socketio; import com.fr.config.RemoteConfigEvent; import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.design.EnvChangeEntrance; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.loghandler.DesignerLogger; @@ -146,7 +147,7 @@ public class DesignerSocketIO { UIUtil.invokeAndWaitIfNeeded(new Runnable() { @Override public void run() { - JOptionPane.showMessageDialog( + FineJOptionPane.showMessageDialog( DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Remote_Disconnected"), UIManager.getString("OptionPane.messageDialogTitle"), diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JPolyWorkBookProcessInfo.java b/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JPolyWorkBookProcessInfo.java new file mode 100644 index 0000000000..ec5d05c7f0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JPolyWorkBookProcessInfo.java @@ -0,0 +1,77 @@ +package com.fr.design.mainframe.template.info; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.main.impl.WorkBook; +import com.fr.report.block.Block; +import com.fr.report.poly.PolyChartBlock; +import com.fr.report.poly.PolyWorkSheet; +import com.fr.report.report.Report; + +import java.util.Iterator; + +/** + * Created by kerry on 2020-05-06 + */ +public class JPolyWorkBookProcessInfo extends JWorkBookProcessInfo { + public JPolyWorkBookProcessInfo(WorkBook template) { + super(template); + } + + @Override + public int getReportType() { + return 1; + } + + @Override + public int getCellCount() { + return 0; + } + + @Override + public int getFloatCount() { + return 0; + } + + @Override + public int getBlockCount() { + int blockCount = 0; + if (!template.isElementCaseBook()) { // 如果是聚合报表 + for (int i = 0; i < template.getReportCount(); i++) { + Report report = template.getReport(i); + // 考虑多个sheet下 包含WorkSheet的情况 需要判断下 + if (report instanceof PolyWorkSheet) { + PolyWorkSheet r = (PolyWorkSheet) report; + blockCount += r.getBlockCount(); + } + } + } + return blockCount; + } + + + @Override + public boolean isTestTemplate() { + Iterator it = this.template.getTableDataNameIterator(); + if (!it.hasNext() || getBlockCount() <= 1 || isTestECReport() || isTestChartBlock()) { + return true; + } + return false; + } + + + private boolean isTestChartBlock() { + int count = this.template.getReportCount(); + for (int m = 0; m < count; m++) { + PolyWorkSheet report = (PolyWorkSheet) this.template.getReport(m); + int blockCount = report.getBlockCount(); + for (int i = 0; i < blockCount; i++) { + Block block = report.getBlock(i); + if (block instanceof PolyChartBlock && isTestChartCollection((ChartCollection) ((PolyChartBlock) block).getChartCollection())) { + return true; + } + } + } + return false; + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java b/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java index eec7773282..c23a03f1c3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java @@ -1,10 +1,16 @@ package com.fr.design.mainframe.template.info; + +import com.fr.base.Style; import com.fr.base.parameter.ParameterUI; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.json.JSONArray; import com.fr.main.impl.WorkBook; import com.fr.main.parameter.ReportParameterAttr; +import com.fr.report.cell.TemplateCellElement; import com.fr.report.cellcase.CellCase; -import com.fr.report.poly.PolyWorkSheet; +import com.fr.report.elementcase.TemplateElementCase; +import com.fr.report.report.Report; import com.fr.report.worksheet.WorkSheet; import java.util.Iterator; @@ -33,7 +39,7 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { for (int j = 0; j < cc.getRowCount(); j++) { Iterator iter = cc.getRow(j); while (iter.hasNext()) { - cellCount ++; + cellCount++; iter.next(); } } @@ -41,6 +47,7 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { } return cellCount; } + // 获取模板悬浮元素个数 public int getFloatCount() { int chartCount = 0; @@ -49,24 +56,19 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { WorkSheet r = (WorkSheet) template.getReport(i); Iterator fiter = r.getBlock().floatIterator(); while (fiter.hasNext()) { - chartCount ++; + chartCount++; fiter.next(); } } } return chartCount; } + // 获取模板聚合块个数 public int getBlockCount() { - int blockCount = 0; - if (!template.isElementCaseBook()) { // 如果是聚合报表 - for (int i = 0; i < template.getReportCount(); i++) { - PolyWorkSheet r = (PolyWorkSheet) template.getReport(i); - blockCount += r.getBlockCount(); - } - } - return blockCount; + return 0; } + // 获取模板控件数 public int getWidgetCount() { ReportParameterAttr attr = template.getReportParameterAttr(); @@ -77,4 +79,73 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { ParameterUI pui = attr.getParameterUI(); return pui == null ? 0 : (pui.getAllWidgets().length - 1); } + + @Override + public boolean isTestTemplate() { + Iterator it = this.template.getTableDataNameIterator(); + if (!it.hasNext() || isTestECReport() || getCellCount() <= 5) { + return true; + } + return false; + } + + protected boolean isTestECReport() { + int count = this.template.getReportCount(); + for (int m = 0; m < count; m++) { + Report report = this.template.getReport(m); + Iterator iterator = report.iteratorOfElementCase(); + while (iterator.hasNext()) { + TemplateElementCase templateElementCase = (TemplateElementCase) iterator.next(); + int columnLength = templateElementCase.getColumnCount(); + int rowLength = templateElementCase.getRowCount(); + for (int i = 0; i < columnLength; i++) { + for (int j = 0; j < rowLength; j++) { + TemplateCellElement templateCellElement = templateElementCase.getTemplateCellElement(i, j); + if (templateCellElement == null) { + continue; + } + Object value = templateCellElement.getValue(); + if (isTestCell(value, templateCellElement.getStyle())) { + return true; + } + + } + } + } + } + return false; + } + + protected boolean isTestCell(Object value, Style style) { + if (value instanceof ChartCollection && isTestChartCollection((ChartCollection) value)) { + return true; + } + return false; + } + + + @Override + public boolean useParaPane() { + ReportParameterAttr parameterAttr = this.template.getReportParameterAttr(); + if (parameterAttr == null) { + return false; + } + return parameterAttr.getParameterUI() != null; + } + + + @Override + public JSONArray getComponentsInfo() { + return new JSONArray(); + } + + @Override + public JSONArray getReuseCmpList() { + return JSONArray.create(); + } + + @Override + public void updateTemplateOperationInfo(TemplateOperate templateOption) { + + } } diff --git a/designer-realize/src/main/java/com/fr/design/present/StyleArrayPane.java b/designer-realize/src/main/java/com/fr/design/present/StyleArrayPane.java index 76c1e72617..87d78d6904 100644 --- a/designer-realize/src/main/java/com/fr/design/present/StyleArrayPane.java +++ b/designer-realize/src/main/java/com/fr/design/present/StyleArrayPane.java @@ -3,26 +3,32 @@ package com.fr.design.present; import com.fr.base.Style; import com.fr.config.ServerPreferenceConfig; import com.fr.config.StyleMap; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.NameInspector; import com.fr.design.gui.controlpane.AbstractNameableCreator; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ModNameActionListener; -import com.fr.design.mainframe.DesignerContext; +import com.fr.design.i18n.Toolkit; import com.fr.design.style.StylePane; +import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; import com.fr.stable.Nameable; -import com.fr.transaction.Configurations; -import com.fr.transaction.WorkerAdaptor; +import com.fr.stable.StringUtils; +import javax.swing.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; public class StyleArrayPane extends JListControlPane { - + + private boolean namePermitted = true; + /** * Constructor. */ @@ -30,11 +36,37 @@ public class StyleArrayPane extends JListControlPane { super(); this.addModNameActionListener(new ModNameActionListener() { public void nameModed(int index, String oldName, String newName) { + if (ComparatorUtils.equals(oldName, newName) || ComparatorUtils.equals(newName, NameInspector.ILLEGAL_NAME_HOLDER)) { + return; + } + namePermitted = true; + String[] allNames = nameableList.getAllNames(); + allNames[index] = StringUtils.EMPTY; + if (StringUtils.isEmpty(newName)) { + showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Empty_Name"), index); + return; + } + if (isNameRepeated(new List[] {Arrays.asList(allNames)}, newName)) { + showTipDialogAndReset(Toolkit.i18nText("Fine-Design_Basic_Predefined_Style_Duplicate_Name", newName), index); + return; + } populateSelectedValue(); } }); } + + private void showTipDialogAndReset(String content, int index) { + nameableList.stopEditing(); + + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(StyleArrayPane.this), + content, + Toolkit.i18nText("Fine-Design_Basic_Alert"), + JOptionPane.WARNING_MESSAGE); + setIllegalIndex(index); + namePermitted = false; + } + /** * 创建样式设置组件 * @@ -105,4 +137,8 @@ public class StyleArrayPane extends JListControlPane { configManager.setStyleMap(styleMap); } + + public boolean isNamePermitted() { + return namePermitted; + } } diff --git a/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java b/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java index db9234925e..20beaa5643 100644 --- a/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/PageSetupPane.java @@ -885,12 +885,12 @@ public class PageSetupPane extends BasicPane { Icon topBottomIcon = BaseUtils.readIcon("/com/fr/base/images/dialog/pagesetup/down.png"); - topBottomRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Top_To_Bottom")); + topBottomRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Top_To_Bottom"),false,false); pageOrderPane.add(FRGUIPaneFactory.createIconRadio_S_Pane(topBottomIcon, topBottomRadioButton)); topBottomRadioButton.setMnemonic('B'); Icon leftRightIcon = BaseUtils.readIcon("/com/fr/base/images/dialog/pagesetup/over.png"); - leftRightRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Left_To_Right")); + leftRightRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Left_To_Right"), false, false); pageOrderPane.add(FRGUIPaneFactory.createIconRadio_S_Pane(leftRightIcon, leftRightRadioButton)); leftRightRadioButton.setMnemonic('R'); @@ -907,9 +907,9 @@ public class PageSetupPane extends BasicPane { defaultPane.add(outcenterOnPagePane); - this.horizonalCenterCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Horizontally")); + this.horizonalCenterCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Horizontally"), false, false); this.horizonalCenterCheckBox.setMnemonic('H'); - this.verticalCenterCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Vertically")); + this.verticalCenterCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_Vertically"), false, false); this.verticalCenterCheckBox.setMnemonic('V'); centerOnPagePane.add(GUICoreUtils.createFlowPane(horizonalCenterCheckBox, FlowLayout.CENTER)); diff --git a/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java b/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java index 0406abffb9..39061a4b6d 100644 --- a/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/RichTextEditingPane.java @@ -14,9 +14,14 @@ import com.fr.log.FineLoggerFactory; import com.fr.report.cell.cellattr.core.RichText; import com.fr.report.cell.cellattr.core.RichTextConverter; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; +import javax.swing.text.DefaultHighlighter; import javax.swing.text.Element; +import javax.swing.text.Highlighter; import javax.swing.text.StyledDocument; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -44,6 +49,7 @@ public class RichTextEditingPane extends UITextPane{ */ public RichTextEditingPane() { this.addMouseListener(doubleClickFormulaListener); + this.addFocusListener(focusListener); } /** @@ -195,4 +201,34 @@ public class RichTextEditingPane extends UITextPane{ } } }; + + private FocusListener focusListener = new FocusAdapter() { + /** + * 移除高亮,重新选中文本 + * @param e + */ + public void focusGained(FocusEvent e) { + RichTextEditingPane richTextPane = RichTextEditingPane.this; + richTextPane.getHighlighter().removeAllHighlights(); + richTextPane.select(richTextPane.getSelectionStart(), richTextPane.getSelectionEnd()); + } + + /** + * 失去焦点时,被选中的文本保持着被选中时的样式 + * @param e + */ + public void focusLost(FocusEvent e) { + RichTextEditingPane richTextPane = RichTextEditingPane.this; + int start = richTextPane.getSelectionStart(); + int end = richTextPane.getSelectionEnd(); + richTextPane.select(start, end); + Highlighter highlighter = richTextPane.getHighlighter(); + richTextPane.getHighlighter().removeAllHighlights(); + try { + highlighter.addHighlight(start, end, DefaultHighlighter.DefaultPainter); + } catch (BadLocationException exception) { + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + } + } + }; } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/report/RichTextPane.java b/designer-realize/src/main/java/com/fr/design/report/RichTextPane.java index d2cb19e868..fa19c38f82 100644 --- a/designer-realize/src/main/java/com/fr/design/report/RichTextPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/RichTextPane.java @@ -1,6 +1,7 @@ package com.fr.design.report; import com.fr.base.BaseFormula; +import com.fr.base.FRContext; import com.fr.base.Style; import com.fr.design.cell.editor.RichTextToolBar; import com.fr.design.dialog.BasicPane; @@ -36,7 +37,7 @@ public class RichTextPane extends BasicPane { //12号字体有个奇怪的bug, 字体下部分渲染会截断一部分, 换其他字体没问题, 字体改大小也没问题. //直接弄个jtexarea放到jframe里也有同样问题, 不知道是字体渲染bug还是jdk问题 - public static final FRFont DEFAUL_FONT = FRFont.getInstance().applySize(13); + public static final FRFont DEFAUL_FONT = FRContext.getDefaultValues().getFRFont().applySize(13); private RichTextEditingPane textPane; //用于populate时动态更新按钮 diff --git a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java index 4a6984d0f0..6da8957b26 100644 --- a/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java @@ -67,7 +67,7 @@ public class UnitFieldPane extends JPanel { this.unitType = unitType; - valueSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, 1.0)); + valueSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, Integer.MIN_VALUE, Double.MAX_VALUE, 1.0)); textField = ((JSpinner.DefaultEditor) valueSpinner.getEditor()).getTextField(); textField.setColumns(OperatingSystem.isWindows() ? TEXT_FIELD_COLUMNS_WINDOWS : TEXT_FIELD_COLUMNS); InputEventBaseOnOS.addBasicEditInputMap(textField); 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 9bb14d106a..f1cd05a907 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 @@ -31,6 +31,7 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.WidgetInfoConfig; import com.fr.general.Background; +import com.fr.log.FineLoggerFactory; import com.fr.report.web.button.Email; import com.fr.report.web.button.Export; import com.fr.report.web.button.write.AppendColumnRow; @@ -223,8 +224,12 @@ public class EditToolBar extends BasicPane { if (widget instanceof Button) { String iconname = ((Button) widget).getIconName(); if (StringUtils.isNotBlank(iconname)) { - Image iimage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconname); - toolBarButton.setIcon(new ImageIcon(iimage)); + Image iconImage = WidgetInfoConfig.getInstance().getIconManager().getIconImage(iconname); + if (iconImage != null) { + toolBarButton.setIcon(new ImageIcon(iconImage)); + } else { + FineLoggerFactory.getLogger().warn(iconname + " can not find in finedb!"); + } } } } diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java index a6576faa10..9ebbf875fe 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WebCssPane.java @@ -12,6 +12,7 @@ import com.fr.file.FILEChooserPane; import com.fr.file.filter.ChooseFileFilter; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.web.attr.ReportWebAttr; import javax.swing.BorderFactory; @@ -46,7 +47,8 @@ public class WebCssPane extends BasicPane { northPane.add(localText, FlowLayout.CENTER); northPane.add(chooseFile, FlowLayout.RIGHT); outnorth.add(northPane,BorderLayout.NORTH); - UILabel infor = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CSS_Warning")); + UILabel infor = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CSS_Warning", + ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBAPP_NAME)); infor.setForeground(new Color(207, 42, 39)); outnorth.add(infor,BorderLayout.CENTER); this.add(outnorth, BorderLayout.NORTH); diff --git a/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java index bf04e554f8..b2934b10e3 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java @@ -15,6 +15,7 @@ import com.fr.file.filter.ChooseFileFilter; import com.fr.log.FineLoggerFactory; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; import com.fr.web.attr.ReportWebAttr; import javax.swing.BorderFactory; @@ -97,7 +98,8 @@ public class WebJsPane extends BasicPane { northPane.add(localText); northPane.add(chooseFile); firstnorth.add(northPane,BorderLayout.NORTH); - infor1 = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1")); + infor1 = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1", + ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBAPP_NAME)); infor1.setForeground(new Color(207, 42, 39)); firstnorth.add(infor1,BorderLayout.CENTER); @@ -107,7 +109,7 @@ public class WebJsPane extends BasicPane { centerPane.add(urlText); centerPane.add(testConnection); secondnorth.add(centerPane,BorderLayout.NORTH); - infor2 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2")); + infor2 = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2", ProjectConstants.WEBAPP_NAME)); infor2.setForeground(new Color(207, 42, 39)); secondnorth.add(infor2,BorderLayout.CENTER); @@ -127,7 +129,7 @@ public class WebJsPane extends BasicPane { if (url.matches("^[a-zA-z]+://.+js")) { return url; } else { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(WebJsPane.this), com.fr.design.i18n.Toolkit.i18nText("Add_JS_warning")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(WebJsPane.this), com.fr.design.i18n.Toolkit.i18nText("Add_JS_warning")); return ""; } } @@ -188,7 +190,7 @@ public class WebJsPane extends BasicPane { public void actionPerformed(ActionEvent arg0) { String uri = urlText.getText(); if (!uri.matches("^[a-zA-z]+://.+js")) { - JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(WebJsPane.this), com.fr.design.i18n.Toolkit.i18nText("Add_JS_warning")); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(WebJsPane.this), com.fr.design.i18n.Toolkit.i18nText("Add_JS_warning")); return; } InputStream in = null; @@ -221,13 +223,13 @@ public class WebJsPane extends BasicPane { localRadioSelectAction(); urlFileRadioButton.setForeground(new Color(143, 142, 139)); localFileRadioButton.setForeground(Color.black); - infor1.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1")); + infor1.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING1", ProjectConstants.WEBAPP_NAME, ProjectConstants.WEBAPP_NAME)); infor2.setText(" "); } else if (urlFileRadioButton.isSelected()) { urlRadioSelectAction(); localFileRadioButton.setForeground(new Color(143, 142, 139)); urlFileRadioButton.setForeground(Color.black); - infor2.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2")); + infor2.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_JS_WARNING2", ProjectConstants.WEBAPP_NAME)); infor1.setText(" "); } if (StringUtils.isEmpty(urlText.getText()) && StringUtils.isEmpty(localText.getText())) { diff --git a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java index 2b22297837..2ff9d41800 100644 --- a/designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java +++ b/designer-realize/src/main/java/com/fr/design/webattr/printsettings/AbstractNativePrintSettingPane.java @@ -103,14 +103,14 @@ public abstract class AbstractNativePrintSettingPane extends JPanel { showDialogCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Show_Print_Setting_Window_When_Printing")); showDialogCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); UILabel showDialogCheckTip = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Use_Default_Settings")); - JPanel showDialogCheckPane = GUICoreUtils.createFlowPane(new Component[] { + JPanel showDialogCheckPane = GUICoreUtils.createFlowPane(new Component[]{ showDialogCheck, showDialogCheckTip}, FlowLayout.LEFT); // 打印需要指定 sheet needSelectSheetCheck = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Engine_Need_Select_Sheet_When_Printing")); needSelectSheetCheck.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20)); UILabel needSelectSheetCheckTip = GUICoreUtils.createTipLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Tip_Invalid_In_Page_View")); - JPanel needSelectSheetCheckPane = GUICoreUtils.createFlowPane(new Component[] { + JPanel needSelectSheetCheckPane = GUICoreUtils.createFlowPane(new Component[]{ needSelectSheetCheck, needSelectSheetCheckTip}, FlowLayout.LEFT); return createHeaderPane(tipDownload, showDialogCheckPane, needSelectSheetCheckPane); @@ -263,7 +263,7 @@ public abstract class AbstractNativePrintSettingPane extends JPanel { ' ' + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_PageSetup_mm") + ']'; - this.setText(sbuf); + this.setText(" " + sbuf); break; } } @@ -461,8 +461,8 @@ public abstract class AbstractNativePrintSettingPane extends JPanel { extraUpdate(nativePrintAttr); nativePrintAttr.setShowDialog(showDialogCheck.isSelected()); nativePrintAttr.setNeedSelectSheet(needSelectSheetCheck.isSelected()); - nativePrintAttr.setPrinterName((String)printerComboBox.getSelectedItem()); - nativePrintAttr.setCopy((int)copySpinner.getValue()); + nativePrintAttr.setPrinterName((String) printerComboBox.getSelectedItem()); + nativePrintAttr.setCopy((int) copySpinner.getValue()); // 页码 if (allPageRadioButton.isSelected()) { @@ -472,7 +472,7 @@ public abstract class AbstractNativePrintSettingPane extends JPanel { } else if (customPageRadioButton.isSelected()) { nativePrintAttr.setPageType(NativePrintAttr.PageType.SPECIFIED_PAGES); nativePrintAttr.setArea(specifiedAreaField.getText()); - } else if (doublePrintComboBox.getSelectedIndex() == ODD_INDEX){ + } else if (doublePrintComboBox.getSelectedIndex() == ODD_INDEX) { nativePrintAttr.setPageType(NativePrintAttr.PageType.ODD_PAGES); } else { nativePrintAttr.setPageType(NativePrintAttr.PageType.EVEN_PAGES); @@ -494,7 +494,7 @@ public abstract class AbstractNativePrintSettingPane extends JPanel { nativePrintAttr.setInheritPageMarginSetting(inheritPageMarginSettingCheck.isSelected()); nativePrintAttr.setMargin(pageMarginSettingPane.updateBean()); nativePrintAttr.setFitPaperSize(fitPaperSizeCheck.isSelected()); - nativePrintAttr.setScalePercent((int)scalePercentField.getValue()); + nativePrintAttr.setScalePercent((int) scalePercentField.getValue()); } protected void extraUpdate(NativePrintAttr nativePrintAttr) { diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java index 2df2e9f2a0..0dbde28ad7 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java @@ -1,6 +1,7 @@ package com.fr.design.widget; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.gui.core.WidgetConstants; import com.fr.design.widget.ui.ButtonDefinePane; import com.fr.design.widget.ui.CheckBoxDefinePane; @@ -42,7 +43,13 @@ import com.fr.form.ui.TextEditor; import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeEditor; import com.fr.form.ui.Widget; +import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.report.web.button.form.TreeNodeToggleButton; import com.fr.report.web.button.write.AppendRowButton; import com.fr.report.web.button.write.DeleteRowButton; @@ -66,6 +73,26 @@ public class WidgetDefinePaneFactory { private static Map, Appearance> pluginDefineMap = ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap(); static { + putDefault(); + + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshPluginMap(); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PluginModule.ExtraDesign, CellWidgetOptionProvider.XML_TAG); + } + }); + } + + private WidgetDefinePaneFactory() { + + } + + private static void putDefault() { defineMap.put(NumberEditor.class, new Appearance(NumberEditorDefinePane.class, WidgetConstants.NUMBER + "")); defineMap.put(DateEditor.class, new Appearance(DateEditorDefinePane.class, WidgetConstants.DATE + "")); defineMap.put(ComboCheckBox.class, new Appearance(ComboCheckBoxDefinePane.class, WidgetConstants.COMBOCHECKBOX + "")); @@ -96,8 +123,9 @@ public class WidgetDefinePaneFactory { defineMap.put(TreeNodeToggleButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + "")); } - private WidgetDefinePaneFactory() { - + private static void refreshPluginMap() { + pluginDefineMap.clear(); + pluginDefineMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap()); } @Nullable diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java index e6438897cf..86eba335d9 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java @@ -1,13 +1,20 @@ package com.fr.design.widget; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.widget.mobile.WidgetMobilePane; import com.fr.design.widget.ui.mobile.MultiFileEditorMobilePane; import com.fr.design.widget.ui.mobile.ScanCodeMobilePane; import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.TextEditor; import com.fr.form.ui.Widget; +import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import java.util.HashMap; import java.util.Map; @@ -17,22 +24,43 @@ import java.util.Map; */ public class WidgetMobilePaneFactory { private static Map, Class> mobilePaneMap = new HashMap<>(); + private static Map, Class> mobilePluginPaneMap = new HashMap<>(); static { mobilePaneMap.put(MultiFileEditor.class, MultiFileEditorMobilePane.class); mobilePaneMap.put(TextEditor.class, ScanCodeMobilePane.class); - mobilePaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); + mobilePluginPaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); + + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshPluginMap(); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PluginModule.ExtraDesign, CellWidgetOptionProvider.XML_TAG); + } + }); } private WidgetMobilePaneFactory() { } + private static void refreshPluginMap() { + mobilePluginPaneMap.clear(); + mobilePluginPaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); + } + public static WidgetMobilePane createWidgetMobilePane(Widget widget) { WidgetMobilePane mobilePane = WidgetMobilePane.DEFAULT_PANE; try { if (mobilePaneMap.containsKey(widget.getClass())) { mobilePane = mobilePaneMap.get(widget.getClass()).newInstance(); mobilePane.populate(widget); + } else if (mobilePluginPaneMap.containsKey(widget.getClass())){ + mobilePane = mobilePluginPaneMap.get(widget.getClass()).newInstance(); + mobilePane.populate(widget); } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-realize/src/main/java/com/fr/design/widget/ui/RadioDefinePane.java b/designer-realize/src/main/java/com/fr/design/widget/ui/RadioDefinePane.java index b3915ac119..5de31c110c 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/ui/RadioDefinePane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/ui/RadioDefinePane.java @@ -10,6 +10,10 @@ import com.fr.general.FRFont; import javax.swing.*; import java.awt.*; +/** + * @deprecated + */ +@Deprecated public class RadioDefinePane extends AbstractDataModify { public RadioDefinePane() { this.iniComoponents(); diff --git a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java index 3873ae2e7f..349503bd72 100644 --- a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java @@ -5,8 +5,10 @@ import com.fr.base.DynamicUnitList; import com.fr.base.ScreenResolution; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; +import com.fr.design.fun.ReportLengthUNITProvider; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.unit.UnitConvertUtil; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.FloatSelection; @@ -14,7 +16,6 @@ import com.fr.grid.selection.Selection; import com.fr.log.FineLoggerFactory; import com.fr.report.elementcase.ElementCase; import com.fr.stable.ColumnRow; -import com.fr.stable.Constants; import com.fr.stable.unit.FU; import com.fr.stable.unit.UNIT; @@ -306,25 +307,10 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { // int resolution = ScreenResolution.getScreenResolution(); FU ulen = FU.valueOfPix((int) doubleValue, resolution); FU tulen = FU.valueOfPix((int) totalDoubleValue, resolution); - String unit; - double len, tlen; - if (unitType == Constants.UNIT_PT) { - len = ulen.toPTValue4Scale2(); - tlen = tulen.toPTValue4Scale2(); - unit = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_PT"); - } else if (unitType == Constants.UNIT_CM) { - len = ulen.toCMValue4Scale2(); - tlen = tulen.toCMValue4Scale2(); - unit = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_CM"); - } else if (unitType == Constants.UNIT_INCH) { - len = ulen.toINCHValue4Scale3(); - tlen = tulen.toINCHValue4Scale3(); - unit = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_INCH"); - } else { - len = ulen.toMMValue4Scale2(); - tlen = tulen.toMMValue4Scale2(); - unit = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Unit_MM"); - } + ReportLengthUNITProvider lengthUNIT = UnitConvertUtil.parseLengthUNIT(unitType); + String unit = lengthUNIT.unitText(); + double len = lengthUNIT.unit2Value4Scale(ulen); + double tlen = lengthUNIT.unit2Value4Scale(tulen); StringBuilder sb = new StringBuilder(); sb.append(String.format("%.2f", new Double(len))) .append('/').append(String.format("%.2f", new Double(tlen))) diff --git a/designer-realize/src/main/java/com/fr/grid/CellElementPainter.java b/designer-realize/src/main/java/com/fr/grid/CellElementPainter.java index 607fde54f7..6148ee8d68 100644 --- a/designer-realize/src/main/java/com/fr/grid/CellElementPainter.java +++ b/designer-realize/src/main/java/com/fr/grid/CellElementPainter.java @@ -9,7 +9,7 @@ import com.fr.report.core.PaintUtils; import com.fr.report.elementcase.ElementCase; public class CellElementPainter { - public void paintBackground(Graphics2D g2d, ElementCase report, CellElement ce, int width, int height) { + public void paintBackground(Graphics2D g2d, ElementCase report, CellElement ce, double width, double height) { Style.paintBackground(g2d, ce.getStyle(), width, height); } 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 266cb5cb02..ff027af084 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -497,12 +497,12 @@ public class GridUI extends ComponentUI { paintCellElementRectangleList.add(this.tmpRectangle.clone()); - int cellWidth = (int) this.tmpRectangle.getWidth(); - int cellHeight = (int) this.tmpRectangle.getHeight(); + double cellWidth = this.tmpRectangle.getWidth(); + double cellHeight = this.tmpRectangle.getHeight(); // denny_Grid: 画Grid中单元格的内容(包括单元格的背景Content + Background), 不包括边框 - painter.paintBackground(g2d, report, tmpCellElement, cellWidth, cellHeight); - painter.paintContent(g2d, report, tmpCellElement, cellWidth, cellHeight, resolution); + painter.paintBackground(g2d, report, tmpCellElement, cellWidth - 1, cellHeight - 1); + painter.paintContent(g2d, report, tmpCellElement, (int) cellWidth, (int) cellHeight, resolution); // denny_Grid: 注意下面还要减一, 因为上面translate时加一 g2d.translate(-this.tmpRectangle.getX() - 1, -this.tmpRectangle.getY() - 1); paintAuthorityCell(g2d, tmpCellElement); 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 57a6532250..1f8d181ce3 100644 --- a/designer-realize/src/main/java/com/fr/start/Designer.java +++ b/designer-realize/src/main/java/com/fr/start/Designer.java @@ -1,5 +1,8 @@ package com.fr.start; +import com.fr.design.os.impl.SupportOSImpl; +import com.fr.log.FineLoggerFactory; + /** * 设计器主进程入口(无缝更换升级jar包,若使用其他类作为入口,需要重新打包designer.exe等,升级后仍然走的原来逻辑) * @@ -11,7 +14,25 @@ package com.fr.start; public class Designer { public static void main(String[] args) { - // 创建进程 - DesignerLauncher.getInstance().start(args); + try { + if (DesignerJavaRuntime.getInstance().isInValidVmOptions() + || SupportOSImpl.NON_GUARDIAN_START.support()) { + runNonGuardianDesigner(args); + } else { + // 创建进程 + DesignerLauncher.getInstance().start(args); + } + } catch (Exception e) { + runNonGuardianDesigner(args); + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + /** + * 启动非守护设计器 + * @param args 参数 + */ + private static void runNonGuardianDesigner(String[] args) { + MainDesigner.main(args); } } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerInitial.java b/designer-realize/src/main/java/com/fr/start/DesignerInitial.java index 856208f400..39c702af56 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerInitial.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerInitial.java @@ -1,12 +1,15 @@ package com.fr.start; import com.fr.design.constants.DesignerLaunchStatus; +import com.fr.design.fun.DesignerStartClassProcessor; import com.fr.design.mainframe.DesignerContext; import com.fr.design.ui.util.UIUtil; import com.fr.event.Event; import com.fr.event.EventDispatcher; import com.fr.event.Listener; import com.fr.event.Null; +import com.fr.invoke.Reflect; +import com.fr.stable.bridge.StableFactory; /** * Created by juhaoyu on 2019-06-14. @@ -14,13 +17,18 @@ import com.fr.event.Null; */ public class DesignerInitial { - private static volatile MainDesigner designer; + private static volatile BaseDesigner designer; public static void init(final String... args) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { - designer = new MainDesigner(args); + DesignerStartClassProcessor processor = StableFactory.getMarkedInstanceObjectFromClass(DesignerStartClassProcessor.MARK_STRING, DesignerStartClassProcessor.class); + if (processor != null) { + designer = Reflect.on(processor.transform()).create(args).get(); + } else { + designer = new MainDesigner(args); + } } }); } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java b/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java index 351bf1e44f..b99f648aed 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java @@ -1,11 +1,28 @@ package com.fr.start; +import com.fr.design.os.impl.SupportOSImpl; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralContext; +import com.fr.general.GeneralUtils; +import com.fr.general.IOUtils; +import com.fr.locale.InterProviderFactory; +import com.fr.log.FineLoggerFactory; import com.fr.process.engine.core.AbstractJavaRuntime; +import com.fr.stable.ArrayUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.os.OperatingSystem; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + /** * 设计器Java运行环境 * @@ -16,18 +33,47 @@ import com.fr.stable.os.OperatingSystem; public class DesignerJavaRuntime extends AbstractJavaRuntime { private static final String DOT = "."; + private static final String REMOTE_DEBUG = "-agentlib:jdwp=transport=dt_socket"; private static final String INSTALL4J = ".install4j"; private static final String JAVA_EXEC = "java"; private static final String WIN_JRE_BIN = StableUtils.pathJoin("jre", "bin"); private static final String MAC_JRE_BIN = StableUtils.pathJoin("jre.bundle", "Contents", "Home", "jre", "bin"); + private static final String BIN_HOME = StableUtils.pathJoin(StableUtils.getInstallHome(), "bin"); + private static final String LOGO_PATH = StableUtils.pathJoin(BIN_HOME, "logo.png"); + private static final String DOCK_OPTIONS = "-Xdock:icon=" + LOGO_PATH; + private static final String DOCK_NAME_OPTIONS = "-Xdock:name=" + FineDesigner.class.getSimpleName(); + private static final String WIN_VM_OPTIONS_PATH = StableUtils.pathJoin(BIN_HOME, "designer.vmoptions"); private static final String[] DEBUG_OPTIONS = new String[]{"-Dfile.encoding=UTF-8", "-Xmx2048m"}; + static { + try { + if (SupportOSImpl.DOCK_ICON.support()) { + IOUtils.copy(DesignerJavaRuntime.class.getResourceAsStream("/com/fr/design/icon/logo.png"), "logo.png", new File(BIN_HOME)); + } + } catch (IOException ignore) { + } + } + private static final DesignerJavaRuntime INSTANCE = new DesignerJavaRuntime(); public static DesignerJavaRuntime getInstance() { return INSTANCE; } + /** + * 远程调试不走启动守护 + * @return + */ + public boolean isInValidVmOptions() { + String[] options = getJvmOptions(); + for (String op : options) { + if (op.startsWith(REMOTE_DEBUG)) { + return true; + } + } + return false; + } + @Override public String getJavaExec() { String installHome = StableUtils.getInstallHome(); @@ -49,7 +95,7 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime { } private boolean isInstallVersion() { - return !ComparatorUtils.equals(StableUtils.getInstallHome(), DOT); + return !ComparatorUtils.equals(GeneralUtils.readFullBuildNO(), InterProviderFactory.getProvider().getLocText("Fine-Core_Basic_About_No_Build")); } @@ -62,7 +108,28 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime { @Override public String[] getJvmOptions() { if (isInstallVersion()) { - return super.getJvmOptions(); + String[] options = super.getJvmOptions(); + // win下环境变量 存在错误的设置会导致问题 直接读vmoptions + if (SupportOSImpl.VM_OPTIONS_ADAPTER.support()) { + List optionList = new ArrayList<>(); + try (BufferedReader reader = new BufferedReader(new FileReader(new File(WIN_VM_OPTIONS_PATH)))) { + String option = null; + while ((option = reader.readLine()) != null) { + optionList.add(option.trim()); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return DEBUG_OPTIONS; + } + if (!optionList.isEmpty()) { + return optionList.toArray(new String[0]); + } + } + if (SupportOSImpl.DOCK_ICON.support()) { + options = ArrayUtils.addAll(options, DOCK_OPTIONS, DOCK_NAME_OPTIONS); + } + FineLoggerFactory.getLogger().debug("Vm Options: " + Arrays.toString(options)); + return options; } else { return DEBUG_OPTIONS; } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerLauncher.java b/designer-realize/src/main/java/com/fr/start/DesignerLauncher.java index 48cf9e4d06..90ebc1a319 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerLauncher.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerLauncher.java @@ -1,5 +1,6 @@ package com.fr.start; +import com.fr.design.RestartHelper; import com.fr.process.FineProcess; import com.fr.process.engine.FineJavaProcessFactory; import com.fr.process.engine.core.FineProcessContext; @@ -64,6 +65,6 @@ public class DesignerLauncher { public void restart() { beforeExit(); - start(args); + RestartHelper.restart(); } } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java b/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java index 3e8663f89e..c76e6b0728 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerSubListener.java @@ -26,13 +26,15 @@ public class DesignerSubListener { } public void start() { - FineProcessContext.getParentPipe().listen(FineProcessEngineEvent.READY, new Listener() { - @Override - public void on(Event event, Null param) { - if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) { - FineProcessContext.getParentPipe().fire(new CarryMessageEvent(DesignerProcessType.INSTANCE.obtain())); + if (FineProcessContext.getParentPipe() != null) { + FineProcessContext.getParentPipe().listen(FineProcessEngineEvent.READY, new Listener() { + @Override + public void on(Event event, Null param) { + if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) { + FineProcessContext.getParentPipe().fire(new CarryMessageEvent(DesignerProcessType.INSTANCE.obtain())); + } } - } - }); + }); + } } } diff --git a/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java index acbd92271a..f5c9174649 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java @@ -1,5 +1,6 @@ package com.fr.start; +import com.fr.common.report.ReportState; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.dialog.ErrorDialog; import com.fr.design.i18n.Toolkit; @@ -9,12 +10,14 @@ import com.fr.design.utils.DesignUtils; import com.fr.event.Event; import com.fr.event.Listener; import com.fr.event.Null; +import com.fr.general.ComparatorUtils; import com.fr.process.FineProcess; import com.fr.process.ProcessEventPipe; import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.stable.StringUtils; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; @@ -28,15 +31,17 @@ import java.util.concurrent.TimeUnit; public class DesignerSuperListener { private static final DesignerSuperListener INSTANCE = new DesignerSuperListener(); - private static final int ONCE_DELAY = 90; + private static final int ONCE_DELAY = 180; private static final int FIXED_DELAY = 0; private static final int FIXED_FREQ = 2; private final ScheduledExecutorService service = Executors.newScheduledThreadPool(2, new NamedThreadFactory("DesignerListener")); + private final ExecutorService helpService = Executors.newSingleThreadExecutor( new NamedThreadFactory("DesignerSuperListener-Help")); private FineProcess process; private ScheduledFuture fixedFuture; private ScheduledFuture onceFuture; + private volatile boolean cancel = false; private DesignerSuperListener() { @@ -49,6 +54,7 @@ public class DesignerSuperListener { public void start() { process = FineProcessContext.getProcess(DesignerProcessType.INSTANCE); startExitListener(); + startHelpLister(); startFrameListener(); startFallBackListener(); } @@ -57,7 +63,28 @@ public class DesignerSuperListener { process.getPipe().listen(FineProcessEngineEvent.DESTROY, new Listener() { @Override public void on(Event event, Null param) { - DesignerLauncher.getInstance().exit(); + System.exit(0); + } + }); + } + + private void startHelpLister() { + helpService.submit(new Runnable() { + @Override + public void run() { + while (!cancel) { + ProcessEventPipe pipe = process.getPipe(); + String msg = pipe.info(); + if (ComparatorUtils.equals(ReportState.STOP.getValue(), msg)) { + onceFuture.cancel(false); + } + if (ComparatorUtils.equals(ReportState.ACTIVE.getValue(), msg)) { + startFrameListener(); + } + if (ComparatorUtils.equals(DesignerProcessType.INSTANCE.obtain(), msg)) { + frameReport(); + } + } } }); } @@ -66,6 +93,7 @@ public class DesignerSuperListener { onceFuture = service.schedule(new Runnable() { @Override public void run() { + cancel = true; ProcessEventPipe pipe = process.getPipe(); pipe.fire(FineProcessEngineEvent.READY); if (StringUtils.isNotEmpty(pipe.info())) { @@ -88,6 +116,7 @@ public class DesignerSuperListener { @Override protected void okEvent() { dispose(); + DesignerLauncher.getInstance().exit(); } @Override @@ -97,7 +126,6 @@ public class DesignerSuperListener { } }; dialog.setVisible(true); - DesignerLauncher.getInstance().exit(); } private void startFallBackListener() { @@ -138,10 +166,12 @@ public class DesignerSuperListener { public void stopTask() { onceFuture.cancel(false); fixedFuture.cancel(false); + cancel = true; } public void stop() { stopTask(); service.shutdown(); + helpService.shutdown(); } } diff --git a/designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java b/designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java new file mode 100644 index 0000000000..a59d15faf3 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java @@ -0,0 +1,143 @@ +package com.fr.start; + +import com.fr.common.report.ReportState; +import com.fr.design.RestartHelper; +import com.fr.design.dialog.ErrorDialog; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.messagecollect.StartErrorMessageCollector; +import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; +import com.fr.exit.DesignerExiter; +import com.fr.general.IOUtils; +import com.fr.io.utils.ResourceIOUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.process.ProcessEventPipe; +import com.fr.process.engine.core.CarryMessageEvent; +import com.fr.process.engine.core.FineProcessContext; +import com.fr.stable.StableUtils; +import com.fr.stable.lifecycle.ErrorType; +import com.fr.stable.lifecycle.FineLifecycleFatalError; +import com.fr.stable.project.ProjectConstants; + +import javax.swing.*; +import java.util.HashMap; +import java.util.Map; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/16 + */ +public class LifecycleFatalErrorHandler { + + private static final LifecycleFatalErrorHandler INSTANCE = new LifecycleFatalErrorHandler(); + private Map map = new HashMap<>(); + + private LifecycleFatalErrorHandler() { + for (ErrorType type : ErrorType.values()) { + if (ErrorType.FINEDB.equals(type)) { + map.put(type, FineDBHandler.SELF); + } else { + map.put(type, DefaultHandler.SELF); + } + } + } + + public static LifecycleFatalErrorHandler getInstance() { + return INSTANCE; + } + + public void handle(FineLifecycleFatalError fatal) { + SplashContext.getInstance().hide(); + FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.STOP.getValue())); + map.get(fatal.getErrorType()).handle(fatal); + } + + interface Handler { + void handle(FineLifecycleFatalError error); + } + + /** + * finedb处理 + */ + enum FineDBHandler implements Handler { + + SELF { + @Override + public void handle(FineLifecycleFatalError fatal) { + StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.FINEDB_PROBLEM.getId(), + DesignerErrorMessage.FINEDB_PROBLEM.getMessage(), + fatal.getMessage()); + FineLoggerFactory.getLogger().error(DesignerErrorMessage.FINEDB_PROBLEM.getId() + ": " + DesignerErrorMessage.FINEDB_PROBLEM.getMessage()); + int result = FineJOptionPane.showOptionDialog(null, + Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset"), + Toolkit.i18nText("Fine-Design_Basic_Error_Tittle"), + JOptionPane.YES_NO_OPTION, + JOptionPane.ERROR_MESSAGE, + IOUtils.readIcon("com/fr/design/images/error/error2.png"), + new Object[] {Toolkit.i18nText("Fine-Design_Basic_Reset"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}, + null); + if (result == JOptionPane.YES_OPTION) { + boolean success = false; + try { + ResourceIOUtils.copy(StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_NAME), + StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_BAK_NAME)); + success = ResourceIOUtils.delete(StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_NAME)); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + afterBackupFailed(); + } + if (!success) { + afterBackupFailed(); + } else { + RestartHelper.restart(); + } + } else { + DesignerExiter.getInstance().execute(); + } + } + + private void afterBackupFailed() { + FineJOptionPane.showMessageDialog(null, + Toolkit.i18nText("Fine-Design_Error_Finedb_Backup_Reset_Result", + ResourceIOUtils.getRealPath(StableUtils.pathJoin(ProjectConstants.EMBED_DB_DIRECTORY, ProjectConstants.FINE_DB_NAME))), + Toolkit.i18nText("Fine-Design_Basic_Error"), + JOptionPane.ERROR_MESSAGE); + DesignerExiter.getInstance().execute(); + } + } + } + + /** + * 默认处理 + */ + enum DefaultHandler implements Handler { + SELF { + @Override + public void handle(FineLifecycleFatalError fatal) { + FineLoggerFactory.getLogger().error(fatal.getMessage(), fatal); + StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(), + DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(), + fatal.getMessage()); + ErrorDialog dialog = new ErrorDialog(null, Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), + Toolkit.i18nText("Fine-Design_Error_Start_Report"), + fatal.getMessage()) { + @Override + protected void okEvent() { + dispose(); + DesignerExiter.getInstance().execute(); + } + + @Override + protected void restartEvent() { + dispose(); + RestartHelper.restart(); + } + }; + dialog.setVisible(true); + } + } + } + + +} diff --git a/designer-realize/src/main/java/com/fr/start/MainDesigner.java b/designer-realize/src/main/java/com/fr/start/MainDesigner.java index 238b035125..2cdc832308 100644 --- a/designer-realize/src/main/java/com/fr/start/MainDesigner.java +++ b/designer-realize/src/main/java/com/fr/start/MainDesigner.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; @@ -13,7 +12,6 @@ import com.fr.design.actions.server.StyleListAction; import com.fr.design.actions.server.WidgetManagerAction; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.constants.UIConstants; -import com.fr.design.dialog.ErrorDialog; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.MutilTempalteTabPane; @@ -23,7 +21,6 @@ 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; @@ -32,8 +29,6 @@ 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.messagecollect.StartErrorMessageCollector; -import com.fr.design.mainframe.messagecollect.entity.DesignerErrorMessage; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; @@ -42,17 +37,19 @@ import com.fr.design.menu.ShortCut; import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.concurrent.ThreadFactoryBuilder; import com.fr.design.utils.gui.GUICoreUtils; -import com.fr.exit.DesignerExiter; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.module.Module; import com.fr.module.ModuleContext; +import com.fr.module.engine.event.LifecycleErrorEvent; import com.fr.runtime.FineRuntime; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.stable.lifecycle.ErrorType; -import com.fr.stable.lifecycle.LifecycleFatalError; +import com.fr.stable.lifecycle.FineLifecycleFatalError; import com.fr.stable.xml.XMLTools; import com.fr.start.module.StartupArgs; import com.fr.start.server.ServerTray; @@ -60,7 +57,6 @@ import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.workspace.WorkContext; import javax.swing.JComponent; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.border.MatteBorder; import java.awt.Component; @@ -106,39 +102,20 @@ public class MainDesigner extends BaseDesigner { watch.start(); //启动运行时 FineRuntime.start(); + DesignerSubListener.getInstance().start(); + EventDispatcher.listen(LifecycleErrorEvent.SELF, new Listener() { + @Override + public void on(Event event, FineLifecycleFatalError param) { + LifecycleFatalErrorHandler.getInstance().handle(param); + } + }); Module designerRoot = ModuleContext.parseRoot("designer-startup.xml"); //传递启动参数 designerRoot.setSingleton(StartupArgs.class, new StartupArgs(args)); try { designerRoot.start(); - } catch (LifecycleFatalError fatal) { - SplashContext.getInstance().hide(); - if (ErrorType.FINEDB.equals(fatal.getErrorType())) { - StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.FINEDB_PROBLEM.getId(), - DesignerErrorMessage.FINEDB_PROBLEM.getMessage(), - fatal.getMessage()); - JOptionPane.showMessageDialog(null, fatal.getMessage(), Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); - } - FineLoggerFactory.getLogger().error(fatal.getMessage(), fatal); - StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.UNEXCEPTED_START_FAILED.getId(), - DesignerErrorMessage.UNEXCEPTED_START_FAILED.getMessage(), - fatal.getMessage()); - ErrorDialog dialog = new ErrorDialog(null, Toolkit.i18nText("Fine-Design_Error_Start_Apology_Message"), - Toolkit.i18nText("Fine-Design_Error_Start_Report"), - fatal.getMessage()) { - @Override - protected void okEvent() { - dispose(); - DesignerExiter.getInstance().execute(); - } - - @Override - protected void restartEvent() { - dispose(); - RestartHelper.restart(); - } - }; - dialog.setVisible(true); + } catch (FineLifecycleFatalError fatal) { + LifecycleFatalErrorHandler.getInstance().handle(fatal); } if (WorkContext.getCurrent().isLocal()) { 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 796b983f84..38efb4c1fc 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 @@ -63,6 +63,7 @@ import com.fr.design.update.actions.RecoverForDesigner; import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; import com.fr.form.stable.ElementCaseThumbnailProcessor; +import com.fr.general.GeneralContext; import com.fr.general.xml.GeneralXMLTools; import com.fr.js.EmailJavaScript; import com.fr.js.JavaScriptImpl; @@ -75,6 +76,11 @@ import com.fr.locale.LocaleScope; import com.fr.log.FineLoggerFactory; import com.fr.log.LogHandler; import com.fr.module.Activator; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.quickeditor.cellquick.CellBiasTextPainterEditor; import com.fr.quickeditor.cellquick.CellDSColumnEditor; import com.fr.quickeditor.cellquick.CellFormulaQuickEditor; @@ -181,6 +187,7 @@ public class DesignerActivator extends Activator { ActionFactory.registerFloatInsertActionClass(actionsForInsertFloatElement()); DesignModuleFactory.registerCreators4Hyperlink(hyperlinkTypes()); + createPluginListener(); justStartModules4Designer(); CalculatorProviderContext.setValueConverter(valueConverter()); @@ -193,6 +200,21 @@ public class DesignerActivator extends Activator { InformationCollector.getInstance().collectStartTime(); } + private void createPluginListener() { + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + ActionFactory.referCellInsertActionClass(actionsForInsertCellElement()); + ActionFactory.referFloatInsertActionClass(actionsForInsertFloatElement()); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PluginModule.ExtraDesign, ElementUIProvider.MARK_STRING); + } + }); + } + private static Class[] actionsForInsertCellElement() { List> classes = new ArrayList<>(); Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); 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 3dd7322f61..56af5583f5 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 @@ -16,14 +16,15 @@ import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignerPort; import com.fr.exit.DesignerExiter; import com.fr.general.ComparatorUtils; -import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; import com.fr.record.analyzer.EnableMetrics; import com.fr.record.analyzer.Metrics; +import com.fr.stable.ArrayUtils; import com.fr.stable.BuildContext; import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import com.fr.start.DesignerProcessType; import com.fr.start.OemHandler; import com.fr.start.ServerStarter; @@ -34,8 +35,6 @@ import com.fr.start.server.FineEmbedServer; import com.fr.value.NotNullLazyValue; import org.jetbrains.annotations.NotNull; -import javax.swing.JFrame; -import javax.swing.JOptionPane; import java.io.File; import java.util.concurrent.ExecutorService; @@ -58,6 +57,8 @@ public class DesignerStartup extends Activator { BuildContext.setBuildFilePath("/com/fr/stable/build.properties"); // 检查是否是-Ddebug = true 启动 并切换对应的端口以及环境配置文件 checkDebugStart(); + // 都是在启动过程中读取,这边提前初始化xml配置 + DesignerEnvManager.getEnvManager(); // 初始化look and feel DesignUtils.initLookAndFeel(); if (DesignUtils.isPortOccupied()) { @@ -68,7 +69,9 @@ public class DesignerStartup extends Activator { if (DesignUtils.isStarted()) { // 如果端口被占用了 说明程序已经运行了一次,也就是说,已经建立一个监听服务器,现在只要给服务器发送命令就好了 final String[] args = startupArgsValue.getValue().get(); - DesignUtils.clientSend(args); + if (ArrayUtils.isNotEmpty(args)) { + DesignUtils.clientSend(args); + } FineLoggerFactory.getLogger().info("The Designer Has Been Started"); if (args.length == 0) { TipDialog dialog = new TipDialog(null, @@ -89,6 +92,10 @@ public class DesignerStartup extends Activator { } }; dialog.setVisible(true); + StartErrorMessageCollector.getInstance().record(DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getId(), + DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getMessage(), + StringUtils.EMPTY); + FineLoggerFactory.getLogger().error(DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getId() + ": " + DesignerErrorMessage.DESIGNER_PROCESS_OCCUPIED.getMessage()); } DesignerExiter.getInstance().execute(); return; diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/template/info/JWorkBookProcessInfoTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/template/info/JWorkBookProcessInfoTest.java new file mode 100644 index 0000000000..2629fc4621 --- /dev/null +++ b/designer-realize/src/test/java/com.fr/design/mainframe/template/info/JWorkBookProcessInfoTest.java @@ -0,0 +1,49 @@ +package com.fr.design.mainframe.template.info; + +import com.fr.base.Style; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.form.main.parameter.FormParameterUI; +import com.fr.invoke.Reflect; +import com.fr.json.JSONArray; +import com.fr.main.impl.WorkBook; +import com.fr.main.parameter.ReportParameterAttr; +import com.fr.plugin.chart.vanchart.VanChart; +import org.junit.Assert; +import org.junit.Test; + +/** + * Created by kerry on 2020-05-08 + */ +public class JWorkBookProcessInfoTest { + + @Test + public void testIsTestCell() { + ChartCollection chartCollection = new ChartCollection(); + chartCollection.addChart(new VanChart()); + JWorkBookProcessInfo processInfo = new JWorkBookProcessInfo(new WorkBook()); + boolean result = Reflect.on(processInfo).call("isTestCell", chartCollection, Style.getInstance()).get(); + Assert.assertTrue(result); + } + + + @Test + public void testUseParaPane(){ + WorkBook workBook = new WorkBook(); + JWorkBookProcessInfo processInfo = new JWorkBookProcessInfo(workBook); + Assert.assertFalse(processInfo.useParaPane()); + + ReportParameterAttr attr = new ReportParameterAttr(); + workBook.setReportParameterAttr(attr); + Assert.assertFalse(processInfo.useParaPane()); + + attr.setParameterUI(new FormParameterUI()); + Assert.assertTrue(processInfo.useParaPane()); + } + + @Test + public void testGetComponentsInfo() { + JWorkBookProcessInfo processInfo = new JWorkBookProcessInfo(new WorkBook()); + JSONArray ja = processInfo.getComponentsInfo(); + Assert.assertEquals(0, ja.size()); + } +} diff --git a/designer-realize/src/test/java/com/fr/start/DesignerJavaRuntimeTest.java b/designer-realize/src/test/java/com/fr/start/DesignerJavaRuntimeTest.java new file mode 100644 index 0000000000..13576a6e02 --- /dev/null +++ b/designer-realize/src/test/java/com/fr/start/DesignerJavaRuntimeTest.java @@ -0,0 +1,30 @@ +package com.fr.start; + +import junit.framework.TestCase; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/3/10 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({DesignerJavaRuntime.class}) +public class DesignerJavaRuntimeTest extends TestCase { + + public void testIsInValidVmOptions() { + PowerMock.mockStatic(DesignerJavaRuntime.class); + DesignerJavaRuntime designerJavaRuntime = PowerMock.createPartialMock(DesignerJavaRuntime.class, "isInstallVersion", "getJvmOptions"); + String[] options = new String[]{"-Dfile.encoding=UTF-8", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"}; + EasyMock.expect(designerJavaRuntime.getJvmOptions()).andReturn(options).anyTimes(); + EasyMock.replay(designerJavaRuntime); + PowerMock.replay(DesignerJavaRuntime.class); + Assert.assertTrue(designerJavaRuntime.isInValidVmOptions()); + } +} \ No newline at end of file