diff --git a/build.gradle b/build.gradle index 6446da4044..3580cbae0d 100644 --- a/build.gradle +++ b/build.gradle @@ -64,7 +64,7 @@ allprojects { implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swag:1.0' implementation 'net.java.dev.jna:jna:5.4.0' - implementation 'org.apache.tomcat:tomcat-catalina:8.5.32' + implementation 'org.apache.tomcat:tomcat-catalina:8.5.57' implementation 'io.socket:socket.io-client:0.7.0' implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.core:fine-core:' + frDevVersion @@ -73,6 +73,7 @@ allprojects { implementation 'com.fr.decision:fine-decision:' + frVersion implementation 'com.fr.schedule:fine-schedule:' + frVersion implementation 'com.fr.report:fine-report-engine:' + frDevVersion + implementation 'com.fr.design:design-i18n:' + frDevVersion testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1' 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 88d2625d02..6f1c94eee3 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -163,7 +163,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * alphafine */ private AlphaFineConfigManager alphaFineConfigManager = AlphaFineConfigManager.getInstance(); - + /** * 阅后即焚的配置项 */ @@ -218,14 +218,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { if (needCheckEnv) { checkNameEnvMap(); } - - GeneralContext.addEnvChangedListener(new EnvChangedListener() { - @Override - public void envChanged() { - - designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX); - designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME); - } + GeneralContext.addEnvChangedListener(() -> { + designerEnvManager.setCurrentDirectoryPrefix(FILEFactory.ENV_PREFIX); + designerEnvManager.setDialogCurrentDirectory(ProjectConstants.REPORTLETS_NAME); }); } @@ -1424,7 +1419,9 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { * @return */ private Locale checkLocale(Locale locale) { - return SupportLocale.getInstance().isSupport(locale) ? locale : Locale.US; + // Yvan: REPORT-39341,有一些情况下,获取到的是zh-Hans-CN这种,需要找到项目中最匹配的Locale + return SupportLocale.getInstance().isSupport(locale) ? + locale : SupportLocale.getInstance().getSuitableLocale(locale); } private void readReportLengthUnit(XMLableReader reader) { @@ -1475,7 +1472,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } public String getUUID() { - return StringUtils.isEmpty(uuid) ? UUID.randomUUID().toString() : uuid; + if (StringUtils.isEmpty(uuid)) { + uuid = UUID.randomUUID().toString(); + } + return uuid; } public int getActiveKeyStatus() { @@ -1578,7 +1578,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { } } } - + private void readSnapChatConfig(XMLableReader reader) { reader.readXMLObject(this.snapChatConfig = SnapChatConfig.getInstance()); } @@ -1801,14 +1801,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { 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/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index 15a7c87c08..93dc57a8f4 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -37,7 +37,7 @@ public interface UIConstants { public static final Image APPFIT_H3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png"); public static final Image APPFIT_H4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png"); - public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0); + public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 1, 0, 0); public static final Border CELL_ATTR_EMPTYBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 0); public static final Border CELL_ATTR_PRESENTBORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0); public static final Border CELL_ATTR_NORMALBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 15); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java index bebcd14e25..51bd8b49bf 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java @@ -72,24 +72,18 @@ public class TableDataCreatorProducer { public TableDataNameObjectCreator[] createServerTableDataCreator() { TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Database_Query"), - "ds", "/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class, DBTableDataPane.class); TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), - "Class", "/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class, ClassTableDataPane.class); TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), - "Embedded", "/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class, EmbeddedTableDataPane.class); TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_File"), - "File", "/com/fr/design/images/data/file.png", FileTableData.class, FileTableDataSmallPane.class); - TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Tree"), - "Tree", "/com/fr/design/images/data/tree.png", RecursionTableData.class, GlobalTreeTableDataPane.class) { public boolean isNeedParameterWhenPopulateJControlPane() { @@ -97,7 +91,6 @@ public class TableDataCreatorProducer { } }; TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Relation"), - "Multi", "/com/fr/design/images/data/multi.png", ConditionTableData.class, GlobalMultiTDTableDataPane.class) { public boolean isNeedParameterWhenPopulateJControlPane() { @@ -105,7 +98,6 @@ public class TableDataCreatorProducer { } }; TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), - "Proc", "/com/fr/design/images/data/store_procedure.png", StoreProcedure.class, ProcedureDataPane.class) { @Override @@ -113,9 +105,7 @@ public class TableDataCreatorProducer { return true; } }; - TableDataNameObjectCreator[] creators = new TableDataNameObjectCreator[]{dataBase, ds_Class, table, fileTable, storeProcedure, multiTable, treeTable}; - return merge(creators, ExtraDesignClassManager.getInstance().getServerTableDataCreators()); } @@ -141,6 +131,6 @@ public class TableDataCreatorProducer { for (int i = 0; i < coverIndexList.size(); i ++) { creators[coverIndexList.get(i)] = coverCreators.get(i); } - return (TableDataNameObjectCreator[])ArrayUtils.addAll(creators, list.toArray(new TableDataNameObjectCreator[list.size()])); + return ArrayUtils.addAll(creators, list.toArray(new TableDataNameObjectCreator[0])); } } diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java index 8f49b6e504..94efc5faa8 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java @@ -1,21 +1,22 @@ package com.fr.design.data.datapane; import com.fr.base.BaseUtils; -import com.fr.general.NameObject; import com.fr.design.constants.UIConstants; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.UserObjectRefreshJTree; import com.fr.design.icon.IconPathConstants; import com.fr.general.ComparatorUtils; +import com.fr.general.NameObject; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; -import java.awt.*; +import java.awt.Color; +import java.awt.Component; /** * TableData Tree @@ -31,6 +32,7 @@ public class TableDataTree extends UserObjectRefreshJTree { this.setCellRenderer(tableDataTreeCellRenderer); this.setEditable(false); } + // CellRenderer private DefaultTreeCellRenderer tableDataTreeCellRenderer = new DefaultTreeCellRenderer() { private static final long serialVersionUID = 1L; @@ -66,14 +68,7 @@ public class TableDataTree extends UserObjectRefreshJTree { this.setIcon(null); this.setText(PENDING.toString()); } - // 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..." - UILabel label = new UILabel(); - label.setText(getText()); - label.setIcon(getIcon()); - Dimension dim = label.getPreferredSize(); - dim.height += 2; - this.setSize(dim); - this.setPreferredSize(dim); + this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); this.setTextSelectionColor(Color.WHITE); this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); @@ -152,7 +147,7 @@ public class TableDataTree extends UserObjectRefreshJTree { /* * p:获得选中的NameObject = name + tabledata. - */ + */ public NameObject getSelectedNameObject() { TreePath selectedTreePath = this.getSelectionPath(); if (selectedTreePath == null) { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java index 8b5c626571..8964ff8de0 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java @@ -69,7 +69,16 @@ public class TreeTableDataComboBox extends UIComboBox { } } } - + + /** + * 带参刷新方法 + * @param source 数据源数据集 + */ + public void refresh(TableDataSource source) { + this.source = source; + refresh(); + } + public void setSelectedTableDataByName(String name) { TableDataWrapper tableDataWrapper; if (res_map.get(name) != null) { diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java index 23e6f46136..d1beacb1d8 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java @@ -218,7 +218,7 @@ public class DBTableDataPane extends AbstractTableDataPane { paramTexts[0] = SqlUtils.tryPureSqlText(sqlTextPane.getText()); paramTexts[1] = SqlUtils.tryPureSqlText(pageQuery); List existParameterList = editorPane.update(); - Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[existParameterList.size()]); + Parameter[] ps = existParameterList == null ? new Parameter[0] : existParameterList.toArray(new Parameter[0]); editorPane.populate(ParameterUtils.analyzeAndUnionParameters(paramTexts, ps)); } diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java index d43e6bdee4..13fd60a60d 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MaxMemRowCountPanel.java @@ -73,6 +73,7 @@ public class MaxMemRowCountPanel extends UIToolbar { switchCache = new UIComboBox(CACHE_LIST); switchCache.addActionListener(switchStateL); numberSpinner = new UISpinner(0, Integer.MAX_VALUE, 1); + numberSpinner.setNumberFieldColumns(4); } private void showAllPanel() { diff --git a/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java b/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java index 21042a57a9..11a49fafe1 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/ErrorDialog.java @@ -35,7 +35,7 @@ public abstract class ErrorDialog extends JDialog implements ActionListener { JPanel messagePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); UILabel boldFontLabel = new UILabel(message); UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Send_Report_To_Us")); - Font font = FRFont.getInstance("Dialog", Font.BOLD, 20); + Font font = FRFont.getInstance(label.getFont().getFontName(), Font.BOLD, 20); boldFontLabel.setFont(font); messagePane.add(boldFontLabel); messagePane.add(label); diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java index 2f30f70b97..37a671eeb8 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java @@ -40,6 +40,12 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { private WorkspaceConnectionInfo connection; + /** + * 标记下新创建的远程工作目录 兼容存留的远程目录客户升级后再回退 读取为密文 + * 仅保证当前新增是加密的 + */ + private boolean newCreated; + public static RemoteDesignerWorkspaceInfo create(WorkspaceConnectionInfo connection) { RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); info.connection = connection; @@ -79,12 +85,21 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { return remindTime; } + public boolean isNewCreated() { + return newCreated; + } + + public void setNewCreated(boolean newCreated) { + this.newCreated = newCreated; + } + @Override public void readXML(XMLableReader reader) { if (reader.isAttr()) { this.name = reader.getAttrAsString("name", StringUtils.EMPTY); this.remindTime = reader.getAttrAsString("remindTime", StringUtils.EMPTY); + this.newCreated = reader.getAttrAsBoolean("newCreated", false); } if (reader.isChildNode()) { String tagName = reader.getTagName(); @@ -92,32 +107,49 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo { String url = reader.getAttrAsString("url", StringUtils.EMPTY); String username = reader.getAttrAsString("username", StringUtils.EMPTY); //密码解密 - String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n")); + String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n")); String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY); - String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + String certSecretKey = readCertSecretKey(reader); boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true); this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd); } } } + private String readCertSecretKey(XMLableReader reader) { + if (isNewCreated()) { + return SecurityToolbox.defaultDecrypt(reader.getAttrAsString("certSecretKey", StringUtils.EMPTY).replaceAll(StringUtils.BLANK, "\r\n")); + } else { + return reader.getAttrAsString("certSecretKey", StringUtils.EMPTY); + } + } + @Override public void writeXML(XMLPrintWriter writer) { writer.attr("name", name); writer.attr("remindTime", remindTime); + writer.attr("newCreated", isNewCreated()); if (this.connection != null) { writer.startTAG("Connection"); writer.attr("url", connection.getUrl()); writer.attr("username", connection.getUserName()); writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword())); writer.attr("certPath", connection.getCertPath()); - writer.attr("certSecretKey", connection.getCertSecretKey()); + writeCertSecretKey(writer); writer.attr("rememberPwd", connection.isRememberPwd()); writer.end(); } } + private void writeCertSecretKey(XMLPrintWriter writer) { + if (isNewCreated()) { + writer.attr("certSecretKey", SecurityToolbox.defaultEncrypt(connection.getCertSecretKey())); + } else { + writer.attr("certSecretKey", connection.getCertSecretKey()); + } + } + @Override @SuppressWarnings("squid:S2975") public Object clone() throws CloneNotSupportedException { diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java index 42791ad522..8fbb2d2a5d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java @@ -24,7 +24,7 @@ public class LoginDialog extends UIDialog { } private void init(Component pane) { - if (StableUtils.getMajorJavaVersion() == 8) { + if (StableUtils.getMajorJavaVersion() >= 8) { setUndecorated(true); } JPanel panel = (JPanel) getContentPane(); diff --git a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java index 72fa6149b6..69ad0f08d1 100644 --- a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java @@ -16,7 +16,7 @@ public class ShopDialog extends UIDialog { public ShopDialog(Frame frame, BasicPane pane) { super(frame); - if (StableUtils.getMajorJavaVersion() == 8) { + if (StableUtils.getMajorJavaVersion() >= 8) { setUndecorated(true); } JPanel panel = (JPanel) getContentPane(); 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 d7f858b65f..628adfec64 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 @@ -159,7 +159,7 @@ public class WebViewDlgHelper { } public static void createLoginDialog() { - if (StableUtils.getMajorJavaVersion() == VERSION_8) { + if (StableUtils.getMajorJavaVersion() >= VERSION_8) { File file = new File(StableUtils.pathJoin(installHome, "scripts")); if (!file.exists()) { confirmDownLoadShopJS(); @@ -172,7 +172,7 @@ public class WebViewDlgHelper { public static void createLoginDialog(Window parent) { - if (StableUtils.getMajorJavaVersion() == VERSION_8) { + if (StableUtils.getMajorJavaVersion() >= VERSION_8) { File file = new File(StableUtils.pathJoin(installHome, "scripts")); if (!file.exists()) { confirmDownLoadShopJS(); diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java index 46cdae35bd..6103e68002 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/JTreeAutoBuildPane.java @@ -26,14 +26,14 @@ 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.stable.StringUtils; - -import javax.swing.*; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.List; +import javax.swing.*; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previewable, EditOrNewLabel.Editable { private TreeTableDataComboBox treeTableDataComboBox; @@ -61,6 +61,23 @@ public class JTreeAutoBuildPane extends BasicPane implements PreviewLabel.Previe tdChange(); } }); + // REPORT-38762 加一个展开监听事件,下拉框展开时刷新一下数据集 + treeTableDataComboBox.addPopupMenuListener(new PopupMenuListener() { + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + treeTableDataComboBox.refresh(DesignTableDataManager.getEditingTableDataSource()); + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + + } + }); selectTreeDataPanel.add(treeTableDataComboBox); treeTableDataComboBox.setPreferredSize(new Dimension(200, 25)); treeTableDataComboBox.setSelectedIndex(-1); diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index df07acf1ab..77407a3eda 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -19,7 +19,7 @@ import java.awt.event.MouseMotionListener; public class UIEastResizableContainer extends JPanel { private static final long serialVersionUID = 1854340560790476907L; - public static final int MAX_CONTAINER_WIDTH = 500; + public static final int MAX_CONTAINER_WIDTH = 340; public static final int MIN_CONTAINER_WIDTH = 286; private int containerWidth = 240; @@ -266,13 +266,7 @@ public class UIEastResizableContainer extends JPanel { @Override public void mouseDragged(MouseEvent e) { - containerWidth = UIEastResizableContainer.this.getWidth() + (UIEastResizableContainer.this.getLocationOnScreen().x - e.getXOnScreen()); - containerWidth = Math.min(containerWidth, MAX_CONTAINER_WIDTH); - containerWidth = Math.max(containerWidth, MIN_CONTAINER_WIDTH); - refreshContainer(); - if ( DesignModeContext.isAuthorityEditing()) { - DesignerContext.getDesignerFrame().doResize(); - } + // do noting } }); addMouseListener(new MouseAdapter() { diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index fb6752ac19..c60ae27605 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -30,6 +30,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver private static final int LEN = 13; private static final int WIDTH = 13; private static final int HEIGHT = 10; + private static final int DEFAULT_NUMBERFIELD_COLUMNS = 2; private UINumberField textField; private UIButton preButton; private UIButton nextButton; @@ -40,9 +41,22 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver private UIObserverListener uiObserverListener; private GlobalNameListener globalNameListener = null; private boolean lessMinValue = false; + /** + * Spinner内的数字文本框长度 + */ + private int numberFieldColumns; public UISpinner(double minValue, double maxValue, double dierta) { + init(minValue, maxValue, dierta); + } + + public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) { + init(minValue, maxValue, dierta); + textField.setValue(defaultValue); + } + + private void init(double minValue, double maxValue, double dierta) { this.minValue = minValue; this.maxValue = maxValue; this.dierta = dierta; @@ -50,11 +64,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver iniListener(); } - public UISpinner(double minValue, double maxValue, double dierta, double defaultValue) { - this(minValue, maxValue, dierta); - textField.setValue(defaultValue); - } - private void iniListener() { if (shouldResponseChangeListener()) { this.addChangeListener(new ChangeListener() { @@ -156,6 +165,13 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver fireStateChanged(); } + /** + * 设置Spinner内的数字输入框列数 + * @param numberFieldColumns 输入框列数 + */ + public void setNumberFieldColumns(int numberFieldColumns) { + textField.setColumns(numberFieldColumns); + } public void setEnabled(boolean flag) { super.setEnabled(flag); @@ -308,7 +324,8 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver } protected UINumberField initNumberField() { - return new UINumberField(2) { + int columns = this.numberFieldColumns == 0 ? DEFAULT_NUMBERFIELD_COLUMNS : this.numberFieldColumns; + return new UINumberField(columns) { public boolean shouldResponseChangeListener() { return false; } diff --git a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java index d5a9044d5e..435d5a465a 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer-base/src/main/java/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -2,7 +2,6 @@ package com.fr.design.gui.itree.filetree; import com.fr.base.FRContext; import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.RefreshableJTree; import com.fr.design.i18n.Toolkit; @@ -14,13 +13,13 @@ import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.workspace.WorkContext; +import javax.swing.BorderFactory; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; import java.awt.Color; import java.awt.Component; -import java.awt.Dimension; import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -79,14 +78,7 @@ public class EnvFileTree extends RefreshableJTree { this.setIcon(null); this.setText(PENDING.toString()); } - // 这里新建一个Label作为render是因为JTree在动态刷新的时候,节点上render画布的的宽度不会变,会使得一部分比较长的数据显示为"..." - UILabel label = new UILabel(); - label.setText(getText()); - label.setIcon(getIcon()); - this.setSize(label.getPreferredSize()); - Dimension dim = label.getPreferredSize(); - dim.height += 2; - this.setPreferredSize(dim); + this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); this.setTextSelectionColor(Color.WHITE); this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 42365dcc57..2f65fca0a8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -257,8 +257,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } }; - private ProgressDialog progressDialog; - public DesignerFrame(ToolBarMenuDock ad) { setName(DESIGNER_FRAME_NAME); @@ -338,7 +336,6 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta this.setDropTarget(new DropTarget(this, DnDConstants.ACTION_MOVE, new FileDropTargetListener(), true)); closeMode = UIConstants.CLOSE_OF_AUTHORITY; initMenuPane(); - this.progressDialog = new ProgressDialog(this); } public void resizeFrame() { @@ -748,9 +745,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * @param al 组件名称 */ public void checkCombineUp(boolean flag, ArrayList al) { - - combineUp.checkComponentsByNames(flag, al); - + //Yvan: 检查当前是否为WORK_SHEET状态,因为只有WORK_SHEET中含有格式刷组件,此时是不需要进行checkComponentsByNames的 + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (jTemplate != null) { + // 第一个条件满足后还需要添加一重判断,判断是编辑报表块还是参数面板,编辑报表块时则直接return + if (jTemplate.getMenuState() == DesignState.WORK_SHEET && !jTemplate.isUpMode()) { + return; + } + combineUp.checkComponentsByNames(flag, al); + } } /** @@ -1262,23 +1265,15 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } + @Deprecated public ProgressDialog getProgressDialog() { - return progressDialog; + return new ProgressDialog(this); } - public void showProgressDialog() { - - progressDialog.setVisible(true); - - } - - /** - * 隐藏进度框 - */ - public void hideProgressDialog() { + @Deprecated + public void openProgressDialog() { - progressDialog.setVisible(false); } /** @@ -1286,17 +1281,17 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta * * @param progress 进度值 */ + @Deprecated public void updateProgress(int progress) { - progressDialog.setProgressValue(progress); } /** * 释放进度框 */ + @Deprecated public void disposeProgressDialog() { - progressDialog.dispose(); } /** @@ -1307,4 +1302,5 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta public boolean isDesignerOpened() { return designerOpened; } + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java index a9d9281e99..870853a45a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java @@ -556,7 +556,7 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt ); newNameLabel.setHorizontalAlignment(SwingConstants.RIGHT); newNameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); - newNameLabel.setPreferredSize(new Dimension(118, 15)); + //newNameLabel.setPreferredSize(new Dimension(118, 15)); // 重命名输入框 nameField = new UITextField(oldName); 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 a273828d84..c7c587563a 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 @@ -511,7 +511,10 @@ public class EastRegionContainerPane extends UIEastResizableContainer { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { - propertyItemMap.get(key).replaceContentPane(pane); + PropertyItem item = propertyItemMap.get(key); + if (item != null) { + item.replaceContentPane(pane); + } } }); } diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java index b16e6b2792..7c8f675b1e 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterInputPane.java @@ -20,14 +20,18 @@ import com.fr.design.editor.editor.TextEditor; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.FRGUIPaneFactory; - import com.fr.stable.ParameterProvider; import com.fr.stable.StringUtils; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Dimension; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; @@ -37,31 +41,34 @@ import java.util.Map.Entry; /** * The dialog used to input parameter. + * * @editor zhou * @since 2012-3-26上午11:09:45 */ public class ParameterInputPane extends BasicPane { - /** - * - */ - private static final long serialVersionUID = 1L; + /** + * + */ + private static final long serialVersionUID = 1L; + + // alex:保存编辑器对应的参数的名字 + private java.util.Map editorNameMap; // Map + + private boolean allowBlank = true; - // alex:保存编辑器对应的参数的名字 - private java.util.Map editorNameMap; // Map + private FlowTableLayoutHelper flowTableLayoutHelper; - private boolean allowBlank = true; - - /** + /** * Constructor. */ public ParameterInputPane(ParameterProvider[] parameters) { this.initComponents(parameters); } - public ParameterInputPane(ParameterProvider[] parameters, boolean allowBlank) { - this.allowBlank = allowBlank; - this.initComponents(parameters); - } + public ParameterInputPane(ParameterProvider[] parameters, boolean allowBlank) { + this.allowBlank = allowBlank; + this.initComponents(parameters); + } private void initComponents(ParameterProvider[] parameters) { this.setLayout(new BorderLayout(0, 4)); @@ -71,24 +78,24 @@ public class ParameterInputPane extends BasicPane { this.add(new JScrollPane(contentPane), BorderLayout.CENTER); contentPane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters") + ":")); - FlowTableLayoutHelper flowTableLayoutHelper = new FlowTableLayoutHelper(); + flowTableLayoutHelper = new FlowTableLayoutHelper(); + + editorNameMap = new java.util.HashMap(); - editorNameMap = new java.util.HashMap(); - //Parameter list. java.util.List nameAddedList = new java.util.ArrayList(); // alex:已经加到界面中去的参数名 if (parameters != null && parameters.length > 0) { for (int i = 0; i < parameters.length; i++) { ParameterProvider parameter = parameters[i]; - + // alex:已经在界面中的参数,不加了 if (nameAddedList.contains(parameter.getName())) { - continue; - } - if(parameter instanceof StoreProcedureParameter - && ((StoreProcedureParameter) parameter).getSchema() == StoreProcedureConstants.OUT) { - continue; - } + continue; + } + if (parameter instanceof StoreProcedureParameter + && ((StoreProcedureParameter) parameter).getSchema() == StoreProcedureConstants.OUT) { + continue; + } final Object pv = parameter.getValue(); Editor[] editors = makeEditorByValue(pv); @@ -100,135 +107,140 @@ public class ParameterInputPane extends BasicPane { editPane.setPreferredSize(new Dimension(180, editPane.getPreferredSize().height)); String parameterDisplayName = parameter.getName(); - if(StringUtils.isNotBlank(parameter.getName())) { - parameterDisplayName = parameter.getName(); + if (StringUtils.isNotBlank(parameter.getName())) { + parameterDisplayName = parameter.getName(); } contentPane.add(flowTableLayoutHelper.createLabelFlowPane(parameterDisplayName + ":", editPane)); //add editor to parameter hashtable. - initTextListener(textF); + initTextListener(textF); this.editorNameMap.put(textF, parameter.getName()); nameAddedList.add(parameter.getName()); } } + } + @Override + public void addNotify() { + super.addNotify(); + // windows 高DPI下,使用getPreferredSize必须在添加到容器之后,否则得到的数值不准确,因此先放到这调整大小 flowTableLayoutHelper.adjustLabelWidth(); } protected void initTextListener(ValueEditorPane textF) { - textF.getCurrentEditor().addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); - } - }); - } - - private Editor[] makeEditorByValue(Object pv) { - Editor[] editors = {null}; - if (pv instanceof Integer) { - editors[0] = new IntegerEditor(); - } else if (pv instanceof Double || pv instanceof Float) { - editors[0] = new DoubleEditor(); - } else if (pv instanceof Float) { - editors[0] = new FloatEditor(); - } else if (pv instanceof Date) { - editors[0] = new DateEditor(true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date")); - } else if (pv instanceof Boolean) { - editors[0] = new BooleanEditor(); - } else if (pv instanceof BaseFormula) { - editors = ValueEditorPaneFactory.basicEditors(); - } else { - editors[0] = new TextEditor(); - } - return editors; - } - + textF.getCurrentEditor().addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(); + } + }); + } + + private Editor[] makeEditorByValue(Object pv) { + Editor[] editors = {null}; + if (pv instanceof Integer) { + editors[0] = new IntegerEditor(); + } else if (pv instanceof Double || pv instanceof Float) { + editors[0] = new DoubleEditor(); + } else if (pv instanceof Float) { + editors[0] = new FloatEditor(); + } else if (pv instanceof Date) { + editors[0] = new DateEditor(true, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Date")); + } else if (pv instanceof Boolean) { + editors[0] = new BooleanEditor(); + } else if (pv instanceof BaseFormula) { + editors = ValueEditorPaneFactory.basicEditors(); + } else { + editors[0] = new TextEditor(); + } + return editors; + } + @Override protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters"); + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Parameters"); } /** * Update */ - public Map update() { - - java.util.Map nameValueMap = new java.util.HashMap(); - - Iterator> entryIt = this.editorNameMap.entrySet().iterator(); - while(entryIt.hasNext()) { - java.util.Map.Entry entry = entryIt.next(); - ValueEditorPane editor = entry.getKey(); - String parameterName = entry.getValue(); - - Object editorStringValue = editor.update(); - nameValueMap.put(parameterName, editorStringValue); - } - - return nameValueMap; + public Map update() { + + java.util.Map nameValueMap = new java.util.HashMap(); + + Iterator> entryIt = this.editorNameMap.entrySet().iterator(); + while (entryIt.hasNext()) { + java.util.Map.Entry entry = entryIt.next(); + ValueEditorPane editor = entry.getKey(); + String parameterName = entry.getValue(); + + Object editorStringValue = editor.update(); + nameValueMap.put(parameterName, editorStringValue); + } + + return nameValueMap; + } + + public void checkValid() throws Exception { + if (!allowBlank) { + boolean valid = true; + String error = ""; + Iterator> entryIt = this.editorNameMap.entrySet().iterator(); + while (entryIt.hasNext()) { + java.util.Map.Entry entry = entryIt.next(); + ValueEditorPane editor = entry.getKey(); + String parameterName = entry.getValue(); + Object editorStringValue = editor.update(); + if (editorStringValue == null || StringUtils.isEmpty(Utils.objectToString(editorStringValue))) { + valid = false; + error += parameterName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Null_Des") + "\n"; + } + } + if (!valid) { + throw new Exception(error); + } + } } - public void checkValid() throws Exception { - if (!allowBlank) { - boolean valid = true; - String error = ""; - Iterator> entryIt = this.editorNameMap.entrySet().iterator(); - while (entryIt.hasNext()) { - java.util.Map.Entry entry = entryIt.next(); - ValueEditorPane editor = entry.getKey(); - String parameterName = entry.getValue(); - Object editorStringValue = editor.update(); - if (editorStringValue == null || StringUtils.isEmpty(Utils.objectToString(editorStringValue))) { - valid = false; - error += parameterName + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Not_Null_Des") + "\n"; - } - } - if (!valid) { - throw new Exception(error); - } - } - } - /** * The class help to flowlayout components */ private static class FlowTableLayoutHelper { - private List labelList = new ArrayList(); + private List labelList = new ArrayList(); - public FlowTableLayoutHelper() { - } + public FlowTableLayoutHelper() { + } - public JPanel createLabelFlowPane(String text, JComponent comp) { - JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + public JPanel createLabelFlowPane(String text, JComponent comp) { + JPanel centerPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - UILabel textLabel = new UILabel(text); - centerPane.add(textLabel); - textLabel.setHorizontalAlignment(SwingConstants.LEFT); + UILabel textLabel = new UILabel(text); + centerPane.add(textLabel); + textLabel.setHorizontalAlignment(SwingConstants.LEFT); - this.labelList.add(textLabel); - centerPane.add(comp); + this.labelList.add(textLabel); + centerPane.add(comp); - return centerPane; - } + return centerPane; + } - public void adjustLabelWidth() { - int maxWidth = 0; + public void adjustLabelWidth() { + int maxWidth = 0; - for (int i = 0; i < labelList.size(); i++) { - maxWidth = Math.max(maxWidth, labelList.get(i).getPreferredSize().width); - } + for (int i = 0; i < labelList.size(); i++) { + maxWidth = Math.max(maxWidth, labelList.get(i).getPreferredSize().width); + } - for (int i = 0; i < labelList.size(); i++) { - UILabel label = labelList.get(i); + for (int i = 0; i < labelList.size(); i++) { + UILabel label = labelList.get(i); - Dimension labelDim = new Dimension(maxWidth, label.getPreferredSize().height); + Dimension labelDim = new Dimension(maxWidth, label.getPreferredSize().height); - label.setPreferredSize(labelDim); - label.setSize(labelDim); - label.setMinimumSize(labelDim); - } - } + label.setPreferredSize(labelDim); + label.setSize(labelDim); + label.setMinimumSize(labelDim); + } + } } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java index 2bf64642f2..f443a10ecf 100644 --- a/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java +++ b/designer-base/src/main/java/com/fr/design/utils/DesignUtils.java @@ -19,10 +19,10 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.CommonCodeUtils; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; +import com.fr.stable.os.OperatingSystem; import com.fr.start.ServerStarter; import com.fr.workspace.WorkContext; -import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.UIManager; import java.awt.Desktop; @@ -31,7 +31,6 @@ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -83,6 +82,7 @@ public class DesignUtils { /** * 判断设计器端口是否被其他程序占用 * 尝试去通信,无回应就是其他程序占用端口,否则需要继续判断是否为设计器进程未关闭 + * * @return */ public static boolean isPortOccupied() { @@ -153,7 +153,7 @@ public class DesignUtils { return; } try (Socket socket = new Socket("localhost", port)) { - clientSend(lines, socket); + clientSend(lines, socket); } catch (Exception ignore) { } @@ -189,10 +189,10 @@ public class DesignUtils { DesignerEnvManager.getEnvManager().setCurrentEnv2Default(); ServerStarter.browserDemoURL(); } else if ("check".equals(line)) { - clientSend(new String[] {"response"}, socket); + clientSend(new String[]{"response"}, socket); } else if ("end".equals(line)) { - DesignerExiter.getInstance().execute(); } - else if (StringUtils.isNotEmpty(line)) { + DesignerExiter.getInstance().execute(); + } else if (StringUtils.isNotEmpty(line)) { File f = new File(line); String path = f.getAbsolutePath(); @@ -219,7 +219,7 @@ public class DesignUtils { } - public static void responseToClient(Socket socket) { + public static void responseToClient(Socket socket) { try (OutputStream outputStream = socket.getOutputStream()) { outputStream.write("reponse".getBytes(StandardCharsets.UTF_8)); outputStream.flush(); @@ -285,13 +285,20 @@ public class DesignUtils { return key.startsWith("TextField.") || key.startsWith("PasswordField."); } + /** + * 获取当前系统语言下设计器用的默认字体 + * + * @return 默认字体 + */ private static FRFont getCurrentLocaleFont() { FRFont guiFRFont; Locale defaultLocale = Locale.getDefault(); - - if (isDisplaySimSun(defaultLocale)) { + // JDK9 之后宋体在计算label中字母的空间上出现问题,暂时先用雅黑兼容,以后再统一字体 + if (StableUtils.getMajorJavaVersion() >= 9 && OperatingSystem.isWindows()) { + guiFRFont = getNamedFont("Microsoft YaHei"); + } else if (isDisplaySimSun(defaultLocale)) { guiFRFont = getNamedFont("SimSun"); - } else { + } else { guiFRFont = getNamedFont("Dialog"); } diff --git a/designer-base/src/main/java/com/fr/env/EnvListPane.java b/designer-base/src/main/java/com/fr/env/EnvListPane.java index 911a7b22f8..2d875cb458 100644 --- a/designer-base/src/main/java/com/fr/env/EnvListPane.java +++ b/designer-base/src/main/java/com/fr/env/EnvListPane.java @@ -3,6 +3,7 @@ package com.fr.env; import com.fr.design.DesignerEnvManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; +import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.LocalDesignerWorkspaceInfo; import com.fr.design.env.RemoteDesignerWorkspaceInfo; import com.fr.design.gui.controlpane.JListControlPane; @@ -17,8 +18,10 @@ import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.*; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; /** * @author yaohwu @@ -98,11 +101,30 @@ public class EnvListPane extends JListControlPane { DesignerEnvManager mgr = DesignerEnvManager.getEnvManager(); //这里代码时序换一下,因为update中需要借助mgr来获取提醒时间,已确认mgr对res无依赖 Nameable[] res = this.update(); + Set set = findNewWorkSpaceInfo(res); mgr.clearAllEnv(); for (Nameable re : res) { NameObject nameObject = (NameObject) re; - mgr.putEnv(nameObject.getName(), (DesignerWorkspaceInfo) nameObject.getObject()); + DesignerWorkspaceInfo info = (DesignerWorkspaceInfo) nameObject.getObject(); + if (set.contains(re) && info.getType() == DesignerWorkspaceType.Remote) { + RemoteDesignerWorkspaceInfo newInfo = (RemoteDesignerWorkspaceInfo) info; + newInfo.setNewCreated(true); + mgr.putEnv(nameObject.getName(), newInfo); + } else { + mgr.putEnv(nameObject.getName(), info); + } } return this.getSelectedName(); } + + private Set findNewWorkSpaceInfo(Nameable[] res) { + Set set = new HashSet<>(); + for (Nameable val : res) { + NameObject nameObject = (NameObject) val; + if (DesignerEnvManager.getEnvManager().getWorkspaceInfo(nameObject.getName()) == null) { + set.add(val); + } + } + return set; + } } diff --git a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java index 7e95c48d27..f8f7a13ea2 100644 --- a/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java +++ b/designer-base/src/main/java/com/fr/start/server/FineEmbedServerMonitor.java @@ -32,7 +32,7 @@ public class FineEmbedServerMonitor { */ private static final int STEP_HEARTBEAT = 40; private static volatile FineEmbedServerMonitor monitor; - private static ProgressDialog progressBar = DesignerContext.getDesignerFrame().getProgressDialog(); + private static ProgressDialog progressDialog = new ProgressDialog(DesignerContext.getDesignerFrame()); //由于默认值的字体不支持韩文,所以要对韩文单独生成字体 private FRFont font = null; private static final int FONT_RGB = 333334; @@ -47,7 +47,7 @@ public class FineEmbedServerMonitor { @Override public void on(Event event, Null aNull) { getInstance().reset(); - DesignerContext.getDesignerFrame().hideProgressDialog(); + progressDialog.dispose(); } }); } @@ -64,7 +64,7 @@ public class FineEmbedServerMonitor { } public int getProgress() { - if (progress == progressBar.getProgressMaximum()) { + if (progress == progressDialog.getProgressMaximum()) { return progress; } else { progress += STEP; @@ -73,7 +73,7 @@ public class FineEmbedServerMonitor { } public void setComplete() { - this.progress = progressBar.getProgressMaximum(); + this.progress = progressDialog.getProgressMaximum(); } public void reset() { @@ -81,7 +81,7 @@ public class FineEmbedServerMonitor { } public boolean isComplete() { - return this.progress >= progressBar.getProgressMaximum(); + return this.progress >= progressDialog.getProgressMaximum(); } public void monitor() { @@ -92,11 +92,12 @@ public class FineEmbedServerMonitor { public void run() { if (isComplete()) { scheduler.shutdown(); - DesignerContext.getDesignerFrame().hideProgressDialog(); + progressDialog.dispose(); return; } - if (!DesignerContext.getDesignerFrame().getProgressDialog().isVisible()) { - DesignerContext.getDesignerFrame().showProgressDialog(); + if (!progressDialog.isVisible()) { + progressDialog = new ProgressDialog(DesignerContext.getDesignerFrame()); + progressDialog.setVisible(true); //如果为韩文则改变字体 LocaleCenter.buildAction(new LocaleAction() { @Override @@ -105,9 +106,9 @@ public class FineEmbedServerMonitor { } }, SupportLocaleImpl.SUPPORT_KOREA); String text = Toolkit.i18nText("Fine-Design_Basic_Loading_Embed_Server"); - DesignerContext.getDesignerFrame().getProgressDialog().updateLoadingText(text, font); + progressDialog.updateLoadingText(text, font); } - DesignerContext.getDesignerFrame().updateProgress(getProgress()); + progressDialog.setProgressValue(getProgress()); } }, 0, STEP_HEARTBEAT, TimeUnit.MILLISECONDS); diff --git a/designer-base/src/main/java/com/fr/start/server/ServerTray.java b/designer-base/src/main/java/com/fr/start/server/ServerTray.java index 2b3713c0f7..4ad6e15b49 100644 --- a/designer-base/src/main/java/com/fr/start/server/ServerTray.java +++ b/designer-base/src/main/java/com/fr/start/server/ServerTray.java @@ -29,9 +29,9 @@ public class ServerTray { private MenuItem stopMenu; - private Image trayStartedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStarted.png"); + private Image trayStartedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStarted@2x.png"); - private Image trayStoppedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStopped.png"); + private Image trayStoppedImage = BaseUtils.readImage("/com/fr/base/images/oem/trayStopped@2x.png"); private ServerManageFrame serverManageFrame; @@ -188,4 +188,4 @@ public class ServerTray { } }); } -} \ No newline at end of file +} diff --git a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java index b7d123d66e..f60d6da291 100644 --- a/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java +++ b/designer-base/src/test/java/com/fr/design/DesignerEnvManagerTest.java @@ -3,6 +3,7 @@ package com.fr.design; import junit.framework.TestCase; import java.util.Locale; +import org.junit.Assert; public class DesignerEnvManagerTest extends TestCase{ @@ -17,4 +18,11 @@ public class DesignerEnvManagerTest extends TestCase{ assertEquals("下边界", envManager.getLanguage(), Locale.SIMPLIFIED_CHINESE); } + + public void testGetUUID() { + DesignerEnvManager envManager = new DesignerEnvManager(); + String uuid0 = envManager.getUUID(); + String uuid1 = envManager.getUUID(); + Assert.assertEquals(uuid0, uuid1); + } } diff --git a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java index 54dbae3b02..d6e89cd93f 100644 --- a/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java +++ b/designer-base/src/test/java/com/fr/design/env/RemoteDesignerWorkspaceInfoTest.java @@ -1,9 +1,16 @@ package com.fr.design.env; +import com.fr.invoke.Reflect; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLReaderHelper; +import com.fr.stable.xml.XMLableReader; import com.fr.workspace.connect.WorkspaceConnectionInfo; import junit.framework.TestCase; import org.junit.Assert; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; + /** * @author hades * @version 10.0 @@ -22,4 +29,64 @@ public class RemoteDesignerWorkspaceInfoTest extends TestCase { Assert.assertFalse(workspaceInfo3.checkValid()); } + public void testReadXml() { + String xml0 = ""; + String xml1 = ""; + byte[] bytes0 = xml0.getBytes(); + byte[] bytes1 = xml1.getBytes(); + RemoteDesignerWorkspaceInfo info = new RemoteDesignerWorkspaceInfo(); + ByteArrayInputStream in0 = new ByteArrayInputStream(bytes0); + ByteArrayInputStream in1 = new ByteArrayInputStream(bytes1); + + try { + XMLableReader reader0 = XMLReaderHelper.createXMLableReader(in0, XMLPrintWriter.XML_ENCODER); + Reflect.on(reader0).set("state", 1); + info.setNewCreated(true); + info.readXML(reader0); + Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey()); + + XMLableReader reader1 = XMLReaderHelper.createXMLableReader(in1, XMLPrintWriter.XML_ENCODER); + Reflect.on(reader1).set("state", 1); + info.setNewCreated(false); + info.readXML(reader1); + Assert.assertEquals("xxxxxxx", info.getConnection().getCertSecretKey()); + } catch (Exception ignore) { + + } + } + + public void testWriteXml() { + ByteArrayOutputStream out0 = new ByteArrayOutputStream(); + XMLPrintWriter writer0 = XMLPrintWriter.create(out0); + RemoteDesignerWorkspaceInfo info0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true)); + info0.setNewCreated(true); + info0.writeXML(writer0); + writer0.close(); + String result0 = new String(out0.toByteArray()); + Assert.assertTrue(result0.contains("certSecretKey")); + Assert.assertFalse(result0.contains("certSecretKey=\"xxxxx\"")); + + ByteArrayOutputStream out1 = new ByteArrayOutputStream(); + XMLPrintWriter writer1 = XMLPrintWriter.create(out1); + RemoteDesignerWorkspaceInfo info1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("127.0.0.1", "1", "1", "/xxx", "xxxxx", true)); + info1.writeXML(writer1); + writer1.close(); + String result1 = new String(out1.toByteArray()); + Assert.assertTrue(result1.contains("certSecretKey")); + Assert.assertTrue(result1.contains("certSecretKey=\"xxxxx\"")); + + } + } diff --git a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java index e4e27b7f49..16f983c758 100644 --- a/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/design/chartx/component/AbstractCustomFieldComboBoxPane.java @@ -82,6 +82,10 @@ public abstract class AbstractCustomFieldComboBoxPane extends BasicBeanPane extends BasicBeanPane{ * @return 界面是否接受对象 */ public boolean accept(Object ob) { - return ob instanceof ChartCollection && ((ChartCollection)ob).getSelectedChart().getFilterDefinition() instanceof ReportDataDefinition; + TopDefinitionProvider filterDefinition = ((ChartCollection) ob).getSelectedChartProvider(Chart.class).getFilterDefinition(); + return ob instanceof ChartCollection && filterDefinition instanceof ReportDataDefinition && !(filterDefinition instanceof CustomDefinition); } /** diff --git a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java index 119d73bda6..fe02f67c04 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/ExtendedCustomFieldComboBoxPane.java @@ -22,6 +22,10 @@ public class ExtendedCustomFieldComboBoxPane extends AbstractCustomFieldComboBox return new ExtendedCustomFieldNamePane(); } + @Override + protected boolean seriesComboBoxHasNone() { + return true; + } @Override public void populateBean(AbstractDataConfig ob) { diff --git a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java index 6df855cd70..f20675066f 100644 --- a/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java +++ b/designer-chart/src/main/java/com/fr/extended/chart/UIComboBoxWithNone.java @@ -41,7 +41,9 @@ public class UIComboBoxWithNone extends UIComboBox { public void setSelectedItem(Object anObject) { super.setSelectedItem(anObject); - if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。 + //找不到的都选中无。中文的无 英文下是none。 + //改正:找不到的且anObject不是null的 全部选中无。 + if (getSelectedIndex() == -1 && anObject != null) { super.setSelectedItem(getDefaultLocaleString()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java index 77b16b4993..4659faaa84 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java @@ -1,19 +1,28 @@ package com.fr.van.chart.box; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; +import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.box.attr.AttrBoxTooltipContent; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; +import java.util.Map; public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { @@ -27,6 +36,14 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { private VanChartFormatPaneWithCheckBox min; private VanChartFormatPaneWithCheckBox outlier; + private VanChartFormatPaneWithoutCheckBox richTextNumber; + private VanChartFormatPaneWithoutCheckBox richTextMax; + private VanChartFormatPaneWithoutCheckBox richTextQ3; + private VanChartFormatPaneWithoutCheckBox richTextMedian; + private VanChartFormatPaneWithoutCheckBox richTextQ1; + private VanChartFormatPaneWithoutCheckBox richTextMin; + private VanChartFormatPaneWithoutCheckBox richTextOutlier; + private JPanel dataNumberPane; private JPanel dataOutlierPane; @@ -36,8 +53,8 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new CategoryNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); number = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { protected String getCheckBoxText() { @@ -76,7 +93,48 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { }; } - protected JPanel createCommonPanel() { + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + + richTextNumber = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Number"); + } + }; + richTextMax = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Max_Value"); + } + }; + richTextQ3 = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Q3"); + } + }; + richTextMedian = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Median"); + } + }; + richTextQ1 = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Data_Q1"); + } + }; + richTextMin = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Min_Value"); + } + }; + richTextOutlier = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"); + } + }; + } + + protected JPanel createCommonFormatPanel() { JPanel commonPanel = new JPanel(new BorderLayout()); commonPanel.add(createCateAndSeriesPane(), BorderLayout.NORTH); @@ -86,6 +144,20 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { return commonPanel; } + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{richTextNumber, null}, + new Component[]{richTextMax, null}, + new Component[]{richTextQ3, null}, + new Component[]{richTextMedian, null}, + new Component[]{richTextQ1, null}, + new Component[]{richTextMin, null}, + new Component[]{richTextOutlier, null} + }; + } + protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p, p, p, p, p, p, p, p}; } @@ -93,13 +165,15 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { private JPanel createCateAndSeriesPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, p}; - double[] rowSize = {p, p}; + double[] columnSize = {f, e}; + double[] rowSize = {p, p, p}; Component[][] cateAndSeries = new Component[][]{ - new Component[]{categoryNameFormatPane, null}, - new Component[]{seriesNameFormatPane, null} + new Component[]{null, null}, + new Component[]{null, getCategoryNameFormatPane()}, + new Component[]{null, getSeriesNameFormatPane()} }; return TableLayoutHelper.createTableLayoutPane(cateAndSeries, rowSize, columnSize); @@ -108,13 +182,14 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { private JPanel createDataNumberPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double[] columnSize = {f, p}; + double[] columnSize = {f, e}; double[] rowSize = {p, p}; Component[][] dataNumber = new Component[][]{ new Component[]{null, null}, - new Component[]{number, null}, + new Component[]{null, number}, }; dataNumberPane = TableLayoutHelper.createTableLayoutPane(dataNumber, rowSize, columnSize); @@ -125,22 +200,24 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { private JPanel createDataDetailPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; - double[] columnSize = {f, p}; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + double[] columnSize = {f, e}; JPanel detailPane = new JPanel(new BorderLayout()); Component[][] dataDetail = new Component[][]{ new Component[]{null, null}, - new Component[]{max, null}, - new Component[]{q3, null}, - new Component[]{median, null}, - new Component[]{q1, null}, - new Component[]{min, null} + new Component[]{null, max}, + new Component[]{new UILabel(getLabelContentTitle()), q3}, + new Component[]{null, median}, + new Component[]{null, q1}, + new Component[]{null, min} }; Component[][] dataOutlier = new Component[][]{ new Component[]{null, null}, - new Component[]{outlier, null}, + new Component[]{null, outlier}, }; dataOutlierPane = TableLayoutHelper.createTableLayoutPane(dataOutlier, new double[]{p, p}, columnSize); @@ -152,8 +229,8 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } public boolean isDirty() { - return categoryNameFormatPane.isDirty() - || seriesNameFormatPane.isDirty() + return getCategoryNameFormatPane().isDirty() + || getSeriesNameFormatPane().isDirty() || number.isDirty() || max.isDirty() || q3.isDirty() @@ -164,8 +241,8 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } public void setDirty(boolean isDirty) { - categoryNameFormatPane.setDirty(isDirty); - seriesNameFormatPane.setDirty(isDirty); + getCategoryNameFormatPane().setDirty(isDirty); + getSeriesNameFormatPane().setDirty(isDirty); number.setDirty(isDirty); max.setDirty(isDirty); q3.setDirty(isDirty); @@ -180,8 +257,8 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { - categoryNameFormatPane.populate(attrTooltipContent.getCategoryFormat()); - seriesNameFormatPane.populate(attrTooltipContent.getSeriesFormat()); + getCategoryNameFormatPane().populate(attrTooltipContent.getCategoryFormat()); + getSeriesNameFormatPane().populate(attrTooltipContent.getSeriesFormat()); if (attrTooltipContent instanceof AttrBoxTooltipContent) { AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; @@ -198,9 +275,43 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } } + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + Map params = getRichTextAttr().getParams(); + + AttrTooltipCategoryFormat categoryFormat = attrTooltipContent.getRichTextCategoryFormat(); + getRichTextCategoryNameFormatPane().populate(categoryFormat); + getRichTextCategoryNameFormatPane().updateFormatParams(params, categoryFormat.getJs()); + + AttrTooltipSeriesFormat seriesFormat = attrTooltipContent.getRichTextSeriesFormat(); + getRichTextSeriesNameFormatPane().populate(seriesFormat); + getRichTextSeriesNameFormatPane().updateFormatParams(params, seriesFormat.getJs()); + + if (attrTooltipContent instanceof AttrBoxTooltipContent) { + AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; + + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + richTextNumber, richTextMax, richTextQ3, richTextMedian, + richTextQ1, richTextMin, richTextOutlier + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + boxTooltipContent.getRichTextNumber(), + boxTooltipContent.getRichTextMax(), + boxTooltipContent.getRichTextQ3(), + boxTooltipContent.getRichTextMedian(), + boxTooltipContent.getRichTextQ1(), + boxTooltipContent.getRichTextMin(), + boxTooltipContent.getRichTextOutlier() + }; + + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(attrTooltipContent.getRichTextAttr()); + } + } + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { - categoryNameFormatPane.update(attrTooltipContent.getCategoryFormat()); - seriesNameFormatPane.update(attrTooltipContent.getSeriesFormat()); + getCategoryNameFormatPane().update(attrTooltipContent.getCategoryFormat()); + getSeriesNameFormatPane().update(attrTooltipContent.getSeriesFormat()); if (attrTooltipContent instanceof AttrBoxTooltipContent) { AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; @@ -217,6 +328,23 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } } + protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { + getRichTextCategoryNameFormatPane().update(attrTooltipContent.getRichTextCategoryFormat()); + getRichTextSeriesNameFormatPane().update(attrTooltipContent.getRichTextSeriesFormat()); + + if (attrTooltipContent instanceof AttrBoxTooltipContent) { + AttrBoxTooltipContent boxTooltipContent = (AttrBoxTooltipContent) attrTooltipContent; + + richTextNumber.update(boxTooltipContent.getRichTextNumber()); + richTextMax.update(boxTooltipContent.getRichTextMax()); + richTextQ3.update(boxTooltipContent.getRichTextQ3()); + richTextMedian.update(boxTooltipContent.getRichTextMedian()); + richTextQ1.update(boxTooltipContent.getRichTextQ1()); + richTextMin.update(boxTooltipContent.getRichTextMin()); + richTextOutlier.update(boxTooltipContent.getRichTextOutlier()); + } + } + public void checkFormatVisible(boolean detailed) { this.detailed = detailed; diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelDetailPane.java new file mode 100644 index 0000000000..3243bad711 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelDetailPane.java @@ -0,0 +1,17 @@ +package com.fr.van.chart.column; + +import com.fr.chart.chartattr.Plot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; + +public class VanChartColumnPlotLabelDetailPane extends VanChartPlotLabelDetailPane { + + public VanChartColumnPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { + super(plot, parent); + } + + protected boolean hasLabelOrientationPane() { + return !((VanChartColumnPlot) this.getPlot()).isBar(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelPane.java new file mode 100644 index 0000000000..e80f6310d5 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartColumnPlotLabelPane.java @@ -0,0 +1,20 @@ +package com.fr.van.chart.column; + +import com.fr.chart.chartattr.Plot; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; + +import java.awt.BorderLayout; + +public class VanChartColumnPlotLabelPane extends VanChartPlotLabelPane { + + public VanChartColumnPlotLabelPane(Plot plot, VanChartStylePane parent) { + super(plot, parent); + } + + protected void createLabelPane() { + VanChartColumnPlotLabelDetailPane labelDetailPane = new VanChartColumnPlotLabelDetailPane(getPlot(), getParentPane()); + setLabelDetailPane(labelDetailPane); + getLabelPane().add(labelDetailPane, BorderLayout.CENTER); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java index ceb9bf4807..86766676b4 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/column/VanChartCustomStackAndAxisConditionPane.java @@ -6,18 +6,19 @@ import com.fr.data.condition.ListCondition; import com.fr.design.beans.BasicBeanPane; import com.fr.design.condition.LiteConditionPane; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icontainer.UIScrollPane; 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.utils.gui.GUICoreUtils; - import com.fr.plugin.chart.base.AttrSeriesStackAndAxis; import com.fr.van.chart.designer.style.series.VanChartSeriesConditionPane; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JPanel; +import javax.swing.ScrollPaneConstants; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; @@ -46,10 +47,13 @@ public class VanChartCustomStackAndAxisConditionPane extends BasicBeanPane> autoAdjustLabelPlots = new HashSet>(); + private static Set> autoAdjustLabelPlots = new HashSet<>(); static { autoAdjustLabelPlots.add(VanChartColumnPlot.class); @@ -89,15 +91,31 @@ public class PlotFactory { return autoAdjustLabelPlots.contains(plot.getClass()); } + private static Set> borderAndBackgroundLabelPlots = new HashSet<>(); + + static { + borderAndBackgroundLabelPlots.add(PiePlot4VanChart.class); + borderAndBackgroundLabelPlots.add(VanChartColumnPlot.class); + borderAndBackgroundLabelPlots.add(VanChartLinePlot.class); + borderAndBackgroundLabelPlots.add(VanChartAreaPlot.class); + } + + public static boolean hasBorderAndBackgroundPlotLabel(Plot plot) { + return borderAndBackgroundLabelPlots.contains(plot.getClass()); + } + /** * 标签Map */ - private static Map, Class> labelMap = new HashMap, Class>(); + private static Map, Class> labelMap = new HashMap<>(); static { + labelMap.put(VanChartColumnPlot.class, VanChartColumnPlotLabelPane.class); labelMap.put(VanChartGaugePlot.class, VanChartGaugePlotLabelPane.class); labelMap.put(VanChartScatterPlot.class, VanChartScatterPlotLabelPane.class); labelMap.put(VanChartBubblePlot.class, VanChartScatterPlotLabelPane.class); + labelMap.put(VanChartGanttPlot.class, VanChartGanttPlotLabelPane.class); + labelMap.put(VanChartStructurePlot.class, VanChartStructurePlotLabelPane.class); } /** @@ -139,8 +157,6 @@ public class PlotFactory { labelContentMap.put(VanChartTreeMapPlot.class, VanChartMultiPieLabelContentPane.class); labelContentMap.put(VanChartFunnelPlot.class, VanChartFunnelLabelContentPane.class); labelContentMap.put(VanChartHeatMapPlot.class, VanChartMapLabelContentPane.class); - labelContentMap.put(VanChartGanttPlot.class, VanChartGanttLabelContentPane.class); - labelContentMap.put(VanChartStructurePlot.class, VanChartStructureLabelContentPane.class); } private static Map, Class> tooltipContentMap = new HashMap, Class>(); @@ -182,7 +198,7 @@ public class PlotFactory { refreshTooltipContentMap.put(VanChartMultiPiePlot.class, VanChartMutiPieRefreshTooltipContentPane.class); refreshTooltipContentMap.put(VanChartTreeMapPlot.class, VanChartMutiPieRefreshTooltipContentPane.class); refreshTooltipContentMap.put(VanChartFunnelPlot.class, VanChartFunnelRefreshTooltipContentPane.class); - refreshTooltipContentMap.put(VanChartWordCloudPlot.class, VanChartWordCloudRefreshTootipContentPane.class); + refreshTooltipContentMap.put(VanChartWordCloudPlot.class, VanChartWordCloudRefreshTooltipContentPane.class); refreshTooltipContentMap.put(VanChartStructurePlot.class, VanChartStructureRefreshTooltipContentPane.class); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java new file mode 100644 index 0000000000..dafaef060c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java @@ -0,0 +1,361 @@ +package com.fr.van.chart.designer.component; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class VanChartLabelContentPaneWithoutRichText extends BasicBeanPane { + + private UIButtonGroup content; + + private ValueFormatPaneWithCheckBox valueFormatPane; + private PercentFormatPaneWithCheckBox percentFormatPane; + private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; + private SeriesNameFormatPaneWithCheckBox seriesNameFormatPane; + + //监控刷新时,自动数据点提示使用 + private ChangedValueFormatPaneWithCheckBox changedValueFormatPane; + private ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane; + private UIButtonGroup styleButton; + private ChartTextAttrPane textAttrPane; + private JPanel centerPane; + private JPanel commonPanel; + private JPanel stylePanel; + private VanChartHtmlLabelPane htmlLabelPane; + + private VanChartStylePane parent; + private JPanel showOnPane; + + public VanChartLabelContentPaneWithoutRichText(VanChartStylePane parent, JPanel showOnPane) { + this.parent = parent; + this.showOnPane = showOnPane; + + this.setLayout(new BorderLayout()); + this.add(createLabelContentPane(), BorderLayout.CENTER); + } + + public ValueFormatPaneWithCheckBox getValueFormatPane() { + return valueFormatPane; + } + + public void setValueFormatPane(ValueFormatPaneWithCheckBox valueFormatPane) { + this.valueFormatPane = valueFormatPane; + } + + public PercentFormatPaneWithCheckBox getPercentFormatPane() { + return percentFormatPane; + } + + public void setPercentFormatPane(PercentFormatPaneWithCheckBox percentFormatPane) { + this.percentFormatPane = percentFormatPane; + } + + public CategoryNameFormatPaneWithCheckBox getCategoryNameFormatPane() { + return categoryNameFormatPane; + } + + public void setCategoryNameFormatPane(CategoryNameFormatPaneWithCheckBox categoryNameFormatPane) { + this.categoryNameFormatPane = categoryNameFormatPane; + } + + public SeriesNameFormatPaneWithCheckBox getSeriesNameFormatPane() { + return seriesNameFormatPane; + } + + public void setSeriesNameFormatPane(SeriesNameFormatPaneWithCheckBox seriesNameFormatPane) { + this.seriesNameFormatPane = seriesNameFormatPane; + } + + private JPanel createLabelContentPane() { + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + + initFormatPane(parent, showOnPane); + + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + commonPanel = createCommonPanel(); + htmlLabelPane = createHtmlLabelPane(); + htmlLabelPane.setParent(parent); + stylePanel = createTextStylePane(); + centerPane = new JPanel(new CardLayout()) { + @Override + public Dimension getPreferredSize() { + if (content.getSelectedIndex() == 0) { + return commonPanel.getPreferredSize(); + } else { + return new Dimension(commonPanel.getPreferredSize().width, htmlLabelPane.getPreferredSize().height); + } + } + }; + centerPane.add(htmlLabelPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); + centerPane.add(commonPanel, Toolkit.i18nText("Fine-Design_Chart_Common")); + + double[] column = {f, e}; + double[] row = {p, p, p}; + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(getLabelContentTitle()), content}, + new Component[]{null, centerPane}, + }; + initContentListener(); + JPanel paramsPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, column); + + JPanel contentPane = new JPanel(new BorderLayout()); + contentPane.add(paramsPanel, BorderLayout.CENTER); + contentPane.add(stylePanel, BorderLayout.SOUTH); + + return getLabelContentPane(contentPane); + } + + protected boolean hasTextStylePane() { + return true; + } + + private JPanel createTextStylePane() { + styleButton = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + + textAttrPane = new ChartTextAttrPane() { + protected Component[][] getComponents(JPanel buttonPane) { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{null, getFontNameComboBox()}, + new Component[]{null, buttonPane} + }; + } + }; + + JPanel buttonPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), styleButton); + + JPanel stylePanel = new JPanel(new BorderLayout()); + stylePanel.add(buttonPane, BorderLayout.CENTER); + stylePanel.add(textAttrPane, BorderLayout.SOUTH); + + initStyleButtonListener(); + + return stylePanel; + } + + private void initStyleButtonListener() { + styleButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + checkStylePane(); + } + }); + } + + private void checkStylePane() { + if (hasTextStylePane()) { + stylePanel.setVisible(true); + textAttrPane.setVisible(styleButton.getSelectedIndex() == 1); + } else { + stylePanel.setVisible(false); + } + } + + protected String getLabelContentTitle() { + return Toolkit.i18nText("Fine-Design_Report_Text"); + } + + protected JPanel getLabelContentPane(JPanel contentPane) { + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Content"), contentPane); + } + + protected VanChartHtmlLabelPane createHtmlLabelPane() { + return new VanChartHtmlLabelPane(); + } + + protected JPanel createCommonPanel() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] columnSize = {f, p}; + double[] rowSize = getRowSize(p); + + return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize); + } + + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); + seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); + valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); + percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + } + + protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); + } + + protected double[] getRowSize(double p) { + return new double[]{p, p, p, p}; + } + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{categoryNameFormatPane, null}, + new Component[]{seriesNameFormatPane, null}, + new Component[]{valueFormatPane, null}, + new Component[]{percentFormatPane, null}, + }; + } + + private void initContentListener() { + content.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkCardPane(); + } + }); + } + + + private void checkCardPane() { + CardLayout cardLayout = (CardLayout) centerPane.getLayout(); + if (content.getSelectedIndex() == 1) { + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); + if (isDirty()) { + setCustomFormatterText(); + setDirty(false); + } + } else { + cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Common")); + } + } + + protected void setCustomFormatterText() { + htmlLabelPane.setCustomFormatterText(updateBean().getFormatterTextFromCommon()); + } + + public boolean isDirty() { + return categoryNameFormatPane.isDirty() || seriesNameFormatPane.isDirty() || valueFormatPane.isDirty() || percentFormatPane.isDirty() + || (changedValueFormatPane != null && changedValueFormatPane.isDirty()) || (changedValueFormatPane != null && changedPercentFormatPane.isDirty()); + } + + public void setDirty(boolean isDirty) { + categoryNameFormatPane.setDirty(isDirty); + seriesNameFormatPane.setDirty(isDirty); + valueFormatPane.setDirty(isDirty); + percentFormatPane.setDirty(isDirty); + + if (changedValueFormatPane != null) { + changedValueFormatPane.setDirty(isDirty); + } + if (changedPercentFormatPane != null) { + changedPercentFormatPane.setDirty(isDirty); + } + } + + @Override + protected String title4PopupWindow() { + return ""; + } + + + @Override + public void populateBean(AttrTooltipContent attrTooltipContent) { + if (attrTooltipContent == null) { + return; + } + + content.setSelectedIndex(attrTooltipContent.isCommon() ? 0 : 1); + + populateFormatPane(attrTooltipContent); + + htmlLabelPane.populate(attrTooltipContent.getHtmlLabel()); + if (!attrTooltipContent.isCommon()) { + setDirty(false); + } + if (hasTextStylePane()) { + this.styleButton.setSelectedIndex(attrTooltipContent.isCustom() ? 1 : 0); + this.textAttrPane.populate(attrTooltipContent.getTextAttr()); + } + checkCardPane(); + checkStylePane(); + } + + protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { + categoryNameFormatPane.populate(attrTooltipContent.getCategoryFormat()); + seriesNameFormatPane.populate(attrTooltipContent.getSeriesFormat()); + valueFormatPane.populate(attrTooltipContent.getValueFormat()); + percentFormatPane.populate(attrTooltipContent.getPercentFormat()); + + if (changedValueFormatPane != null) { + changedValueFormatPane.populate(attrTooltipContent.getChangedValueFormat()); + } + if (changedPercentFormatPane != null) { + changedPercentFormatPane.populate(attrTooltipContent.getChangedPercentFormat()); + } + } + + public AttrTooltipContent updateBean() { + AttrTooltipContent attrTooltipContent = createAttrTooltip(); + + attrTooltipContent.setCommon(content.getSelectedIndex() == 0); + + updateFormatPane(attrTooltipContent); + + updateFormatsWithPaneWidth(attrTooltipContent); + + htmlLabelPane.update(attrTooltipContent.getHtmlLabel()); + + if (hasTextStylePane()) { + attrTooltipContent.setCustom(styleButton.getSelectedIndex() == 1); + attrTooltipContent.setTextAttr(this.textAttrPane.update()); + } + + return attrTooltipContent; + } + + protected AttrTooltipContent createAttrTooltip() { + return new AttrTooltipContent(); + } + + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { + categoryNameFormatPane.update(attrTooltipContent.getCategoryFormat()); + seriesNameFormatPane.update(attrTooltipContent.getSeriesFormat()); + valueFormatPane.update(attrTooltipContent.getValueFormat()); + percentFormatPane.update(attrTooltipContent.getPercentFormat()); + + if (changedValueFormatPane != null) { + changedValueFormatPane.update(attrTooltipContent.getChangedValueFormat()); + } + if (changedPercentFormatPane != null) { + changedPercentFormatPane.update(attrTooltipContent.getChangedPercentFormat()); + } + } + + private void updateFormatsWithPaneWidth(AttrTooltipContent attrTooltipContent) { + int paneWidth = seriesNameFormatPane.getWidth(); + if (paneWidth == 0) { + attrTooltipContent.getSeriesFormat().setEnable(false); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java index 0c3b5a4548..09e208cc10 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java @@ -1,7 +1,9 @@ package com.fr.van.chart.designer.component; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -24,18 +26,37 @@ public class VanChartRefreshTooltipContentPane extends VanChartTooltipContentPan protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); - changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane)); + setChangedPercentFormatPane(new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + setRichTextChangedValueFormatPane(new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextChangedPercentFormatPane(new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{changedValueFormatPane,null}, - new Component[]{percentFormatPane,null}, - new Component[]{changedPercentFormatPane,null}, + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getChangedValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + new Component[]{getChangedPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextChangedValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java new file mode 100644 index 0000000000..d1f294e41d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java @@ -0,0 +1,110 @@ +package com.fr.van.chart.designer.component; + +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.stable.StringUtils; +import com.teamdev.jxbrowser.chromium.Browser; +import com.teamdev.jxbrowser.chromium.JSValue; +import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; +import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; + +import java.util.Map; + +public class VanChartRichEditorPane { + + private static final String namespace = "Pool"; + private static final String variable = "data"; + private static final String richEditorPath = "/com/fr/design/editor/rich_editor.html"; + private static final String expression = "dispatch()"; + + private static ModernUIPane richEditorPane; + private static Browser browser; + + public static ModernUIPane createRichEditorPane(AttrTooltipRichText richEditor) { + RichEditorModel model = getRichEditorModel(richEditor); + + if (richEditorPane == null) { + richEditorPane = initPane(model); + } else if (browser != null) { + updatePane(browser, model); + } + + return richEditorPane; + } + + public static ModernUIPane initPane(RichEditorModel model) { + return new ModernUIPane.Builder() + .prepare(new ScriptContextAdapter() { + public void onScriptContextCreated(ScriptContextEvent event) { + browser = event.getBrowser(); + + JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); + ns.asObject().setProperty(variable, model); + } + }) + .withEMB(richEditorPath) + .namespace(namespace).build(); + } + + public static void updatePane(Browser browser, RichEditorModel model) { + JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); + ns.asObject().setProperty(variable, model); + browser.executeJavaScript("window." + namespace + "." + expression); + } + + public static RichEditorModel getRichEditorModel(AttrTooltipRichText richText) { + Map paramsMap = richText.getParams(); + StringBuilder paramsStr = new StringBuilder(StringUtils.EMPTY); + + if (paramsMap != null) { + for (Map.Entry entry : paramsMap.entrySet()) { + paramsStr.append(entry.getKey()).append(":").append(entry.getValue()); + paramsStr.append("-"); + } + } + + int len = paramsStr.length(); + + if (len > 0) { + paramsStr.deleteCharAt(len - 1); + } + + return new RichEditorModel(richText.getContent(), richText.isAuto(), paramsStr.toString()); + } + + public static class RichEditorModel { + private String content; + private boolean auto; + private String params; + + public RichEditorModel(String content, boolean auto, String params) { + this.content = content; + this.auto = auto; + this.params = params; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public boolean isAuto() { + return auto; + } + + public void setAuto(boolean auto) { + this.auto = auto; + } + + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index 5920dd969f..ca96165119 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -1,129 +1,419 @@ package com.fr.van.chart.designer.component; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - +import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; +import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; +import javax.swing.JComponent; +import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; /** - * 内容界面 。数据点提示 + * 数据点提示内容界面,含有通用设置、富文本编辑器、自定义JS界面 */ public class VanChartTooltipContentPane extends BasicBeanPane { private static final long serialVersionUID = 8825929000117843641L; - protected UIButtonGroup content; - protected ValueFormatPaneWithCheckBox valueFormatPane; - protected PercentFormatPaneWithCheckBox percentFormatPane; - protected CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; - protected SeriesNameFormatPaneWithCheckBox seriesNameFormatPane; + private UIButtonGroup content; + + private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; + private SeriesNameFormatPaneWithCheckBox seriesNameFormatPane; + private ValueFormatPaneWithCheckBox valueFormatPane; + private PercentFormatPaneWithCheckBox percentFormatPane; //监控刷新时,自动数据点提示使用 - protected ChangedValueFormatPaneWithCheckBox changedValueFormatPane; - protected ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane; + private ChangedValueFormatPaneWithCheckBox changedValueFormatPane; + private ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane; - private JPanel centerPane; + private CategoryNameFormatPaneWithoutCheckBox richTextCategoryNameFormatPane; + private SeriesNameFormatPaneWithoutCheckBox richTextSeriesNameFormatPane; + private ValueFormatPaneWithoutCheckBox richTextValueFormatPane; + private PercentFormatPaneWithoutCheckBox richTextPercentFormatPane; + private ChangedValueFormatPaneWithoutCheckBox richTextChangedValueFormatPane; + private ChangedPercentFormatPaneWithoutCheckBox richTextChangedPercentFormatPane; + + private JPanel centerPanel; private JPanel commonPanel; + private JPanel editorPanel; + private JPanel htmlPanel; + private JPanel stylePanel; + private UIButtonGroup styleButton; + private ChartTextAttrPane textAttrPane; private VanChartHtmlLabelPane htmlLabelPane; private VanChartStylePane parent; private JPanel showOnPane; + private AttrTooltipRichText richText; + public VanChartTooltipContentPane(VanChartStylePane parent, JPanel showOnPane){ this.parent = parent; this.showOnPane = showOnPane; + this.richText = new AttrTooltipRichText(); + + initFormatPane(parent, showOnPane); + initRichTextFormatPane(parent, showOnPane); this.setLayout(new BorderLayout()); this.add(createLabelContentPane(),BorderLayout.CENTER); } + public CategoryNameFormatPaneWithCheckBox getCategoryNameFormatPane() { + return categoryNameFormatPane; + } + + public void setCategoryNameFormatPane(CategoryNameFormatPaneWithCheckBox categoryNameFormatPane) { + this.categoryNameFormatPane = categoryNameFormatPane; + } + + public SeriesNameFormatPaneWithCheckBox getSeriesNameFormatPane() { + return seriesNameFormatPane; + } + + public void setSeriesNameFormatPane(SeriesNameFormatPaneWithCheckBox seriesNameFormatPane) { + this.seriesNameFormatPane = seriesNameFormatPane; + } + + public ValueFormatPaneWithCheckBox getValueFormatPane() { + return valueFormatPane; + } + + public void setValueFormatPane(ValueFormatPaneWithCheckBox valueFormatPane) { + this.valueFormatPane = valueFormatPane; + } + + public PercentFormatPaneWithCheckBox getPercentFormatPane() { + return percentFormatPane; + } + + public void setPercentFormatPane(PercentFormatPaneWithCheckBox percentFormatPane) { + this.percentFormatPane = percentFormatPane; + } + + public ChangedValueFormatPaneWithCheckBox getChangedValueFormatPane() { + return changedValueFormatPane; + } + + public void setChangedValueFormatPane(ChangedValueFormatPaneWithCheckBox changedValueFormatPane) { + this.changedValueFormatPane = changedValueFormatPane; + } + + public ChangedPercentFormatPaneWithCheckBox getChangedPercentFormatPane() { + return changedPercentFormatPane; + } + + public void setChangedPercentFormatPane(ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane) { + this.changedPercentFormatPane = changedPercentFormatPane; + } + + public CategoryNameFormatPaneWithoutCheckBox getRichTextCategoryNameFormatPane() { + return richTextCategoryNameFormatPane; + } + + public void setRichTextCategoryNameFormatPane(CategoryNameFormatPaneWithoutCheckBox richTextCategoryNameFormatPane) { + this.richTextCategoryNameFormatPane = richTextCategoryNameFormatPane; + } + + public SeriesNameFormatPaneWithoutCheckBox getRichTextSeriesNameFormatPane() { + return richTextSeriesNameFormatPane; + } + + public void setRichTextSeriesNameFormatPane(SeriesNameFormatPaneWithoutCheckBox richTextSeriesNameFormatPane) { + this.richTextSeriesNameFormatPane = richTextSeriesNameFormatPane; + } + + public ValueFormatPaneWithoutCheckBox getRichTextValueFormatPane() { + return richTextValueFormatPane; + } + + public void setRichTextValueFormatPane(ValueFormatPaneWithoutCheckBox richTextValueFormatPane) { + this.richTextValueFormatPane = richTextValueFormatPane; + } + + public PercentFormatPaneWithoutCheckBox getRichTextPercentFormatPane() { + return richTextPercentFormatPane; + } + + public void setRichTextPercentFormatPane(PercentFormatPaneWithoutCheckBox richTextPercentFormatPane) { + this.richTextPercentFormatPane = richTextPercentFormatPane; + } + + public ChangedValueFormatPaneWithoutCheckBox getRichTextChangedValueFormatPane() { + return richTextChangedValueFormatPane; + } + + public void setRichTextChangedValueFormatPane(ChangedValueFormatPaneWithoutCheckBox richTextChangedValueFormatPane) { + this.richTextChangedValueFormatPane = richTextChangedValueFormatPane; + } + + public ChangedPercentFormatPaneWithoutCheckBox getRichTextChangedPercentFormatPane() { + return richTextChangedPercentFormatPane; + } + + public void setRichTextChangedPercentFormatPane(ChangedPercentFormatPaneWithoutCheckBox richTextChangedPercentFormatPane) { + this.richTextChangedPercentFormatPane = richTextChangedPercentFormatPane; + } + + public AttrTooltipRichText getRichTextAttr() { + return richText; + } + private JPanel createLabelContentPane() { - content = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + initDetailPane(); + initCenterPane(); - initFormatPane(parent, showOnPane); + JPanel content = new JPanel(new BorderLayout()); - double p = TableLayout.PREFERRED; - double f = TableLayout.FILL; - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + content.add(createButtonPane(), BorderLayout.NORTH); + content.add(centerPanel, BorderLayout.CENTER); + content.add(stylePanel, BorderLayout.SOUTH); - commonPanel = createCommonPanel(); - htmlLabelPane = createHtmlLabelPane(); - htmlLabelPane.setParent(parent); + initContentListener(); - centerPane = new JPanel(new CardLayout()){ - @Override + return getLabelContentPane(content); + } + + private void initDetailPane() { + commonPanel = createCommonFormatPanel(); + editorPanel = createRichEditorPanel(); + htmlPanel = createHtmlPane(); + stylePanel = createCommonStylePane(); + } + + private void initCenterPane() { + centerPanel = new JPanel(new CardLayout()) { public Dimension getPreferredSize() { - if(content.getSelectedIndex() == 0){ + if (content.getSelectedIndex() == 0) { return commonPanel.getPreferredSize(); + } else if (content.getSelectedIndex() == 1) { + return editorPanel.getPreferredSize(); } else { - return new Dimension(commonPanel.getPreferredSize().width,htmlLabelPane.getPreferredSize().height); + return htmlPanel.getPreferredSize(); } } }; - centerPane.add(htmlLabelPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); - centerPane.add(commonPanel,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); - double[] column = {f, e}; - double[] row = {p,p,p}; + centerPanel.add(commonPanel, Toolkit.i18nText("Fine-Design_Chart_Common")); + centerPanel.add(editorPanel, Toolkit.i18nText("Fine-Design_Chart_Rich_Text")); + centerPanel.add(htmlPanel, Toolkit.i18nText("Fine-Design_Chart_Custom")); + } + + protected String getLabelContentTitle() { + return Toolkit.i18nText("Fine-Design_Report_Text"); + } + + protected JPanel getLabelContentPane(JPanel contentPane) { + return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Content"), contentPane); + } + + private JPanel createButtonPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] column = {f, p}; + double[] row = {p, p}; + + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + Component[][] components = new Component[][]{ - new Component[]{null,null}, - new Component[]{new UILabel(getLabelContentTitle()),content}, - new Component[]{null,centerPane}, + new Component[]{null, null}, + new Component[]{content, null} }; - initContentListener(); - JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, column); - return getLabelContentPane(contentPane); + + return TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, column); } - protected String getLabelContentTitle () { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Text"); + protected JPanel createCommonFormatPanel() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + JPanel formatContent = TableLayoutHelper.createTableLayoutPane(getPaneComponents(), getRowSize(p), new double[]{f, p}); + + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(getLabelContentTitle()), formatContent} + }; + + return TableLayoutHelper.createTableLayoutPane(components, new double[]{p, p}, new double[]{f, e}); } - protected JPanel getLabelContentPane(JPanel contentPane) { - return createTableLayoutPaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content"), contentPane); + private JPanel createCommonStylePane() { + styleButton = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Automatic"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + + textAttrPane = new ChartTextAttrPane() { + protected Component[][] getComponents(JPanel buttonPane) { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{null, getFontNameComboBox()}, + new Component[]{null, buttonPane} + }; + } + }; + + JPanel buttonPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), styleButton); + + JPanel stylePanel = new JPanel(new BorderLayout()); + stylePanel.add(buttonPane, BorderLayout.CENTER); + stylePanel.add(textAttrPane, BorderLayout.SOUTH); + + initStyleButtonListener(); + + return stylePanel; } - protected VanChartHtmlLabelPane createHtmlLabelPane() { - return new VanChartHtmlLabelPaneWithOutWidthAndHeight(); + private void initStyleButtonListener() { + styleButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + checkStylePane(); + } + }); } - protected JPanel createCommonPanel() { + private void checkStylePane() { + textAttrPane.setVisible(styleButton.getSelectedIndex() == 1); + } + + private JPanel createRichEditorPanel() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; + double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; + + double[] columnSize = {f, e}; + double[] rowSize = {p, p, p}; + + JPanel formatContent = TableLayoutHelper.createTableLayoutPane(getRichTextComponents(), getRowSize(p), new double[]{f, p}); + + Component[][] components = new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Content_Style")), createRichEditorButton()}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Use_Format")), formatContent} + }; + + return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + } + + private JComponent createRichEditorButton() { + UIButton contentTextArea = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Rich_Text_Edit")); - double[] columnSize = {f, p}; - double[] rowSize = getRowSize(p); + contentTextArea.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + fireRichEditor(); + } + }); - return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize); + return contentTextArea; } - protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane){ + private void fireRichEditor() { + final ModernUIPane pane = VanChartRichEditorPane.createRichEditorPane(richText); + BasicDialog dialog = pane.showWindow(new JFrame()); + + pane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); + + dialog.addDialogActionListener(new DialogActionAdapter() { + + public void doOk() { + VanChartRichEditorPane.RichEditorModel model = pane.update(); + + String content = model.getContent(); + updateLocalRichText(content, model.isAuto()); + + SwingUtilities.getWindowAncestor(pane).setVisible(false); + } + + public void doCancel() { + SwingUtilities.getWindowAncestor(pane).setVisible(false); + } + }); + + dialog.setVisible(true); + + if (parent != null) { + parent.attributeChanged(); + } + } + + private JPanel createHtmlPane() { + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + + double[] column = {f, p}; + double[] row = {p, p}; + + htmlLabelPane = createHtmlLabelPane(); + htmlLabelPane.setParent(parent); + + Component[][] htmlComponents = new Component[][]{ + new Component[]{null, null}, + new Component[]{htmlLabelPane, null} + }; + + return TableLayout4VanChartHelper.createGapTableLayoutPane(htmlComponents, row, column); + } + + protected VanChartHtmlLabelPane createHtmlLabelPane() { + return new VanChartHtmlLabelPaneWithOutWidthAndHeight(); + } + + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); } + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + richTextCategoryNameFormatPane = new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane); + richTextSeriesNameFormatPane = new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane); + richTextValueFormatPane = new ValueFormatPaneWithoutCheckBox(parent, showOnPane); + richTextPercentFormatPane = new PercentFormatPaneWithoutCheckBox(parent, showOnPane); + } + protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); } @@ -132,12 +422,21 @@ public class VanChartTooltipContentPane extends BasicBeanPane paramMap, String value) { + String key = this.getCheckBoxText(); + + if (paramMap != null && !paramMap.containsKey(key)) { + paramMap.put(key, value); + } + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/VanChartFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/VanChartFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..35d475a555 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/VanChartFormatPaneWithoutCheckBox.java @@ -0,0 +1,16 @@ +package com.fr.van.chart.designer.component.format; + +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public abstract class VanChartFormatPaneWithoutCheckBox extends VanChartFormatPaneWithCheckBox { + + public VanChartFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected boolean showSelectBox() { + return false; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/XFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/XFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..da09d29dc2 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/XFormatPaneWithoutCheckBox.java @@ -0,0 +1,16 @@ +package com.fr.van.chart.designer.component.format; + +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public class XFormatPaneWithoutCheckBox extends VanChartFormatPaneWithoutCheckBox { + + public XFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return "x"; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/YFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/YFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..b5422dd507 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/YFormatPaneWithoutCheckBox.java @@ -0,0 +1,16 @@ +package com.fr.van.chart.designer.component.format; + +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public class YFormatPaneWithoutCheckBox extends VanChartFormatPaneWithoutCheckBox { + + public YFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return "y"; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java index 94506858e1..6459ef480b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java @@ -1,7 +1,8 @@ package com.fr.van.chart.designer.component.label; -import com.fr.van.chart.designer.component.VanChartLabelContentPane; +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -9,18 +10,21 @@ import javax.swing.JPanel; /** * Created by mengao on 2017/8/13. */ -public class GaugeLabelContentPane extends VanChartLabelContentPane { +public class GaugeLabelContentPane extends VanChartLabelContentPaneWithoutRichText { public GaugeLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { super(parent, showOnPane); } protected String getLabelContentTitle() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Content"); + return Toolkit.i18nText("Fine-Design_Chart_Content"); } protected JPanel getLabelContentPane(JPanel contentPane) { return contentPane; } + protected boolean hasTextStylePane() { + return false; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCate.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCate.java index 982b0a3a7e..23133813c7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCate.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCate.java @@ -27,7 +27,7 @@ public class LabelContentPaneWithCate extends GaugeLabelContentPane { protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, + new Component[]{getCategoryNameFormatPane(),null}, }; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCateValue.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCateValue.java index 1d2bbf5e49..4b8f8013df 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCateValue.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithCateValue.java @@ -27,8 +27,8 @@ public class LabelContentPaneWithCateValue extends GaugeLabelContentPane { protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{valueFormatPane,null}, + new Component[]{getCategoryNameFormatPane(),null}, + new Component[]{getValueFormatPane(),null}, }; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithOutCate.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithOutCate.java index 45bcb3b83a..821fa1d722 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithOutCate.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithOutCate.java @@ -27,9 +27,9 @@ public class LabelContentPaneWithOutCate extends GaugeLabelContentPane { protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{seriesNameFormatPane, null}, - new Component[]{valueFormatPane, null}, - new Component[]{percentFormatPane, null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, }; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithPercent.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithPercent.java index 0efbb9bb92..0c73f25e18 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithPercent.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/LabelContentPaneWithPercent.java @@ -26,7 +26,7 @@ public class LabelContentPaneWithPercent extends GaugeLabelContentPane { protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{percentFormatPane, null}, + new Component[]{getPercentFormatPane(), null}, }; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java index 1774888ba5..309bf244a0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java @@ -1,7 +1,9 @@ package com.fr.van.chart.designer.component.tooltip; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -19,8 +21,16 @@ public class RefreshTooltipContentPaneWithOutSeries extends TooltipContentPaneWi protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); - changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane)); + setChangedPercentFormatPane(new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + setRichTextChangedValueFormatPane(new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextChangedPercentFormatPane(new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected double[] getRowSize(double p){ @@ -29,11 +39,21 @@ public class RefreshTooltipContentPaneWithOutSeries extends TooltipContentPaneWi protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{changedValueFormatPane,null}, - new Component[]{percentFormatPane,null}, - new Component[]{changedPercentFormatPane,null}, + new Component[]{getCategoryNameFormatPane(),null}, + new Component[]{getValueFormatPane(),null}, + new Component[]{getChangedValueFormatPane(),null}, + new Component[]{getPercentFormatPane(),null}, + new Component[]{getChangedPercentFormatPane(),null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextChangedValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} }; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java index 61216a57fd..25e0808102 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java @@ -23,9 +23,17 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{percentFormatPane,null}, + new Component[]{getCategoryNameFormatPane(),null}, + new Component[]{getValueFormatPane(),null}, + new Component[]{getPercentFormatPane(),null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null} }; } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java index 69e2357a98..d5f866c818 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/component/VanChartAxisButtonPane.java @@ -8,7 +8,6 @@ import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; - import com.fr.plugin.chart.VanChartAttrHelper; import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; @@ -18,6 +17,8 @@ import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.Icon; import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; @@ -29,8 +30,6 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.List; /** * 坐标轴-上方按钮界面 @@ -41,9 +40,12 @@ public class VanChartAxisButtonPane extends BasicBeanPane { private static final int B_W = 56; private static final int B_H = 21; private static final int COL_COUNT = 3; + private static final int MAX_COUNT = 20; private UIButton addButton; private UIPopupMenu popupMenu; + private UIMenuItem itemX; + private UIMenuItem itemY; private List indexList_X = new ArrayList(); private List indexList_Y = new ArrayList(); @@ -51,7 +53,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane { private VanChartAxisPane parent; - public VanChartAxisButtonPane(VanChartAxisPane vanChartAxisPane){ + public VanChartAxisButtonPane(VanChartAxisPane vanChartAxisPane) { this.parent = vanChartAxisPane; this.setLayout(new BorderLayout()); @@ -66,6 +68,20 @@ public class VanChartAxisButtonPane extends BasicBeanPane { buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 10, 0)); this.add(buttonPane, BorderLayout.CENTER); + itemX = new UIMenuItem(VanChartAttrHelper.X_AXIS_PREFIX); + itemX.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addXAxis(); + } + }); + itemY = new UIMenuItem(VanChartAttrHelper.Y_AXIS_PREFIX); + itemY.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addYAxis(); + } + }); addButton.addActionListener(addListener); } @@ -92,12 +108,12 @@ public class VanChartAxisButtonPane extends BasicBeanPane { pane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); buttonPane.add(pane); } - if(pane != null) { + if (pane != null) { pane.add(indexList_Y.get(i)); } } - if(popupMenu != null){ + if (popupMenu != null) { popupMenu.setVisible(false); } @@ -114,19 +130,19 @@ public class VanChartAxisButtonPane extends BasicBeanPane { indexList_X.clear(); indexList_Y.clear(); List xList = plot.getXAxisList(); - for(VanChartAxis axis : xList){ + for (VanChartAxis axis : xList) { ChartAxisButton x = new ChartAxisButton(plot.getXAxisName(axis)); x.setToolTipText(plot.getXAxisName(axis)); indexList_X.add(x); } List yList = plot.getYAxisList(); - for(VanChartAxis axis : yList){ + for (VanChartAxis axis : yList) { ChartAxisButton y = new ChartAxisButton(plot.getYAxisName(axis)); y.setToolTipText(plot.getYAxisName(axis)); indexList_Y.add(y); } - if(indexList_X.isEmpty()){ + if (indexList_X.isEmpty()) { this.removeAll(); } else { indexList_X.get(0).setSelected(true); @@ -143,7 +159,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane { return null; } - public String getNewChartName(List existList, String prefix){ + public String getNewChartName(List existList, String prefix) { int count = existList.size() + 1; while (true) { String name_test = prefix + count; @@ -165,31 +181,19 @@ public class VanChartAxisButtonPane extends BasicBeanPane { ActionListener addListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if(popupMenu == null){ - popupMenu = new UIPopupMenu(); - UIMenuItem item_x = new UIMenuItem(VanChartAttrHelper.X_AXIS_PREFIX); - item_x.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - addXAxis(); - } - }); - UIMenuItem item_y = new UIMenuItem(VanChartAttrHelper.Y_AXIS_PREFIX); - item_y.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - addYAxis(); - } - }); - popupMenu.add(item_x); - popupMenu.add(item_y); + popupMenu = new UIPopupMenu(); + if (indexList_X.size() < MAX_COUNT) { + popupMenu.add(itemX); + } + if (indexList_Y.size() < MAX_COUNT) { + popupMenu.add(itemY); } popupMenu.setVisible(true); GUICoreUtils.showPopupMenu(popupMenu, addButton, addButton.getWidth() - popupMenu.getPreferredSize().width, addButton.getY() - 1 + addButton.getHeight()); } }; - private void addXAxis(){ + private void addXAxis() { String name = getNewChartName(indexList_X, VanChartAttrHelper.X_AXIS_PREFIX); ChartAxisButton button = new ChartAxisButton(name); @@ -199,7 +203,7 @@ public class VanChartAxisButtonPane extends BasicBeanPane { layoutPane(); } - private void addYAxis(){ + private void addYAxis() { String name = getNewChartName(indexList_Y, VanChartAttrHelper.Y_AXIS_PREFIX); ChartAxisButton button = new ChartAxisButton(name); @@ -216,9 +220,10 @@ public class VanChartAxisButtonPane extends BasicBeanPane { private class AddButton extends UIButton { - public AddButton(Icon icon){ + public AddButton(Icon icon) { super(icon); } + /** * 组件是否需要响应添加的观察者事件 * @@ -277,19 +282,19 @@ public class VanChartAxisButtonPane extends BasicBeanPane { } private void noSelected() { - for(ChartAxisButton button : indexList_X){ + for (ChartAxisButton button : indexList_X) { button.setSelected(false); } - for(ChartAxisButton button : indexList_Y){ + for (ChartAxisButton button : indexList_Y) { button.setSelected(false); } } private void checkMoveOn(boolean moveOn) { - for(ChartAxisButton button : indexList_X){ + for (ChartAxisButton button : indexList_X) { button.isMoveOn = false; } - for(ChartAxisButton button : indexList_Y){ + for (ChartAxisButton button : indexList_Y) { button.isMoveOn = false; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java index 64187f89b9..9a5c453828 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeCateOrPercentLabelDetailPane.java @@ -22,7 +22,7 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe } protected double[] getLabelPaneRowSize(Plot plot, double p) { - if (hasLabelAlign(plot)) { + if (hasLabelAlignPane()) { return new double[]{p, p, p, p}; } @@ -37,10 +37,10 @@ public class VanChartGaugeCateOrPercentLabelDetailPane extends VanChartGaugeLabe switch (getGaugeStyle()) { case POINTER: case POINTER_SEMI: - dataLabelContentPane = new LabelContentPaneWithCate(parent, VanChartGaugeCateOrPercentLabelDetailPane.this); + setDataLabelContentPane(new LabelContentPaneWithCate(getParentPane(), VanChartGaugeCateOrPercentLabelDetailPane.this)); break; default: - dataLabelContentPane = new LabelContentPaneWithPercent(parent, VanChartGaugeCateOrPercentLabelDetailPane.this); + setDataLabelContentPane(new LabelContentPaneWithPercent(getParentPane(), VanChartGaugeCateOrPercentLabelDetailPane.this)); break; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java index bbdb6acb3d..665fdc2565 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeLabelDetailPane.java @@ -24,6 +24,8 @@ import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; /** * Created by mengao on 2017/8/13. @@ -35,6 +37,8 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { private UIButtonGroup align; private JPanel alignPane; private Integer[] oldAlignValues; + private UIButtonGroup style; + private ChartTextAttrPane textFontPane; public VanChartGaugeLabelDetailPane(Plot plot, VanChartStylePane parent) { super(plot, parent); @@ -63,6 +67,15 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return TableLayoutHelper.createTableLayoutPane(getLabelStyleComponents(plot), row, col); } + protected void initStyleListener() { + style.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + checkStyleUse(); + } + }); + } + protected boolean isFontSizeAuto() { return false; } @@ -101,8 +114,9 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { }; } - protected JPanel getLabelPositionPane(Component[][] comps, double[] row, double[] col) { - return TableLayoutHelper.createTableLayoutPane(comps, row, col); + // 仪表盘标签内无布局tab + protected JPanel getLabelLayoutPane(JPanel panel, String title) { + return panel; } protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { @@ -110,17 +124,20 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { } protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { - if (hasLabelAlign(plot)) { + if (hasLabelAlignPane()) { return new Component[][]{ - new Component[]{dataLabelContentPane, null}, + new Component[]{getDataLabelContentPane(), null}, new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Vertical"), plot), null}, new Component[]{createLabelAlignPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Horizontal")), null}, new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null}, }; } else { - return super.getLabelPaneComponents(plot, p, columnSize); + return new Component[][]{ + new Component[]{getDataLabelContentPane(), null}, + new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot), null}, + }; } } @@ -170,8 +187,8 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { alignPane.setLayout(new BorderLayout()); alignPane.add(getLabelPositionPane(comps, row, col), BorderLayout.CENTER); - if (parent != null) { - parent.initListener(alignPane); + if (getParentPane() != null) { + getParentPane().initListener(alignPane); } } @@ -206,19 +223,29 @@ public class VanChartGaugeLabelDetailPane extends VanChartPlotLabelDetailPane { return getGaugeStyle() == GaugeStyle.THERMOMETER && !((VanChartGaugePlot) plot).getGaugeDetailStyle().isHorizontalLayout(); } + protected boolean hasLabelAlignPane() { + return getGaugeStyle() == GaugeStyle.THERMOMETER; + } + public void populate(AttrLabelDetail detail) { super.populate(detail); style.setSelectedIndex(1); + textFontPane.populate(detail.getTextAttr()); if (hasLabelAlign(this.getPlot()) && align != null) { align.setSelectedItem(detail.getAlign()); } + + checkStyleUse(); } public void update(AttrLabelDetail detail) { super.update(detail); detail.setCustom(true); + if (textFontPane != null) { + detail.setTextAttr(textFontPane.update()); + } if (align != null) { if (align.getSelectedItem() != null) { detail.setAlign(align.getSelectedItem()); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java index 0f81deefca..9bc21a0446 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugePlotLabelPane.java @@ -1,13 +1,15 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; - +import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.attr.GaugeDetailStyle; import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.AttrLabelDetail; import com.fr.plugin.chart.gauge.VanChartGaugePlot; import com.fr.plugin.chart.type.GaugeStyle; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.design.i18n.Toolkit; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -18,6 +20,9 @@ import java.awt.BorderLayout; public class VanChartGaugePlotLabelPane extends VanChartPlotLabelPane { private static final long serialVersionUID = -322148616244458359L; + private UIButtonGroup orientation; + private JPanel layoutPane; + private VanChartPlotLabelDetailPane gaugeValueLabelPane; public VanChartGaugePlotLabelPane(Plot plot, VanChartStylePane parent) { @@ -25,10 +30,10 @@ public class VanChartGaugePlotLabelPane extends VanChartPlotLabelPane { } protected void createLabelPane() { - labelPane = new JPanel(new BorderLayout(0, 4)); - labelDetailPane = new VanChartGaugeCateOrPercentLabelDetailPane(this.plot, this.parent); - gaugeValueLabelPane = new VanChartGaugeValueLabelDetailPane(this.plot, this.parent); - GaugeStyle gaugeStyle = ((VanChartGaugePlot)this.plot).getGaugeStyle(); + setLabelPane(new JPanel(new BorderLayout(0, 4))); + setLabelDetailPane(new VanChartGaugeCateOrPercentLabelDetailPane(getPlot(), getParentPane())); + gaugeValueLabelPane = new VanChartGaugeValueLabelDetailPane(getPlot(), getParentPane()); + GaugeStyle gaugeStyle = ((VanChartGaugePlot)getPlot()).getGaugeStyle(); String cateTitle, valueTitle = Toolkit.i18nText("Fine-Design_Chart_Value_Label"); switch (gaugeStyle){ case POINTER: @@ -39,25 +44,67 @@ public class VanChartGaugePlotLabelPane extends VanChartPlotLabelPane { cateTitle = Toolkit.i18nText("Fine-Design_Chart_Percent_Label"); break; } - JPanel cateOrPercentPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(cateTitle, labelDetailPane); + JPanel cateOrPercentPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(cateTitle, getLabelDetailPane()); JPanel valuePane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(valueTitle, gaugeValueLabelPane); - labelPane.add(cateOrPercentPane, BorderLayout.NORTH); - labelPane.add(valuePane, BorderLayout.SOUTH); + + layoutPane = createGaugeLabelLayoutPane(); + + getLabelPane().add(cateOrPercentPane, BorderLayout.NORTH); + getLabelPane().add(valuePane, BorderLayout.CENTER); + getLabelPane().add(layoutPane, BorderLayout.SOUTH); + + checkLayoutPaneVisible(); + } + + private void checkLayoutPaneVisible() { + layoutPane.setVisible(showLayoutPane()); + } + + private boolean showLayoutPane() { + VanChartGaugePlot plot = (VanChartGaugePlot) this.getPlot(); + GaugeDetailStyle gaugeDetailStyle = plot.getGaugeDetailStyle(); + + return plot.getGaugeStyle() == GaugeStyle.THERMOMETER && gaugeDetailStyle != null && gaugeDetailStyle.isHorizontalLayout(); + } + + // 试管仪表盘横行布局时,正常标签外增加布局tab,同时控制百分比和值标签的文本方向 + private JPanel createGaugeLabelLayoutPane() { + orientation = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), + Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), + }); + + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Text_Orientation"), orientation); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); } public void populate(AttrLabel attr) { super.populate(attr); if(gaugeValueLabelPane != null && attr != null){ - gaugeValueLabelPane.populate(attr.getGaugeValueLabelDetail()); + AttrLabelDetail labelDetail = attr.getGaugeValueLabelDetail(); + gaugeValueLabelPane.populate(labelDetail); + orientation.setSelectedIndex(labelDetail.isHorizontal() ? 0 : 1); + + checkLayoutPaneVisible(); } } public AttrLabel update() { AttrLabel attrLabel = super.update(); + if(gaugeValueLabelPane != null && attrLabel != null){ - gaugeValueLabelPane.update(attrLabel.getGaugeValueLabelDetail()); + AttrLabelDetail defaultLabelDetail = attrLabel.getAttrLabelDetail(); + AttrLabelDetail valueLabelDetail = attrLabel.getGaugeValueLabelDetail(); + + gaugeValueLabelPane.update(valueLabelDetail); + + boolean horizontal = orientation.getSelectedIndex() == 0; + defaultLabelDetail.setHorizontal(horizontal); + valueLabelDetail.setHorizontal(horizontal); } + return attrLabel; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java index 01a21d3823..be528c9733 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartGaugeValueLabelDetailPane.java @@ -24,10 +24,10 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP switch (getGaugeStyle()) { case POINTER: case POINTER_SEMI: - dataLabelContentPane = new LabelContentPaneWithOutCate(parent, VanChartGaugeValueLabelDetailPane.this); + setDataLabelContentPane(new LabelContentPaneWithOutCate(getParentPane(), VanChartGaugeValueLabelDetailPane.this)); break; default: - dataLabelContentPane = new LabelContentPaneWithCateValue(parent, VanChartGaugeValueLabelDetailPane.this); + setDataLabelContentPane(new LabelContentPaneWithCateValue(getParentPane(), VanChartGaugeValueLabelDetailPane.this)); break; } } @@ -44,7 +44,7 @@ public class VanChartGaugeValueLabelDetailPane extends VanChartGaugeLabelDetailP private Component[][] getLabelPaneComponentsWithBackground(Plot plot, double p, double[] columnSize) { return new Component[][]{ - new Component[]{dataLabelContentPane, null}, + new Component[]{getDataLabelContentPane(), null}, new Component[]{createLabelStylePane(new double[]{p}, columnSize, plot), null}, new Component[]{createBackgroundColorPane(), null}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index c506d89ea1..22f8ace786 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -7,12 +7,11 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.style.color.ColorSelectBox; -import com.fr.design.i18n.Toolkit; - import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.attr.plot.VanChartLabelPositionPlot; import com.fr.plugin.chart.base.AttrLabelDetail; @@ -20,6 +19,8 @@ import com.fr.plugin.chart.base.AttrTooltipContent; 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.background.VanChartBackgroundWithOutImagePane; +import com.fr.van.chart.designer.component.border.VanChartBorderWithShapePane; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -28,9 +29,6 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** * Created by Mitisky on 15/12/7. @@ -38,22 +36,22 @@ import java.awt.event.ActionListener; public class VanChartPlotLabelDetailPane extends BasicPane { private static final long serialVersionUID = -22438250307946275L; - protected BasicBeanPane dataLabelContentPane; + private BasicBeanPane dataLabelContentPane; - protected UIButtonGroup position; - protected UIButtonGroup autoAdjust; - protected UIToggleButton tractionLine; + private UIButtonGroup position; + private UIButtonGroup autoAdjust; + private UIButtonGroup orientation; + private UIToggleButton tractionLine; - protected UIButtonGroup style; - protected ChartTextAttrPane textFontPane; - - protected ColorSelectBox backgroundColor; + private ColorSelectBox backgroundColor; + private VanChartBorderWithShapePane borderPane; + private VanChartBackgroundWithOutImagePane backgroundPane; private JPanel tractionLinePane; private JPanel positionPane; private Integer[] oldPositionValues; - protected VanChartStylePane parent; + private VanChartStylePane parent; private Plot plot; public VanChartPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { @@ -62,6 +60,18 @@ public class VanChartPlotLabelDetailPane extends BasicPane { initLabelDetailPane(plot); } + public BasicBeanPane getDataLabelContentPane() { + return dataLabelContentPane; + } + + public void setDataLabelContentPane(BasicBeanPane dataLabelContentPane) { + this.dataLabelContentPane = dataLabelContentPane; + } + + public VanChartStylePane getParentPane() { + return parent; + } + protected void initLabelDetailPane (Plot plot) { this.setLayout(new BorderLayout()); initToolTipContentPane(plot); @@ -91,17 +101,48 @@ public class VanChartPlotLabelDetailPane extends BasicPane { protected Component[][] getLabelPaneComponents(Plot plot, double p, double[] columnSize) { if(hasLabelPosition(plot)){ + + // 仅饼图、柱形图、条形图、折线图、面积图含有边框和背景 + if (hasBorderAndBackground(plot)) { + return new Component[][]{ + new Component[]{dataLabelContentPane,null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, + new Component[]{createLabelBorderPane(), null}, + new Component[]{createLabelBackgroundPane(), null} + }; + } + return new Component[][]{ new Component[]{dataLabelContentPane,null}, - new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null}, - new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot),null}, - }; - } else { - return new Component[][]{ - new Component[]{dataLabelContentPane,null}, - new Component[]{createLabelStylePane(getLabelStyleRowSize(p), columnSize, plot),null}, + new Component[]{createLabelPositionPane(Toolkit.i18nText("Fine-Design_Chart_Layout_Position"), plot), null} }; } + + return new Component[][]{ + new Component[]{dataLabelContentPane,null} + }; + } + + private JPanel createLabelBorderPane() { + borderPane = new VanChartBorderWithShapePane(); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); + } + + private JPanel createLabelBackgroundPane() { + backgroundPane = new VanChartBackgroundWithOutImagePane(){ + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{null, null}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Fill")), typeComboBox}, + new Component[]{null, centerPane}, + new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Alpha")), transparent}, + }; + } + }; + + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane); } protected double[] getLabelStyleRowSize(double p) { @@ -116,6 +157,10 @@ public class VanChartPlotLabelDetailPane extends BasicPane { return plot instanceof VanChartLabelPositionPlot; } + private boolean hasBorderAndBackground(Plot plot) { + return PlotFactory.hasBorderAndBackgroundPlotLabel(plot); + } + protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); } @@ -150,8 +195,11 @@ public class VanChartPlotLabelDetailPane extends BasicPane { positionPane = new JPanel(); checkPositionPane(title); - panel.add(positionPane, BorderLayout.CENTER); + panel.add(positionPane, BorderLayout.NORTH); + if (hasLabelOrientationPane()) { + panel.add(createLabelOrientationPane(), BorderLayout.CENTER); + } if (plot.isSupportLeadLine()) { tractionLine = new UIToggleButton(Toolkit.i18nText("Fine-Design_Chart_Show_Guideline")); @@ -161,7 +209,25 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } else if (PlotFactory.plotAutoAdjustLabelPosition(plot)) { panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Auto_Adjust"), autoAdjust), BorderLayout.SOUTH); } - return panel; + + return getLabelLayoutPane(panel, Toolkit.i18nText("Fine-Design_Form_Attr_Layout")); + } + + protected JPanel getLabelLayoutPane(JPanel panel, String title) { + return createTableLayoutPaneWithTitle(title, panel); + } + + protected boolean hasLabelOrientationPane() { + return false; + } + + private JPanel createLabelOrientationPane() { + orientation = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), + Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), + }); + + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Text_Orientation"), orientation); } protected void checkPositionPane(String title) { @@ -198,13 +264,10 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } } - protected JPanel getLabelPositionPane (Component[][] comps, double[] row, double[] col){ - JPanel panel = TableLayoutHelper.createTableLayoutPane(comps,row,col); - return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Form_Attr_Layout"), panel); + return TableLayoutHelper.createTableLayoutPane(comps, row, col); } - protected void initPositionListener() { position.addChangeListener(new ChangeListener() { @Override @@ -214,17 +277,6 @@ public class VanChartPlotLabelDetailPane extends BasicPane { }); } - protected JPanel createLabelStylePane(double[] row, double[] col, Plot plot) { - style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"), - Toolkit.i18nText("Fine-Design_Chart_Custom")}); - textFontPane =initTextFontPane(); - - initStyleListener(); - - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(getLabelStyleComponents(plot),row,col); - return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel); - } - protected ChartTextAttrPane initTextFontPane () { return new ChartTextAttrPane(){ protected Component[][] getComponents(JPanel buttonPane) { @@ -237,24 +289,6 @@ public class VanChartPlotLabelDetailPane extends BasicPane { }; } - protected Component[][] getLabelStyleComponents(Plot plot) { - UILabel text = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Character"), SwingConstants.LEFT); - return new Component[][]{ - new Component[]{null,null}, - new Component[]{text,style}, - new Component[]{textFontPane,null}, - }; - } - - protected void initStyleListener() { - style.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkStyleUse(); - } - }); - } - protected JPanel createBackgroundColorPane() { backgroundColor = new ColorSelectBox(100); return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundColor); @@ -265,18 +299,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } private void checkAllUse() { - checkStyleUse(); if(tractionLine == null){ return; } checkPositionEnabled(); } - protected void checkStyleUse() { - textFontPane.setVisible(style.getSelectedIndex() == 1); - textFontPane.setPreferredSize(style.getSelectedIndex() == 1 ? new Dimension(0, 60) : new Dimension(0, 0)); - } - private void checkPosition() { tractionLine.setSelected(position.getSelectedItem() == Constants.OUTSIDE); checkPositionEnabled(); @@ -295,18 +323,25 @@ public class VanChartPlotLabelDetailPane extends BasicPane { if(position != null){ position.setSelectedItem(detail.getPosition()); } + if(orientation != null){ + orientation.setSelectedIndex(detail.isHorizontal() ? 0 : 1); + } if(tractionLine != null){ tractionLine.setSelected(detail.isShowGuidLine()); } if(autoAdjust != null){ - autoAdjust.setSelectedIndex(detail.isAutoAdjust() == true ? 0 : 1); + autoAdjust.setSelectedIndex(detail.isAutoAdjust() ? 0 : 1); } - style.setSelectedIndex(detail.isCustom() ? 1 : 0); - textFontPane.populate(detail.getTextAttr()); if(backgroundColor != null){ backgroundColor.setSelectObject(detail.getBackgroundColor()); } + if(borderPane != null){ + borderPane.populate(detail.getBorder()); + } + if(backgroundPane != null){ + backgroundPane.populate(detail.getBackground()); + } checkAllUse(); } @@ -324,16 +359,21 @@ public class VanChartPlotLabelDetailPane extends BasicPane { detail.setAutoAdjust(autoAdjust != null && autoAdjust.getSelectedItem()); + if(orientation != null){ + detail.setHorizontal(orientation.getSelectedIndex() == 0); + } if(tractionLine != null){ detail.setShowGuidLine(tractionLine.isSelected() && detail.getPosition() == Constants.OUTSIDE); } - detail.setCustom(style.getSelectedIndex() == 1); - if(textFontPane != null){ - detail.setTextAttr(textFontPane.update()); - } if(backgroundColor != null){ detail.setBackgroundColor(backgroundColor.getSelectObject()); } + if(borderPane != null){ + borderPane.update(detail.getBorder()); + } + if(backgroundPane != null){ + backgroundPane.update(detail.getBackground()); + } } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelNoCheckPane.java index 95eb30204f..beb89e5d78 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelNoCheckPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelNoCheckPane.java @@ -19,12 +19,12 @@ public class VanChartPlotLabelNoCheckPane extends VanChartPlotLabelPane { protected void addComponents() { this.setLayout(new BorderLayout()); - this.add(labelPane,BorderLayout.CENTER); + this.add(getLabelPane(),BorderLayout.CENTER); } public void populate(AttrLabel attr) { super.populate(attr); - isLabelShow.setSelected(true); - labelPane.setVisible(true); + getLabelShowCheckBox().setSelected(true); + getLabelPane().setVisible(true); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java index e0a007dd25..f1fa6f0f1a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelPane.java @@ -3,6 +3,7 @@ package com.fr.van.chart.designer.style.label; import com.fr.chart.chartattr.Plot; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -19,24 +20,52 @@ import java.awt.event.ActionListener; public class VanChartPlotLabelPane extends BasicPane { private static final long serialVersionUID = -1701936672446232396L; - protected UICheckBox isLabelShow; + private UICheckBox isLabelShow; - protected VanChartPlotLabelDetailPane labelDetailPane; + private VanChartPlotLabelDetailPane labelDetailPane; - protected VanChartStylePane parent; - protected Plot plot; + private VanChartStylePane parent; + private Plot plot; - protected JPanel labelPane; + private JPanel labelPane; public VanChartPlotLabelPane(Plot plot, VanChartStylePane parent) { this.parent = parent; this.plot = plot; - isLabelShow = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Label")); + isLabelShow = new UICheckBox(Toolkit.i18nText("Fine-Design_Chart_Use_Label")); labelPane = new JPanel(new BorderLayout(0, 4)); createLabelPane(); addComponents(); } + public UICheckBox getLabelShowCheckBox() { + return isLabelShow; + } + + public VanChartPlotLabelDetailPane getLabelDetailPane() { + return labelDetailPane; + } + + public void setLabelDetailPane(VanChartPlotLabelDetailPane labelDetailPane) { + this.labelDetailPane = labelDetailPane; + } + + public VanChartStylePane getParentPane() { + return parent; + } + + public Plot getPlot() { + return plot; + } + + public JPanel getLabelPane() { + return labelPane; + } + + public void setLabelPane(JPanel labelPane) { + this.labelPane = labelPane; + } + protected void createLabelPane() { labelDetailPane = new VanChartPlotLabelDetailPane(this.plot, this.parent); labelPane.add(labelDetailPane, BorderLayout.CENTER); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotRefreshTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotRefreshTooltipPane.java index ade1d85bdb..0f71c9de69 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotRefreshTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotRefreshTooltipPane.java @@ -72,7 +72,6 @@ public class VanChartPlotRefreshTooltipPane extends VanChartPlotTooltipNoCheckPa Component[][] components = new Component[][]{ new Component[]{refreshTooltipContentPane,null}, new Component[]{initDurationPane(),null}, - new Component[]{createLabelStylePane(),null}, new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java index 1c3ed4aa53..aa86fb9a73 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/tooltip/VanChartPlotTooltipPane.java @@ -7,8 +7,6 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; -import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; - import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.widget.FRWidgetFactory; import com.fr.plugin.chart.base.AttrTooltip; @@ -28,13 +26,11 @@ import java.awt.event.ActionListener; public class VanChartPlotTooltipPane extends BasicPane { private static final long serialVersionUID = 6087381131907589370L; + // todo 使用private protected UICheckBox isTooltipShow; protected VanChartTooltipContentPane tooltipContentPane; - protected UIButtonGroup style; - protected ChartTextAttrPane textFontPane; - protected VanChartBorderWithRadiusPane borderPane; protected VanChartBackgroundWithOutImagePane backgroundPane; @@ -95,7 +91,6 @@ public class VanChartPlotTooltipPane extends BasicPane { protected Component[][] createComponents(Plot plot) { Component[][] components = new Component[][]{ new Component[]{tooltipContentPane,null}, - new Component[]{createLabelStylePane(),null}, new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"),borderPane),null}, new Component[]{TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane),null}, new Component[]{createDisplayStrategy(plot),null}, @@ -108,38 +103,6 @@ public class VanChartPlotTooltipPane extends BasicPane { tooltipContentPane = PlotFactory.createPlotTooltipContentPane(plot, parent, VanChartPlotTooltipPane.this); } - protected JPanel createLabelStylePane() { - style = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Automatic"),Toolkit.i18nText("Fine-Design_Chart_Custom")}); - textFontPane = new ChartTextAttrPane() { - protected Component[][] getComponents(JPanel buttonPane) { - return new Component[][]{ - new Component[]{null, null}, - new Component[]{null, getFontNameComboBox()}, - new Component[]{null, buttonPane} - }; - } - }; - - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Character"), style); - JPanel panel1 = new JPanel(new BorderLayout()); - panel1.add(panel, BorderLayout.CENTER); - panel1.add(textFontPane, BorderLayout.SOUTH); - - initStyleListener(); - - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), panel1); - } - - - private void initStyleListener() { - style.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkStyleUse(); - } - }); - } - protected JPanel createDisplayStrategy(Plot plot) { showAllSeries = new UICheckBox(getShowAllSeriesLabelText()); followMouse = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Follow_Mouse"), @@ -175,7 +138,6 @@ public class VanChartPlotTooltipPane extends BasicPane { private void checkAllUse() { checkBoxUse(); - checkStyleUse(); } /** * 检查box使用. @@ -184,10 +146,6 @@ public class VanChartPlotTooltipPane extends BasicPane { tooltipPane.setVisible(isTooltipShow.isSelected()); } - private void checkStyleUse() { - textFontPane.setVisible(style.getSelectedIndex() == 1); - } - protected AttrTooltip getAttrTooltip() { return new AttrTooltip(); } @@ -202,8 +160,6 @@ public class VanChartPlotTooltipPane extends BasicPane { tooltipContentPane.populateBean(attr.getContent()); } - style.setSelectedIndex(attr.isCustom() ? 1 : 0); - textFontPane.populate(attr.getTextAttr()); borderPane.populate(attr.getGeneralInfo()); backgroundPane.populate(attr.getGeneralInfo()); if(showAllSeries != null) { @@ -224,10 +180,6 @@ public class VanChartPlotTooltipPane extends BasicPane { attrTooltip.setContent(tooltipContentPane.updateBean()); } - attrTooltip.setCustom(style.getSelectedIndex() == 1); - if(textFontPane != null){ - attrTooltip.setTextAttr(textFontPane.update()); - } borderPane.update(attrTooltip.getGeneralInfo()); backgroundPane.update(attrTooltip.getGeneralInfo()); if(showAllSeries != null) { 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 a4b53796fd..9cf9165547 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 @@ -1,10 +1,13 @@ package com.fr.van.chart.designer.type; import com.fr.base.BaseUtils; +import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.base.AttrFillStyle; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Legend; import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.chart.chartdata.NormalTableDataDefinition; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.chartglyph.DataSheet; @@ -167,6 +170,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane children = parent.children(); - if (children.hasMoreElements()){ + if (children.hasMoreElements()) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) children.nextElement(); selectTreeNode(node, m_model); } } - public void changeRootNode(TreeNode node){ + public void changeRootNode(TreeNode node) { DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); m_model.setRoot(node); } public String getSelectNodeJSONPath() { - if(this.getLastSelectedPathComponent() == null){ + if (this.getLastSelectedPathComponent() == null) { return StringUtils.EMPTY; } - DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode)this.getLastSelectedPathComponent(); + DefaultMutableTreeNode currentSel = (DefaultMutableTreeNode) this.getLastSelectedPathComponent(); return CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(currentSel.getUserObject().toString()); } //根据路径精确查找 public DefaultMutableTreeNode setSelectNodePath(String jsonUrl) { - if(StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)){ + if (StringUtils.isEmpty(jsonUrl) || CompatibleGEOJSONHelper.isDeprecated(jsonUrl)) { return null; } DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot(); Enumeration els = root.postorderEnumeration(); - while(els.hasMoreElements()){ + while (els.hasMoreElements()) { DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement(); - if(el == null || el.getUserObject() == null){ + if (el == null || el.getUserObject() == null) { return null; } String dirPath = el.getUserObject().toString(); - String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath); + String url = CompatibleGEOJSONHelper.getJsonUrlByPathIncludeParam(dirPath); //先equals再valid原因:valid 远程下实时去服务器看有没有json文件 if (ComparatorUtils.equals(jsonUrl, url) && GEOJSONTreeHelper.isValidDirPath(dirPath)) { selectTreeNode(el, m_model); @@ -115,14 +114,7 @@ public class MapDataTree extends JTree { DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) value; String name = getPresentName(treeNode); this.setText(name); - - UILabel label = new UILabel(); - label.setText(getText()); - label.setIcon(getIcon()); - this.setSize(label.getPreferredSize()); - Dimension dim = label.getPreferredSize(); - dim.height += 2; - this.setPreferredSize(dim); + this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); this.setBackgroundNonSelectionColor(UIConstants.NORMAL_BACKGROUND); this.setForeground(UIConstants.FONT_COLOR); this.setBackgroundSelectionColor(UIConstants.FLESH_BLUE); @@ -131,25 +123,25 @@ public class MapDataTree extends JTree { }; protected String getPresentName(DefaultMutableTreeNode treeNode) { - if(treeNode == null || treeNode.getUserObject() == null){ + if (treeNode == null || treeNode.getUserObject() == null) { return StringUtils.EMPTY; } return ChartGEOJSONHelper.getPresentNameWithPath(treeNode.getUserObject().toString()); } //模糊搜索 深度优先. - public void search(String text){ - if(StringUtils.isEmpty(text)){ + public void search(String text) { + if (StringUtils.isEmpty(text)) { return; } DefaultTreeModel m_model = (DefaultTreeModel) this.getModel(); DefaultMutableTreeNode root = (DefaultMutableTreeNode) m_model.getRoot(); Enumeration els = root.postorderEnumeration(); - while(els.hasMoreElements()){ + while (els.hasMoreElements()) { DefaultMutableTreeNode el = (DefaultMutableTreeNode) els.nextElement(); - String path = el.getUserObject().toString(); + String path = el.getUserObject().toString(); String fileName = ChartGEOJSONHelper.getPresentNameWithPath(path); if (StringUtils.contains(fileName, text) && GEOJSONTreeHelper.isValidDirPath(path)) { selectTreeNode(el, m_model); @@ -158,7 +150,7 @@ public class MapDataTree extends JTree { } } - public void selectTreeNode(DefaultMutableTreeNode node, DefaultTreeModel m_model){ + public void selectTreeNode(DefaultMutableTreeNode node, DefaultTreeModel m_model) { TreeNode[] nodes = m_model.getPathToRoot(node); TreePath treePath = new TreePath(nodes); setSelectionPath(treePath); diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/FunnelPercentFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/FunnelPercentFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..5495131b3a --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/FunnelPercentFormatPaneWithoutCheckBox.java @@ -0,0 +1,18 @@ +package com.fr.van.chart.funnel.designer.style; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public class FunnelPercentFormatPaneWithoutCheckBox extends PercentFormatPaneWithoutCheckBox { + + public FunnelPercentFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Value_Conversion"); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java index e2382c6852..3df529fc3f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java @@ -4,8 +4,12 @@ import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -25,18 +29,34 @@ public class VanChartFunnelLabelContentPane extends VanChartLabelContentPane { protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{percentFormatPane,null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null} }; } @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new CategoryNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new FunnelPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected AttrTooltipContent createAttrTooltip() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java index c98dfcce46..3b45d188bd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java @@ -1,7 +1,9 @@ package com.fr.van.chart.funnel.designer.style; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -18,8 +20,16 @@ public class VanChartFunnelRefreshTooltipContentPane extends VanChartFunnelToolt protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); - changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane)); + setChangedPercentFormatPane(new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + setRichTextChangedValueFormatPane(new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextChangedPercentFormatPane(new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected double[] getRowSize(double p){ @@ -28,11 +38,21 @@ public class VanChartFunnelRefreshTooltipContentPane extends VanChartFunnelToolt protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{changedValueFormatPane,null}, - new Component[]{percentFormatPane,null}, - new Component[]{changedPercentFormatPane,null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getChangedValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + new Component[]{getChangedPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextChangedValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} }; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java index 1a5199c091..4c4ff52201 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java @@ -4,8 +4,11 @@ import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -25,18 +28,34 @@ public class VanChartFunnelTooltipContentPane extends VanChartTooltipContentPane protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{percentFormatPane,null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null} }; } @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new CategoryNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new FunnelPercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new FunnelPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected AttrTooltipContent createAttrTooltip() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/VanChartGanttLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/VanChartGanttLabelContentPane.java deleted file mode 100644 index fe4b2e80ae..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/VanChartGanttLabelContentPane.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fr.van.chart.gantt.designer.style; - -import com.fr.van.chart.designer.component.VanChartHtmlLabelPane; -import com.fr.van.chart.designer.style.VanChartStylePane; -import com.fr.van.chart.gantt.designer.style.tooltip.VanChartGanttTooltipContentPane; - -import javax.swing.JPanel; - -/** - * Created by hufan on 2017/1/13. - */ -public class VanChartGanttLabelContentPane extends VanChartGanttTooltipContentPane { - public VanChartGanttLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); - } - - protected VanChartHtmlLabelPane createHtmlLabelPane() { - return new VanChartHtmlLabelPane(); - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java new file mode 100644 index 0000000000..54ab3fd1f1 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java @@ -0,0 +1,121 @@ +package com.fr.van.chart.gantt.designer.style.label; + +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.gantt.attr.AttrGanttTooltipContent; +import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.gantt.designer.style.tooltip.VanChartDateFormatPaneWithCheckBox; +import com.fr.van.chart.gantt.designer.style.tooltip.VanChartFormatComBoxWithCheckBox; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * Created by hufan on 2017/1/13. + */ +public class VanChartGanttLabelContentPane extends VanChartLabelContentPaneWithoutRichText { + + private VanChartFormatPaneWithCheckBox processesFormatPane; + private VanChartDateFormatPaneWithCheckBox startTimeFormatPane; + private VanChartDateFormatPaneWithCheckBox endTimeFormatPane; + private VanChartFormatComBoxWithCheckBox durationFormatPane; + private VanChartFormatPaneWithCheckBox progressFormatPane; + + public VanChartGanttLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + processesFormatPane = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + @Override + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Project_Name"); + } + }; + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + startTimeFormatPane = new VanChartDateFormatPaneWithCheckBox(parent, showOnPane) { + @Override + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Start_Time"); + } + }; + endTimeFormatPane = new VanChartDateFormatPaneWithCheckBox(parent, showOnPane) { + @Override + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_End_Time"); + } + }; + durationFormatPane = new VanChartFormatComBoxWithCheckBox(); + progressFormatPane = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { + @Override + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Process"); + } + }; + } + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{processesFormatPane, null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{startTimeFormatPane, null}, + new Component[]{endTimeFormatPane, null}, + new Component[]{durationFormatPane, null}, + new Component[]{progressFormatPane, null} + }; + } + + protected double[] getRowSize(double p) { + return new double[]{p, p, p, p, p, p}; + } + + @Override + protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { + if (attrTooltipContent instanceof AttrGanttTooltipContent) { + AttrGanttTooltipContent ganttTooltipContent = (AttrGanttTooltipContent) attrTooltipContent; + processesFormatPane.populate(ganttTooltipContent.getProcessesFormat()); + getSeriesNameFormatPane().populate(ganttTooltipContent.getSeriesFormat()); + startTimeFormatPane.populate(ganttTooltipContent.getStartTimeFormat()); + endTimeFormatPane.populate(ganttTooltipContent.getEndTimeFormat()); + durationFormatPane.populate(ganttTooltipContent.getDurationFormat()); + progressFormatPane.populate(ganttTooltipContent.getProgressFormat()); + } + } + + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { + if (attrTooltipContent instanceof AttrGanttTooltipContent) { + AttrGanttTooltipContent ganttTooltipContent = (AttrGanttTooltipContent) attrTooltipContent; + processesFormatPane.update(ganttTooltipContent.getProcessesFormat()); + getSeriesNameFormatPane().update(ganttTooltipContent.getSeriesFormat()); + startTimeFormatPane.update(ganttTooltipContent.getStartTimeFormat()); + endTimeFormatPane.update(ganttTooltipContent.getEndTimeFormat()); + durationFormatPane.update(ganttTooltipContent.getDurationFormat()); + progressFormatPane.update(ganttTooltipContent.getProgressFormat()); + } + } + + public boolean isDirty() { + return processesFormatPane.isDirty() + || getSeriesNameFormatPane().isDirty() + || startTimeFormatPane.isDirty() + || endTimeFormatPane.isDirty() + || durationFormatPane.isDirty() + || progressFormatPane.isDirty(); + } + + public void setDirty(boolean isDirty) { + processesFormatPane.setDirty(isDirty); + getSeriesNameFormatPane().setDirty(isDirty); + startTimeFormatPane.setDirty(isDirty); + endTimeFormatPane.setDirty(isDirty); + durationFormatPane.setDirty(isDirty); + progressFormatPane.setDirty(isDirty); + } + + protected AttrTooltipContent createAttrTooltip() { + return new AttrGanttTooltipContent(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelDetailPane.java new file mode 100644 index 0000000000..e00e0afd4e --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelDetailPane.java @@ -0,0 +1,16 @@ +package com.fr.van.chart.gantt.designer.style.label; + +import com.fr.chart.chartattr.Plot; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; + +public class VanChartGanttPlotLabelDetailPane extends VanChartPlotLabelDetailPane { + + public VanChartGanttPlotLabelDetailPane(Plot plot, VanChartStylePane parent) { + super(plot, parent); + } + + protected void initToolTipContentPane(Plot plot) { + setDataLabelContentPane(new VanChartGanttLabelContentPane(getParentPane(), VanChartGanttPlotLabelDetailPane.this)); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelPane.java new file mode 100644 index 0000000000..546f772dd8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttPlotLabelPane.java @@ -0,0 +1,20 @@ +package com.fr.van.chart.gantt.designer.style.label; + +import com.fr.chart.chartattr.Plot; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; + +import java.awt.BorderLayout; + +public class VanChartGanttPlotLabelPane extends VanChartPlotLabelPane { + + public VanChartGanttPlotLabelPane(Plot plot, VanChartStylePane parent) { + super(plot, parent); + } + + protected void createLabelPane() { + VanChartGanttPlotLabelDetailPane labelDetailPane = new VanChartGanttPlotLabelDetailPane(getPlot(), getParentPane()); + setLabelDetailPane(labelDetailPane); + getLabelPane().add(labelDetailPane, BorderLayout.CENTER); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java index c89dff0392..9236773e71 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/series/VanChartGanttSeriesPane.java @@ -59,10 +59,6 @@ public class VanChartGanttSeriesPane extends VanChartAbstractPlotSeriesPane { return ganntStylePane; } - protected void checkCompsEnabledWithLarge(Plot plot) { - - } - private JPanel createLinkLinePane(){ lineWidth = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); colorSelect = new ColorSelectBoxWithOutTransparent(100); diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartDateFormatPaneWithCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartDateFormatPaneWithCheckBox.java new file mode 100644 index 0000000000..7ed6e93bc0 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartDateFormatPaneWithCheckBox.java @@ -0,0 +1,18 @@ +package com.fr.van.chart.gantt.designer.style.tooltip; + +import com.fr.design.gui.style.FormatPane; +import com.fr.van.chart.designer.PlotFactory; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public abstract class VanChartDateFormatPaneWithCheckBox extends VanChartFormatPaneWithCheckBox { + public VanChartDateFormatPaneWithCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected FormatPane createFormatPane(){ + return PlotFactory.createAutoFormatPane(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartDateFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartDateFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..ee395284a7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartDateFormatPaneWithoutCheckBox.java @@ -0,0 +1,18 @@ +package com.fr.van.chart.gantt.designer.style.tooltip; + +import com.fr.design.gui.style.FormatPane; +import com.fr.van.chart.designer.PlotFactory; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public abstract class VanChartDateFormatPaneWithoutCheckBox extends VanChartFormatPaneWithoutCheckBox { + public VanChartDateFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected FormatPane createFormatPane() { + return PlotFactory.createAutoFormatPane(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java new file mode 100644 index 0000000000..95da8ea986 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithCheckBox.java @@ -0,0 +1,100 @@ +package com.fr.van.chart.gantt.designer.style.tooltip; + +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.i18n.Toolkit; +import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; +import com.fr.plugin.chart.base.format.IntervalTimeFormat; + +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.Map; + +public class VanChartFormatComBoxWithCheckBox extends JPanel { + private static final String LABEL_TEXT = Toolkit.i18nText("Fine-Design_Chart_Duration_Time"); + + private UICheckBox isSelectedBox; + private UIComboBox formatComBox; + + private boolean isDirty; + + public VanChartFormatComBoxWithCheckBox() { + this.setLayout(new BorderLayout()); + isSelectedBox = new UICheckBox(LABEL_TEXT); + formatComBox = new UIComboBox(IntervalTimeFormat.getFormats()); + isSelectedBox.addMouseListener(new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + isDirty = true; + } + + @Override + public void mousePressed(MouseEvent e) { + + } + + @Override + public void mouseReleased(MouseEvent e) { + + } + + @Override + public void mouseEntered(MouseEvent e) { + + } + + @Override + public void mouseExited(MouseEvent e) { + + } + }); + formatComBox.setPreferredSize(new Dimension(40, 20)); + + if (showSelectBox()) { + this.add(isSelectedBox, BorderLayout.CENTER); + } else { + this.add(new UILabel(LABEL_TEXT), BorderLayout.CENTER); + } + + this.add(formatComBox, BorderLayout.EAST); + } + + protected boolean showSelectBox() { + return true; + } + + public boolean isDirty() { + return isDirty; + } + + public void setDirty(boolean isDirty) { + this.isDirty = isDirty; + } + + public void populate(AttrTooltipFormat tooltipFormat) { + if (tooltipFormat instanceof AttrTooltipDurationFormat) { + this.isSelectedBox.setSelected(tooltipFormat.isEnable()); + formatComBox.setSelectedItem(((AttrTooltipDurationFormat) tooltipFormat).getIntervalTimeFormat()); + } + } + + public void update(AttrTooltipFormat tooltipFormat) { + if (tooltipFormat instanceof AttrTooltipDurationFormat) { + tooltipFormat.setEnable(isSelectedBox.isSelected()); + ((AttrTooltipDurationFormat) tooltipFormat).setIntervalTimeFormat((IntervalTimeFormat) formatComBox.getSelectedItem()); + } + } + + public void updateFormatParams(Map paramMap, String value) { + String key = LABEL_TEXT; + + if (paramMap != null && !paramMap.containsKey(key)) { + paramMap.put(key, value); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithoutCheckBox.java new file mode 100644 index 0000000000..20a74e3762 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartFormatComBoxWithoutCheckBox.java @@ -0,0 +1,8 @@ +package com.fr.van.chart.gantt.designer.style.tooltip; + +public class VanChartFormatComBoxWithoutCheckBox extends VanChartFormatComBoxWithCheckBox { + + protected boolean showSelectBox() { + return false; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java index 6bff1d5708..3d3d87d10d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java @@ -1,26 +1,24 @@ package com.fr.van.chart.gantt.designer.style.tooltip; -import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.style.FormatPane; - +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; -import com.fr.plugin.chart.base.format.AttrTooltipFormat; -import com.fr.plugin.chart.base.format.IntervalTimeFormat; +import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat; +import com.fr.plugin.chart.base.format.AttrTooltipProcessesFormat; +import com.fr.plugin.chart.base.format.AttrTooltipProgressFormat; +import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; +import com.fr.plugin.chart.base.format.AttrTooltipStartTimeFormat; import com.fr.plugin.chart.gantt.attr.AttrGanttTooltipContent; -import com.fr.van.chart.designer.PlotFactory; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; -import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; +import java.util.Map; /** * Created by hufan on 2017/1/13. @@ -32,6 +30,12 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane private VanChartFormatComBoxWithCheckBox durationFormatPane; private VanChartFormatPaneWithCheckBox progressFormatPane; + private VanChartFormatPaneWithoutCheckBox richTextProcessesFormatPane; + private VanChartDateFormatPaneWithoutCheckBox richTextStartTimeFormatPane; + private VanChartDateFormatPaneWithoutCheckBox richTextEndTimeFormatPane; + private VanChartFormatComBoxWithoutCheckBox richTextDurationFormatPane; + private VanChartFormatPaneWithoutCheckBox richTextProgressFormatPane; + public VanChartGanttTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { super(parent, showOnPane); } @@ -40,27 +44,52 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane processesFormatPane = new VanChartFormatPaneWithCheckBox(parent, showOnPane){ @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Project_Name"); + return Toolkit.i18nText("Fine-Design_Chart_Project_Name"); } }; - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); startTimeFormatPane = new VanChartDateFormatPaneWithCheckBox(parent, showOnPane){ @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Start_Time"); + return Toolkit.i18nText("Fine-Design_Chart_Start_Time"); } }; endTimeFormatPane = new VanChartDateFormatPaneWithCheckBox(parent, showOnPane){ @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_End_Time"); + return Toolkit.i18nText("Fine-Design_Chart_End_Time"); } }; durationFormatPane = new VanChartFormatComBoxWithCheckBox(); progressFormatPane = new VanChartFormatPaneWithCheckBox(parent, showOnPane){ @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Process"); + return Toolkit.i18nText("Fine-Design_Chart_Process"); + } + }; + } + + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + richTextProcessesFormatPane = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane){ + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Project_Name"); + } + }; + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + richTextStartTimeFormatPane = new VanChartDateFormatPaneWithoutCheckBox(parent, showOnPane){ + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Start_Time"); + } + }; + richTextEndTimeFormatPane = new VanChartDateFormatPaneWithoutCheckBox(parent, showOnPane){ + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_End_Time"); + } + }; + richTextDurationFormatPane = new VanChartFormatComBoxWithoutCheckBox(); + richTextProgressFormatPane = new VanChartFormatPaneWithoutCheckBox(parent, showOnPane){ + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Process"); } }; } @@ -68,7 +97,7 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane protected Component[][] getPaneComponents(){ return new Component[][]{ new Component[]{processesFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, + new Component[]{getSeriesNameFormatPane(),null}, new Component[]{startTimeFormatPane,null}, new Component[]{endTimeFormatPane,null}, new Component[]{durationFormatPane, null}, @@ -76,16 +105,28 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane }; } + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{richTextProcessesFormatPane,null}, + new Component[]{getRichTextSeriesNameFormatPane(),null}, + new Component[]{richTextStartTimeFormatPane,null}, + new Component[]{richTextEndTimeFormatPane,null}, + new Component[]{richTextDurationFormatPane, null}, + new Component[]{richTextProgressFormatPane, null} + }; + } + protected double[] getRowSize(double p){ return new double[]{p,p,p,p,p,p}; } @Override protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { + // fixme 当前的样式面板设计都是基于一个大而全的父类,在子类中组合需要的属性,导致父类的属性多是protected,且子类不能明确获取自己Model的type if (attrTooltipContent instanceof AttrGanttTooltipContent){ AttrGanttTooltipContent ganttTooltipContent = (AttrGanttTooltipContent) attrTooltipContent; processesFormatPane.populate(ganttTooltipContent.getProcessesFormat()); - seriesNameFormatPane.populate(ganttTooltipContent.getSeriesFormat()); + getSeriesNameFormatPane().populate(ganttTooltipContent.getSeriesFormat()); startTimeFormatPane.populate(ganttTooltipContent.getStartTimeFormat()); endTimeFormatPane.populate(ganttTooltipContent.getEndTimeFormat()); durationFormatPane.populate(ganttTooltipContent.getDurationFormat()); @@ -93,11 +134,44 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane } } + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + if(attrTooltipContent instanceof AttrGanttTooltipContent){ + AttrGanttTooltipContent ganttTooltipContent = (AttrGanttTooltipContent) attrTooltipContent; + Map params = getRichTextAttr().getParams(); + + AttrTooltipProcessesFormat processesFormat = ganttTooltipContent.getRichTextProcessesFormat(); + richTextProcessesFormatPane.populate(processesFormat); + richTextProcessesFormatPane.updateFormatParams(params, processesFormat.getJs()); + + AttrTooltipSeriesFormat seriesFormat = ganttTooltipContent.getRichTextSeriesFormat(); + getRichTextSeriesNameFormatPane().populate(seriesFormat); + getRichTextSeriesNameFormatPane().updateFormatParams(params, seriesFormat.getJs()); + + AttrTooltipStartTimeFormat startTimeFormat = ganttTooltipContent.getRichTextStartTimeFormat(); + richTextStartTimeFormatPane.populate(startTimeFormat); + richTextStartTimeFormatPane.updateFormatParams(params, startTimeFormat.getJs()); + + AttrTooltipEndTimeFormat endTimeFormat = ganttTooltipContent.getRichTextEndTimeFormat(); + richTextEndTimeFormatPane.populate(endTimeFormat); + richTextEndTimeFormatPane.updateFormatParams(params, endTimeFormat.getJs()); + + AttrTooltipDurationFormat durationFormat = ganttTooltipContent.getRichTextDurationFormat(); + richTextDurationFormatPane.populate(durationFormat); + richTextDurationFormatPane.updateFormatParams(params, durationFormat.getJs()); + + AttrTooltipProgressFormat progressFormat = ganttTooltipContent.getRichTextProgressFormat(); + richTextProgressFormatPane.populate(progressFormat); + richTextProgressFormatPane.updateFormatParams(params, progressFormat.getJs()); + + populateRichText(attrTooltipContent.getRichTextAttr()); + } + } + protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { if (attrTooltipContent instanceof AttrGanttTooltipContent){ AttrGanttTooltipContent ganttTooltipContent = (AttrGanttTooltipContent) attrTooltipContent; processesFormatPane.update(ganttTooltipContent.getProcessesFormat()); - seriesNameFormatPane.update(ganttTooltipContent.getSeriesFormat()); + getSeriesNameFormatPane().update(ganttTooltipContent.getSeriesFormat()); startTimeFormatPane.update(ganttTooltipContent.getStartTimeFormat()); endTimeFormatPane.update(ganttTooltipContent.getEndTimeFormat()); durationFormatPane.update(ganttTooltipContent.getDurationFormat()); @@ -105,9 +179,22 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane } } + protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { + if(attrTooltipContent instanceof AttrGanttTooltipContent) { + AttrGanttTooltipContent ganttTooltipContent = (AttrGanttTooltipContent) attrTooltipContent; + + richTextProcessesFormatPane.update(ganttTooltipContent.getRichTextProcessesFormat()); + getRichTextSeriesNameFormatPane().update(ganttTooltipContent.getRichTextSeriesFormat()); + richTextStartTimeFormatPane.update(ganttTooltipContent.getRichTextStartTimeFormat()); + richTextEndTimeFormatPane.update(ganttTooltipContent.getRichTextEndTimeFormat()); + richTextDurationFormatPane.update(ganttTooltipContent.getRichTextDurationFormat()); + richTextProgressFormatPane.update(ganttTooltipContent.getRichTextProgressFormat()); + } + } + public boolean isDirty() { return processesFormatPane.isDirty() - || seriesNameFormatPane.isDirty() + || getSeriesNameFormatPane().isDirty() || startTimeFormatPane.isDirty() || endTimeFormatPane.isDirty() || durationFormatPane.isDirty() @@ -116,7 +203,7 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane public void setDirty(boolean isDirty) { processesFormatPane.setDirty(isDirty); - seriesNameFormatPane.setDirty(isDirty); + getSeriesNameFormatPane().setDirty(isDirty); startTimeFormatPane.setDirty(isDirty); endTimeFormatPane.setDirty(isDirty); durationFormatPane.setDirty(isDirty); @@ -126,79 +213,4 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane protected AttrTooltipContent createAttrTooltip() { return new AttrGanttTooltipContent(); } - - private abstract class VanChartDateFormatPaneWithCheckBox extends VanChartFormatPaneWithCheckBox { - public VanChartDateFormatPaneWithCheckBox(VanChartStylePane parent, JPanel showOnPane) { - super(parent, showOnPane); - } - - @Override - protected FormatPane createFormatPane(){ - return PlotFactory.createAutoFormatPane(); - } - } - - private class VanChartFormatComBoxWithCheckBox extends JPanel{ - private UICheckBox isSelectedBox; - private UIComboBox formatComBox; - - private boolean isDirty; - - private VanChartFormatComBoxWithCheckBox() { - this.setLayout(new BorderLayout()); - isSelectedBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Duration_Time")); - formatComBox = new UIComboBox(IntervalTimeFormat.getFormats()); - isSelectedBox.addMouseListener(new MouseListener() { - @Override - public void mouseClicked(MouseEvent e) { - isDirty = true; - } - - @Override - public void mousePressed(MouseEvent e) { - - } - - @Override - public void mouseReleased(MouseEvent e) { - - } - - @Override - public void mouseEntered(MouseEvent e) { - - } - - @Override - public void mouseExited(MouseEvent e) { - - } - }); - formatComBox.setPreferredSize(new Dimension(40,20)); - this.add(isSelectedBox, BorderLayout.CENTER); - this.add(formatComBox, BorderLayout.EAST); - } - - private boolean isDirty() { - return isDirty; - } - - private void setDirty(boolean isDirty) { - this.isDirty = isDirty; - } - - private void populate(AttrTooltipFormat tooltipFormat) { - if(tooltipFormat instanceof AttrTooltipDurationFormat) { - this.isSelectedBox.setSelected(tooltipFormat.isEnable()); - formatComBox.setSelectedItem(((AttrTooltipDurationFormat) tooltipFormat).getIntervalTimeFormat()); - } - } - - private void update(AttrTooltipFormat tooltipFormat) { - if(tooltipFormat instanceof AttrTooltipDurationFormat) { - tooltipFormat.setEnable(isSelectedBox.isSelected()); - ((AttrTooltipDurationFormat) tooltipFormat).setIntervalTimeFormat((IntervalTimeFormat) formatComBox.getSelectedItem()); - } - } - } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java index c918088cac..de2b9171c9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java @@ -5,9 +5,13 @@ import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipMapValueFormat; import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -22,10 +26,18 @@ public class VanChartMapLabelContentPane extends VanChartLabelContentPane { @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new MapAreaNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new MapAreaNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new MapAreaNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java index 76bd33f59d..21b8995f30 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java @@ -3,7 +3,9 @@ package com.fr.van.chart.map.designer.style.tooltip; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -17,25 +19,45 @@ public class VanChartMapRefreshTooltipContentPane extends VanChartMapTooltipCont super(null, showOnPane); } + protected double[] getRowSize(double p){ + return new double[]{p,p,p,p,p,p}; + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); - changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane)); + setChangedPercentFormatPane(new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane)); } - protected double[] getRowSize(double p){ - return new double[]{p,p,p,p,p,p}; + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + setRichTextChangedValueFormatPane(new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextChangedPercentFormatPane(new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{changedValueFormatPane,null}, - new Component[]{percentFormatPane,null}, - new Component[]{changedPercentFormatPane,null}, + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getChangedValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + new Component[]{getChangedPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextChangedValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java index 1a2b593a3b..cc4ca79828 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java @@ -5,9 +5,13 @@ import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipMapValueFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -22,10 +26,18 @@ public class VanChartMapTooltipContentPane extends VanChartTooltipContentPane { @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new MapAreaNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new MapAreaNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new MapAreaNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/line/StartAndEndNameFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/map/line/StartAndEndNameFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..9630f9b12d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/line/StartAndEndNameFormatPaneWithoutCheckBox.java @@ -0,0 +1,17 @@ +package com.fr.van.chart.map.line; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public class StartAndEndNameFormatPaneWithoutCheckBox extends CategoryNameFormatPaneWithoutCheckBox { + public StartAndEndNameFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Start_And_End"); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java index 66566c6bf3..1b3d31bee5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java @@ -5,8 +5,11 @@ import com.fr.plugin.chart.base.format.AttrTooltipStartAndEndNameFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -21,10 +24,18 @@ public class VanChartLineMapTooltipContentPane extends VanChartTooltipContentPan @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane){ - categoryNameFormatPane = new StartAndEndNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new StartAndEndNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new SeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new StartAndEndNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/MultiPieLevelNameFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/MultiPieLevelNameFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..71789e63ab --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/MultiPieLevelNameFormatPaneWithoutCheckBox.java @@ -0,0 +1,18 @@ +package com.fr.van.chart.multilayer.style; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public class MultiPieLevelNameFormatPaneWithoutCheckBox extends CategoryNameFormatPaneWithoutCheckBox { + + public MultiPieLevelNameFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Level_Name"); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/MultiPieSeriesNameFormatPaneWithoutCheckBox.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/MultiPieSeriesNameFormatPaneWithoutCheckBox.java new file mode 100644 index 0000000000..95cf23f2e7 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/MultiPieSeriesNameFormatPaneWithoutCheckBox.java @@ -0,0 +1,18 @@ +package com.fr.van.chart.multilayer.style; + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; + +public class MultiPieSeriesNameFormatPaneWithoutCheckBox extends SeriesNameFormatPaneWithoutCheckBox { + + public MultiPieSeriesNameFormatPaneWithoutCheckBox(VanChartStylePane parent, JPanel showOnPane) { + super(parent, showOnPane); + } + + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java index 637279d134..7fc9256bda 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java @@ -4,7 +4,9 @@ import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.multilayer.style.AttrTooltipMultiLevelNameFormat; import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -19,10 +21,18 @@ public class VanChartMultiPieLabelContentPane extends VanChartLabelContentPane { @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new MultiPieLevelNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new MultiPieSeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new MultiPieLevelNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new MultiPieSeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new MultiPieLevelNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new MultiPieSeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected AttrTooltipContent createAttrTooltip() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java index 3c500d3bf8..dab7a5043b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java @@ -4,7 +4,9 @@ import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.multilayer.style.AttrTooltipMultiLevelNameFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -19,10 +21,18 @@ public class VanChartMultiPieTooltipContentPane extends VanChartTooltipContentPa @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new MultiPieLevelNameFormatPaneWithCheckBox(parent, showOnPane); - seriesNameFormatPane = new MultiPieSeriesNameFormatPaneWithCheckBox(parent, showOnPane); - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + setCategoryNameFormatPane(new MultiPieLevelNameFormatPaneWithCheckBox(parent, showOnPane)); + setSeriesNameFormatPane(new MultiPieSeriesNameFormatPaneWithCheckBox(parent, showOnPane)); + setValueFormatPane(new ValueFormatPaneWithCheckBox(parent, showOnPane)); + setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + setRichTextCategoryNameFormatPane(new MultiPieLevelNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextSeriesNameFormatPane(new MultiPieSeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java index 56893ec66b..a38383306d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java @@ -1,7 +1,9 @@ package com.fr.van.chart.multilayer.style; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -21,8 +23,16 @@ public class VanChartMutiPieRefreshTooltipContentPane extends VanChartMultiPieTo protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); - changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + setChangedValueFormatPane(new ChangedValueFormatPaneWithCheckBox(parent, showOnPane)); + setChangedPercentFormatPane(new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane)); + } + + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + setRichTextChangedValueFormatPane(new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane)); + setRichTextChangedPercentFormatPane(new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } protected double[] getRowSize(double p){ @@ -31,12 +41,23 @@ public class VanChartMutiPieRefreshTooltipContentPane extends VanChartMultiPieTo protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{changedValueFormatPane,null}, - new Component[]{percentFormatPane,null}, - new Component[]{changedPercentFormatPane,null}, + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getChangedValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + new Component[]{getChangedPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextChangedValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java index 9e6e08a0ad..27f10bfc8b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/pie/VanChartPiePlotPane.java @@ -83,4 +83,9 @@ public class VanChartPiePlotPane extends AbstractVanChartTypePane { public Chart getDefaultChart() { return PieIndependentVanChart.newPieChartTypes[0]; } + + //重置数据配置 + protected void resetFilterDefinition(Chart chart) { + resetMoreCateDefinition(chart); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarConditionPane.java index 9c46cd8ef7..0d60f64de7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarConditionPane.java @@ -53,7 +53,7 @@ public class VanChartRadarConditionPane extends DataSeriesConditionPane{ } else { classPaneMap.put(VanChartAttrMarker.class, new VanChartMarkerConditionPane(this)); classPaneMap.put(VanChartAttrLine.class, new VanChartLineWidthConditionPane(this)); - classPaneMap.put(AttrAreaSeriesFillColorBackground.class, new VanChartAreaFillColorConditionPane(this)); + classPaneMap.put(AttrAreaSeriesFillColorBackground.class, new VanChartAreaFillColorConditionPane(this, plot)); classPaneMap.put(AttrEffect.class, new VanChartEffectConditionPane(this, EffectHelper.getRadarPlotDefaultEffect())); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarPlotPane.java index a77c71bc90..e05bbe2422 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/radar/VanChartRadarPlotPane.java @@ -49,4 +49,8 @@ public class VanChartRadarPlotPane extends AbstractVanChartTypePane { return RadarIndependentVanChart.RadarVanChartTypes[0]; } + //重置数据配置 + protected void resetFilterDefinition(Chart chart) { + resetMoreCateDefinition(chart); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java index 902f655172..43d70e0b66 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java @@ -1,9 +1,13 @@ package com.fr.van.chart.scatter; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltipContent; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -15,7 +19,7 @@ import java.awt.Component; public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterTooltipContentPane { private ChangedValueFormatPaneWithCheckBox changedSizeFormatPane; - + private ChangedValueFormatPaneWithoutCheckBox richTextChangedSizeFormatPane; public VanChartScatterRefreshTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { super(null, showOnPane); @@ -25,9 +29,17 @@ public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterToo protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); changedSizeFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + setChangedPercentFormatPane(changedPercentFormatPane); } + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + richTextChangedSizeFormatPane = new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane); + ChangedPercentFormatPaneWithoutCheckBox richTextChangedPercentFormatPane = new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane); + setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); + } protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p, p}; @@ -35,12 +47,24 @@ public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterToo protected Component[][] getPaneComponents() { return new Component[][]{ - new Component[]{seriesNameFormatPane, null}, - new Component[]{getxFormatPane(), null}, - new Component[]{getyFormatPane(), null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getXFormatPane(), null}, + new Component[]{getYFormatPane(), null}, new Component[]{getSizeFormatPane(), null}, new Component[]{changedSizeFormatPane, null}, - new Component[]{changedPercentFormatPane, null}, + new Component[]{getChangedPercentFormatPane(), null}, + }; + } + + @Override + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextXFormatPane(), null}, + new Component[]{getRichTextYFormatPane(), null}, + new Component[]{getRichTextSizeFormatPane(), null}, + new Component[]{richTextChangedSizeFormatPane, null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} }; } @@ -51,18 +75,49 @@ public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterToo if (attrTooltipContent instanceof ScatterAttrTooltipContent) { ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; changedSizeFormatPane.populate(scatterAttrTooltipContent.getChangeSizeFormat()); - changedPercentFormatPane.populate(scatterAttrTooltipContent.getChangedSizePercentFormat()); + getChangedPercentFormatPane().populate(scatterAttrTooltipContent.getChangedSizePercentFormat()); } } + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + super.populateRichEditor(attrTooltipContent); + + if (attrTooltipContent instanceof ScatterAttrTooltipContent) { + ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; + + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + richTextChangedSizeFormatPane, + getRichTextChangedPercentFormatPane() + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + scatterAttrTooltipContent.getRichTextChangeSizeFormat(), + scatterAttrTooltipContent.getRichTextChangedSizePercentFormat() + }; + + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(attrTooltipContent.getRichTextAttr()); + } + } + @Override protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { super.updateFormatPane(attrTooltipContent); if (attrTooltipContent instanceof ScatterAttrTooltipContent) { ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; changedSizeFormatPane.update(scatterAttrTooltipContent.getChangeSizeFormat()); - changedPercentFormatPane.update(scatterAttrTooltipContent.getChangedSizePercentFormat()); + getChangedPercentFormatPane().update(scatterAttrTooltipContent.getChangedSizePercentFormat()); + } + } + + protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { + super.updateRichEditor(attrTooltipContent); + + if (attrTooltipContent instanceof ScatterAttrTooltipContent) { + ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; + richTextChangedSizeFormatPane.update(scatterAttrTooltipContent.getRichTextChangeSizeFormat()); + getRichTextChangedPercentFormatPane().update(scatterAttrTooltipContent.getRichTextChangedSizePercentFormat()); } } @@ -70,13 +125,13 @@ public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterToo public void setDirty(boolean isDirty) { super.setDirty(isDirty); changedSizeFormatPane.setDirty(isDirty); - changedPercentFormatPane.setDirty(isDirty); + getChangedPercentFormatPane().setDirty(isDirty); } @Override public boolean isDirty() { - return super.isDirty() || changedSizeFormatPane.isDirty() || changedPercentFormatPane.isDirty(); + return super.isDirty() || changedSizeFormatPane.isDirty() || getChangedPercentFormatPane().isDirty(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java index 705ea1a0f6..9431b4ab76 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java @@ -1,11 +1,16 @@ package com.fr.van.chart.scatter; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltipContent; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.XFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.XFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.YFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.YFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -20,11 +25,15 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa private YFormatPaneWithCheckBox yFormatPane; private ValueFormatPaneWithCheckBox sizeFormatPane; - public XFormatPaneWithCheckBox getxFormatPane() { + private XFormatPaneWithoutCheckBox richTextXFormatPane; + private YFormatPaneWithoutCheckBox richTextYFormatPane; + private ValueFormatPaneWithoutCheckBox richTextSizeFormatPane; + + public XFormatPaneWithCheckBox getXFormatPane() { return xFormatPane; } - public YFormatPaneWithCheckBox getyFormatPane() { + public YFormatPaneWithCheckBox getYFormatPane() { return yFormatPane; } @@ -32,6 +41,18 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa return sizeFormatPane; } + public XFormatPaneWithoutCheckBox getRichTextXFormatPane() { + return richTextXFormatPane; + } + + public YFormatPaneWithoutCheckBox getRichTextYFormatPane() { + return richTextYFormatPane; + } + + public ValueFormatPaneWithoutCheckBox getRichTextSizeFormatPane() { + return richTextSizeFormatPane; + } + public VanChartScatterTooltipContentPane(VanChartStylePane parent, JPanel showOnPane){ super(parent, showOnPane); } @@ -45,16 +66,35 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa sizeFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); } + @Override + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + richTextXFormatPane = new XFormatPaneWithoutCheckBox(parent, showOnPane); + richTextYFormatPane = new YFormatPaneWithoutCheckBox(parent, showOnPane); + richTextSizeFormatPane = new ValueFormatPaneWithoutCheckBox(parent, showOnPane); + } + @Override protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{seriesNameFormatPane,null}, + new Component[]{getSeriesNameFormatPane(),null}, new Component[]{xFormatPane,null}, new Component[]{yFormatPane,null}, new Component[]{sizeFormatPane,null}, }; } + @Override + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{richTextXFormatPane, null}, + new Component[]{richTextYFormatPane, null}, + new Component[]{richTextSizeFormatPane, null} + }; + } + @Override protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { super.populateFormatPane(attrTooltipContent); @@ -66,6 +106,27 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa } } + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + super.populateRichEditor(attrTooltipContent); + + if (attrTooltipContent instanceof ScatterAttrTooltipContent) { + ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; + + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + richTextXFormatPane, richTextYFormatPane, richTextSizeFormatPane + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + scatterAttrTooltipContent.getRichTextXFormat(), + scatterAttrTooltipContent.getRichTextYFormat(), + scatterAttrTooltipContent.getRichTextSizeFormat() + }; + + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(attrTooltipContent.getRichTextAttr()); + } + } + @Override protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { super.updateFormatPane(attrTooltipContent); @@ -77,17 +138,28 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa } } + protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { + super.updateRichEditor(attrTooltipContent); + + if (attrTooltipContent instanceof ScatterAttrTooltipContent) { + ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; + richTextXFormatPane.update(scatterAttrTooltipContent.getRichTextXFormat()); + richTextYFormatPane.update(scatterAttrTooltipContent.getRichTextYFormat()); + richTextSizeFormatPane.update(scatterAttrTooltipContent.getRichTextSizeFormat()); + } + } + @Override public void setDirty(boolean isDirty) { xFormatPane.setDirty(isDirty); yFormatPane.setDirty(isDirty); sizeFormatPane.setDirty(isDirty); - seriesNameFormatPane.setDirty(isDirty); + getSeriesNameFormatPane().setDirty(isDirty); } @Override public boolean isDirty() { - return xFormatPane.isDirty() || yFormatPane.isDirty() || sizeFormatPane.isDirty() || seriesNameFormatPane.isDirty(); + return xFormatPane.isDirty() || yFormatPane.isDirty() || sizeFormatPane.isDirty() || getSeriesNameFormatPane().isDirty(); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelDetailPane.java index d507934e6b..a78261f655 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelDetailPane.java @@ -19,6 +19,6 @@ public class VanChartScatterPlotLabelDetailPane extends VanChartPlotLabelDetailP @Override protected void initToolTipContentPane(Plot plot) { - dataLabelContentPane = new VanChartScatterLabelContentPane(parent,VanChartScatterPlotLabelDetailPane.this); + setDataLabelContentPane(new VanChartScatterLabelContentPane(getParentPane(),VanChartScatterPlotLabelDetailPane.this)); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelNoCheckPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelNoCheckPane.java index 71e783b061..a409180732 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelNoCheckPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelNoCheckPane.java @@ -19,12 +19,12 @@ public class VanChartScatterPlotLabelNoCheckPane extends VanChartScatterPlotLabe protected void addComponents() { this.setLayout(new BorderLayout()); - this.add(labelPane,BorderLayout.CENTER); + this.add(getLabelPane(), BorderLayout.CENTER); } public void populate(AttrLabel attr) { super.populate(attr); - isLabelShow.setSelected(true); - labelPane.setVisible(true); + getLabelShowCheckBox().setSelected(true); + getLabelPane().setVisible(true); } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java index 632ce7f6f5..fb8be90163 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/component/label/VanChartScatterPlotLabelPane.java @@ -18,7 +18,8 @@ public class VanChartScatterPlotLabelPane extends VanChartPlotLabelPane { @Override protected void createLabelPane() { - labelDetailPane = new VanChartScatterPlotLabelDetailPane(this.plot, this.parent); - labelPane.add(labelDetailPane, BorderLayout.CENTER); + VanChartScatterPlotLabelDetailPane labelDetailPane = new VanChartScatterPlotLabelDetailPane(getPlot(), getParentPane()); + setLabelDetailPane(labelDetailPane); + getLabelPane().add(labelDetailPane, BorderLayout.CENTER); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java index af4d721756..f380c8267a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java @@ -1,9 +1,10 @@ package com.fr.van.chart.structure.desinger.style; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.multilayer.style.AttrTooltipMultiLevelNameFormat; -import com.fr.van.chart.designer.component.VanChartLabelContentPane; +import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; @@ -16,7 +17,7 @@ import java.awt.Component; /** * Created by shine on 2017/2/15. */ -public class VanChartStructureLabelContentPane extends VanChartLabelContentPane { +public class VanChartStructureLabelContentPane extends VanChartLabelContentPaneWithoutRichText { public VanChartStructureLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { super(parent, showOnPane); } @@ -24,28 +25,33 @@ public class VanChartStructureLabelContentPane extends VanChartLabelContentPane @Override protected Component[][] getPaneComponents(){ return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null} + new Component[]{getCategoryNameFormatPane(),null}, + new Component[]{getSeriesNameFormatPane(),null}, + new Component[]{getValueFormatPane(),null} }; } @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane){ - categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane){ + CategoryNameFormatPaneWithCheckBox categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane){ @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Node_Name"); + return Toolkit.i18nText("Fine-Design_Chart_Node_Name"); } }; - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane){ + SeriesNameFormatPaneWithCheckBox seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane){ @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); + return Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); } }; - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + ValueFormatPaneWithCheckBox valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); + PercentFormatPaneWithCheckBox percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + + setCategoryNameFormatPane(categoryNameFormatPane); + setSeriesNameFormatPane(seriesNameFormatPane); + setValueFormatPane(valueFormatPane); + setPercentFormatPane(percentFormatPane); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelDetailPane.java new file mode 100644 index 0000000000..20e784c525 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelDetailPane.java @@ -0,0 +1,16 @@ +package com.fr.van.chart.structure.desinger.style; + +import com.fr.chart.chartattr.Plot; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.label.VanChartPlotLabelDetailPane; + +public class VanChartStructurePlotLabelDetailPane extends VanChartPlotLabelDetailPane { + + public VanChartStructurePlotLabelDetailPane(Plot plot, VanChartStylePane parent) { + super(plot, parent); + } + + protected void initToolTipContentPane(Plot plot) { + setDataLabelContentPane(new VanChartStructureLabelContentPane(getParentPane(), VanChartStructurePlotLabelDetailPane.this)); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelPane.java new file mode 100644 index 0000000000..e4cdc99e19 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructurePlotLabelPane.java @@ -0,0 +1,20 @@ +package com.fr.van.chart.structure.desinger.style; + +import com.fr.chart.chartattr.Plot; +import com.fr.van.chart.designer.style.VanChartStylePane; +import com.fr.van.chart.designer.style.label.VanChartPlotLabelPane; + +import java.awt.BorderLayout; + +public class VanChartStructurePlotLabelPane extends VanChartPlotLabelPane { + + public VanChartStructurePlotLabelPane(Plot plot, VanChartStylePane parent) { + super(plot, parent); + } + + protected void createLabelPane() { + VanChartStructurePlotLabelDetailPane labelDetailPane = new VanChartStructurePlotLabelDetailPane(getPlot(), getParentPane()); + setLabelDetailPane(labelDetailPane); + getLabelPane().add(labelDetailPane, BorderLayout.CENTER); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java index 5fa83be5b8..52295346bf 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java @@ -1,7 +1,9 @@ package com.fr.van.chart.structure.desinger.style; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -10,7 +12,7 @@ import java.awt.Component; /** * Created by mengao on 2017/6/9. */ -public class VanChartStructureRefreshTooltipContentPane extends VanChartStructureTooltipContentPane{ +public class VanChartStructureRefreshTooltipContentPane extends VanChartStructureTooltipContentPane { public VanChartStructureRefreshTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { super(null, showOnPane); } @@ -19,22 +21,44 @@ public class VanChartStructureRefreshTooltipContentPane extends VanChartStructur protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); - changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + ChangedValueFormatPaneWithCheckBox changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane); + ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + + setChangedValueFormatPane(changedValueFormatPane); + setChangedPercentFormatPane(changedPercentFormatPane); } - protected double[] getRowSize(double p){ - return new double[]{p,p,p,p,p}; + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + ChangedValueFormatPaneWithoutCheckBox richTextChangedValueFormatPane = new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane); + ChangedPercentFormatPaneWithoutCheckBox richTextChangedPercentFormatPane = new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane); + + setRichTextChangedValueFormatPane(richTextChangedValueFormatPane); + setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); } - @Override - protected Component[][] getPaneComponents(){ + protected double[] getRowSize(double p) { + return new double[]{p, p, p, p, p}; + } + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getChangedValueFormatPane(), null}, + new Component[]{getChangedPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{changedValueFormatPane,null}, - new Component[]{changedPercentFormatPane,null}, + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextChangedValueFormatPane(), null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} }; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java index 63490eaffa..2a72f6a09b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java @@ -1,13 +1,18 @@ package com.fr.van.chart.structure.desinger.style; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.multilayer.style.AttrTooltipMultiLevelNameFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -22,30 +27,64 @@ public class VanChartStructureTooltipContentPane extends VanChartTooltipContentP } @Override - protected Component[][] getPaneComponents(){ + protected Component[][] getPaneComponents() { return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null} + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null} }; } @Override - protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane){ - categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane){ + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null} + }; + } + + @Override + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + CategoryNameFormatPaneWithCheckBox categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane) { @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Node_Name"); + return Toolkit.i18nText("Fine-Design_Chart_Node_Name"); } }; - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane){ + SeriesNameFormatPaneWithCheckBox seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane) { @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); + return Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); } }; - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + ValueFormatPaneWithCheckBox valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); + PercentFormatPaneWithCheckBox percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + + setCategoryNameFormatPane(categoryNameFormatPane); + setSeriesNameFormatPane(seriesNameFormatPane); + setValueFormatPane(valueFormatPane); + setPercentFormatPane(percentFormatPane); + } + + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + CategoryNameFormatPaneWithoutCheckBox richTextCategoryNameFormatPane = new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Node_Name"); + } + }; + SeriesNameFormatPaneWithoutCheckBox richTextSeriesNameFormatPane = new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); + } + }; + ValueFormatPaneWithoutCheckBox richTextValueFormatPane = new ValueFormatPaneWithoutCheckBox(parent, showOnPane); + PercentFormatPaneWithoutCheckBox richTextPercentFormatPane = new PercentFormatPaneWithoutCheckBox(parent, showOnPane); + + setRichTextCategoryNameFormatPane(richTextCategoryNameFormatPane); + setRichTextSeriesNameFormatPane(richTextSeriesNameFormatPane); + setRichTextValueFormatPane(richTextValueFormatPane); + setRichTextPercentFormatPane(richTextPercentFormatPane); } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java new file mode 100644 index 0000000000..30b754dd00 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java @@ -0,0 +1,79 @@ +package com.fr.van.chart.wordcloud.designer.style; + + +import com.fr.design.i18n.Toolkit; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.style.VanChartStylePane; + +import javax.swing.JPanel; +import java.awt.Component; + +/** + * Created by mengao on 2017/6/9. + */ +public class VanChartWordCloudRefreshTooltipContentPane extends VanChartWordCloudTooltipContentPane { + public VanChartWordCloudRefreshTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { + super(null, showOnPane); + } + + @Override + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initFormatPane(parent, showOnPane); + + ChangedValueFormatPaneWithCheckBox changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane) { + @Override + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Change_Word_Value"); + } + }; + + ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); + + setChangedValueFormatPane(changedValueFormatPane); + setChangedPercentFormatPane(changedPercentFormatPane); + } + + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + super.initRichTextFormatPane(parent, showOnPane); + + ChangedValueFormatPaneWithoutCheckBox richTextChangedValueFormatPane = new ChangedValueFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Change_Word_Value"); + } + }; + + ChangedPercentFormatPaneWithoutCheckBox richTextChangedPercentFormatPane = new ChangedPercentFormatPaneWithoutCheckBox(parent, showOnPane); + + setRichTextChangedValueFormatPane(richTextChangedValueFormatPane); + setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); + } + + protected double[] getRowSize(double p) { + return new double[]{p, p, p, p, p, p}; + } + + protected Component[][] getPaneComponents() { + return new Component[][]{ + new Component[]{getCategoryNameFormatPane(), null}, + new Component[]{getSeriesNameFormatPane(), null}, + new Component[]{getValueFormatPane(), null}, + new Component[]{getChangedValueFormatPane(), null}, + new Component[]{getPercentFormatPane(), null}, + new Component[]{getChangedPercentFormatPane(), null}, + }; + } + + protected Component[][] getRichTextComponents() { + return new Component[][]{ + new Component[]{getRichTextCategoryNameFormatPane(), null}, + new Component[]{getRichTextSeriesNameFormatPane(), null}, + new Component[]{getRichTextValueFormatPane(), null}, + new Component[]{getRichTextChangedValueFormatPane(), null}, + new Component[]{getRichTextPercentFormatPane(), null}, + new Component[]{getRichTextChangedPercentFormatPane(), null} + }; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTootipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTootipContentPane.java deleted file mode 100644 index 4f748214f8..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTootipContentPane.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.fr.van.chart.wordcloud.designer.style; - - -import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; -import com.fr.van.chart.designer.style.VanChartStylePane; - -import javax.swing.JPanel; -import java.awt.Component; - -/** - * Created by mengao on 2017/6/9. - */ -public class VanChartWordCloudRefreshTootipContentPane extends VanChartWordCloudTooltipContentPane { - public VanChartWordCloudRefreshTootipContentPane(VanChartStylePane parent, JPanel showOnPane) { - super(null, showOnPane); - } - - @Override - protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - super.initFormatPane(parent, showOnPane); - - changedValueFormatPane = new ChangedValueFormatPaneWithCheckBox(parent, showOnPane){ - @Override - protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Change_Word_Value"); - } - }; - - changedPercentFormatPane = new ChangedPercentFormatPaneWithCheckBox(parent, showOnPane); - } - - protected double[] getRowSize(double p){ - return new double[]{p,p,p,p,p,p}; - } - - protected Component[][] getPaneComponents(){ - return new Component[][]{ - new Component[]{categoryNameFormatPane,null}, - new Component[]{seriesNameFormatPane,null}, - new Component[]{valueFormatPane,null}, - new Component[]{changedValueFormatPane,null}, - new Component[]{percentFormatPane,null}, - new Component[]{changedPercentFormatPane,null}, - }; - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java index 08845b2b7a..850645c758 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java @@ -1,13 +1,18 @@ package com.fr.van.chart.wordcloud.designer.style; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -22,25 +27,54 @@ public class VanChartWordCloudTooltipContentPane extends VanChartTooltipContentP @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { - categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane){ + CategoryNameFormatPaneWithCheckBox categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane) { @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); + return Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); } }; - seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane){ + SeriesNameFormatPaneWithCheckBox seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane) { @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Word_Name"); + return Toolkit.i18nText("Fine-Design_Chart_Word_Name"); } }; - valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane){ + ValueFormatPaneWithCheckBox valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane) { @Override protected String getCheckBoxText() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Word_Value"); + return Toolkit.i18nText("Fine-Design_Chart_Word_Value"); } }; - percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + PercentFormatPaneWithCheckBox percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); + + setCategoryNameFormatPane(categoryNameFormatPane); + setSeriesNameFormatPane(seriesNameFormatPane); + setValueFormatPane(valueFormatPane); + setPercentFormatPane(percentFormatPane); + } + + protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { + CategoryNameFormatPaneWithoutCheckBox richTextCategoryNameFormatPane = new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); + } + }; + SeriesNameFormatPaneWithoutCheckBox richTextSeriesNameFormatPane = new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Word_Name"); + } + }; + ValueFormatPaneWithoutCheckBox richTextValueFormatPane = new ValueFormatPaneWithoutCheckBox(parent, showOnPane) { + protected String getCheckBoxText() { + return Toolkit.i18nText("Fine-Design_Chart_Word_Value"); + } + }; + PercentFormatPaneWithoutCheckBox richTextPercentFormatPane = new PercentFormatPaneWithoutCheckBox(parent, showOnPane); + + setRichTextCategoryNameFormatPane(richTextCategoryNameFormatPane); + setRichTextSeriesNameFormatPane(richTextSeriesNameFormatPane); + setRichTextValueFormatPane(richTextValueFormatPane); + setRichTextPercentFormatPane(richTextPercentFormatPane); } @Override diff --git a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.css b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.css new file mode 100644 index 0000000000..27eb74d9b2 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.css @@ -0,0 +1,22 @@ +.editor-insert-param-inactivated-font .b-font { + *zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = ''); +} +.editor-insert-param-inactivated-font .b-font:before { + content: "\e6ea"; + color: inherit; +} +.editor-insert-param-inactivated-font.disabled .b-font:before { + content: "\e6ea"; + color: inherit; +} +.editor-insert-param-active-font .b-font { + *zoom: expression( this.runtimeStyle['zoom'] = '1',this.innerHTML = ''); +} +.editor-insert-param-active-font .b-font:before { + content: "\e6ea"; + color: #23beef; +} +.editor-insert-param-active-font.disabled .b-font:before { + content: "\e6ea"; + color: #23beef; +} \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html new file mode 100644 index 0000000000..1f50c2ddfd --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.constant.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.constant.js new file mode 100644 index 0000000000..3642aed285 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.constant.js @@ -0,0 +1,6 @@ +!(function () { + + BI.constant("bi.constant.design.chart.common.editor.placeholder_style", { + fontColor: "#c4c9d1" + }); +}()); \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js new file mode 100644 index 0000000000..d0e49dd5f9 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js @@ -0,0 +1,255 @@ +!(function () { + var Widget = BI.inherit(BI.Widget, { + props: { + baseCls: "bi-design-chart-common-editor", + isAuto: true, + content: "", + placeholder: "", + fontStyle: {}, + dimensionIds: [], + toolbar: { + buttons: [] + }, + textAlign: "center" + }, + + _store: function () { + var o = this.options; + + return BI.Models.getModel("bi.model.design.chart.common.editor", { + dimensionIds: o.dimensionIds, + isAuto: o.isAuto + }); + }, + + render: function () { + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.nic_editor", + $value: "chart-common-editor", + height: 365, + cls: "editor bi-border bi-focus-shadow " + (o.textAlign === "center" ? "editor-center-text" : ""), + listeners: [{ + eventName: BI.NicEditor.EVENT_FOCUS, + action: function () { + self.clearPlaceholder(); + self.store.setEditorBlurState(false); + } + }, { + eventName: BI.NicEditor.EVENT_BLUR, + action: function () { + self.setPlaceholder(); + self.store.setEditorBlurState(true); + } + }] + }); + + return { + type: "bi.vtape", + ref: function (_ref) { + self.bar = _ref; + }, + items: [{ + type: "bi.htape", + items: [{ + type: "bi.label", + text: "字体样式: ", + textAlign: "left", + width: 70 + }, { + type: "bi.button_group", + items: this.model.fontStyleItems, + ref: function (_ref) { + self.fontStyleGroup = _ref; + }, + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function () { + var isAuto = this.getValue()[0]; + self.store.changeIsAuto(isAuto); + self.changeFontStyleMode(isAuto); + } + }], + layouts: [{ + type: "bi.left", + rgap: 5 + }], + value: this.model.mode, + width: 125 + }, this._getToolBar()], + height: 24 + }, { + el: this.editor, + tgap: 10 + }] + }; + }, + + _getToolBar: function () { + var self = this; + return { + type: "bi.design.chart.common.editor.toolbar", + cls: "toolbar-region", + wId: this.options.wId, + editor: this.editor, + buttons: this.options.toolbar.buttons, + ref: function (_ref) { + self.toolbar = _ref; + } + }; + }, + + mounted: function () { + this.editor.bindToolbar(this.bar); + this.editor.setValue(this._formatContent(this.options.content)); + this.setFocus(); + }, + + _cleanHtml: function (value) { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + var dimensionIds = this.options.dimensionIds; + var dataIdMap = {}; + + for (var i = 0, len = dimensionIds.length; i < len; i++) { + var dimensionId = dimensionIds[i]; + var key = BI.keys(dimensionId)[0]; + + dataIdMap[key] = dimensionId[key]; + } + + var result = BI.replaceAll(value, "

", ""); + // 去掉image的src属性,因为数据太大了 + result = value.replaceAll("", function (imageStr) { + var attrs = editorService.getImageAttr(imageStr); + var str = ""; + }); + + return result; + }, + + getValue: function () { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + var value = this._cleanHtml(this.editor.getValue(BI.NicEditor.FormatType.ESCAPE)); + // BI.each(this.model.dimensionIds, function (idx, dId) { + // var fullName = BI.Utils.getNotGeoDimensionFullName(dId); + // value = editorService.appendImageAttr(value, fullName, BICst.RICH_TEXT_INFO.DATA_ID, dId); + // }); + + if (editorService.isEmptyRichText(value)) { + value = ""; + } + + if (BI.isNotEmptyString(this.options.placeholder) && editorService.isRichTextEqual(value, this.options.placeholder)) { + value = null; + } + + return { + isAuto: this.model.isAuto, + content: value + }; + }, + + setValue: function (obj) { + var keys = BI.keys(obj); + if (BI.contains(keys, "content")) { + this.editor.setValue(this._formatContent(obj.content)); + } + if (BI.contains(keys, "isAuto")) { + this.store.changeIsAuto(obj.isAuto); + this.fontStyleGroup.setValue(obj.isAuto); + } + }, + + _formatContent: function (content) { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + + content = editorService.setImageSrc(content); + + if (editorService.isBlankRichText(content) + || editorService.isRichTextEqual(content, this.options.placeholder)) { + content = this.options.placeholder || ""; + } + + return content; + }, + + // 切换到“自动”时的处理方法 + _switchToAutoStyle: function () { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"), + content = this.editor.getValue(BI.NicEditor.FormatType.ESCAPE), + isEqualToPlaceholder = editorService.isRichTextEqual(content, this.options.placeholder); + + var HTML_ONLY_STYLE_TAG = "||||||||||||||||||||

"; + + if (!isEqualToPlaceholder) { + content = content.replaceAll(HTML_ONLY_STYLE_TAG, ""); + } + + return content; + }, + + clearPlaceholder: function () { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + var content = this.editor.getValue(BI.NicEditor.FormatType.ESCAPE); + var isSameContent = editorService.isRichTextEqual(content, this.options.placeholder); + + if (isSameContent) { + content = editorService.convertText2RichText("", this.options.fontStyle); + this.editor.setValue(content); + this.setFocus(); + } + }, + + setPlaceholder: function () { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + var content = this.editor.getValue(BI.NicEditor.FormatType.ESCAPE); + var isSameContent = editorService.isBlankRichText(content); + + if (isSameContent) { + this.editor.setValue(this.options.placeholder); + } + }, + + // 字体样式切换 + changeFontStyleMode: function (isAuto) { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + var switchFn = this.options.switchFn, + content = this.editor.getValue(BI.NicEditor.FormatType.ESCAPE), + origin = content; + if (isAuto) { + content = this._switchToAutoStyle(); + this.setFocus(); + } else if (editorService.isRichTextEqual(content, this.options.placeholder)) { + content = ""; + } + if (BI.isFunction(switchFn)) { + content = switchFn(isAuto, content); + } + if (content !== origin) { + this.editor.setValue(content); + } + }, + + setFocus: function () { + var instance = this.editor.instance; + instance && instance.initSelection(); + } + }); + + Widget.EVENT_CHANGE = "EVENT_CHANGE"; + + BI.shortcut("bi.design.chart.common.editor", Widget); + +}()); diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js new file mode 100644 index 0000000000..dbe2784463 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js @@ -0,0 +1,53 @@ +!(function () { + + var Model = BI.inherit(Fix.Model, { + childContext: ["isAuto", "dimensionIds"], + + state: function () { + var o = this.options; + + return { + isAuto: o.isAuto, + dimensionIds: o.dimensionIds, + isEditorBlur: true + }; + }, + + computed: { + fontStyleItems: function () { + return [{ + type: "bi.single_select_radio_item", + text: "自动", + hgap: 5, + logic: { + dynamic: true + }, + value: true, + selected: this.options.isAuto + }, { + type: "bi.single_select_radio_item", + text: "自定义", + hgap: 5, + logic: { + dynamic: true + }, + value: false, + selected: !this.options.isAuto + }]; + } + }, + + actions: { + changeIsAuto: function (isAuto) { + this.model.isAuto = isAuto; + }, + + setEditorBlurState: function (isBlur) { + this.model.isEditorBlur = isBlur; + } + } + }); + + BI.model("bi.model.design.chart.common.editor", Model); + +}()); diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.service.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.service.js new file mode 100644 index 0000000000..87fa2bdf62 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.service.js @@ -0,0 +1,562 @@ +!(function () { + + /** + * HTML解析类,使用方法: + * new HTMLParser().parse(htmlText, { + * startTag: function (tagName, attrs) {}, + * endTag: function (tagName) {}, + * text: function (text) {} + * }) + */ + function HTMLParser () { + + } + + HTMLParser.prototype = { + constructor: HTMLParser, + + startTagPattern: /<([-\w\d_]+)\s*([^>]*)\s*(\/?)>/, + endTagPattern: /^<\/([-\w\d_]+)[^>]*>/, + attrPattern: /([-\w\d_]+)\s*=\s*["']([^"']*)["']/g, + // 特殊的字符 + specialCharsPatterns: [{ + pattern: / /g, + subStr: " " + }, { + pattern: /</g, + subStr: "<" + }, { + pattern: />/g, + subStr: ">" + }, { + pattern: /&/g, + subStr: "&" + }], + + handle: { + // 以下为处理开始标签和文本的时候触发的函数,可以自定义 + startTag: function () { + }, + endTag: function () { + }, + text: function () { + } + }, + + /** + * + * @param html + * @param handle + * @param isReplaceSpecialChars 是否需要替换HTML中的特殊字符 + */ + parse: function (html, handle, isReplaceSpecialChars) { + var index, isText = false, + match, last = html, + me = this; + + isReplaceSpecialChars = isReplaceSpecialChars !== null ? isReplaceSpecialChars : true; + + if (BI.isPlainObject(handle)) { + BI.isFunction(handle.startTag) && (this.handle.startTag = handle.startTag); + BI.isFunction(handle.endTag) && (this.handle.endTag = handle.endTag); + BI.isFunction(handle.text) && (this.handle.text = handle.text); + } + + while (html) { + isText = true; + + // 结束标签 + if (html.indexOf("'$%{}"]/.test(params)) { + return window.encodeURIComponent(params).replace(/'/g, escape); + } + return params; + }, + + decode: function (params) { + try { + var result = window.decodeURIComponent(params); + if (/[<>'$%{}"]/.test(result)) { + return result; + } + return params; + } catch (e) { + return params; + } + }, + + HTMLParser: HTMLParser, + + getImageAttr: getImageAttr, + + /** + * 构造一个富文本中的参数图片 + */ + getEditorParamImage: function (param, fillStyle) { + var attr = BI.DOM.getImage(param, fillStyle); + return "" + this.encode(attr.param)
+                + ""; + }, + + /** + * 给image设置属性 + */ + appendImageAttr: function (html, altValue, attrName, attrValue, isCovered) { + altValue = this.encode(altValue); + attrName = this.encode(attrName); + attrValue = this.encode(attrValue); + isCovered = isCovered || false; // 属性是否可以覆盖 + + return html.replaceAll("", function (imageStr) { + var attrs = getImageAttr(imageStr); + + if (attrs && attrs["alt"] === altValue && (BI.isNull(attrs[attrName]) || isCovered)) { + attrs[attrName] = attrValue; + imageStr = ""; + }); + + return { + startHtml: startHtml, + endHtml: endHtml + }; + }, + + /** + * 将富文本HTML转化成普通的文本,不需要记录fontStyle + */ + convertRichText2Text: function (html) { + var content = "", + line = "", + htmlFragments = []; + + new HTMLParser().parse(html, { + startTag: function (tagName, attrs) { + // 只关心br、img + switch (tagName) { + case "br": + line += "\n"; + htmlFragments.push(tagName); + break; + case "img": + BI.each(attrs, function (idx, obj) { + if (obj.name === "alt") { + line += "${" + obj.value + "}"; + } + }); + break; + default: + break; + } + }, + endTag: function (tagName) { + if (tagName === "div") { + //

这样的情况下应该只代表一个回车符 + htmlFragments[htmlFragments.length - 1] !== "br" && (line += "\n"); + htmlFragments = []; + } + + content += line; + line = ""; + }, + text: function (text) { + htmlFragments.push(text); + line += text; + } + }); + + // 去掉最后的换行符 + content = content.replace(/\n$/, ""); + + return content; + }, + + convertImage2Text: function (html) { + if (BI.isNull(html)) { + return html; + } + return html.replaceAll("", function (imageStr) { + var matched = imageStr.match(/alt="(.*?)"/); + var startHtml = ""; + var endHtml = ""; + return startHtml + (matched ? matched[1] : imageStr) + endHtml; + }); + }, + + isRichTextEqual: function (html1, html2) { + if (BI.isNotNull(html1)) { + html1 = this.convertImage2Text(html1); + } + if (BI.isNotNull(html2)) { + html2 = this.convertImage2Text(html2); + } + + return html1 === html2; + }, + + isRichTextNotEqual: function (html1, html2) { + return !this.isRichTextEqual(html1, html2); + }, + + isBlankRichText: function (html) { + html = html || ""; + html = this.convertRichText2Text(html); + return BI.trim(html).length === 0; + }, + + // 显示整个富文本中缺失的字段 + showMissingFields: function (html, validDimensionIds) { + var self = this; + + return html.replaceAll("", function (imageStr) { + var attrs = getImageAttr(imageStr); + return attrs && BI.contains(validDimensionIds, attrs[BICst.RICH_TEXT_INFO.DATA_ID]) + ? imageStr + : self.getMissingFieldImage( + attrs[BICst.RICH_TEXT_INFO.DATA_ID], + attrs[BICst.RICH_TEXT_INFO.DATA_NAME], + attrs[BICst.RICH_TEXT_INFO.ALT] + ); + }); + }, + + // 获取缺失元素的图片 + getMissingFieldImage: function (dId, name, fullName) { + var missingText = ""; + var missingImage = BI.DOM.getImage(missingText, "#ff0000"); + var html = this.getEditorParamImage(fullName, "#ff0000"); + + // 将原来的dId、name、fullName保存起来 + html = this.appendImageAttr(html, fullName, BICst.RICH_TEXT_INFO.DATA_ORIGIN_ID, dId); + html = this.appendImageAttr(html, fullName, BICst.RICH_TEXT_INFO.DATA_ORIGIN_NAME, name); + html = this.appendImageAttr(html, fullName, BICst.RICH_TEXT_INFO.DATA_ORIGIN_FULL_NAME, fullName); + html = this.appendImageAttr(html, fullName, BICst.RICH_TEXT_INFO.SRC, missingImage.src, true); + // 标记出这个参数是一个“缺失元素” + html = this.appendImageAttr(html, fullName, BICst.RICH_TEXT_INFO.DATA_IS_MISSING_FIELD, "true", true); + html = this.appendImageAttr(html, fullName, "style", missingImage.style, true); + return html; + }, + + // 将“缺失元素”替换成原来的字段 + restoreMissingField: function (html) { + var self = this; + + return html.replaceAll("", function (imageStr) { + var attrs = getImageAttr(imageStr); + + if (attrs && attrs[BICst.RICH_TEXT_INFO.DATA_ORIGIN_ID]) { + var fullName = attrs[BICst.RICH_TEXT_INFO.DATA_ORIGIN_FULL_NAME]; + var image = self.getEditorParamImage(fullName); + + image = self.appendImageAttr(image, fullName, BICst.RICH_TEXT_INFO.DATA_ID, attrs[BICst.RICH_TEXT_INFO.DATA_ORIGIN_ID]); + image = self.appendImageAttr(image, fullName, BICst.RICH_TEXT_INFO.DATA_NAME, attrs[BICst.RICH_TEXT_INFO.DATA_ORIGIN_NAME]); + return image; + } + + if (attrs + && attrs[BICst.RICH_TEXT_INFO.DATA_IS_INSERT_PARAM] + && !attrs[BICst.RICH_TEXT_INFO.DATA_ID] + ) { + imageStr = self.appendImageAttr( + imageStr, + attrs[BICst.RICH_TEXT_INFO.ALT], + BICst.RICH_TEXT_INFO.DATA_UN_VALID, + "true", + true + ); + } + + return imageStr; + }); + }, + + // 将富文本字符串中由用户主动插入的字段参数标记出来 + markTheInsertParamImages: function (html) { + return html.replaceAll("", function (imageStr) { + var attrs = getImageAttr(imageStr); + + // "缺失元素"和普通的字段参数直接过滤(从富文本编辑器中插入的参数只有data-id属性) + if (BI.has(attrs, BICst.RICH_TEXT_INFO.DATA_NAME) + || BI.has(attrs, BICst.RICH_TEXT_INFO.DATA_ORIGIN_ID)) { + return imageStr; + } + + attrs[BICst.RICH_TEXT_INFO.DATA_IS_INSERT_PARAM] = "true"; + imageStr = "", function (imageStr) { + var attrs = self.getImageAttr(imageStr); + // 已有src + if (BI.has(attrs, BICst.RICH_TEXT_INFO.SRC) && attrs[BICst.RICH_TEXT_INFO.SRC]) { + return imageStr; + } + var alt = self.decode(attrs[BICst.RICH_TEXT_INFO.ALT]); + var image = BI.DOM.getImage(alt); + imageStr = self.appendImageAttr(imageStr, alt, BICst.RICH_TEXT_INFO.SRC, image.src, true); + imageStr = self.appendImageAttr(imageStr, alt, "style", image.style, true); + return imageStr; + }); + }, + + isEmptyRichText: function (html) { + return "" === html.replaceAll("|

