diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 77c779ce3e..9cb45918c1 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -18,6 +18,7 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.i18n.Toolkit; import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.mainframe.vcs.VcsConfigManager; +import com.fr.design.notification.SnapChatConfig; import com.fr.design.update.push.DesignerPushUpdateConfigManager; import com.fr.design.style.color.ColorSelectConfigManager; import com.fr.design.utils.DesignUtils; @@ -161,6 +162,11 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * alphafine */ private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance(); + + /** + * 阅后即焚的配置项 + */ + private SnapChatConfig snapChatConfig = SnapChatConfig.getInstance(); private DesignerPushUpdateConfigManager designerPushUpdateConfigManager = DesignerPushUpdateConfigManager.getInstance(); @@ -1562,11 +1568,17 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readVcsAttr(reader); } else if (DesignerPort.XML_TAG.equals(name)) { readDesignerPort(reader); + }else if (name.equals(SnapChatConfig.XML_TAG)) { + readSnapChatConfig(reader); } else { readLayout(reader, name); } } } + + private void readSnapChatConfig(XMLableReader reader) { + reader.readXMLObject(this.snapChatConfig = SnapChatConfig.getInstance()); + } private void readAlphaFineAttr(XMLableReader reader) { reader.readXMLObject(this.alphaFineConfigManager = AlphaFineConfigManager.getInstance()); @@ -1783,9 +1795,17 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeDesignerPushUpdateAttr(writer); writeVcsAttr(writer); writeDesignerPort(writer); + writeSnapChatConfig(writer); writer.end(); } - + + private void writeSnapChatConfig(XMLPrintWriter writer) { + + if (this.snapChatConfig != null) { + this.snapChatConfig.writeXML(writer); + } + } + private void writeAlphaFineAttr(XMLPrintWriter writer) { if (this.alphaFineConfigManager != null) { this.alphaFineConfigManager.writeXML(writer); 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 81e62239b4..f16cdd5047 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -404,6 +404,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())); 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 3fc03f438f..387082ed05 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; @@ -149,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; @@ -199,7 +197,6 @@ public class PreferencePane extends BasicPane { createFunctionPane(generalPane); createEditPane(generalPane); - createGuiOfGridPane(generalPane); createColorSettingPane(generalPane); createVcsSettingPane(generalPane); @@ -447,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")); @@ -591,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") + ":"); @@ -696,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()); @@ -768,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()); 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/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/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/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/FormAdaptiveConfigUIProcessor.java b/designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java new file mode 100644 index 0000000000..1f2853b91d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/FormAdaptiveConfigUIProcessor.java @@ -0,0 +1,36 @@ +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); + +} + 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/PropertyItemPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java new file mode 100644 index 0000000000..4e5112d8cc --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/PropertyItemPaneProvider.java @@ -0,0 +1,50 @@ +package com.fr.design.fun; + +import com.fr.design.mainframe.PaneHolder; +import com.fr.design.mainframe.PropertyItemBean; +import com.fr.stable.fun.mark.Mutable; +import org.jetbrains.annotations.Nullable; + +/** + * created by Harrison on 2020/03/23 + **/ +public interface PropertyItemPaneProvider extends Mutable { + + int CURRENT_LEVEL = 1; + + String XML_TAG = "PropertyItemPaneProvider"; + + int FIRST = 100; + + int LAST = -100; + + /** + * 独一无二的标志 + * + * @return 标志 + */ + String key(); + + /** + * 配置属性 + * + * @return 熟悉 + */ + PropertyItemBean getItem(); + + /** + * 面板持有者 + * + * @param clazz 类型 + * @return 持有者 + */ + @Nullable + PaneHolder getPaneHolder(Class clazz); + + /** + * 想要替代的类型 + * + * @return 替代类型 + */ + String replaceKey(); +} 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/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/AbstractPropertyItemPaneProvider.java b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPropertyItemPaneProvider.java new file mode 100644 index 0000000000..44e4abd4d1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/fun/impl/AbstractPropertyItemPaneProvider.java @@ -0,0 +1,31 @@ +package com.fr.design.fun.impl; + +import com.fr.design.fun.PropertyItemPaneProvider; +import com.fr.design.mainframe.PaneHolder; +import com.fr.stable.fun.impl.AbstractProvider; +import com.fr.stable.fun.mark.API; + +/** + * created by Harrison on 2020/03/23 + **/ +@API(level = PropertyItemPaneProvider.CURRENT_LEVEL) +public abstract class AbstractPropertyItemPaneProvider extends AbstractProvider implements PropertyItemPaneProvider { + + @Override + public PaneHolder getPaneHolder(Class clazz) { + + if (sign().equals(clazz)) { + return getPathHolder0(); + } + return null; + } + + protected abstract PaneHolder getPathHolder0(); + + protected abstract Class sign(); + + @Override + public int currentAPILevel() { + return PropertyItemPaneProvider.CURRENT_LEVEL; + } +} 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/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/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/icombocheckbox/UIComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java index e2a5719d4b..0652f9cf8f 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 @@ -360,6 +360,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/imenu/UIMenuItem.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java index 37f1fe0528..3230dbda21 100644 --- a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItem.java @@ -1,15 +1,11 @@ package com.fr.design.gui.imenu; -import java.awt.*; - -import javax.swing.*; -import javax.swing.plaf.basic.BasicMenuItemUI; - import com.fr.design.constants.UIConstants; -import com.fr.stable.Constants; import com.fr.stable.StringUtils; -import com.fr.design.utils.gui.GUIPaintUtils; -import sun.swing.SwingUtilities2; + +import javax.swing.Action; +import javax.swing.Icon; +import javax.swing.JMenuItem; public class UIMenuItem extends JMenuItem{ public UIMenuItem() { @@ -42,66 +38,5 @@ public class UIMenuItem extends JMenuItem{ public String getText() { return StringUtils.BLANK + super.getText(); } - - private class UIMenuItemUI extends BasicMenuItemUI { - @Override - protected void paintBackground(Graphics g, JMenuItem menuItem,Color bgColor) { - if(menuItem.getIcon() == null) { - super.paintBackground(g, menuItem, bgColor); - return; - } - ButtonModel model = menuItem.getModel(); - Color oldColor = g.getColor(); - int menuWidth = menuItem.getWidth(); - int menuHeight = menuItem.getHeight(); - - g.setColor(UIConstants.NORMAL_BACKGROUND); - g.fillRect(0, 0, menuWidth, menuHeight); - if(menuItem.isOpaque()) { - if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D)g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); - } else { - GUIPaintUtils.fillPaint((Graphics2D)g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); - } - g.setColor(oldColor); - } - else if (model.isArmed() || (menuItem instanceof JMenu && - model.isSelected())) { - GUIPaintUtils.fillPaint((Graphics2D)g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); - g.setColor(oldColor); - } - } - - protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { - ButtonModel model = menuItem.getModel(); - FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); - int mnemIndex = menuItem.getDisplayedMnemonicIndex(); - - if(!model.isEnabled()) { - // *** paint the text disabled - if ( UIManager.get("MenuItem.disabledForeground") instanceof Color ) { - g.setColor( UIManager.getColor("MenuItem.disabledForeground") ); - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, - -1, textRect.x, textRect.y + fm.getAscent()); - } else { - g.setColor(menuItem.getBackground().brighter()); - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, - -1, textRect.x, textRect.y + fm.getAscent()); - g.setColor(menuItem.getBackground().darker()); - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, - -1, textRect.x - 1, textRect.y + - fm.getAscent() - 1); - } - } else { - // *** paint the text normally - if (model.isArmed()|| (menuItem instanceof JMenu && model.isSelected())) { - g.setColor(Color.WHITE); // Uses protected field. - } - SwingUtilities2.drawStringUnderlineCharAt(menuItem, g,text, - -1, textRect.x, textRect.y + fm.getAscent()); - } - } - - } - + } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java new file mode 100644 index 0000000000..0d883abfbf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/imenu/UIMenuItemUI.java @@ -0,0 +1,81 @@ +package com.fr.design.gui.imenu; + +import com.fr.design.constants.UIConstants; +import com.fr.design.utils.gui.GUIPaintUtils; +import com.fr.stable.Constants; +import sun.swing.SwingUtilities2; + +import javax.swing.ButtonModel; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicMenuItemUI; +import java.awt.Color; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; + +/** + * created by Harrison on 2020/03/22 + **/ +public class UIMenuItemUI extends BasicMenuItemUI { + + @Override + protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { + if (menuItem.getIcon() == null) { + super.paintBackground(g, menuItem, bgColor); + return; + } + ButtonModel model = menuItem.getModel(); + Color oldColor = g.getColor(); + int menuWidth = menuItem.getWidth(); + int menuHeight = menuItem.getHeight(); + + g.setColor(UIConstants.NORMAL_BACKGROUND); + g.fillRect(0, 0, menuWidth, menuHeight); + if (menuItem.isOpaque()) { + if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + } else { + GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); + } + g.setColor(oldColor); + } else if (model.isArmed() || (menuItem instanceof JMenu && + model.isSelected())) { + GUIPaintUtils.fillPaint((Graphics2D) g, 30, 0, menuWidth - 30, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); + g.setColor(oldColor); + } + } + + protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { + ButtonModel model = menuItem.getModel(); + FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g); + int mnemIndex = menuItem.getDisplayedMnemonicIndex(); + + if (!model.isEnabled()) { + // *** paint the text disabled + if (UIManager.get("MenuItem.disabledForeground") instanceof Color) { + g.setColor(UIManager.getColor("MenuItem.disabledForeground")); + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x, textRect.y + fm.getAscent()); + } else { + g.setColor(menuItem.getBackground().brighter()); + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x, textRect.y + fm.getAscent()); + g.setColor(menuItem.getBackground().darker()); + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x - 1, textRect.y + + fm.getAscent() - 1); + } + } else { + // *** paint the text normally + if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { + g.setColor(Color.WHITE); // Uses protected field. + } + SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, text, + -1, textRect.x, textRect.y + fm.getAscent()); + } + } + +} 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/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/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 07191d536d..cf8f4f74d4 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -3,7 +3,9 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignerEnvManager; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.constants.UIConstants; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.icontainer.UIEastResizableContainer; @@ -12,12 +14,38 @@ import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.general.FRFont; - +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +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.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Container; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsEnvironment; +import java.awt.Image; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; @@ -26,6 +54,7 @@ import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -101,9 +130,102 @@ public class EastRegionContainerPane extends UIEastResizableContainer { defaultAuthorityPane = getDefaultPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Support_Authority_Edit")); switchMode(PropertyMode.REPORT); setContainerWidth(CONTAINER_WIDTH); + + initPluginPane(); + listenPlugin(); } - + + private void listenPlugin() { + + PluginFilter filter = new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PropertyItemPaneProvider.XML_TAG); + } + }; + PluginListenerRegistration.getInstance().listen( + PluginEventType.AfterRun, + new PluginEventListener(PropertyItemPaneProvider.FIRST) { + @Override + public void on(PluginEvent event) { + PluginContext context = event.getContext(); + PluginRuntime runtime = context.getRuntime(); + Set providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPropertyItem(provider); + } + updateAllPropertyPane(); + } + }, filter); + PluginListenerRegistration.getInstance().listen( + PluginEventType.BeforeStop, + new PluginEventListener(PropertyItemPaneProvider.FIRST) { + @Override + public void on(PluginEvent event) { + PluginContext context = event.getContext(); + PluginRuntime runtime = context.getRuntime(); + Set providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + removePropertyItem(provider); + + } + updateAllPropertyPane(); + } + }, filter); + } + + private void removePropertyItem(PropertyItemPaneProvider provider) { + + propertyItemMap.remove(provider.key()); + String replaceKey = provider.replaceKey(); + if (replaceKey == null) { + return; + } + PropertyItem replaceItem = propertyItemMap.get(replaceKey); + if (replaceItem != null) { + replaceItem.setReplace(false); + } + } + + private void initPluginPane() { + + ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPropertyItem(provider); + } + } + + private void addPropertyItem(PropertyItemPaneProvider provider) { + + String key = provider.key(); + PropertyItemBean itemBean = provider.getItem(); + PropertyItem propertyItem = new PropertyItem(itemBean.getName(), + itemBean.getTitle(), + itemBean.getBtnIconName(), + itemBean.getBtnIconBaseDir(), + itemBean.getVisibleModes(), + itemBean.getEnableModes()); + UIButton button = propertyItem.getButton(); + List buttonListeners = itemBean.getButtonListeners(); + for (ActionListener buttonListener : buttonListeners) { + button.addActionListener(buttonListener); + } + propertyItemMap.put(key, propertyItem); + + String replaceKey = provider.replaceKey(); + if (replaceKey == null) { + return; + } + PropertyItem replaceItem = propertyItemMap.get(replaceKey); + if (replaceItem != null) { + replaceItem.setReplace(true); + } + + } + private void initPropertyItemList() { + propertyItemMap = new LinkedHashMap<>(); // 有序map // 单元格元素 PropertyItem cellElement = new PropertyItem(KEY_CELL_ELEMENT, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cell_Element"), @@ -360,6 +482,11 @@ public class EastRegionContainerPane extends UIEastResizableContainer { public void replaceConfiguredRolesPane(JComponent pane) { propertyItemMap.get(KEY_CONFIGURED_ROLES).replaceContentPane(pane); } + + public void replaceKeyPane(String key, JComponent pane) { + + propertyItemMap.get(key).replaceContentPane(pane); + } public JComponent getConfiguredRolesPane() { return propertyItemMap.get(KEY_CONFIGURED_ROLES).getContentPane(); @@ -511,6 +638,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private PopupDialog popupDialog; // 弹出框 private boolean isPoppedOut = false; // 是否弹出 private boolean isVisible = true; // 是否可见 + private boolean replace = false; // 是否被替代 private boolean isEnabled = true; // 是否可用 private Set visibleModes; private Set enableModes; @@ -521,14 +649,21 @@ public class EastRegionContainerPane extends UIEastResizableContainer { private static final String ICON_SUFFIX_DISABLED = "_disabled.png"; private static final String ICON_SUFFIX_SELECTED = "_selected.png"; private String btnIconName; + private String iconBaseDir; private String iconSuffix = ICON_SUFFIX_NORMAL; // normal, diabled, selected, 三者之一 private final Color selectedBtnBackground = new Color(0xF5F5F7); private Color originBtnBackground; - + + public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes) { + this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes); + } + + public PropertyItem(String name, String title, String btnIconName, String iconBaseDir, PropertyMode[] visibleModes, PropertyMode[] enableModes) { this.name = name; this.title = title; this.btnIconName = btnIconName; + this.iconBaseDir = iconBaseDir; initButton(); initPropertyPanel(); initModes(visibleModes, enableModes); @@ -563,13 +698,19 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } public boolean isVisible() { - return isVisible; + // 取决于可见且未替代 + return isVisible && !replace; } public void setVisible(boolean isVisible) { this.isVisible = isVisible; } - + + public void setReplace(boolean replace) { + + this.replace = replace; + } + public boolean isEnabled() { return isEnabled; } @@ -579,7 +720,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer { this.isEnabled = isEnabled; button.setEnabled(isEnabled); } - + + public void setIconBaseDir(String iconBaseDir) { + this.iconBaseDir = iconBaseDir; + } + + private String getIconBaseDir() { + + return StringUtils.isEmpty(iconBaseDir) ? ICON_BASE_DIR : iconBaseDir; + } + private void initPropertyPanel() { propertyPanel = new JPanel(); propertyPanel.setBackground(Color.pink); @@ -660,7 +810,8 @@ public class EastRegionContainerPane extends UIEastResizableContainer { } private String getBtnIconUrl() { - return ICON_BASE_DIR + btnIconName + iconSuffix; + + return getIconBaseDir() + btnIconName + iconSuffix; } public void resetButtonIcon() { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/PaneHolder.java b/designer-base/src/main/java/com/fr/design/mainframe/PaneHolder.java new file mode 100644 index 0000000000..aef5e0b137 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/PaneHolder.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe; + +import javax.swing.JPanel; + +/** + * created by Harrison on 2020/03/23 + **/ +public interface PaneHolder { + + /** + * 得到 Pane + * + * @param arg 参数 + * @return 面板 + */ + JPanel getInstance(T arg); +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java b/designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java new file mode 100644 index 0000000000..ee54364ba5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/PropertyItemBean.java @@ -0,0 +1,78 @@ +package com.fr.design.mainframe; + +import java.awt.event.ActionListener; +import java.util.List; + +/** + * created by Harrison on 2020/03/23 + **/ +public class PropertyItemBean { + + private String name; + private String title; + private String btnIconName; + private String btnIconBaseDir; + private EastRegionContainerPane.PropertyMode[] visibleModes; + private EastRegionContainerPane.PropertyMode[] enableModes; + private List buttonListeners; + + public PropertyItemBean() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getBtnIconName() { + return btnIconName; + } + + public void setBtnIconName(String btnIconName) { + this.btnIconName = btnIconName; + } + + public String getBtnIconBaseDir() { + + return btnIconBaseDir; + } + + public void setBtnIconBaseDir(String btnIconBaseDir) { + this.btnIconBaseDir = btnIconBaseDir; + } + + public EastRegionContainerPane.PropertyMode[] getVisibleModes() { + return visibleModes; + } + + public void setVisibleModes(EastRegionContainerPane.PropertyMode[] visibleModes) { + this.visibleModes = visibleModes; + } + + public EastRegionContainerPane.PropertyMode[] getEnableModes() { + return enableModes; + } + + public void setEnableModes(EastRegionContainerPane.PropertyMode[] enableModes) { + this.enableModes = enableModes; + } + + public List getButtonListeners() { + return buttonListeners; + } + + public void setButtonListeners(List buttonListeners) { + this.buttonListeners = buttonListeners; + } +} 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..69e2c08029 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 @@ -30,6 +30,7 @@ public class ChartInfo extends AbstractPointInfo { 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 +45,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; // 判断图表是否可以上传的天数 @@ -57,6 +63,8 @@ public class ChartInfo extends AbstractPointInfo { private boolean testTemplate; + private boolean testChart; + private ChartInfo() { } @@ -64,6 +72,7 @@ public class ChartInfo extends AbstractPointInfo { this.chartId = chartId; this.templateId = templateId; this.book = book; + this.testChart = true; } public String getChartId() { @@ -91,13 +100,17 @@ public class ChartInfo extends AbstractPointInfo { @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); @@ -105,13 +118,14 @@ public class ChartInfo extends AbstractPointInfo { } public static ChartInfo newInstance(String chartId, String chartType) { - return newInstance(chartId, chartType, null); + return newInstance(chartId, chartType, null, false, false); } - public static ChartInfo newInstance(String chartId, String chartType, String createTime) { + public static ChartInfo newInstance(String chartId, String chartType, 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(); @@ -138,6 +152,11 @@ 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; @@ -158,6 +177,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,6 +190,11 @@ 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(); writer.end(); } @@ -182,6 +207,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 +224,11 @@ 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)); } } } @@ -231,8 +262,16 @@ public class ChartInfo extends AbstractPointInfo { chartConsumingMap.put(ATTR_CHART_TYPE, chartType); 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); } + public void updateFirstType(String chartType) { + chartConsumingMap.put(ATTR_FIRST_CHART_TYPE, chartType); + } + + @Override public ChartInfo clone() { ChartInfo chartInfo = new 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..5b76b197c3 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 @@ -7,7 +7,6 @@ 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; @@ -53,39 +52,36 @@ 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(ChartProvider chartProvider, String createTime, boolean isReuse) { + collection(chartProvider.getChartUuid(), chartProvider.getID(), createTime, isReuse); } /** * 新建图表,保存状态 */ - public void collection(String chartId, String chartType, String createTime) { - if (!shouldCollectInfo()) { + public void collection(String chartId, String chartType, String createTime, boolean isReuse) { + if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) { return; } - - ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, createTime); + ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType, 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()); - } + updateChartPropertyTime(chartProvider.getChartUuid(), chartProvider.getID()); } /** * 图表编辑,更新编辑时间 */ public void updateChartPropertyTime(String chartId, String chartType) { - if (!shouldCollectInfo()) { + if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) { return; } - ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); + ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType, null); //更新编辑时间 chartInfo.updatePropertyTime(); @@ -94,22 +90,19 @@ public class ChartInfoCollector extends AbstractPointCollector { chartInfo.resetIdleDayCount(); } - public void updateChartTypeTime(ChartProvider chartProvider) { - if (chartProvider instanceof VanChart) { - VanChart vanChart = (VanChart) chartProvider; - updateChartTypeTime(vanChart.getUuid(), vanChart.getID()); - } + public void updateChartTypeTime(ChartProvider chartProvider, String oldType) { + updateChartTypeTime(chartProvider.getChartUuid(), chartProvider.getID(), oldType); } /** * 图表类型变化,更新类型和类型确认时间 */ - public void updateChartTypeTime(String chartId, String chartType) { - if (!shouldCollectInfo()) { + public void updateChartTypeTime(String chartId, String chartType, String oldType) { + if (!shouldCollectInfo() || StringUtils.isEmpty(chartId)) { return; } - ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType); + ChartInfo chartInfo = getOrCreateChartInfo(chartId, chartType, oldType); //更新类型确认时间和类型 chartInfo.updateChartType(chartType); @@ -118,7 +111,7 @@ public class ChartInfoCollector extends AbstractPointCollector { chartInfo.resetIdleDayCount(); } - private ChartInfo getOrCreateChartInfo(String chartId, String chartType) { + private ChartInfo getOrCreateChartInfo(String chartId, String chartType, String oldType) { //缓存中有从缓存中拿 if (chartInfoCacheMap.containsKey(chartId)) { return chartInfoCacheMap.get(chartId); @@ -129,12 +122,26 @@ public class ChartInfoCollector extends AbstractPointCollector { chartInfoCacheMap.put(chartId, chartInfo); return chartInfo; } - //都有的话创建一个并加入到缓存中 + //都没有的话创建一个并加入到缓存中 ChartInfo chartInfo = ChartInfo.newInstance(chartId, chartType); + 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); + } + } + /** * 保存模板的时候将该模板中的图表埋点信息保存 */ 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-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; @@ -73,9 +75,20 @@ public class SidebarMobileBookMarkStyleCustomDefinePane extends 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/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index cdafa8c410..bc4b85ced8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -12,7 +12,6 @@ import com.fr.design.actions.UpdateAction; import com.fr.design.actions.community.BBSAction; import com.fr.design.actions.community.BugAction; import com.fr.design.actions.community.CenterAction; -import com.fr.design.actions.community.CusDemandAction; import com.fr.design.actions.community.FacebookFansAction; import com.fr.design.actions.community.NeedAction; import com.fr.design.actions.community.QuestionAction; @@ -53,7 +52,9 @@ import com.fr.design.mainframe.ToolBarNewTemplatePane; import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; +import com.fr.design.menu.SnapChatMenuDef; import com.fr.design.menu.ToolBarDef; +import com.fr.design.notification.SnapChatAllTypes; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.update.actions.SoftwareUpdateAction; @@ -563,15 +564,24 @@ public abstract class ToolBarMenuDock { * @return 社区菜单的子菜单 */ public ShortCut[] createCommunityShortCuts() { + final java.util.List shortCuts = new ArrayList(); shortCuts.add(new BBSAction()); + + shortCuts.add(SeparatorDef.DEFAULT); + shortCuts.add(new VideoAction()); shortCuts.add(new TutorialAction()); shortCuts.add(new QuestionAction()); shortCuts.add(new TechSolutionAction()); + + shortCuts.add(SeparatorDef.DEFAULT); + shortCuts.add(new BugAction()); shortCuts.add(new NeedAction()); - shortCuts.add(new CusDemandAction()); + + shortCuts.add(SeparatorDef.DEFAULT); + shortCuts.add(new CenterAction()); shortCuts.add(new SignAction()); LocaleCenter.buildAction(new LocaleAction() { @@ -594,7 +604,11 @@ public abstract class ToolBarMenuDock { } public MenuDef createCommunityMenuDef() { - MenuDef menuDef = new MenuDef(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community"), 'C'); + + MenuDef menuDef = new SnapChatMenuDef( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Community"), + 'C', + SnapChatAllTypes.Menu.BBS); ShortCut[] otherCommunityShortCuts = createCommunityShortCuts(); for (ShortCut shortCut : otherCommunityShortCuts) { menuDef.addShortCut(shortCut); 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 c18749c12c..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 @@ -38,8 +38,8 @@ public class MenuDef extends ShortCut { protected UIMenu createdJMenu; protected UIButton createdButton; protected JPopupMenu popupMenu; - private boolean hasScrollSubMenu; - private boolean isHeadMenu; + protected boolean hasScrollSubMenu; + protected boolean isHeadMenu; private String anchor; @@ -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) { @@ -187,18 +191,13 @@ public class MenuDef extends ShortCut { */ public UIMenu createJMenu() { if (createdJMenu == null) { - if (hasScrollSubMenu) { - createdJMenu = new UIScrollMenu(this.getName()); - } else if (isHeadMenu){ - createdJMenu = new UIHeadMenu(this.getName()); - } else { - createdJMenu = new UIMenu(this.getName()); - } + createdJMenu = createJMenu0(); createdJMenu.setMnemonic(this.getMnemonic()); if (this.iconPath != null) { createdJMenu.setIcon(BaseUtils.readIcon(this.iconPath)); } - createdJMenu.addMenuListener(menuDefListener); + MenuListener menuListener = createMenuListener(); + createdJMenu.addMenuListener(menuListener); ContainerListener listener = getContainerListener(); if (listener != null) { createdJMenu.getPopupMenu().addContainerListener(listener); @@ -207,7 +206,20 @@ public class MenuDef extends ShortCut { return createdJMenu; } - + + protected UIMenu createJMenu0() { + + UIMenu createdJMenu; + if (hasScrollSubMenu) { + createdJMenu = new UIScrollMenu(this.getName()); + } else if (isHeadMenu){ + createdJMenu = new UIHeadMenu(this.getName()); + } else { + createdJMenu = new UIMenu(this.getName()); + } + return createdJMenu; + } + protected ContainerListener getContainerListener() { return null; } @@ -377,6 +389,11 @@ public class MenuDef extends ShortCut { public void intoJToolBar(JToolBar toolBar) { toolBar.add(this.createUIButton()); } + + protected MenuListener createMenuListener() { + + return menuDefListener; + } private MenuListener menuDefListener = new MenuListener() { diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java new file mode 100644 index 0000000000..2ec3f6c7ee --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuDef.java @@ -0,0 +1,200 @@ +package com.fr.design.menu; + +import com.fr.design.gui.imenu.UIMenu; +import com.fr.design.gui.imenu.UIScrollMenu; +import com.fr.design.notification.SnapChat; +import com.fr.design.notification.SnapChatConfig; +import com.fr.design.notification.SnapChatKey; + +import javax.swing.JMenu; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.Ellipse2D; +import java.awt.image.BufferedImage; + +/** + * created by Harrison on 2020/03/16 + **/ +public class SnapChatMenuDef extends MenuDef implements SnapChat { + + private SnapChatKey uniqueKey; + private SnapChatMenuUI menuUI = new SnapChatMenuUI(this); + + public SnapChatMenuDef(String name, SnapChatKey uniqueKey) { + super(name); + this.uniqueKey = uniqueKey; + } + + public SnapChatMenuDef(Boolean rePaint, SnapChatKey uniqueKey) { + super(rePaint); + this.uniqueKey = uniqueKey; + } + + public SnapChatMenuDef(String name, char mnemonic, SnapChatKey uniqueKey) { + super(name, mnemonic); + this.uniqueKey = uniqueKey; + } + + @Override + public boolean hasRead() { + + String calcKey = calcKey(); + Boolean val = SnapChatConfig.getInstance().hasRead(calcKey); + // 默认读过了。 + return val == null ? defaultStatus() : val; + } + + @Override + public void markRead() { + + String calcKey = calcKey(); + SnapChatConfig.getInstance().markRead(calcKey); + } + + @Override + public boolean defaultStatus() { + + return true; + } + + @Override + public void addShortCut(ShortCut shortCut) { + + addSnapChatNotification(shortCut); + super.addShortCut(shortCut); + } + + @Override + public void insertShortCut(int index, ShortCut shortCut) { + + addSnapChatNotification(shortCut); + super.insertShortCut(index, shortCut); + } + + + @Override + public SnapChatKey key() { + + return this.uniqueKey; + } + + @Override + protected MenuListener createMenuListener() { + + return new SnapChatMenuListener(); + } + + /** + * 添加提醒 + * + * @param shortCut 快捷方式 + */ + private void addSnapChatNotification(ShortCut shortCut) { + + if (shortCut instanceof SnapChatUpdateAction) { + SnapChatUpdateAction action = (SnapChatUpdateAction) shortCut; + if (!action.hasRead()) { + String calcKey = calcKey(); + SnapChatConfig.getInstance().resetRead(calcKey); + } + } + } + + private String calcKey() { + + return key().calc(); + } + + @Override + protected UIMenu createJMenu0() { + + UIMenu createdJMenu; + if (hasScrollSubMenu) { + createdJMenu = new SnapChatUIScrollMenu(this.getName()); + } else if (isHeadMenu){ + createdJMenu = new SnapChatUIHeadMenu(this.getName()); + } else { + createdJMenu = new SnapChatUIMenu(this.getName()); + } + return createdJMenu; + } + + private class SnapChatMenuListener implements MenuListener { + + @Override + public void menuSelected(MenuEvent e) { + + markRead(); + Object source = e.getSource(); + if (!(source instanceof JMenu)) { + return; + } + updateMenu(); + } + + @Override + public void menuDeselected(MenuEvent e) { + + } + + @Override + public void menuCanceled(MenuEvent e) { + + } + } + + private class SnapChatUIScrollMenu extends UIScrollMenu { + + public SnapChatUIScrollMenu(String s) { + super(s); + } + + @Override + public void updateUI() { + setUI(menuUI); + } + } + + private class SnapChatUIMenu extends UIMenu { + + public SnapChatUIMenu(String name) { + + super(name); + } + + @Override + public void updateUI() { + + setUI(menuUI); + } + } + + private class SnapChatUIHeadMenu extends UIMenu { + + public SnapChatUIHeadMenu(String name) { + + super(name); + } + + @Override + public void updateUI() { + + setUI(menuUI); + } + } + + public static void main(String[] args) { + + BufferedImage image = new BufferedImage(16, 16, Image.SCALE_DEFAULT); + Graphics2D g2d = image.createGraphics(); + g2d.setColor(Color.green); + Ellipse2D.Double shape = + new Ellipse2D.Double(2, 2, 1, 1); + g2d.fill(shape); + g2d.draw(shape); + System.out.println(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuItemUI.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuItemUI.java new file mode 100644 index 0000000000..c9ab8532d2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuItemUI.java @@ -0,0 +1,31 @@ +package com.fr.design.menu; + +import com.fr.design.gui.imenu.UIMenuItemUI; + +import javax.swing.JMenuItem; +import java.awt.Graphics; +import java.awt.Rectangle; + +/** + * created by Harrison on 2020/03/22 + **/ +class SnapChatMenuItemUI extends UIMenuItemUI { + + private final SnapChatUpdateAction snapChatUpdateAction; + + public SnapChatMenuItemUI(SnapChatUpdateAction snapChatUpdateAction) { + + this.snapChatUpdateAction = snapChatUpdateAction; + } + + @Override + protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { + + super.paintText(g, menuItem, textRect, text); + + if (!snapChatUpdateAction.hasRead()) { + SnapChatUtil.paintSnapChat(g, textRect); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuUI.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuUI.java new file mode 100644 index 0000000000..47bc3c6634 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatMenuUI.java @@ -0,0 +1,29 @@ +package com.fr.design.menu; + +import com.fr.design.gui.imenu.UIMenuUI; + +import javax.swing.JMenuItem; +import java.awt.Graphics; +import java.awt.Rectangle; + +/** + * created by Harrison on 2020/03/22 + **/ +public class SnapChatMenuUI extends UIMenuUI { + + private SnapChatMenuDef menuDef; + + public SnapChatMenuUI(SnapChatMenuDef menuDef) { + this.menuDef = menuDef; + } + + @Override + protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) { + + super.paintText(g, menuItem, textRect, text); + + if (!menuDef.hasRead()) { + SnapChatUtil.paintSnapChat(g, textRect); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java new file mode 100644 index 0000000000..9ade762500 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatUpdateAction.java @@ -0,0 +1,79 @@ +package com.fr.design.menu; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.gui.imenu.UIMenuItem; +import com.fr.design.notification.SnapChat; +import com.fr.design.notification.SnapChatConfig; +import com.fr.design.notification.SnapChatKey; + +import java.awt.event.ActionEvent; + +/** + * created by Harrison on 2020/03/22 + **/ +public abstract class SnapChatUpdateAction extends UpdateAction implements SnapChat { + + private SnapChatKey uniqueKey; + + public SnapChatUpdateAction(SnapChatKey uniqueKey) { + this.uniqueKey = uniqueKey; + } + + @Override + public final void actionPerformed(ActionEvent e) { + + markRead(); + actionPerformed0(e); + } + + protected abstract void actionPerformed0(ActionEvent e); + + @Override + public boolean hasRead() { + + String calcKey = calcKey(); + Boolean val = SnapChatConfig.getInstance().hasRead(calcKey); + return val == null ? defaultStatus() : val; + } + + @Override + public void markRead() { + + String calcKey = calcKey(); + SnapChatConfig.getInstance().markRead(calcKey); + } + + @Override + public boolean defaultStatus() { + + return false; + } + + @Override + public SnapChatKey key() { + + return this.uniqueKey; + } + + private String calcKey() { + + return key().calc(); + } + + @Override + public UIMenuItem createMenuItem() { + + Object object = this.getValue(UIMenuItem.class.getName()); + if (object == null && !(object instanceof UIMenuItem)) { + UIMenuItem menuItem = new UIMenuItem(this); + // 设置名字用作单元测 + menuItem.setName(getName()); + menuItem.setUI(new SnapChatMenuItemUI(this)); + object = menuItem; + + this.putValue(UIMenuItem.class.getName(), object); + } + return (UIMenuItem) object; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/menu/SnapChatUtil.java b/designer-base/src/main/java/com/fr/design/menu/SnapChatUtil.java new file mode 100644 index 0000000000..6eb648055a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/menu/SnapChatUtil.java @@ -0,0 +1,33 @@ +package com.fr.design.menu; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.Ellipse2D; + +/** + * created by Harrison on 2020/03/22 + **/ +public class SnapChatUtil { + + public static void paintSnapChat(Graphics g, Rectangle textRect) { + + Color oldColor = g.getColor(); + + double x = textRect.getWidth(); + x += textRect.getX(); + x += 2; + + double y = textRect.getY(); + + Graphics2D g2d = (Graphics2D) g; + g2d.setColor(Color.red); + Ellipse2D.Double shape = + new Ellipse2D.Double(x, y, 4, 4); + g2d.fill(shape); + g2d.draw(shape); + + g2d.setColor(oldColor); + } +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChat.java b/designer-base/src/main/java/com/fr/design/notification/SnapChat.java new file mode 100644 index 0000000000..4f610c060b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChat.java @@ -0,0 +1,35 @@ +package com.fr.design.notification; + +/** + * 阅后即焚的消息提醒 + * + * created by Harrison on 2020/03/16 + **/ +public interface SnapChat { + + /** + * 默认状态 + * + * @return 默认状态 + */ + boolean defaultStatus(); + + /** + * 已读 + * + * @return 是否为已读 + */ + boolean hasRead(); + + /** + * 标记为已读 + */ + void markRead(); + + /** + * 独一无二的标志 + * + * @return 字符标志 + */ + SnapChatKey key(); +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java new file mode 100644 index 0000000000..6aeb384df5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatAllTypes.java @@ -0,0 +1,38 @@ +package com.fr.design.notification; + +import com.fr.stable.CommonUtils; + +/** + * created by Harrison on 2020/03/16 + **/ +public abstract class SnapChatAllTypes { + + public enum Menu implements SnapChatKey { + + /** + * 社区按钮 + */ + BBS("BBS"); + + private static final String SIGN = "0001"; + + private String key; + + Menu(String key) { + this.key = key; + } + + public String getKey() { + return key; + } + + @Override + public String calc() { + + return CommonUtils.join( + new String[]{SIGN, getKey()}, "-" + ); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java new file mode 100644 index 0000000000..c192d054c6 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatConfig.java @@ -0,0 +1,93 @@ +package com.fr.design.notification; + +import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReadable; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; + +import java.util.HashMap; +import java.util.Map; + +/** + * created by Harrison on 2020/03/16 + **/ +@SuppressWarnings("unchecked") +public class SnapChatConfig implements XMLable { + + public static final String XML_TAG = "SnapChatConfig"; + + /** + * 已经阅读过的属性 + */ + private Map markReadMap = new HashMap<>(8); + + private static final SnapChatConfig INSTANCE = new SnapChatConfig(); + + public static SnapChatConfig getInstance() { + return INSTANCE; + } + + public Boolean hasRead(String key) { + + Map map = markReadMap; + return map.get(key); + } + + public void markRead(String key) { + + markReadMap.put(key, Boolean.TRUE); + } + + public void resetRead(String key) { + + markReadMap.put(key, Boolean.FALSE); + } + + @Override + public void readXML(XMLableReader reader) { + + if (reader.isChildNode()) { + if ("item".equals(reader.getTagName())) { + String tmpVal = reader.getElementValue(); + Boolean markRead = Boolean.valueOf(tmpVal); + markReadMap.put(reader.getAttrAsString("key", StringUtils.EMPTY), markRead); + } + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + + writer.startTAG(XML_TAG); + writeMarkReadMapXML(writer); + writer.end(); + } + + private void readMarkReadMapXML(XMLableReader reader) { + + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader reader) { + } + }); + } + + /** + * 写入map + */ + private void writeMarkReadMapXML(XMLPrintWriter writer) { + + writer.startTAG("MarkReadMap"); + for (Map.Entry item : markReadMap.entrySet()) { + writer.startTAG("item").attr("key", item.getKey()).textNode(item.getValue().toString()).end(); + } + writer.end(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + + return super.clone(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/notification/SnapChatKey.java b/designer-base/src/main/java/com/fr/design/notification/SnapChatKey.java new file mode 100644 index 0000000000..fa316db350 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/notification/SnapChatKey.java @@ -0,0 +1,9 @@ +package com.fr.design.notification; + +/** + * created by Harrison on 2020/03/16 + **/ +public interface SnapChatKey { + + String calc(); +} 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 index bc09dbf6a1..1ff796a1dc 100644 --- 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 @@ -1,7 +1,10 @@ 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; @@ -21,25 +24,55 @@ public class MacOsAddListenerAction implements OSBasedAction { public void execute(final Object... objects) { try { Class app = Class.forName("com.apple.eawt.Application"); - Class handler = Class.forName("com.apple.eawt.QuitHandler"); - Object instance = Proxy.newProxyInstance(handler.getClassLoader(), new Class[]{handler}, - new InvocationHandler() { - @Override - public Object invoke(Object proxy, Method method, - Object[] args) throws Throwable { - if ("handleQuitRequestWith".equals(method.getName())) { - if (DesignerContext.getDesignerFrame() != null && DesignerContext.getDesignerFrame().isShowing()) { - DesignerContext.getDesignerFrame().exit(); - } else { - DesignerExiter.getInstance().execute(); - } - } - return null; - } - }); - Reflect.on(Reflect.on(app).call("getApplication").get()).call("setQuitHandler", instance); + 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 f6c0e30549..d799d00466 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 @@ -88,7 +88,7 @@ public enum SupportOSImpl implements SupportOS { NON_GUARDIAN_START { @Override public boolean support() { - return OperatingSystem.isLinux() || Arch.getArch() == Arch.ARM; + return OperatingSystem.isLinux() || Arch.getArch() == Arch.ARM || OperatingSystem.isMacos(); } }, @@ -97,6 +97,14 @@ public enum SupportOSImpl implements SupportOS { public boolean support() { return OperatingSystem.isMacos(); } + }, + + + VM_OPTIONS_ADAPTER { + @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/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/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/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/upm/UpmFinder.java b/designer-base/src/main/java/com/fr/design/upm/UpmFinder.java index 4febad3a99..9a6205cf4a 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/DesignerPort.java b/designer-base/src/main/java/com/fr/design/utils/DesignerPort.java index 55dc1f00d9..254cc5e911 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; @@ -86,7 +90,10 @@ public class DesignerPort implements XMLReadable, XMLWriter { } public void resetPort() { - + ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); + if (eventPipe != null) { + eventPipe.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/exit/DesignerExiter.java b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java index e7189511a1..b9067a22ee 100644 --- a/designer-base/src/main/java/com/fr/exit/DesignerExiter.java +++ b/designer-base/src/main/java/com/fr/exit/DesignerExiter.java @@ -22,7 +22,7 @@ public class DesignerExiter { public void execute() { beforeExit(); if (FineProcessContext.getParentPipe() != null) { - FineProcessContext.getParentPipe().fire(FineProcessEngineEvent.DESTROY); + FineProcessContext.getParentPipe().syncFire(FineProcessEngineEvent.DESTROY); } System.exit(0); } 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/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-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 ca1f4f1400..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, this); + painter.paint(g2d, chartWidth, chartHeight, resolution, null,this); } } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java index 41202061cd..a3e610460b 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/MapAreaMatchPane.java @@ -118,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); 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 9c16b4663d..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()); } @@ -131,20 +139,4 @@ public class MatchAreaTable extends JTable { 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 8a85c84a47..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,8 +3,10 @@ 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.general.GeneralUtils; import com.fr.plugin.chart.map.data.MapMatchResult; import com.fr.stable.StringUtils; @@ -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/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..4358a728dd --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java @@ -0,0 +1,253 @@ +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 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/mainframe/chart/ChartEditPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java index 98ba448d70..3dc90d3a34 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/ChartEditPane.java @@ -6,7 +6,6 @@ import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.BasicPane; @@ -115,14 +114,13 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare selectedPane.update(collection); if (!ComparatorUtils.equals(collection, lastCollection)) { - VanChart vanChart = collection.getSelectedChartProvider(VanChart.class); if (vanChart != null) { //此处画图 - vanChart.demoImgEvent(true); + vanChart.attrChange(); } - try { + ChartInfoCollector.getInstance().checkTestChart(collection.getSelectedChartProvider(ChartProvider.class)); lastCollection = collection.clone(); } catch (CloneNotSupportedException e) { FineLoggerFactory.getLogger().error("error in clone ChartEditPane"); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java index 804ca541ba..4e78591ad1 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/SeriesTypeUseComboxPane.java @@ -9,10 +9,12 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.constants.LayoutConstants; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane; import com.fr.design.utils.gui.GUICoreUtils; +import com.fr.design.utils.gui.UIComponentUtils; import javax.swing.BorderFactory; import javax.swing.JPanel; @@ -59,11 +61,16 @@ public class SeriesTypeUseComboxPane extends UIComboBoxPane { this.add(cardPane, BorderLayout.CENTER); dataScreeningPane = new ChartDataFilterPane(this.initplot, parent); JPanel panel = new UIExpandablePane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), 290, 24, dataScreeningPane); - panel.setBorder(BorderFactory.createEmptyBorder(0,10,0,10)); + panel.setBorder(BorderFactory.createEmptyBorder(0,5,0,5)); dataScreeningPane.setBorder(BorderFactory.createEmptyBorder(10,5,0,5)); 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/module/ChartPreFillStylePane.java b/designer-chart/src/main/java/com/fr/design/module/ChartPreFillStylePane.java index 66a103e657..de85cfcdba 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,12 @@ 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.List; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; @@ -20,8 +21,6 @@ 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; /** @@ -37,7 +36,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 +52,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 +67,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}; @@ -131,7 +130,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { cardLayout.show(changeColorSetPane, "acc"); if (colorList.size() > 0) { - colorAcc.populateBean(colorList.toArray(new Color[colorList.size()])); + colorAdjustPane.updateColor(colorList.toArray(new Color[colorList.size()])); } } } @@ -152,7 +151,7 @@ public class ChartPreFillStylePane extends BasicBeanPane { } else { chartColorMatching.setGradient(false); - Color[] colors = colorAcc.updateBean(); + Color[] colors = colorAdjustPane.getColors(); for(Color color : colors) { colorList.add(color); } 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/VanChartAreaSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/area/VanChartAreaSeriesPane.java index 45beccc7ef..d3b511b1f2 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 @@ -6,6 +6,7 @@ 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.component.VanChartBeautyPane; import com.fr.van.chart.line.VanChartLineSeriesPane; import javax.swing.JPanel; @@ -27,7 +28,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 +44,9 @@ public class VanChartAreaSeriesPane extends VanChartLineSeriesPane { protected Class getStackAndAxisPaneClass() { return VanChartCustomStackAndAxisConditionPane.class; } + + //风格 + protected VanChartBeautyPane createStylePane() { + return new VanChartBeautyPane(); + } } \ 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/style/VanChartCustomSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/style/VanChartCustomSeriesPane.java index 425258a5bf..2cd3d74e1f 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 @@ -4,7 +4,6 @@ import com.fr.chart.chartattr.Chart; 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.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot; @@ -24,7 +23,7 @@ public class VanChartCustomSeriesPane extends ChartSeriesPane { private JPanel seriesPane; protected VanChartCustomPlotSeriesTabPane plotSeriesPane; - private ChartFillStylePane fillStylePane;//配色 + private VanChartFillStylePane fillStylePane;//配色 private VanChartBeautyPane stylePane;//风格 @@ -81,7 +80,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; } 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..63c24a221b 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,237 @@ 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.chart.gui.style.ChartColorAdjustPane; +import com.fr.design.style.background.gradient.FixedGradientBar; +import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import javax.swing.BorderFactory; import javax.swing.JPanel; +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 { - @Override - protected JPanel getContentPane () { + + 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(); + } + + 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 - public Dimension getPreferredSize() { - if(styleSelectBox.getSelectedIndex() != styleSelectBox.getItemCount() - 1) { - return new Dimension(styleSelectBox.getPreferredSize().width, 30); + 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 AttrFillStyle updateBean() { + switch (styleSelectBox.getSelectType()) { + case COMBINATION_COLOR: + return updateCombinationColor(); + case GRADATION_COLOR: + return updateGradationColor(); + case DEFAULT: + return updateDefaultColor(); + default: + return updateNormalColor(); + } + } + + 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 updateDefaultColor(); } - return super.getPreferredSize(); } } 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/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..8fb3aed22e 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 @@ -68,6 +68,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/series/VanChartAbstractPlotSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java index 9b912ee9f7..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.design.i18n.Toolkit; 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(Toolkit.i18nText("Fine-Design_Chart_Color"), panel); - panel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); + panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0)); return panel.getComponentCount() == 0 ? null : colorPane; } @@ -266,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()); @@ -323,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/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index 36f34c9953..e9395ccb56 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 @@ -111,7 +111,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane { if (changeSize) { ((FormArea)jf.getFormDesign().getParent()).onMobileAttrModified(); } - jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent()); //改变布局为自适应布局,只在移动端属性设置保存后改变一次 boolean changeLayout = !oldAdaptive && formMobileAttr.isAdaptivePropertyAutoMatch(); if (changeLayout) { + jf.getFormDesign().getSelectionModel().setSelectedCreator(jf.getFormDesign().getRootComponent()); doChangeBodyLayout(); + WidgetPropertyPane.getInstance().refreshDockingView(); } - WidgetPropertyPane.getInstance().refreshDockingView(); jf.fireTargetModified(); } }); @@ -112,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/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 f17ac09250..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 @@ -593,11 +593,7 @@ public class XWTabFitLayout extends XWFitLayout { */ @Override public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { - if (FormDesignerUtils.isAppRelayout(WidgetPropertyPane.getInstance().getEditingFormDesigner())) { - return new WidgetPropertyUIProvider[] {new MobileBookMarkPropertyUI(this), new MobileBooKMarkUsePropertyUI(this)}; - } else { - return new WidgetPropertyUIProvider[0]; - } + return new WidgetPropertyUIProvider[0]; } @Override 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/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index f61eb2f8a4..06cb19d0ae 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -1,6 +1,7 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; import com.fr.design.DesignModelAdapter; @@ -22,14 +23,16 @@ import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.utils.ComponentUtils; import com.fr.form.share.SharableEditorProvider; +import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; import com.fr.form.ui.ChartEditor; -import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.form.ui.Widget; import com.fr.stable.Constants; +import com.fr.stable.StringUtils; import javax.swing.BorderFactory; import javax.swing.JWindow; +import java.util.List; import java.util.Map; import java.awt.Color; import java.awt.Component; @@ -40,6 +43,7 @@ import java.awt.dnd.DropTarget; import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetEvent; +import java.util.Map; /** * 添加模式下鼠标事件处理器。 @@ -99,7 +103,7 @@ public class FormCreatorDropTarget extends DropTarget { if (addingXCreator.isShared()) { String shareId = addingXCreator.getShareId(); SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); - SharableWidgetBindInfo bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); + SharableWidgetProvider bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); if (sharableEditor != null && bindInfo != null) { Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource()); //合并数据集之后,可能会有数据集名称变化,做一下联动 @@ -284,9 +288,16 @@ public class FormCreatorDropTarget extends DropTarget { } private void dealChartBuryingPoint(Widget widget) { - if (widget instanceof ChartEditor) { - ChartCollection chartCollection = (ChartCollection)((ChartEditor) widget).getChartCollection(); - ChartInfoCollector.getInstance().collection(chartCollection.getSelectedChartProvider(ChartProvider.class), null); + List chartCollections = widget.getChartCollections(); + for (BaseChartCollection baseChartCollection : chartCollections) { + ChartCollection chartCollection = (ChartCollection) baseChartCollection; + for (int i = 0, size = chartCollection.getChartCount(); i < size; i++) { + ChartProvider chart = chartCollection.getChart(i, ChartProvider.class); + //是否是共享的复用组件 + boolean isReuse = StringUtils.isNotEmpty(this.addingModel.getXCreator().getShareId()); + ChartInfoCollector.getInstance().collection(chart, null, isReuse); + ChartInfoCollector.getInstance().checkTestChart(chart); + } } } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java index c32abb2ffc..ecb3faa706 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormWidgetDetailPane.java @@ -1,14 +1,15 @@ package com.fr.design.mainframe; import com.fr.base.BaseUtils; +import com.fr.base.FRContext; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.widget.FRWidgetFactory; +import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; -import com.fr.form.ui.SharableWidgetBindInfo; import com.fr.general.CloudCenter; import com.fr.log.FineLoggerFactory; import com.fr.share.ShareConstants; @@ -50,7 +51,7 @@ public class FormWidgetDetailPane extends FormDockView{ private UIScrollPane downPane; private JPanel reuWidgetPanel; private UIComboBox comboBox; - private SharableWidgetBindInfo[] elCaseBindInfoList; + private SharableWidgetProvider[] elCaseBindInfoList; private UIButton deleteButton; private JPanel editPanel; private JPanel resetPanel; @@ -303,7 +304,7 @@ public class FormWidgetDetailPane extends FormDockView{ public void actionPerformed(ActionEvent e) { String url = CloudCenter.getInstance().acquireUrlByKind("reuse.url"); if (StringUtils.isEmpty(url)) { - FineLoggerFactory.getLogger().info("The URL is empty!"); + FRContext.getLogger().info("The URL is empty!"); return; } try { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index cee0d5b90d..5502274bcd 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -7,6 +7,7 @@ import com.fr.base.extension.FileExtension; import com.fr.base.vcs.DesignerMode; import com.fr.design.DesignModelAdapter; import com.fr.design.DesignState; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.FormMobileAttrAction; import com.fr.design.actions.TemplateParameterAction; import com.fr.design.actions.core.WorkBookSupportable; @@ -30,7 +31,9 @@ import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; +import com.fr.design.fun.FormAdaptiveConfigUIProcessor; import com.fr.design.fun.PreviewProvider; +import com.fr.design.fun.PropertyItemPaneProvider; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.gui.ilable.UILabel; @@ -67,6 +70,14 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.page.PaperSettingProvider; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.context.PluginRuntime; +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.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.worksheet.FormElementCase; @@ -93,6 +104,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Set; public class JForm extends JTemplate implements BaseJForm
{ private static final String FORM_CARD = "FORM"; @@ -118,10 +130,56 @@ public class JForm extends JTemplate implements BaseJForm providers = runtime.get(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } + } + }, filter); + } + + private void initPluginPane() { + + ExtraDesignClassManager classManager = PluginModule.getAgent(PluginModule.ExtraDesign); + Set providers = classManager.getArray(PropertyItemPaneProvider.XML_TAG); + for (PropertyItemPaneProvider provider : providers) { + addPane(provider); + } + } + + private void addPane(PropertyItemPaneProvider provider) { + + PaneHolder holder = provider.getPaneHolder(FormDesigner.class); + if (holder != null) { + JPanel panel = holder.getInstance(formDesign); + EastRegionContainerPane.getInstance().replaceKeyPane(provider.key(), panel); + } } @Override @@ -504,10 +562,19 @@ public class JForm extends JTemplate implements BaseJForm 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/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/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-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/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/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 para = new HashMap<>(); 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/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/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/messagecollect/solid/SolidCollector.java b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java index d090b9e8f1..194ca75d93 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/messagecollect/solid/SolidCollector.java @@ -22,7 +22,6 @@ import java.util.Map; public class SolidCollector { private static final String ATTR_CIPHER_TEXT = "cipherText"; private static final String ATTR_SIGNATURE = "signature"; - private static final String SOLID_UPLOAD_URL = CloudCenter.getInstance().acquireUrlByKind("design.solid"); private static volatile SolidCollector instance; @@ -44,6 +43,11 @@ public class SolidCollector { if (WorkContext.getCurrent().isLocal()) { return; } + String url = CloudCenter.getInstance().acquireConf("design.solid", "https://cloud.fanruan.com/api/solid/upload"); + if (StringUtils.isEmpty(url)) { + FineLoggerFactory.getLogger().info("failed to get solid content upload url..."); + return; + } FineLoggerFactory.getLogger().info("start to get solid content from server..."); try { String cipherText = requestContent(); @@ -51,7 +55,7 @@ public class SolidCollector { Map params = new HashMap<>(); params.put(ATTR_CIPHER_TEXT, cipherText); params.put(ATTR_SIGNATURE, String.valueOf(CommonUtils.signature())); - HttpToolbox.post(SOLID_UPLOAD_URL, params); + HttpToolbox.post(url, params); deleteSolidFile(); } 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/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/webattr/WebJsPane.java b/designer-realize/src/main/java/com/fr/design/webattr/WebJsPane.java index 7c5c2e6b9a..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 @@ -129,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 ""; } } @@ -190,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; 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/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/start/DesignerJavaRuntime.java b/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java index 5f4f62210e..b99f648aed 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerJavaRuntime.java @@ -2,15 +2,25 @@ 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; /** @@ -32,11 +42,14 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime { 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 { - IOUtils.copy(DesignerJavaRuntime.class.getResourceAsStream("/com/fr/design/icon/logo.png"), "logo.png", new File(BIN_HOME)); + 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) { } } @@ -82,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")); } @@ -96,9 +109,26 @@ public class DesignerJavaRuntime extends AbstractJavaRuntime { public String[] getJvmOptions() { if (isInstallVersion()) { 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/DesignerSuperListener.java b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java index f6fa3c9376..f5c9174649 100644 --- a/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java +++ b/designer-realize/src/main/java/com/fr/start/DesignerSuperListener.java @@ -31,7 +31,7 @@ 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; @@ -116,6 +116,7 @@ public class DesignerSuperListener { @Override protected void okEvent() { dispose(); + DesignerLauncher.getInstance().exit(); } @Override @@ -125,7 +126,6 @@ public class DesignerSuperListener { } }; dialog.setVisible(true); - DesignerLauncher.getInstance().exit(); } private void startFallBackListener() { diff --git a/designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java b/designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java index 252b01dc1a..ef416416c9 100644 --- a/designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java +++ b/designer-realize/src/main/java/com/fr/start/LifecycleFatalErrorHandler.java @@ -1,5 +1,6 @@ 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; @@ -10,6 +11,9 @@ 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; @@ -45,6 +49,10 @@ public class LifecycleFatalErrorHandler { public void handle(FineLifecycleFatalError fatal) { SplashContext.getInstance().hide(); + ProcessEventPipe eventPipe = FineProcessContext.getParentPipe(); + if (eventPipe != null) { + eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue())); + } map.get(fatal.getErrorType()).handle(fatal); } 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 60de86543a..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,11 +16,11 @@ 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; @@ -35,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; @@ -71,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,