|
", ""); + }, + + // BI-23091 设置显示名之后更新参数名称 + getNewParamNameRichText: function (content) { + if (!content) { + return content; + } + var self = this; + return content.replaceAll("", function (imageStr) { + var attrs = self.getImageAttr(imageStr); + // 缺失元素 + if (attrs[BICst.RICH_TEXT_INFO.DATA_IS_MISSING_FIELD]) { + return imageStr; + } + var alt = attrs[BICst.RICH_TEXT_INFO.ALT], + dId = attrs[BICst.RICH_TEXT_INFO.DATA_ID], + name = BI.Utils.getNotGeoDimensionFullName(dId); + + if (name !== alt) { + imageStr = self.appendImageAttr(imageStr, alt, BICst.RICH_TEXT_INFO.ALT, name, true); + } + return imageStr; + }); + } + }); + + BI.service("bi.service.design.chart.common.editor", Service); + +}()); diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.js b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.js new file mode 100644 index 0000000000..841860fc02 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.js @@ -0,0 +1,114 @@ +!(function () { + var Widget = BI.inherit(BI.RichEditorParamAction, { + props: { + baseCls: "bi-design-chart-common-editor-insert-param", + dimensionIds: [], + editor: null + }, + + _store: function () { + return BI.Models.getModel("bi.model.design.chart.common.editor.insert_param"); + }, + + watch: { + isSelectedParam: function () { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + this.addParam(this.model.param, editorService.encode); + this.combo.hideView(); + // this._restorePosition(); + } + }, + + render: function () { + var self = this; + + var adapter = BI.createWidget({ + type: "bi.button_group", + items: this.model.items, + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + behaviors: {}, + layouts: [{ + type: "bi.vertical" + }], + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function () { + self._savePosition(); + self.store.changeParam(this.getValue()[0]); + } + }] + }); + + var searchPopup = { + type: "bi.vertical", + cls: "bi-border", + hgap: 15, + tgap: 5, + bgap: 10, + items: [{ + type: "bi.searcher", + adapter: adapter, + width: 210, + height: 24, + listeners: [{ + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + self.store.changeParam(this.getValue()[0]); + } + }] + }, adapter] + }; + + return { + type: "bi.combo", + direction: "bottom,left", + isNeedAdjustWidth: false, + el: { + type: "bi.vertical_adapt", + items: [{ + type: "bi.icon_change_button", + iconCls: "editor-insert-param-inactivated-font", + iconWidth: 24, + iconHeight: 24, + ref: function (_ref) { + self.iconButtonTrigger = _ref; + } + }] + }, + popup: { + el: searchPopup + }, + ref: function (_ref) { + self.combo = _ref; + }, + listeners: [{ + eventName: BI.Combo.EVENT_AFTER_POPUPVIEW, + action: function () { + self.iconButtonTrigger.setIcon("editor-insert-param-active-font"); + } + }, { + eventName: BI.Combo.EVENT_BEFORE_HIDEVIEW, + action: function () { + self.iconButtonTrigger.setIcon("editor-insert-param-inactivated-font"); + } + }] + }; + }, + + _savePosition: function () { + var instance = this._getInstance(); + instance.saveRng(); + }, + + _restorePosition: function () { + var instance = this._getInstance(); + instance.initSelection(); + }, + + _getInstance: function () { + return this.options.editor.selectedInstance || this.options.editor.getInstance(); + } + }); + + BI.shortcut("bi.design.chart.common.editor.insert_param", Widget); +}()); \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.model.js b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.model.js new file mode 100644 index 0000000000..10db72cd0e --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.model.js @@ -0,0 +1,40 @@ +/* + * @Maintainers: xiaofu.qin + */ +!(function () { + + var Model = BI.inherit(Fix.Model, { + context: ["dimensionIds"], + + state: function () { + return { + param: "", + isSelectedParam: false + }; + }, + + computed: { + items: function () { + return BI.map(this.model.dimensionIds, function (idx, dId) { + var key = BI.keys(dId)[0]; + + return { + type: "bi.design.chart.common.editor.search", + text: key, + value: key + }; + }); + } + }, + + actions: { + changeParam: function (param) { + this.model.isSelectedParam = !this.model.isSelectedParam; + this.model.param = param; + } + } + }); + + BI.model("bi.model.design.chart.common.editor.insert_param", Model); + +} ()); diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/item/item.js b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/item/item.js new file mode 100644 index 0000000000..bfd5644414 --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/item/item.js @@ -0,0 +1,38 @@ +!(function () { + + var Widget = BI.inherit(BI.BasicButton, { + props: { + text: "", + iconCls: "", + extraCls: "bi-list-item-active" + }, + + render: function () { + var o = this.options; + return { + type: "bi.vertical_adapt", + height: 25, + items: [{ + type: "bi.center_adapt", + cls: o.iconCls, + items: [{ + type: "bi.icon", + width: 16, + height: 16 + }], + width: 16, + height: 16 + }, { + type: "bi.label", + textAlign: "left", + lgap: 5, + text: o.text, + value: o.text + }] + }; + } + }); + + BI.shortcut("bi.design.chart.common.editor.search", Widget); + +}()); \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/disabled_bar_wrapper.js b/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/disabled_bar_wrapper.js new file mode 100644 index 0000000000..5b07ea39ff --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/disabled_bar_wrapper.js @@ -0,0 +1,22 @@ +/** + * 灰化toolbar的item + */ +!(function () { + + var Widget = BI.inherit(BI.Single, { + props: { + button: null + }, + + render: function () { + return { + type: "bi.vertical_adapt", + disabled: true, + items: [this.options.button] + }; + } + }); + + BI.shortcut("bi.design.chart.common.editor.toolbar.disabled_item_wrapper", Widget); + +}()); \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/toolbar.js b/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/toolbar.js new file mode 100644 index 0000000000..4246ec9bcb --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/toolbar.js @@ -0,0 +1,124 @@ +!(function () { + var RichEditorTextToolbar = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-rich-editor-text-toolbar", + height: 25, + editor: null, + buttons: [ + {type: "bi.rich_editor_font_chooser"}, + {type: "bi.rich_editor_size_chooser"}, + {type: "bi.rich_editor_bold_button"}, + {type: "bi.rich_editor_italic_button"}, + {type: "bi.rich_editor_underline_button"}, + {type: "bi.rich_editor_color_chooser"}, + {type: "bi.rich_editor_align_left_button"}, + {type: "bi.rich_editor_align_center_button"}, + {type: "bi.rich_editor_align_right_button"}, + {type: "bi.design.chart.common.editor.insert_param"} + ] + }, + + _store: function () { + return BI.Models.getModel("bi.model.design.chart.common.editor.toolbar"); + }, + + watch: { + isAuto: function (isAuto) { + this[isAuto ? "hideCustomFontTool" : "showCustomFontTool"](); + } + }, + + render: function () { + var self = this, + o = this.options; + + this.hasInsertCombo = o.buttons[o.buttons.length - 1].type === "bi.design.chart.common.editor.insert_param"; + + this.buttons = BI.createWidgets(BI.map(o.buttons, function (i, btn) { + return BI.extend(btn, { + editor: o.editor + }); + })); + + if (this.hasInsertCombo) { + var leftItems = BI.filter(this.buttons, function (idx) { + return idx !== self.buttons.length - 1; + }); + return { + type: "bi.left_right_vertical_adapt", + lrgap: 10, + items: { + left: this._getButtons(leftItems), + right: [this.buttons[this.buttons.length - 1]] + } + }; + } + + return { + type: "bi.vertical_adapt", + rgap: 10, + items: this._getButtons(this.buttons) + }; + }, + + mounted: function () { + var self = this; + if (BI.isIE9Below()) {// IE8下必须要设置unselectable才能不blur输入框 + this.element.mousedown(function () { + self._noSelect(self.element[0]); + }); + this._noSelect(this.element[0]); + } + + this.model.isAuto && this.hideCustomFontTool(); + }, + + _noSelect: function (element) { + if (element.setAttribute && element.nodeName.toLowerCase() !== "input" && element.nodeName.toLowerCase() !== "textarea") { + element.setAttribute("unselectable", "on"); + } + for (var i = 0; i < element.childNodes.length; i++) { + this._noSelect(element.childNodes[i]); + } + }, + + hideCustomFontTool: function () { + var self = this; + BI.each(this.buttons, function (idx, button) { + if (self.hasInsertCombo) { + idx !== self.buttons.length - 1 && button.setVisible(false); + } else { + button.setVisible(false); + } + }); + }, + + showCustomFontTool: function () { + var self = this; + BI.each(this.buttons, function (idx, button) { + if (self.hasInsertCombo) { + idx !== self.buttons.length - 1 && button.setVisible(true); + } else { + button.setVisible(true); + } + }); + }, + + _getButtons: function (buttons) { + return BI.map(buttons, function (idx, button) { + if (button.options.used === false) { + return { + type: "bi.design.chart.common.editor.toolbar.disabled_item_wrapper", + button: button, + title: button.options.title + }; + } + + return button; + }); + } + }); + + BI.shortcut("bi.design.chart.common.editor.toolbar", RichEditorTextToolbar); +})(); \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/toolbar.model.js b/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/toolbar.model.js new file mode 100644 index 0000000000..96e30eee4d --- /dev/null +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/toolbar/toolbar.model.js @@ -0,0 +1,12 @@ +/* + * @Maintainers: xiaofu.qin + */ +!(function () { + + var Model = BI.inherit(Fix.Model, { + context: ["isAuto", "wId", "dimensionIds"] + }); + + BI.model("bi.model.design.chart.common.editor.toolbar", Model); + +} ()); \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index dfb4d94090..24c3a19dbc 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -3,6 +3,7 @@ */ package com.fr.design.designer.beans.adapters.layout; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.GroupModel; import com.fr.design.designer.beans.ConstraintsGroupModel; import com.fr.design.designer.beans.HoverPainter; @@ -18,6 +19,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FRFitLayoutConstraints; import com.fr.design.designer.properties.FRFitLayoutPropertiesGroupModel; +import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WAbsoluteLayout; @@ -32,6 +34,7 @@ import java.awt.Dimension; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** * 自适应布局的容器适配器 @@ -161,7 +164,8 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { //布局控件要先判断是不是可编辑 XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); - if (topLayout != null && !isMatchEdge && !topLayout.isEditable() && !topLayout.acceptType(XWAbsoluteLayout.class)) { + boolean access = topLayout != null && !isMatchEdge && !topLayout.isEditable() && !topLayout.acceptType(XWAbsoluteLayout.class) && !isExtraContainer(comp); + if (access) { return false; } @@ -178,6 +182,18 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { return y > upHeight && y < downHeight ? horizonValid : verticalValid; } + private boolean isExtraContainer(Component comp) { + if (container != null) { + Set set = ExtraDesignClassManager.getInstance().getArray(FormWidgetOptionProvider.XML_TAG); + for (FormWidgetOptionProvider provider : set) { + if (provider.isContainer() && ComparatorUtils.equals(provider.appearanceForWidget(), comp.getClass())) { + return true; + } + } + } + return false; + } + // 间隔区域 private boolean checkInterval(Component comp) { return container.getComponentCount() > 0 && comp == container; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index 42db0d8503..b3215ede1c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -310,7 +310,6 @@ public class SelectionModel { designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); - designer.getTopXCreators().refresh(); // 触发事件 diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index f846f29bd2..c002bceb38 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -17,8 +17,6 @@ import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.HelpDialogManager; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.module.DesignModuleFactory; import com.fr.form.ui.BaseChartEditor; @@ -231,6 +229,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator { */ public void paint(Graphics g) { designerEditor.paintEditor(g, this.getSize()); + if (coverPanel != null) { + coverPanel.setSize(this.getSize()); + } super.paint(g); if (isEditing) { g.setColor(INNER_BORDER_COLOR); @@ -361,34 +362,4 @@ public class XChartEditor extends XBorderStyleWidgetCreator { return false; } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXChart(this); - } - - private class TopXChart extends TopXCreator { - private final DesignerEditor designerEditor; - - public TopXChart(XCreator creator) { - super(creator); - designerEditor = creator.getDesignerEditor(); - Rectangle bounds = getBounds(); - designerEditor.getEditorTarget().setBounds(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2); - } - - /** - * 更新designerEditor的大小 - */ - protected void resetSize(Rectangle bounds) { - super.resetSize(bounds); - designerEditor.getEditorTarget().setBounds(bounds.x + 1, bounds.y + 1, bounds.width - 2, bounds.height - 2); - } - - @Override - public void paint(Graphics g) { - designerEditor.paintEditor(g, this.getSize()); - super.paint(g); - } - } - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java index 20f2788117..ec83a1f9a5 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java @@ -19,22 +19,16 @@ import com.fr.design.mainframe.CoverReportPane; import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.NoSupportAuthorityEdit; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.gui.LayoutUtils; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.third.javax.annotation.Nullable; import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.ImageIcon; import javax.swing.JComponent; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.Border; import java.awt.BorderLayout; @@ -44,7 +38,6 @@ import java.awt.Dimension; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.MouseEvent; -import java.awt.image.BufferedImage; import java.beans.IntrospectionException; import java.util.ArrayList; import java.util.List; @@ -813,31 +806,10 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo } /** - * 获得该组件的顶层显示组件 + * 是否支持置顶显示 */ - @Nullable - public BasicTopXCreator getTopXCreator() { - return new BasicTopXCreator(this) { - @Override - protected void addComponent() { - Icon icon = new ImageIcon(getImage()); - JLabel jLabel = new JLabel(icon, JLabel.CENTER); - jLabel.setSize(getSize()); - this.add(jLabel); - } - }; - } - - /** - * 获得组件的图像 - */ - public BufferedImage getImage() { - BufferedImage image = CoreGraphHelper.createBufferedImage(getWidth(), getHeight()); - Graphics g = image.createGraphics(); - this.paint(g); - return image; + public boolean isTopable() { + return true; } - - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index 42069e4d8a..260318023e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java @@ -336,4 +336,25 @@ public class XCreatorUtils { } return IOUtils.readIcon(iconPath); } + + public static boolean containComponent(Container ancestor, Container xCreator) { + while (xCreator != null && xCreator.getParent() != ancestor) { + xCreator = xCreator.getParent(); + } + return xCreator != null; + } + + /** + * 获取组件的上一层的XMainBorderLayout,没有则返回null + * */ + @Nullable + public static XWCardMainBorderLayout getTopXMainBorderLayout(Container creator) { + while (creator != null) { + if (creator instanceof XWCardMainBorderLayout) { + return (XWCardMainBorderLayout) creator; + } + creator = creator.getParent(); + } + return null; + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index d84fd2e0cd..718c30aeb6 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -13,8 +13,6 @@ import com.fr.design.mainframe.widget.editors.ElementCaseToolBarEditor; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; import com.fr.design.mainframe.widget.propertypane.BrowserFitPropertyEditor; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.FormProvider; @@ -374,19 +372,4 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme return true; } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXElementCase(this); - } - - private class TopXElementCase extends TopXCreator { - private UILabel imageLabel; - - public TopXElementCase(XCreator creator) { - super(creator); - imageLabel = initImageBackground(); - add(imageLabel); - } - } - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index 5db000e189..2c88e62525 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -7,7 +7,6 @@ import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.WidgetPropertyUIProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.stable.core.PropertyChangeAdapter; @@ -133,7 +132,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { } @Override - public BasicTopXCreator getTopXCreator() { - return null; + public boolean isTopable() { + return false; } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 98143a7ea0..da268b0e6c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -25,8 +25,6 @@ import com.fr.design.mainframe.FormArea; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetHelpDialog; import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.form.ui.Connector; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; @@ -610,8 +608,4 @@ public class XWAbsoluteLayout extends XLayoutContainer { } } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXCreator(this); - } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 06aca3c1b3..3e425b4cd9 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -1222,6 +1222,11 @@ public class XWFitLayout extends XLayoutContainer { return false; } + @Override + public boolean isTopable() { + return false; + } + public boolean switch2FitBodyLayout(XCreator creator) { try { XWFitLayout xfl = (XWFitLayout) creator.getBackupParent(); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java index 384ee07b64..1d37024d98 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java @@ -15,7 +15,6 @@ import com.fr.design.mainframe.widget.editors.BooleanEditor; import com.fr.design.mainframe.widget.editors.WidgetDisplayPosition; import com.fr.design.mainframe.widget.renderer.BackgroundRenderer; import com.fr.design.mainframe.widget.renderer.WidgetDisplayPositionRender; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WParameterLayout; @@ -253,9 +252,7 @@ public class XWParameterLayout extends XWAbsoluteLayout { } @Override - public BasicTopXCreator getTopXCreator() { - return null; + public boolean isTopable() { + return false; } - - } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index b8fe8f0049..964f0aa03d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -7,7 +7,6 @@ import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.adapters.layout.FRTitleLayoutAdapter; import com.fr.design.form.layout.FRTitleLayout; import com.fr.design.fun.WidgetPropertyUIProvider; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; import com.fr.form.ui.Label; import com.fr.form.ui.Widget; import com.fr.form.ui.WidgetTitle; @@ -191,8 +190,4 @@ public class XWTitleLayout extends DedicateLayoutContainer { return creator.getWidgetPropertyUIProviders(); } - @Override - public BasicTopXCreator getTopXCreator() { - return getEditingChildCreator().getTopXCreator(); - } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 3ad1463b97..5b37ad313f 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 @@ -23,8 +23,6 @@ import com.fr.design.mainframe.EditingMouseListener; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetHelpDialog; import com.fr.design.mainframe.WidgetPropertyPane; -import com.fr.design.mainframe.widget.topxcreator.BasicTopXCreator; -import com.fr.design.mainframe.widget.topxcreator.TopXCreator; import com.fr.form.event.Listener; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.LayoutBorderStyle; @@ -515,8 +513,4 @@ public class XWCardMainBorderLayout extends XWBorderLayout { return true; } - @Override - public BasicTopXCreator getTopXCreator() { - return new TopXCreator(this); - } } 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 8d5d232fa6..a706674c7b 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 @@ -639,4 +639,8 @@ public class XWTabFitLayout extends XWFitLayout { checkVisible(); } + @Override + public boolean isTopable() { + return true; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java b/designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java index 78b606a7fc..48938dceee 100644 --- a/designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java +++ b/designer-form/src/main/java/com/fr/design/designer/treeview/ComponentTreeCellRenderer.java @@ -3,60 +3,53 @@ package com.fr.design.designer.treeview; import com.fr.design.constants.UIConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.gui.ilable.UILabel; import com.fr.log.FineLoggerFactory; +import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; import java.awt.Component; -import java.awt.Dimension; public class ComponentTreeCellRenderer extends DefaultTreeCellRenderer { - public ComponentTreeCellRenderer() { - } - - @Override - public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, - boolean leaf, int row, boolean hasFocus) { - super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); - if (value instanceof XCreator) { - String name = ((XCreator) value).toData().getWidgetName(); - setText(name); - Icon icon = null; - try { - icon = XCreatorUtils.getCreatorIcon((XCreator) value); - } catch (Exception e) { - FineLoggerFactory.getLogger().info("{} has not icon or has been deleted", name); - } - if (icon != null) { - setIcon(icon); - } - } - UILabel label = new UILabel(); - label.setText(getText()); - label.setIcon(getIcon()); - Dimension dim = label.getPreferredSize(); - dim.height += 2; - this.setSize(dim); - this.setPreferredSize(dim); - this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); - return this; - } - - @Override - public Icon getClosedIcon() { - return getIcon(); - } - - @Override - public Icon getLeafIcon() { - return getIcon(); - } - - @Override - public Icon getOpenIcon() { - return getIcon(); - } -} \ No newline at end of file + public ComponentTreeCellRenderer() { + } + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, + boolean leaf, int row, boolean hasFocus) { + super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus); + if (value instanceof XCreator) { + String name = ((XCreator) value).toData().getWidgetName(); + setText(name); + Icon icon = null; + try { + icon = XCreatorUtils.getCreatorIcon((XCreator) value); + } catch (Exception e) { + FineLoggerFactory.getLogger().info("{} has not icon or has been deleted", name); + } + if (icon != null) { + setIcon(icon); + } + } + this.setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); + this.setBackgroundNonSelectionColor(UIConstants.TREE_BACKGROUND); + return this; + } + + @Override + public Icon getClosedIcon() { + return getIcon(); + } + + @Override + public Icon getLeafIcon() { + return getIcon(); + } + + @Override + public Icon getOpenIcon() { + return getIcon(); + } +} diff --git a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java index 46377b1adf..3e248f3bae 100644 --- a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java +++ b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java @@ -1,5 +1,9 @@ package com.fr.design.form.util; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.JTemplate; @@ -7,6 +11,7 @@ import com.fr.design.mainframe.template.info.ComponentCreateOperate; import com.fr.design.mainframe.template.info.ComponentDeleteOperate; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WFitLayout; +import java.awt.Container; public class FormDesignerUtils { @@ -17,7 +22,7 @@ public class FormDesignerUtils { * @return */ public static boolean isAppRelayout(FormDesigner designer) { - if (!designer.getRootComponent().acceptType(WFitLayout.class)) { + if (!designer.getRootComponent().acceptType(XWFitLayout.class)) { return false; } return ((WFitLayout) designer.getRootComponent().toData()).isAppRelayout(); @@ -45,4 +50,21 @@ public class FormDesignerUtils { jTemplate.getProcessInfo().updateTemplateOperationInfo(new ComponentDeleteOperate(widget)); } + /** + * 判断当前UI组件是否在绝对画布块中 + * + * @param xCreator + * @return + */ + public static boolean isInAbsoluteLayout(XCreator xCreator) { + Container parent = xCreator.getParent(); + while (parent != null) { + if (parent instanceof XWAbsoluteLayout && !(parent instanceof XWAbsoluteBodyLayout)) { + return true; + } + parent = parent.getParent(); + } + return false; + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java index 4dd84f528b..ee667fd38c 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/ComponentTree.java @@ -90,7 +90,6 @@ public class ComponentTree extends JTree { public void setSelectionPath(TreePath path) { // 不管点击哪一项,都要先退出编辑状态(图表、报表块、绝对布局、tab块) designer.stopEditing(path); - designer.getTopXCreators().refresh(); super.setSelectionPath(path); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 6dcf7f34b7..0e66964b43 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -177,8 +177,8 @@ public class EditingMouseListener extends MouseInputAdapter { if (designer.isDrawLineMode()) { designer.updateDrawLineMode(e); } else { - int relativeX = Math.max(0, designer.getRelativeX(e.getX())); - int relativeY = Math.max(0, designer.getRelativeY(e.getY())); + int relativeX = Math.max(0, e.getX()); + int relativeY = Math.max(0, e.getY()); if (selectionModel.hasSelectionComponent() && selectionModel.getSelection().getRelativeBounds().contains( @@ -316,7 +316,6 @@ public class EditingMouseListener extends MouseInputAdapter { XCreator component = designer.getComponentAt(e); setCoverPaneNotDisplay(component, e, false); - designer.getTopXCreators().displayCoverPane(e); if (processTopLayoutMouseMove(component, e)) { return; @@ -364,7 +363,7 @@ public class EditingMouseListener extends MouseInputAdapter { designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } // component.getParent() 是报表块所在的XWTitleLayout int minX = button.getX() + getParentPositionX(component, 0) - designer.getHorizontalScaleValue(); - int minY = button.getY() + getParentPositionY(component, 0) - designer.getVerticalScaleValue(); + int minY = button.getY() + getParentPositionY(component, 0) - designer.getVerticalScaleValue() + xElementCase.getY(); if (e.getX() + GAP - xElementCase.getInsets().left > minX && e.getX() - GAP - xElementCase.getInsets().left < minX + button.getWidth()) { if (e.getY() + GAP - xElementCase.getInsets().top > minY && e.getY() - GAP - xElementCase.getInsets().top < minY + button.getHeight()) { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); @@ -406,16 +405,7 @@ public class EditingMouseListener extends MouseInputAdapter { } private void setCoverPaneNotDisplay(XCreator component, MouseEvent e, boolean isLinkedHelpDialog) { - if (xElementCase != null) { - int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue(); - int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue(); - Rectangle rect = new Rectangle(x, y, xElementCase.getWidth(), xElementCase.getHeight()); - if (rect.contains(e.getPoint())) { - return; - } - xElementCase.displayCoverPane(false); - } if (xChartEditor != null) { xChartEditor.displayCoverPane(false); } @@ -426,6 +416,15 @@ public class EditingMouseListener extends MouseInputAdapter { if (xTopLayoutContainer != null) { xTopLayoutContainer.setMouseEnter(false); } + //不知道为什么要对XElementCase进行判断,但是直接return会有bug,所以把他放在最后 + if (xElementCase != null) { + int x = getParentPositionX(xElementCase, 0) - designer.getArea().getHorizontalValue(); + int y = getParentPositionY(xElementCase, 0) - designer.getArea().getVerticalValue(); + Rectangle rect = new Rectangle(x, y, xElementCase.getWidth(), xElementCase.getHeight()); + if (!rect.contains(e.getPoint())) { + xElementCase.displayCoverPane(false); + } + } designer.repaint(); } @@ -463,7 +462,7 @@ public class EditingMouseListener extends MouseInputAdapter { designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } int minX = button.getX() + getParentPositionX(component, 0) - designer.getHorizontalScaleValue(); - int minY = button.getY() + getParentPositionY(component, 0) - designer.getVerticalScaleValue(); + int minY = button.getY() + getParentPositionY(component, 0) - designer.getVerticalScaleValue() + xChartEditor.getY(); if (e.getX() + GAP > minX && e.getX() - GAP < minX + button.getWidth()) { if (e.getY() + GAP > minY && e.getY() - GAP < minY + button.getHeight()) { designer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index 5cb0157f9e..c4fa2df8a1 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -35,9 +35,9 @@ import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWBorderLayout; -import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.creator.XWTitleLayout; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; +import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FormWidgetAuthorityEditPane; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.DesignerOpenedListener; @@ -45,7 +45,6 @@ import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.fun.RightSelectionHandlerProvider; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; -import com.fr.design.mainframe.widget.topxcreator.TopXCreators; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; @@ -189,7 +188,7 @@ public class FormDesigner extends TargetComponent
implements TreeSelection this.switchAction = switchAction; topXCreators=new TopXCreators(this); - add(topXCreators); + topXCreators.setVisible(true); // 必须刷新"参数/控件树"面板,否则,若最近一次打开模版为 cpt,重启设计器,打开 frm,控件树消失 populateParameterPropertyPane(); @@ -834,29 +833,70 @@ public class FormDesigner extends TargetComponent implements TreeSelection /** * 从已选择的组件中找x,y所在的组件 */ - private XCreator xCreatorAt(int x, int y, XCreator[] xCreators) { + private XCreator xCreatorAt(int x, int y, XCreator root) { + XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); for (XCreator creator : xCreators) { - if (creator == null || !creator.isVisible()) { + boolean shouldContinue = creator == null + || !creator.isVisible() + || !XCreatorUtils.containComponent(root, creator); + if (shouldContinue) { continue; } - if (creator instanceof XWAbsoluteBodyLayout || creator instanceof XWFitLayout || creator instanceof XWParameterLayout) { - continue; + //获取当前组件父组件相对于rootComponent或者paraComponent的距离 + int relativeParentX = getRelativeParentX(creator.getParent()); + int relativeParentY = getRelativeParentY(creator.getParent()); + + //如果不是布局容器,直接进行对比 + if (!(creator instanceof XLayoutContainer)) { + int newX = x - relativeParentX - creator.getX(); + int newY = y - relativeParentY - creator.getY(); + Rectangle rect = ComponentUtils.computeVisibleRect(creator); + // 判断是否处于交叉区域 + if (isIntersectArea(newX, newY, rect)) { + return creator; + } } - x -= creator.getX(); - y -= creator.getY(); - Rectangle rect = ComponentUtils.computeVisibleRect(creator); - // 判断是否处于交叉区域 - if (!isIntersectArea(x, y, rect)) { - continue; + + //如果是布局容器,从布局容器向下找 + if (creator instanceof XLayoutContainer) { + XCreator result = xCreatorAt(x - relativeParentX, y - relativeParentY, creator, null); + if (result != null) { + return result; + } } - if (creator instanceof XWTitleLayout) { - return creator.getEditingChildCreator(); + + //最后,如果组件为Tab容器中的子组件,再从Tab容器中去找 + XWCardMainBorderLayout borderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); + if (borderLayout != null) { + relativeParentX = getRelativeParentX(borderLayout.getParent()); + relativeParentY = getRelativeParentY(borderLayout.getParent()); + return xCreatorAt(x - relativeParentX, y - relativeParentY, borderLayout, null); } - return creator; } return null; } + /** + * 获取当前组件相对于rootComponent或者paraComponent的横向距离 + */ + private int getRelativeParentX(Container container) { + return returnZero(container) ? 0 : container.getX() + getRelativeParentX(container.getParent()); + } + + /** + * 获取当前组件相对于rootComponent或者paraComponent的纵向距离 + */ + private int getRelativeParentY(Container container) { + return returnZero(container) ? 0 : container.getY() + getRelativeParentY(container.getParent()); + } + + private boolean returnZero(Container container) { + return !(container instanceof XLayoutContainer) + || container == rootComponent + || (paraComponent != null && container == paraComponent); + } + + /** * 刷新顶层组件 * */ @@ -1056,7 +1096,7 @@ public class FormDesigner extends TargetComponent implements TreeSelection } int relativeX = x + (int) (formArea.getHorizontalValue() / scale) - container.getX(); int relativeY = y + (int) (formArea.getVerticalValue() / scale) - container.getY(); - XCreator result = xCreatorAt(relativeX, relativeY, selectionModel.getSelection().getSelectedCreators()); + XCreator result = xCreatorAt(relativeX, relativeY, container); return result == null ? getComponentAt(x, y, null) : result; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 2a8e255e83..233ee2a96a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -22,10 +22,12 @@ import com.fr.form.main.parameter.FormParameterUI; import com.fr.page.WatermarkPainter; import com.fr.report.core.ReportUtils; import com.fr.stable.ArrayUtils; +import com.fr.stable.Constants; import javax.swing.*; import javax.swing.plaf.ComponentUI; import java.awt.AlphaComposite; +import java.awt.Color; import java.awt.Component; import java.awt.Graphics; import java.awt.Graphics2D; @@ -41,6 +43,8 @@ import java.util.ArrayList; */ public class FormDesignerUI extends ComponentUI { + private static final Color DESIGNER_BORDER_COLOR = new Color(198, 198, 198); + // 当前的设计器 private FormDesigner designer; private SelectionModel selectionModel; @@ -84,13 +88,13 @@ public class FormDesignerUI extends ComponentUI { // 设计参数面板 repaintPara(g, paraComponent, c); } - repaintTopXCreators(g); + paintTopXCreators(g); if (designer.isDrawLineMode() && designer.getDrawLineHelper().drawLining()) { designer.getDrawLineHelper().drawAuxiliaryLine(g); return; } - + paintBorder(g); paintSelection(g); if (DesignerMode.isAuthorityEditing()) { @@ -275,6 +279,19 @@ public class FormDesignerUI extends ComponentUI { clipg.dispose(); } + public void paintBorder(Graphics g) { + Rectangle bounds = designer.getTopContainer().getBounds(); + bounds.x = -designer.getHorizontalScaleValue(); + bounds.y = -designer.getVerticalScaleValue(); + Graphics clipg = g.create(); + clipg.clipRect(bounds.x, bounds.y, bounds.width, bounds.height); + Color oldColor = g.getColor(); + g.setColor(DESIGNER_BORDER_COLOR); + GraphHelper.draw(g, bounds, Constants.LINE_THIN); + clipg.dispose(); + g.setColor(oldColor); + } + /** * 画出当前选择、拖拽状态框 * @@ -410,8 +427,8 @@ public class FormDesignerUI extends ComponentUI { clipg = g.create( -designer.getHorizontalScaleValue(), -designer.getVerticalScaleValue() + designer.getParaHeight(), - parent.getSize().width + designer.getHorizontalScaleValue(), - parent.getSize().height + designer.getVerticalScaleValue()); + component.getSize().width + designer.getHorizontalScaleValue(), + component.getSize().height + designer.getVerticalScaleValue()); designer.paintContent(clipg); paintWatermark((Graphics2D) clipg); @@ -436,7 +453,7 @@ public class FormDesignerUI extends ComponentUI { Graphics clipg1; clipg1 = g.create(-designer.getHorizontalScaleValue(), -designer.getVerticalScaleValue(), - parent.getSize().width + designer.getHorizontalScaleValue(), + component.getSize().width + designer.getHorizontalScaleValue(), designer.getParaHeight() + designer.getVerticalScaleValue()); designer.paintPara(clipg1); @@ -446,7 +463,7 @@ public class FormDesignerUI extends ComponentUI { ComponentUtils.resetBuffer(dbcomponents); } - private void repaintTopXCreators(Graphics g){ + private void paintTopXCreators(Graphics g){ designer.paintTopCreators(g); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/BasicTopXCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java similarity index 59% rename from designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/BasicTopXCreator.java rename to designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java index e49aaf6e85..72541a1fe6 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/BasicTopXCreator.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreator.java @@ -1,24 +1,29 @@ -package com.fr.design.mainframe.widget.topxcreator; +package com.fr.design.mainframe; import com.fr.design.designer.creator.XCreator; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.utils.ComponentUtils; +import com.fr.stable.CoreGraphHelper; import javax.swing.*; import java.awt.*; import java.awt.event.MouseEvent; +import java.awt.geom.AffineTransform; +import java.awt.image.BufferedImage; +import java.util.ArrayList; /** * @Author: Yuan.Wang * @Date: 2020/8/31 */ -public class BasicTopXCreator extends JComponent { - private FormDesigner designer; - private XCreator creator; +public class TopXCreator extends JComponent { + private final FormDesigner designer; + private final XCreator creator; - public BasicTopXCreator(XCreator creator) { - this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); + public TopXCreator(FormDesigner designer, XCreator creator) { + this.designer = designer; this.creator = creator; init(); } @@ -28,30 +33,16 @@ public class BasicTopXCreator extends JComponent { setBackground(null); setLayout(null); setBounds(calculateBounds()); - addComponent(); } - //子类可能会重写该方法 - protected void resetSize(Rectangle bounds) { - //do nothing - } - - protected void addComponent() { - - } - /** * 重新设置组件大小 * */ public void resizeTopXCreator() { - Rectangle bounds=calculateBounds(); - setBounds(bounds); - resetSize(bounds); + setBounds(calculateBounds()); } - public void displayCoverPane(MouseEvent e, boolean visible) {} - /** * 计算显示大小 * */ @@ -63,8 +54,15 @@ public class BasicTopXCreator extends JComponent { return bounds; } + @Override public void paint(Graphics g) { super.paint(g); + ArrayList dbcomponents = new ArrayList(); + // 禁止双缓冲 + ComponentUtils.disableBuffer(creator, dbcomponents); + creator.paint(g); + // 恢复双缓冲 + ComponentUtils.resetBuffer(dbcomponents); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreators.java b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java similarity index 57% rename from designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreators.java rename to designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java index f271c3cc10..89b261bb9a 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreators.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java @@ -1,11 +1,10 @@ -package com.fr.design.mainframe.widget.topxcreator; +package com.fr.design.mainframe; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.models.SelectionModel; import com.fr.design.designer.creator.XCreator; -import com.fr.design.mainframe.FormDesigner; - -import java.awt.event.MouseEvent; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import javax.swing.*; import java.awt.*; @@ -31,7 +30,7 @@ public class TopXCreators extends JComponent { setBackground(null); setOpaque(false); designer.addDesignerEditListener(e -> { - if (e.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) { + if (e.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { refresh(); } }); @@ -52,28 +51,6 @@ public class TopXCreators extends JComponent { super.paint(g); } - @Override - public void setVisible(boolean aFlag) { - super.setVisible(aFlag); - for (int i = 0, count = getComponentCount(); i < count; i++) { - if (getComponent(i) instanceof TopXCreator) { - TopXCreator xCreator = (TopXCreator) getComponent(i); - xCreator.displayCoverPane(aFlag); - } - } - repaint(); - } - - /** - * 依据MouseEvent坐标来设置是否显示蒙层 - */ - public void displayCoverPane(MouseEvent e) { - for (int i = 0, count = getComponentCount(); i < count; i++) { - BasicTopXCreator xCreator = (BasicTopXCreator) getComponent(i); - xCreator.displayCoverPane(e, isVisible()); - } - } - /** * 加入被选择的组件 */ @@ -81,10 +58,15 @@ public class TopXCreators extends JComponent { SelectionModel selectionModel = designer.getSelectionModel(); XCreator[] xCreators = selectionModel.getSelection().getSelectedCreators(); for (XCreator creator : xCreators) { - BasicTopXCreator topXCreator = creator.getTopXCreator(); - if (topXCreator != null) { - add(topXCreator); + if (!creator.isTopable()) { + continue; + } + XWCardMainBorderLayout topXMainBorderLayout = XCreatorUtils.getTopXMainBorderLayout(creator); + add(new TopXCreator(designer, creator)); + if (topXMainBorderLayout != null) { + add(new TopXCreator(designer, topXMainBorderLayout)); } + } } @@ -93,9 +75,8 @@ public class TopXCreators extends JComponent { */ private void resizeTopXCreators() { for (int i = 0, count = getComponentCount(); i < count; i++) { - BasicTopXCreator topXCreator = (BasicTopXCreator) getComponent(i); + TopXCreator topXCreator = (TopXCreator) getComponent(i); topXCreator.resizeTopXCreator(); } - repaint(); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java deleted file mode 100644 index 42371a44f9..0000000000 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/topxcreator/TopXCreator.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.fr.design.mainframe.widget.topxcreator; - -import com.fr.design.designer.creator.XCreator; -import com.fr.design.mainframe.CoverReportPane; - -import java.awt.*; -import java.awt.event.MouseEvent; - -/** - * @Author: Yuan.Wang - * @Date: 2020/8/26 - */ -public class TopXCreator extends BasicTopXCreator { - - private final CoverReportPane coverPanel; - - public TopXCreator(XCreator creator) { - super(creator); - coverPanel = new CoverReportPane(); - init(); - } - - private void init() { - coverPanel.setSize(getSize()); - coverPanel.setVisible(false); - add(coverPanel); - } - - - protected void resetSize(Rectangle bounds) { - coverPanel.setSize(getSize()); - } - - /** - * 设置是否显示蒙层 - * */ - public void displayCoverPane(boolean visible) { - coverPanel.setVisible(visible); - } - - /** - * 依据鼠标事件和visible设置是否显示蒙层 - * */ - public void displayCoverPane(MouseEvent event, boolean visible) { - boolean isVisible = visible && getBounds().contains(event.getX(), event.getY()); - coverPanel.setVisible(isVisible); - } - -} diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java index 7427a0281b..69e438401c 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/ChartEditorDefinePane.java @@ -24,6 +24,7 @@ import com.fr.design.mainframe.mobile.ui.MobileCollapsedStylePane; import com.fr.design.mainframe.mobile.ui.MobileComboBoxDialogEditor; import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.mobile.MobileCollapsedStyle; import javax.swing.BorderFactory; @@ -201,9 +202,20 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { MobileCollapsedStyle style = ((ChartEditor) xCreator.toData()).getMobileCollapsedStyle(); this.mobileCollapsedStyleEditor.setStyle(style); + fix(style); this.mobileCollapsedStyleEditor.setSelected(style.isCollapsedWork()); } + /** + * 根据组件当前位置修正下属性 + * + * @param style + */ + private void fix(MobileCollapsedStyle style) { + style.setCollapsedWork(style.isCollapsedWork() && !FormDesignerUtils.isInAbsoluteLayout(xCreator)); + } + + @Override public void update() { ChartMobileAttrProvider mobileAttr = ((BaseChartEditor)xCreator.toData()).getMobileAttr(); @@ -219,7 +231,7 @@ public class ChartEditorDefinePane extends MobileWidgetDefinePane { MobileCollapsedStyle style = this.mobileCollapsedStyleEditor.getStyle(); if (style != null) { ((ChartEditor) xCreator.toData()).setMobileCollapsedStyle(style); - style.setCollapsedWork(this.mobileCollapsedStyleEditor.isSelectedCustom()); + style.setCollapsedWork(this.mobileCollapsedStyleEditor.isSelectedCustom() && !FormDesignerUtils.isInAbsoluteLayout(xCreator)); } DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 } 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 723616280c..bdd5b7d351 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 @@ -176,9 +176,19 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { this.allowFullCheckBox.setSelected(elementCaseEditor.isAllowFullScreen()); this.functionalWhenUnactivatedCheckBox.setSelected(!elementCaseEditor.isFunctionalWhenUnactivated()); this.mobileCollapsedStyleEditor.setStyle(elementCaseEditor.getMobileCollapsedStyle()); + fix(elementCaseEditor.getMobileCollapsedStyle()); this.mobileCollapsedStyleEditor.setSelected(elementCaseEditor.getMobileCollapsedStyle().isCollapsedWork()); } + /** + * 根据组件当前位置修正下属性 + * + * @param style + */ + private void fix(MobileCollapsedStyle style) { + style.setCollapsedWork(style.isCollapsedWork() && !FormDesignerUtils.isInAbsoluteLayout(xCreator)); + } + @Override public void update() { DesignerContext.getDesignerFrame().getSelectedJTemplate().fireTargetModified(); // 触发设计器保存按钮亮起来 @@ -207,7 +217,7 @@ public class ElementCaseDefinePane extends MobileWidgetDefinePane { } MobileCollapsedStyle style = this.mobileCollapsedStyleEditor.getStyle(); if (style != null) { - style.setCollapsedWork(this.mobileCollapsedStyleEditor.isSelectedCustom()); + style.setCollapsedWork(this.mobileCollapsedStyleEditor.isSelectedCustom() && !FormDesignerUtils.isInAbsoluteLayout(xCreator)); ((ElementCaseEditor) xCreator.toData()).setMobileCollapsedStyle(style); } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileTabCommonSettingPane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileTabCommonSettingPane.java index cf4923aed3..85475fd688 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileTabCommonSettingPane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/mobile/component/MobileTabCommonSettingPane.java @@ -112,20 +112,10 @@ public class MobileTabCommonSettingPane extends BasicPane { JPanel selectDotColorPane = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{selectColor, selectDotColorBox}}, TableLayoutHelper.FILL_LASTCOLUMN, IntervalConstants.INTERVAL_L1, LayoutConstants.VGAP_MEDIUM); double[] rowSize = {TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED}; - double[] columnSize = {TableLayout.FILL}; - int[][] rowCount = {{1}, {1}, {1}}; - double[] verticalGaps = {10, 10, 10}; + double[] verticalGaps = {IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1}; double[] dotSettingColumnSize = {TableLayout.PREFERRED, TableLayout.FILL}; - Component[][] components = new Component[][]{ - new Component[]{this.showTabTitleCheck}, - new Component[]{this.tabSlideCheck}, - new Component[]{this.showTabDotIndicatorCheck} - }; - - JPanel tabBaseConfigPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, - IntervalConstants.INTERVAL_L1, IntervalConstants.INTERVAL_L1); - tabBaseConfigPane.setBorder(BorderFactory.createEmptyBorder(0, 0, IntervalConstants.INTERVAL_L1, 0)); + final JPanel tabBaseConfigPanel = createTableConfigJPanel(); JPanel dotIndicatorSettingPanel = TableLayoutHelper.createDiffVGapTableLayoutPane(new JComponent[][]{ {label, dotIndicatorShowTypePane}, @@ -135,11 +125,18 @@ public class MobileTabCommonSettingPane extends BasicPane { BorderFactory.createEmptyBorder(0, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1, 0) ); - final JPanel jPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); - jPanel.add(tabBaseConfigPane, BorderLayout.NORTH); - jPanel.add(dotIndicatorSettingPanel, BorderLayout.CENTER); + final JPanel tableConfigJPanel = FRGUIPaneFactory.createBorderLayout_S_Pane(); + tableConfigJPanel.add(tabBaseConfigPanel, BorderLayout.NORTH); + tableConfigJPanel.add(dotIndicatorSettingPanel, BorderLayout.CENTER); + this.add(tableConfigJPanel, BorderLayout.CENTER); - this.add(jPanel, BorderLayout.CENTER); + tabSlideCheck.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + showTabDotIndicatorCheck.setVisible(tabSlideCheck.isSelected()); + dotIndicatorSettingPanel.setVisible(tabSlideCheck.isSelected() && showTabDotIndicatorCheck.isSelected()); + } + }); showTabDotIndicatorCheck.addChangeListener(new ChangeListener() { @Override @@ -200,4 +197,15 @@ public class MobileTabCommonSettingPane extends BasicPane { colorBox.setSelectObject(color); } } + + private JPanel createTableConfigJPanel() { + final JPanel jPanel = new JPanel(); + BorderLayout borderLayout = new BorderLayout(0, IntervalConstants.INTERVAL_L1); + jPanel.setLayout(borderLayout); + jPanel.add(this.showTabTitleCheck, BorderLayout.NORTH); + jPanel.add(this.tabSlideCheck, BorderLayout.CENTER); + jPanel.add(this.showTabDotIndicatorCheck, BorderLayout.SOUTH); + jPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, IntervalConstants.INTERVAL_L1, 0)); + return jPanel; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java b/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java index 1acf4a4042..5023e6f4f1 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/cell/style/ReportFontNameAction.java @@ -3,6 +3,7 @@ */ package com.fr.design.actions.cell.style; +import com.fr.stable.os.OperatingSystem; import java.awt.Dimension; import javax.swing.ComboBoxModel; @@ -49,6 +50,7 @@ public class ReportFontNameAction extends AbstractStyleAction { public void setFontName(String fontName) { Object object = this.getValue(UIComboBox.class.getName()); + boolean find = false; if (object != null && object instanceof UIComboBox) { UIComboBox comboBox = (UIComboBox) object; ComboBoxModel comboBoxModel = comboBox.getModel(); @@ -60,9 +62,17 @@ public class ReportFontNameAction extends AbstractStyleAction { comboBox.removeActionListener(this); comboBox.setSelectedIndex(i); comboBox.addActionListener(this); + find = true; break; } } + // linux设计器下面 找不到默认就是第一个字体 + boolean access = OperatingSystem.isLinux() && !find && comboBoxModel.getSize() > 0; + if (access) { + comboBox.removeActionListener(this); + comboBox.setSelectedIndex(0); + comboBox.addActionListener(this); + } } } diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java index a8f4b2ac1a..fb904e2190 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java +++ b/designer-realize/src/main/java/com/fr/design/cell/editor/RichTextToolBar.java @@ -502,14 +502,15 @@ public class RichTextToolBar extends BasicPane{ //pt转为px =*4/3 private int scaleUp(int fontSize) { - return (int) FontTransformUtil.pt2px(fontSize); + return roundUp(FontTransformUtil.pt2px(fontSize)); } //px转pt = *3/4 private int scaleDown(int fontSize) { - return (int) FontTransformUtil.px2pt(fontSize); + return roundUp(FontTransformUtil.px2pt(fontSize)); } + private DocumentListener inputListener = new DocumentListener() { @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java index 48ddb6a05a..ec9a2ce9de 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java @@ -1,6 +1,4 @@ -/** - * - */ + package com.fr.design.mainframe; import com.fr.design.mainframe.template.info.JPolyWorkBookProcessInfo; @@ -13,7 +11,6 @@ import com.fr.report.poly.PolyWorkSheet; * 聚合报表Book, 跟WorkBook区别在于不能放入WorkSheet. * * @author neil - * * @date: 2015-2-5-上午8:58:39 */ public class JPolyWorkBook extends JWorkBook { @@ -32,15 +29,12 @@ public class JPolyWorkBook extends JWorkBook { * 创建sheet名称tab面板 * * @param reportCompositeX 当前组件对象 - * * @return sheet名称tab面板 - * * @date 2015-2-5-上午11:42:12 - * */ @Override - public SheetNameTabPane createSheetNameTabPane(ReportComponentComposite reportCompositeX){ - return new PolySheetNameTabPane(reportCompositeX); + public SheetNameTabPane createSheetNameTabPane(ReportComponentComposite reportCompositeX) { + return new SheetNameTabPane(reportCompositeX); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 80c8b2d0b3..a139a54280 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -208,13 +208,7 @@ public class JWorkBook extends JTemplate { } }; - reportComposite.addTargetModifiedListener(new TargetModifiedListener() { - - @Override - public void targetModified(TargetModifiedEvent e) { - JWorkBook.this.fireTargetModified(); - } - }); + reportComposite.addTargetModifiedListener(e -> JWorkBook.this.fireTargetModified()); reportComposite.setParentContainer(centerPane); return centerPane; @@ -241,11 +235,11 @@ public class JWorkBook extends JTemplate { /** * 判断sheet权限 * - * @param rolsName 角色 + * @param rolesName 角色 */ @Override - public void judgeSheetAuthority(String rolsName) { - boolean isCovered = reportComposite.getEditingTemplateReport().getWorkSheetPrivilegeControl().checkInvisible(rolsName); + public void judgeSheetAuthority(String rolesName) { + boolean isCovered = reportComposite.getEditingTemplateReport().getWorkSheetPrivilegeControl().checkInvisible(rolesName); centerPane.setSheeetCovered(isCovered); centerPane.refreshContainer(); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/PolySheetNameTabPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/PolySheetNameTabPane.java index cd61df1b46..8969661bf2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/PolySheetNameTabPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/PolySheetNameTabPane.java @@ -1,35 +1,38 @@ package com.fr.design.mainframe; -import java.awt.Graphics2D; import com.fr.design.menu.MenuDef; +import java.awt.Graphics2D; + /** * 获取 - * + * * @date 2015-2-5-上午10:19:17 - * + * @deprecated 让聚合报表也可以新建普通报表sheet, 逻辑和普通报表保持一致, 弃用此个性化设置 */ -public class PolySheetNameTabPane extends SheetNameTabPane{ - - /** - * 构造函数 - */ - public PolySheetNameTabPane(ReportComponentComposite reportCompositeX) { - super(reportCompositeX); - } - - protected void paintAddButton(Graphics2D g2d){ - ADD_POLY_SHEET.paintIcon(this, g2d, iconLocation, 3); +@Deprecated +public class PolySheetNameTabPane extends SheetNameTabPane { + + /** + * 构造函数 + */ + public PolySheetNameTabPane(ReportComponentComposite reportCompositeX) { + super(reportCompositeX); + } + + protected void paintAddButton(Graphics2D g2d) { + ADD_POLY_SHEET.paintIcon(this, g2d, iconLocation, 3); } - - - protected void firstInsertActionPerformed(){ - new PolyReportInsertAction().actionPerformed(null); + + + protected void firstInsertActionPerformed() { + new PolyReportInsertAction().actionPerformed(null); } - - protected void addInsertGridShortCut(MenuDef def){ + + protected void addInsertGridShortCut(MenuDef def) { } + } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java index c8f92721cb..503a4f413d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/BottomModel.java @@ -49,9 +49,7 @@ public class BottomModel extends AlphaCellModel { public void doAction() { try { Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_GO_TO_FORUM)); - } catch (IOException e) { - FineLoggerFactory.getLogger().error(e.getMessage()); - } catch (URISyntaxException e) { + } catch (IOException | URISyntaxException e) { FineLoggerFactory.getLogger().error(e.getMessage()); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java index 07f5b4d4ed..da44fa510f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/render/ContentCellRender.java @@ -106,11 +106,10 @@ public class ContentCellRender implements ListCellRenderer { if (strings == null) { return modelName; } - for (int i = 0; i < strings.length; i++) { - String primaryStr = getReplacedString(modelName, strings[i]); - modelName = modelName.replaceAll("(?i)" + strings[i], "|" + strings[i] + "|"); + for (String string : strings) { + String primaryStr = getReplacedString(modelName, string); if (StringUtils.isNotEmpty(primaryStr)) { - modelName = modelName.replaceAll(strings[i], primaryStr); + modelName = modelName.replaceAll("(?i)" + primaryStr, "|" + primaryStr + "|"); } } modelName = "